mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 10:12:19 +01:00
DeterministicKeyChain: extract to static addChain() method
This commit is contained in:
parent
6ac5f0b5a7
commit
f37f696108
@ -840,11 +840,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
if (t == Protos.Key.Type.DETERMINISTIC_MNEMONIC) {
|
||||
accountPath = deserializeAccountPath(key.getAccountPathList());
|
||||
if (chain != null) {
|
||||
checkState(lookaheadSize >= 0);
|
||||
chain.setLookaheadSize(lookaheadSize);
|
||||
chain.setSigsRequiredToSpend(sigsRequiredToSpend);
|
||||
chain.maybeLookAhead();
|
||||
chains.add(chain);
|
||||
addChain(chains, chain, lookaheadSize, sigsRequiredToSpend);
|
||||
chain = null;
|
||||
}
|
||||
long timestamp = key.getCreationTimestamp() / 1000;
|
||||
@ -892,11 +888,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
// placed in new following key chain
|
||||
if (key.getDeterministicKey().getIsFollowing()) {
|
||||
if (chain != null) {
|
||||
checkState(lookaheadSize >= 0);
|
||||
chain.setLookaheadSize(lookaheadSize);
|
||||
chain.setSigsRequiredToSpend(sigsRequiredToSpend);
|
||||
chain.maybeLookAhead();
|
||||
chains.add(chain);
|
||||
addChain(chains, chain, lookaheadSize, sigsRequiredToSpend);
|
||||
chain = null;
|
||||
seed = null;
|
||||
}
|
||||
@ -986,15 +978,19 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
}
|
||||
if (chain != null) {
|
||||
checkState(lookaheadSize >= 0);
|
||||
chain.setLookaheadSize(lookaheadSize);
|
||||
chain.setSigsRequiredToSpend(sigsRequiredToSpend);
|
||||
chain.maybeLookAhead();
|
||||
chains.add(chain);
|
||||
addChain(chains, chain, lookaheadSize, sigsRequiredToSpend);
|
||||
}
|
||||
return chains;
|
||||
}
|
||||
|
||||
private static void addChain(List<DeterministicKeyChain> chains, DeterministicKeyChain chain, int lookaheadSize, int sigsRequiredToSpend) {
|
||||
checkState(lookaheadSize >= 0);
|
||||
chain.setLookaheadSize(lookaheadSize);
|
||||
chain.setSigsRequiredToSpend(sigsRequiredToSpend);
|
||||
chain.maybeLookAhead();
|
||||
chains.add(chain);
|
||||
}
|
||||
|
||||
private static HDPath deserializeAccountPath(List<Integer> integerList) {
|
||||
HDPath path = HDPath.deserialize(integerList);
|
||||
return path.isEmpty() ? ACCOUNT_ZERO_PATH : path;
|
||||
|
Loading…
Reference in New Issue
Block a user