mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 02:35:52 +00:00
Wallet-Tool: New action to modify the creation time of wallets.
This is useful for repairing wallets that accidently have been created "in the future".
This commit is contained in:
parent
3966f424a0
commit
79d6716120
@ -48,7 +48,7 @@ public class DeterministicSeed implements EncryptableItem {
|
|||||||
@Nullable private final List<String> mnemonicCode; // only one of mnemonicCode/encryptedMnemonicCode will be set
|
@Nullable private final List<String> mnemonicCode; // only one of mnemonicCode/encryptedMnemonicCode will be set
|
||||||
@Nullable private final EncryptedData encryptedMnemonicCode;
|
@Nullable private final EncryptedData encryptedMnemonicCode;
|
||||||
@Nullable private EncryptedData encryptedSeed;
|
@Nullable private EncryptedData encryptedSeed;
|
||||||
private final long creationTimeSeconds;
|
private long creationTimeSeconds;
|
||||||
|
|
||||||
public DeterministicSeed(String mnemonicCode, byte[] seed, String passphrase, long creationTimeSeconds) throws UnreadableWalletException {
|
public DeterministicSeed(String mnemonicCode, byte[] seed, String passphrase, long creationTimeSeconds) throws UnreadableWalletException {
|
||||||
this(decodeMnemonicCode(mnemonicCode), seed, passphrase, creationTimeSeconds);
|
this(decodeMnemonicCode(mnemonicCode), seed, passphrase, creationTimeSeconds);
|
||||||
@ -175,6 +175,10 @@ public class DeterministicSeed implements EncryptableItem {
|
|||||||
return creationTimeSeconds;
|
return creationTimeSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCreationTimeSeconds(long creationTimeSeconds) {
|
||||||
|
this.creationTimeSeconds = creationTimeSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
public DeterministicSeed encrypt(KeyCrypter keyCrypter, KeyParameter aesKey) {
|
public DeterministicSeed encrypt(KeyCrypter keyCrypter, KeyParameter aesKey) {
|
||||||
checkState(encryptedMnemonicCode == null, "Trying to encrypt seed twice");
|
checkState(encryptedMnemonicCode == null, "Trying to encrypt seed twice");
|
||||||
checkState(mnemonicCode != null, "Mnemonic missing so cannot encrypt");
|
checkState(mnemonicCode != null, "Mnemonic missing so cannot encrypt");
|
||||||
|
@ -177,6 +177,7 @@ public class WalletTool {
|
|||||||
DECRYPT,
|
DECRYPT,
|
||||||
MARRY,
|
MARRY,
|
||||||
ROTATE,
|
ROTATE,
|
||||||
|
SET_CREATION_TIME,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum WaitForEnum {
|
public enum WaitForEnum {
|
||||||
@ -369,6 +370,7 @@ public class WalletTool {
|
|||||||
case DECRYPT: decrypt(); break;
|
case DECRYPT: decrypt(); break;
|
||||||
case MARRY: marry(); break;
|
case MARRY: marry(); break;
|
||||||
case ROTATE: rotate(); break;
|
case ROTATE: rotate(); break;
|
||||||
|
case SET_CREATION_TIME: setCreationTime(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wallet.isConsistent()) {
|
if (!wallet.isConsistent()) {
|
||||||
@ -1084,4 +1086,18 @@ public class WalletTool {
|
|||||||
setup();
|
setup();
|
||||||
System.out.println(wallet.toString(options.has("dump-privkeys"), true, true, chain));
|
System.out.println(wallet.toString(options.has("dump-privkeys"), true, true, chain));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setCreationTime() {
|
||||||
|
DeterministicSeed seed = wallet.getActiveKeyChain().getSeed();
|
||||||
|
if (seed == null) {
|
||||||
|
System.err.println("Active chain does not have a seed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long creationTime = getCreationTimeSeconds();
|
||||||
|
if (creationTime > 0)
|
||||||
|
System.out.println("Setting creation time to: " + Utils.dateTimeFormat(creationTime * 1000));
|
||||||
|
else
|
||||||
|
System.out.println("Clearing creation time.");
|
||||||
|
seed.setCreationTimeSeconds(creationTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,12 @@ Usage: wallet-tool --flags action-name
|
|||||||
created before this date will be re-spent to a key (from an HD tree) that was created after it.
|
created before this date will be re-spent to a key (from an HD tree) that was created after it.
|
||||||
If --date is missing, the current time is assumed. If the time covers all keys, a new HD tree
|
If --date is missing, the current time is assumed. If the time covers all keys, a new HD tree
|
||||||
will be created from a new random seed.
|
will be created from a new random seed.
|
||||||
|
set-creation-time Modify the creation time of the active chain of this wallet. This is useful for repairing
|
||||||
|
wallets that accidently have been created "in the future". Currently, watching wallets are not
|
||||||
|
supported.
|
||||||
|
If --date is specified, that's the creation date.
|
||||||
|
If --unixtime is specified, that's the creation time and it overrides --date.
|
||||||
|
If you omit both options, the creation time is being cleared (set to 0).
|
||||||
|
|
||||||
>>> GENERAL OPTIONS
|
>>> GENERAL OPTIONS
|
||||||
--debuglog Enables logging from the core library.
|
--debuglog Enables logging from the core library.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user