From 2c370c07c73dd2930d21878e3ec70bbc8e9aa1ca Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 20 Apr 2018 16:37:47 +0200 Subject: [PATCH] DeterministicKeyChain: Make accountPath final. It's not meant to be changed. --- .../bitcoinj/wallet/DeterministicKeyChain.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java b/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java index 0bec749b..1757c375 100644 --- a/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java +++ b/core/src/main/java/org/bitcoinj/wallet/DeterministicKeyChain.java @@ -105,7 +105,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain { private DeterministicHierarchy hierarchy; @Nullable private DeterministicKey rootKey; @Nullable private DeterministicSeed seed; - @Nullable private ImmutableList accountPath; + @Nullable private final ImmutableList accountPath; // Paths through the key tree. External keys are ones that are communicated to other parties. Internal keys are // keys created for change addresses, coinbases, mixing, etc - anything that isn't communicated. The distinction @@ -323,7 +323,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain { */ public DeterministicKeyChain(DeterministicKey watchingKey) { checkArgument(watchingKey.isPubKeyOnly(), "Private subtrees not currently supported: if you got this key from DKC.getWatchingKey() then use .dropPrivate().dropParent() on it first."); - setAccountPath(watchingKey.getPath()); + this.accountPath = watchingKey.getPath(); basicKeyChain = new BasicKeyChain(); this.seed = null; this.rootKey = null; @@ -352,7 +352,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain { this.rootKey = null; basicKeyChain.importKey(key); hierarchy = new DeterministicHierarchy(key); - setAccountPath(key.getPath()); + this.accountPath = key.getPath(); initializeHierarchyUnencrypted(key); this.isFollowing = isFollowing; } @@ -403,7 +403,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain { */ protected DeterministicKeyChain(DeterministicSeed seed, @Nullable KeyCrypter crypter, ImmutableList accountPath) { - setAccountPath(accountPath); + this.accountPath = accountPath; this.seed = seed; basicKeyChain = new BasicKeyChain(crypter); if (!seed.isEncrypted()) { @@ -433,7 +433,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain { checkNotNull(chain.seed); checkArgument(!chain.rootKey.isEncrypted(), "Chain already encrypted"); - setAccountPath(chain.getAccountPath()); + this.accountPath = chain.getAccountPath(); this.issuedExternalKeys = chain.issuedExternalKeys; this.issuedInternalKeys = chain.issuedInternalKeys; @@ -475,11 +475,6 @@ public class DeterministicKeyChain implements EncryptableKeyChain { return ACCOUNT_ZERO_PATH; } - /** Store account path of this DeterministicKey */ - protected void setAccountPath(ImmutableList accountPath) { - this.accountPath = accountPath; - } - private DeterministicKey encryptNonLeaf(KeyParameter aesKey, DeterministicKeyChain chain, DeterministicKey parent, ImmutableList path) { DeterministicKey key = chain.hierarchy.get(path, false, false);