From f40e16aac4303e8dbae3c1f4490ca0f985ae0f2f Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Sat, 26 Jan 2019 19:07:46 +0100 Subject: [PATCH] DeterministicSeed, DeterministicKeyChain: Remove seedCreationTimeSecs parameter from constructors that create the seed itself. --- .../org/bitcoinj/wallet/DeterministicKeyChain.java | 11 ++++++----- .../java/org/bitcoinj/wallet/DeterministicSeed.java | 5 ++--- .../java/org/bitcoinj/wallet/MarriedKeyChain.java | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java b/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java index 8421b5b1..3a2a3080 100644 --- a/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java +++ b/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java @@ -258,7 +258,8 @@ public class DeterministicKeyChain implements EncryptableKeyChain { DeterministicKeyChain chain; if (random != null) { // Default passphrase to "" if not specified - chain = new DeterministicKeyChain(new DeterministicSeed(random, bits, getPassphrase(), seedCreationTimeSecs), null, accountPath); + checkState(seedCreationTimeSecs == 0); + chain = new DeterministicKeyChain(new DeterministicSeed(random, bits, getPassphrase()), null, accountPath); } else if (entropy != null) { chain = new DeterministicKeyChain(new DeterministicSeed(entropy, getPassphrase(), seedCreationTimeSecs), null, accountPath); } else if (seed != null) { @@ -286,7 +287,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain { * object and the default entropy size. */ public DeterministicKeyChain(SecureRandom random) { - this(random, DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds()); + this(random, DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS, DEFAULT_PASSPHRASE_FOR_MNEMONIC); } /** @@ -294,7 +295,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain { * object and of the requested size in bits. */ public DeterministicKeyChain(SecureRandom random, int bits) { - this(random, bits, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds()); + this(random, bits, DEFAULT_PASSPHRASE_FOR_MNEMONIC); } /** @@ -302,8 +303,8 @@ public class DeterministicKeyChain implements EncryptableKeyChain { * object and of the requested size in bits. The derived seed is further protected with a user selected passphrase * (see BIP 39). */ - public DeterministicKeyChain(SecureRandom random, int bits, String passphrase, long seedCreationTimeSecs) { - this(new DeterministicSeed(random, bits, passphrase, seedCreationTimeSecs)); + public DeterministicKeyChain(SecureRandom random, int bits, String passphrase) { + this(new DeterministicSeed(random, bits, passphrase)); } /** diff --git a/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java b/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java index 9026782b..8775e03c 100644 --- a/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java +++ b/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java @@ -88,10 +88,9 @@ public class DeterministicSeed implements EncryptableItem { * @param random Entropy source * @param bits number of bits, must be divisible by 32 * @param passphrase A user supplied passphrase, or an empty string if there is no passphrase - * @param creationTimeSeconds When the seed was originally created, UNIX time. */ - public DeterministicSeed(SecureRandom random, int bits, String passphrase, long creationTimeSeconds) { - this(getEntropy(random, bits), checkNotNull(passphrase), creationTimeSeconds); + public DeterministicSeed(SecureRandom random, int bits, String passphrase) { + this(getEntropy(random, bits), checkNotNull(passphrase), Utils.currentTimeSeconds()); } /** diff --git a/core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java b/core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java index 25c2da59..b7be26fe 100644 --- a/core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java +++ b/core/src/main/java/org/bitcoinj/wallet/MarriedKeyChain.java @@ -104,7 +104,8 @@ public class MarriedKeyChain extends DeterministicKeyChain { MarriedKeyChain chain; if (random != null) { - chain = new MarriedKeyChain(new DeterministicSeed(random, bits, getPassphrase(), seedCreationTimeSecs), null, accountPath); + checkState(seedCreationTimeSecs == 0); + chain = new MarriedKeyChain(new DeterministicSeed(random, bits, getPassphrase()), null, accountPath); } else if (entropy != null) { chain = new MarriedKeyChain(new DeterministicSeed(entropy, getPassphrase(), seedCreationTimeSecs), null, accountPath); } else if (seed != null) { @@ -133,8 +134,8 @@ public class MarriedKeyChain extends DeterministicKeyChain { } // Builder constructors - private MarriedKeyChain(SecureRandom random, int bits, String passphrase, long seedCreationTimeSecs) { - super(random, bits, passphrase, seedCreationTimeSecs); + private MarriedKeyChain(SecureRandom random, int bits, String passphrase) { + super(random, bits, passphrase); } private MarriedKeyChain(byte[] entropy, String passphrase, long seedCreationTimeSecs) {