mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-30 23:02:15 +00: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")) {
|
if (options.has("privkey")) {
|
||||||
String data = (String) options.valueOf("privkey");
|
String data = (String) options.valueOf("privkey");
|
||||||
byte[] decode = Utils.parseAsHexOrBase58(data);
|
if (data.charAt(0) == 'L') {
|
||||||
if (decode == null) {
|
DumpedPrivateKey dpk;
|
||||||
System.err.println("Could not understand --privkey as either hex or base58: " + data);
|
try {
|
||||||
return;
|
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")) {
|
if (options.has("pubkey")) {
|
||||||
// Give the user a hint.
|
// Give the user a hint.
|
||||||
System.out.println("You don't have to specify --pubkey when a private key is supplied.");
|
System.out.println("You don't have to specify --pubkey when a private key is supplied.");
|
||||||
|
Loading…
Reference in New Issue
Block a user