Option to decrypt private keys and seed on the fly if printing a wallet dump of an encrypted wallet.

This commit is contained in:
Andreas Schildbach
2017-08-11 11:14:30 +02:00
parent 49e6af3bd7
commit ca033e3368
9 changed files with 64 additions and 31 deletions

View File

@@ -1447,7 +1447,21 @@ public class WalletTool {
// there just for the dump case.
if (chainFileName.exists())
setup();
System.out.println(wallet.toString(options.has("dump-privkeys"), true, true, chain));
final boolean dumpPrivkeys = options.has("dump-privkeys");
if (dumpPrivkeys && wallet.isEncrypted()) {
if (password != null) {
final KeyParameter aesKey = passwordToKey(true);
if (aesKey == null)
return; // Error message already printed.
System.out.println(wallet.toString(true, aesKey, true, true, chain));
} else {
System.err.println("Can't dump privkeys, wallet is encrypted.");
return;
}
} else {
System.out.println(wallet.toString(dumpPrivkeys, null, true, true, chain));
}
}
private static void setCreationTime() {

View File

@@ -4,8 +4,9 @@ Usage: wallet-tool --flags action-name
wallet-tool action-name --flags
>>> ACTIONS
dump Loads and prints the given wallet in textual form to stdout. Private keys are only printed
if --dump-privkeys is specified.
dump Loads and prints the given wallet in textual form to stdout. Private keys and seed are only
printed if --dump-privkeys is specified. If the wallet is encrypted, also specify the --password
option to dump the private keys and seed.
raw-dump Prints the wallet as a raw protobuf with no parsing or sanity checking applied.
create Makes a new wallet in the file specified by --wallet.
Will complain and require --force if the wallet already exists.