From 0c3096ed747dff443ed9d2483c2f0118658b1b4b Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 15 Mar 2013 23:36:09 +0100 Subject: [PATCH] Add a --unixtime flag to wallet-tool ADD_KEY --- .../src/main/java/com/google/bitcoin/tools/WalletTool.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java b/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java index ea0ab7445..63664f18a 100644 --- a/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java +++ b/tools/src/main/java/com/google/bitcoin/tools/WalletTool.java @@ -79,6 +79,7 @@ public class WalletTool { " Will complain and require --force if the wallet already exists.\n" + " --action=ADD_KEY Adds a new key to the wallet, either specified or freshly generated.\n" + " If --date is specified, that's the creation date.\n" + + " If --unixtime is specified, that's the creation time and it overrides --date.\n" + " If --privkey is specified, use as a hex/base58 encoded private key.\n" + " Don't specify --pubkey in that case, it will be derived automatically.\n" + " If --pubkey is specified, use as a hex/base58 encoded non-compressed public key.\n" + @@ -112,6 +113,7 @@ public class WalletTool { private static OptionSpec actionFlag; private static OptionSpec netFlag; private static OptionSpec dateFlag; + private static OptionSpec unixtimeFlag; private static OptionSpec waitForFlag; private static OptionSpec modeFlag; private static OptionSpec conditionFlag; @@ -250,6 +252,7 @@ public class WalletTool { OptionSpec outputFlag = parser.accepts("output").withRequiredArg(); parser.accepts("value").withRequiredArg(); parser.accepts("fee").withRequiredArg(); + parser.accepts("unixtime").withRequiredArg().ofType(Integer.class); conditionFlag = parser.accepts("condition").withRequiredArg(); parser.accepts("locktime").withRequiredArg(); parser.accepts("allow-unconfirmed"); @@ -658,7 +661,9 @@ public class WalletTool { private static void addKey() { ECKey key; long creationTimeSeconds = 0; - if (options.has(dateFlag)) { + if (options.has(unixtimeFlag)) { + creationTimeSeconds = unixtimeFlag.value(options); + } else if (options.has(dateFlag)) { creationTimeSeconds = dateFlag.value(options).getTime() / 1000; } if (options.has("privkey")) {