mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-30 19:41:24 +00:00
DeterministicKeyChain, MarriedKeyChain: Simplify build().
This commit is contained in:
@@ -245,25 +245,24 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
|
||||
public DeterministicKeyChain build() {
|
||||
checkState(random != null || entropy != null || seed != null || watchingKey!= null, "Must provide either entropy or random or seed or watchingKey");
|
||||
checkState(passphrase == null || seed == null, "Passphrase must not be specified with seed");
|
||||
|
||||
if (accountPath == null)
|
||||
accountPath = ACCOUNT_ZERO_PATH;
|
||||
|
||||
DeterministicKeyChain chain;
|
||||
if (random != null) {
|
||||
if (random != null)
|
||||
// Default passphrase to "" if not specified
|
||||
chain = new DeterministicKeyChain(new DeterministicSeed(random, bits, getPassphrase()), null, accountPath);
|
||||
} else if (entropy != null) {
|
||||
chain = new DeterministicKeyChain(new DeterministicSeed(entropy, getPassphrase(), creationTimeSecs), null, accountPath);
|
||||
} else if (seed != null) {
|
||||
chain = new DeterministicKeyChain(seed, null, accountPath);
|
||||
} else {
|
||||
chain = new DeterministicKeyChain(watchingKey);
|
||||
}
|
||||
|
||||
return chain;
|
||||
return new DeterministicKeyChain(new DeterministicSeed(random, bits, getPassphrase()), null,
|
||||
accountPath);
|
||||
else if (entropy != null)
|
||||
return new DeterministicKeyChain(new DeterministicSeed(entropy, getPassphrase(), creationTimeSecs),
|
||||
null, accountPath);
|
||||
else if (seed != null)
|
||||
return new DeterministicKeyChain(seed, null, accountPath);
|
||||
else if (watchingKey != null)
|
||||
return new DeterministicKeyChain(watchingKey);
|
||||
else
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
protected String getPassphrase() {
|
||||
|
@@ -94,7 +94,6 @@ public class MarriedKeyChain extends DeterministicKeyChain {
|
||||
|
||||
@Override
|
||||
public MarriedKeyChain build() {
|
||||
checkState(random != null || entropy != null || seed != null || watchingKey!= null, "Must provide either entropy or random or seed or watchingKey");
|
||||
checkNotNull(followingKeys, "followingKeys must be provided");
|
||||
|
||||
if (threshold == 0)
|
||||
@@ -103,15 +102,17 @@ public class MarriedKeyChain extends DeterministicKeyChain {
|
||||
accountPath = ACCOUNT_ZERO_PATH;
|
||||
|
||||
MarriedKeyChain chain;
|
||||
if (random != null) {
|
||||
if (random != null)
|
||||
chain = new MarriedKeyChain(new DeterministicSeed(random, bits, getPassphrase()), null, accountPath);
|
||||
} else if (entropy != null) {
|
||||
chain = new MarriedKeyChain(new DeterministicSeed(entropy, getPassphrase(), creationTimeSecs), null, accountPath);
|
||||
} else if (seed != null) {
|
||||
else if (entropy != null)
|
||||
chain = new MarriedKeyChain(new DeterministicSeed(entropy, getPassphrase(), creationTimeSecs), null,
|
||||
accountPath);
|
||||
else if (seed != null)
|
||||
chain = new MarriedKeyChain(seed, null, accountPath);
|
||||
} else {
|
||||
else if (watchingKey != null)
|
||||
chain = new MarriedKeyChain(watchingKey);
|
||||
}
|
||||
else
|
||||
throw new IllegalStateException();
|
||||
chain.addFollowingAccountKeys(followingKeys, threshold);
|
||||
return chain;
|
||||
}
|
||||
|
Reference in New Issue
Block a user