New issue 48 by andreas....@googlemail.com: base58-encode private key
[includes source]
http://code.google.com/p/bitcoinj/issues/detail?id=48
After getting some advice on the group, I propose to add the this method to
ECKey.java:
/**
* Output this ECKey as an base58 encoded private key.
*/
public String toBase58() {
return Base58.encode(priv.toByteArray());
}
That's not the correct way to encode them. See sipas patch.
Also, please don't post short patches like this until you've signed the
CLA. Doing so can create confusion about where the final code comes from. I
haven't used any of your code, but having it lie around in bug reports
doesn't help. Thanks!
(I am posting the patches, because other people might want to use them.
It's ok if you don't use them, that's your decision.)
Who is sipa and where can I find his patch?
Comment #4 on issue 48 by he...@google.com: base58-encode private key
[includes source]
http://code.google.com/p/bitcoinj/issues/detail?id=48
This issue was closed by revision r191.
I'm afraid your patch does not work with all keys.
pub:04f2dbef7d639d0fe2fdc1cba2ee1d846d183cbe45c02c8c62b23752549bc13fb05a4bcb92e77211343683873e98e4fdf937c87fdabb1979b9d92baa14c9f726a9
priv:2bb9fce9382e4f365f1c2a908c60d074bea871fd95b14fb761ab4333eb53f7ef
This should be a testnet key. The following exception occurs when calling
ECKey.getPrivKeyBytes()
D/AndroidRuntime(21894): Shutting down VM
W/dalvikvm(21894): threadid=1: thread exiting with uncaught exception
(group=0x40015560)
D/dalvikvm(21894): GC_CONCURRENT freed 723K, 55% free 3044K/6727K, external
1625K/2137K, paused 2ms+2ms
E/AndroidRuntime(21894): FATAL EXCEPTION: main
E/AndroidRuntime(21894): java.lang.RuntimeException: Unable to create
application de.schildbach.wallet.Application:
java.lang.ArrayIndexOutOfBoundsException: src.length=32 srcPos=1
dst.length=32 dstPos=0 length=32
E/AndroidRuntime(21894): at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:3275)
E/AndroidRuntime(21894): at
android.app.ActivityThread.access$2200(ActivityThread.java:117)
E/AndroidRuntime(21894): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
E/AndroidRuntime(21894): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(21894): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(21894): at
android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(21894): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(21894): at
java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(21894): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(21894): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(21894): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(21894): Caused by:
java.lang.ArrayIndexOutOfBoundsException: src.length=32 srcPos=1
dst.length=32 dstPos=0 length=32
E/AndroidRuntime(21894): at java.lang.System.arraycopy(Native Method)
E/AndroidRuntime(21894): at
com.google.bitcoin.core.ECKey.getPrivKeyBytes(ECKey.java:260)
E/AndroidRuntime(21894): at
com.google.bitcoin.core.ECKey.getPrivateKeyEncoded(ECKey.java:272)
E/AndroidRuntime(21894): at
de.schildbach.wallet.Application.backupKeys(Application.java:254)
E/AndroidRuntime(21894): at
de.schildbach.wallet.Application.onCreate(Application.java:134)
E/AndroidRuntime(21894): at
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
E/AndroidRuntime(21894): at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
E/AndroidRuntime(21894): ... 10 more
Comment #6 on issue 48 by he...@google.com: base58-encode private key
[includes source]
http://code.google.com/p/bitcoinj/issues/detail?id=48
Pending fix.
Comment #7 on issue 48 by mi...@google.com: base58-encode private key
[includes source]
http://code.google.com/p/bitcoinj/issues/detail?id=48
This issue was closed by revision r193.