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