wallet-tool: Create watching wallet with specific creation date.

This commit is contained in:
Andreas Schildbach 2016-03-03 16:53:55 +01:00
parent b024f6e571
commit b6975a2760
2 changed files with 13 additions and 12 deletions

View File

@ -1262,10 +1262,10 @@ public class WalletTool {
System.err.println("Wallet creation requested but " + walletFile + " already exists, use --force");
return;
}
long creationTimeSecs = getCreationTimeSeconds();
if (creationTimeSecs == 0)
creationTimeSecs = MnemonicCode.BIP39_STANDARDISATION_TIME_SECS;
if (options.has(seedFlag)) {
long creationTimeSecs = MnemonicCode.BIP39_STANDARDISATION_TIME_SECS;
if (options.has(dateFlag))
creationTimeSecs = options.valueOf(dateFlag).getTime() / 1000;
String seedStr = options.valueOf(seedFlag);
DeterministicSeed seed;
// Parse as mnemonic code.
@ -1289,8 +1289,7 @@ public class WalletTool {
}
wallet = Wallet.fromSeed(params, seed);
} else if (options.has(watchFlag)) {
DeterministicKey watchKey = DeterministicKey.deserializeB58(null, options.valueOf(watchFlag), params);
wallet = Wallet.fromWatchingKey(params, watchKey);
wallet = Wallet.fromWatchingKeyB58(params, options.valueOf(watchFlag), creationTimeSecs);
} else {
wallet = new Wallet(params);
}
@ -1405,13 +1404,12 @@ public class WalletTool {
}
private static long getCreationTimeSeconds() {
long creationTimeSeconds = 0;
if (options.has(unixtimeFlag)) {
creationTimeSeconds = unixtimeFlag.value(options);
} else if (options.has(dateFlag)) {
creationTimeSeconds = dateFlag.value(options).getTime() / 1000;
}
return creationTimeSeconds;
if (options.has(unixtimeFlag))
return unixtimeFlag.value(options);
else if (options.has(dateFlag))
return dateFlag.value(options).getTime() / 1000;
else
return 0;
}
private static void deleteKey() {

View File

@ -10,6 +10,9 @@ Usage: wallet-tool --flags action-name
create Makes a new wallet in the file specified by --wallet.
Will complain and require --force if the wallet already exists.
If --seed is present, it should specify either a mnemonic code or hex/base58 raw seed bytes.
If --watchkey is present, it creates a watching wallet using the specified base58 xpub.
If --seed or --watchkey is combined with either --date or --unixtime, use that as a birthdate for
the wallet. See the set-creation-time action for the meaning of these flags.
marry Makes the wallet married with other parties, requiring multisig to spend funds.
External public keys for other signing parties must be specified with --xpubkeys (comma separated).
add-key Adds a new key to the wallet, either specified or freshly generated.