mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 18:25:51 +00:00
WalletTool: Fix importing of private key in WIF (wallet import format).
This commit is contained in:
parent
ac7a576b3d
commit
5464e5560e
@ -1406,19 +1406,13 @@ public class WalletTool {
|
||||
long creationTimeSeconds = getCreationTimeSeconds();
|
||||
if (options.has("privkey")) {
|
||||
String data = (String) options.valueOf("privkey");
|
||||
if (data.startsWith("5J") || data.startsWith("5H") || data.startsWith("5K")) {
|
||||
DumpedPrivateKey dpk;
|
||||
try {
|
||||
dpk = DumpedPrivateKey.fromBase58(params, data);
|
||||
} catch (AddressFormatException e) {
|
||||
System.err.println("Could not parse dumped private key " + data);
|
||||
return;
|
||||
}
|
||||
DumpedPrivateKey dpk = DumpedPrivateKey.fromBase58(params, data); // WIF
|
||||
key = dpk.getKey();
|
||||
} else {
|
||||
} catch (AddressFormatException e) {
|
||||
byte[] decode = parseAsHexOrBase58(data);
|
||||
if (decode == null) {
|
||||
System.err.println("Could not understand --privkey as either hex or base58: " + data);
|
||||
System.err.println("Could not understand --privkey as either WIF, hex or base58: " + data);
|
||||
return;
|
||||
}
|
||||
key = ECKey.fromPrivate(new BigInteger(1, decode));
|
||||
|
@ -19,7 +19,7 @@ Usage: wallet-tool --flags action-name
|
||||
add-key Adds a new key to the wallet, either specified or freshly generated.
|
||||
If --date is specified, that's the creation date.
|
||||
If --unixtime is specified, that's the creation time and it overrides --date.
|
||||
If --privkey is specified, use as a hex/base58 encoded private key.
|
||||
If --privkey is specified, use as a WIF-, hex- or base58-encoded private key.
|
||||
Don't specify --pubkey in that case, it will be derived automatically.
|
||||
If --pubkey is specified, use as a hex/base58 encoded non-compressed public key.
|
||||
If --lookahead-size is specified, pre-generate at least this many keys ahead of where we are.
|
||||
|
Loading…
x
Reference in New Issue
Block a user