mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 21:32:35 +01:00
Properly support importing dumped private keys in WalletTool.
This commit is contained in:
parent
32cc7b4880
commit
420a29a388
@ -630,12 +630,23 @@ public class WalletTool {
|
||||
}
|
||||
if (options.has("privkey")) {
|
||||
String data = (String) options.valueOf("privkey");
|
||||
byte[] decode = Utils.parseAsHexOrBase58(data);
|
||||
if (decode == null) {
|
||||
System.err.println("Could not understand --privkey as either hex or base58: " + data);
|
||||
return;
|
||||
if (data.charAt(0) == 'L') {
|
||||
DumpedPrivateKey dpk;
|
||||
try {
|
||||
dpk = new DumpedPrivateKey(params, data);
|
||||
} catch (AddressFormatException e) {
|
||||
System.err.println("Could not parse dumped private key " + data);
|
||||
return;
|
||||
}
|
||||
key = dpk.getKey();
|
||||
} else {
|
||||
byte[] decode = Utils.parseAsHexOrBase58(data);
|
||||
if (decode == null) {
|
||||
System.err.println("Could not understand --privkey as either hex or base58: " + data);
|
||||
return;
|
||||
}
|
||||
key = new ECKey(new BigInteger(1, decode));
|
||||
}
|
||||
key = new ECKey(new BigInteger(1, decode));
|
||||
if (options.has("pubkey")) {
|
||||
// Give the user a hint.
|
||||
System.out.println("You don't have to specify --pubkey when a private key is supplied.");
|
||||
|
Loading…
Reference in New Issue
Block a user