mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
KeyChainGroup: supportsDeterministicChains() without the 'is'
The JavaBean-style syntax is unnecessary and distracting here. Rename the method and provide the old name as a deprecated method.
This commit is contained in:
parent
4e5c00937f
commit
6688a472f1
2 changed files with 26 additions and 14 deletions
|
@ -301,11 +301,23 @@ public class KeyChainGroup implements KeyBag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if it contains any deterministic keychain. */
|
/**
|
||||||
public boolean isSupportsDeterministicChains() {
|
* Are any deterministic keychains supported?
|
||||||
|
* @return true if it contains any deterministic keychain
|
||||||
|
*/
|
||||||
|
public boolean supportsDeterministicChains() {
|
||||||
return chains != null;
|
return chains != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if it contains any deterministic keychain
|
||||||
|
* @deprecated Use {@link #supportsDeterministicChains()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean isSupportsDeterministicChains() {
|
||||||
|
return supportsDeterministicChains();
|
||||||
|
}
|
||||||
|
|
||||||
// This keeps married redeem data in sync with the number of keys issued
|
// This keeps married redeem data in sync with the number of keys issued
|
||||||
private void maybeLookaheadScripts() {
|
private void maybeLookaheadScripts() {
|
||||||
for (DeterministicKeyChain chain : chains) {
|
for (DeterministicKeyChain chain : chains) {
|
||||||
|
@ -318,7 +330,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* Useful for adding a complex pre-configured keychain, such as a married wallet.
|
* Useful for adding a complex pre-configured keychain, such as a married wallet.
|
||||||
*/
|
*/
|
||||||
public void addAndActivateHDChain(DeterministicKeyChain chain) {
|
public void addAndActivateHDChain(DeterministicKeyChain chain) {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
log.info("Activating a new HD chain: {}", chain);
|
log.info("Activating a new HD chain: {}", chain);
|
||||||
for (ListenerRegistration<KeyChainEventListener> registration : basic.getListeners())
|
for (ListenerRegistration<KeyChainEventListener> registration : basic.getListeners())
|
||||||
chain.addEventListener(registration.listener, registration.executor);
|
chain.addEventListener(registration.listener, registration.executor);
|
||||||
|
@ -452,7 +464,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* were added. The default active chain will come last in the list.
|
* were added. The default active chain will come last in the list.
|
||||||
*/
|
*/
|
||||||
public List<DeterministicKeyChain> getActiveKeyChains(long keyRotationTimeSecs) {
|
public List<DeterministicKeyChain> getActiveKeyChains(long keyRotationTimeSecs) {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
List<DeterministicKeyChain> activeChains = new LinkedList<>();
|
List<DeterministicKeyChain> activeChains = new LinkedList<>();
|
||||||
for (DeterministicKeyChain chain : chains)
|
for (DeterministicKeyChain chain : chains)
|
||||||
if (chain.getEarliestKeyCreationTime() >= keyRotationTimeSecs)
|
if (chain.getEarliestKeyCreationTime() >= keyRotationTimeSecs)
|
||||||
|
@ -465,7 +477,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* type and no active chain for this type exists, {@code null} is returned. No upgrade or downgrade is tried.
|
* type and no active chain for this type exists, {@code null} is returned. No upgrade or downgrade is tried.
|
||||||
*/
|
*/
|
||||||
public final DeterministicKeyChain getActiveKeyChain(Script.ScriptType outputScriptType, long keyRotationTimeSecs) {
|
public final DeterministicKeyChain getActiveKeyChain(Script.ScriptType outputScriptType, long keyRotationTimeSecs) {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
List<DeterministicKeyChain> chainsReversed = new ArrayList<>(chains);
|
List<DeterministicKeyChain> chainsReversed = new ArrayList<>(chains);
|
||||||
Collections.reverse(chainsReversed);
|
Collections.reverse(chainsReversed);
|
||||||
for (DeterministicKeyChain chain : chainsReversed)
|
for (DeterministicKeyChain chain : chainsReversed)
|
||||||
|
@ -481,7 +493,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* tried.
|
* tried.
|
||||||
*/
|
*/
|
||||||
public final DeterministicKeyChain getActiveKeyChain() {
|
public final DeterministicKeyChain getActiveKeyChain() {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
if (chains.isEmpty())
|
if (chains.isEmpty())
|
||||||
throw new DeterministicUpgradeRequiredException();
|
throw new DeterministicUpgradeRequiredException();
|
||||||
return chains.get(chains.size() - 1);
|
return chains.get(chains.size() - 1);
|
||||||
|
@ -502,7 +514,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* for more information.
|
* for more information.
|
||||||
*/
|
*/
|
||||||
public int getLookaheadSize() {
|
public int getLookaheadSize() {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
if (lookaheadSize == -1)
|
if (lookaheadSize == -1)
|
||||||
return getActiveKeyChain().getLookaheadSize();
|
return getActiveKeyChain().getLookaheadSize();
|
||||||
else
|
else
|
||||||
|
@ -515,7 +527,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* for more information.
|
* for more information.
|
||||||
*/
|
*/
|
||||||
public int getLookaheadThreshold() {
|
public int getLookaheadThreshold() {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
if (lookaheadThreshold == -1)
|
if (lookaheadThreshold == -1)
|
||||||
return getActiveKeyChain().getLookaheadThreshold();
|
return getActiveKeyChain().getLookaheadThreshold();
|
||||||
else
|
else
|
||||||
|
@ -973,7 +985,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
public void upgradeToDeterministic(Script.ScriptType preferredScriptType, KeyChainGroupStructure structure,
|
public void upgradeToDeterministic(Script.ScriptType preferredScriptType, KeyChainGroupStructure structure,
|
||||||
long keyRotationTimeSecs, @Nullable KeyParameter aesKey)
|
long keyRotationTimeSecs, @Nullable KeyParameter aesKey)
|
||||||
throws DeterministicUpgradeRequiresPassword {
|
throws DeterministicUpgradeRequiresPassword {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
checkNotNull(structure);
|
checkNotNull(structure);
|
||||||
checkArgument(keyRotationTimeSecs >= 0);
|
checkArgument(keyRotationTimeSecs >= 0);
|
||||||
if (!isDeterministicUpgradeRequired(preferredScriptType, keyRotationTimeSecs))
|
if (!isDeterministicUpgradeRequired(preferredScriptType, keyRotationTimeSecs))
|
||||||
|
@ -1004,7 +1016,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* in order to have an active deterministic keychain of the desired script type.
|
* in order to have an active deterministic keychain of the desired script type.
|
||||||
*/
|
*/
|
||||||
public boolean isDeterministicUpgradeRequired(Script.ScriptType preferredScriptType, long keyRotationTimeSecs) {
|
public boolean isDeterministicUpgradeRequired(Script.ScriptType preferredScriptType, long keyRotationTimeSecs) {
|
||||||
if (!isSupportsDeterministicChains())
|
if (!supportsDeterministicChains())
|
||||||
return false;
|
return false;
|
||||||
if (getActiveKeyChain(preferredScriptType, keyRotationTimeSecs) == null)
|
if (getActiveKeyChain(preferredScriptType, keyRotationTimeSecs) == null)
|
||||||
return true;
|
return true;
|
||||||
|
@ -1066,7 +1078,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
|
|
||||||
/** Returns a copy of the current list of chains. */
|
/** Returns a copy of the current list of chains. */
|
||||||
public List<DeterministicKeyChain> getDeterministicKeyChains() {
|
public List<DeterministicKeyChain> getDeterministicKeyChains() {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
return new ArrayList<>(chains);
|
return new ArrayList<>(chains);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1074,7 +1086,7 @@ public class KeyChainGroup implements KeyBag {
|
||||||
* lookahead and thus the Bloom filter that was previously calculated has become stale.
|
* lookahead and thus the Bloom filter that was previously calculated has become stale.
|
||||||
*/
|
*/
|
||||||
public int getCombinedKeyLookaheadEpochs() {
|
public int getCombinedKeyLookaheadEpochs() {
|
||||||
checkState(isSupportsDeterministicChains(), "doesn't support deterministic chains");
|
checkState(supportsDeterministicChains(), "doesn't support deterministic chains");
|
||||||
int epoch = 0;
|
int epoch = 0;
|
||||||
for (DeterministicKeyChain chain : chains)
|
for (DeterministicKeyChain chain : chains)
|
||||||
epoch += chain.getKeyLookaheadEpoch();
|
epoch += chain.getKeyLookaheadEpoch();
|
||||||
|
|
|
@ -4921,7 +4921,7 @@ public class Wallet extends BaseTaggableObject
|
||||||
public boolean checkForFilterExhaustion(FilteredBlock block) {
|
public boolean checkForFilterExhaustion(FilteredBlock block) {
|
||||||
keyChainGroupLock.lock();
|
keyChainGroupLock.lock();
|
||||||
try {
|
try {
|
||||||
if (!keyChainGroup.isSupportsDeterministicChains())
|
if (!keyChainGroup.supportsDeterministicChains())
|
||||||
return false;
|
return false;
|
||||||
int epoch = keyChainGroup.getCombinedKeyLookaheadEpochs();
|
int epoch = keyChainGroup.getCombinedKeyLookaheadEpochs();
|
||||||
for (Transaction tx : block.getAssociatedTransactions().values()) {
|
for (Transaction tx : block.getAssociatedTransactions().values()) {
|
||||||
|
@ -5394,7 +5394,7 @@ public class Wallet extends BaseTaggableObject
|
||||||
// We might have to create a new HD hierarchy if the previous ones are now rotating.
|
// We might have to create a new HD hierarchy if the previous ones are now rotating.
|
||||||
boolean allChainsRotating = true;
|
boolean allChainsRotating = true;
|
||||||
Script.ScriptType preferredScriptType = Script.ScriptType.P2PKH;
|
Script.ScriptType preferredScriptType = Script.ScriptType.P2PKH;
|
||||||
if (keyChainGroup.isSupportsDeterministicChains()) {
|
if (keyChainGroup.supportsDeterministicChains()) {
|
||||||
for (DeterministicKeyChain chain : keyChainGroup.getDeterministicKeyChains()) {
|
for (DeterministicKeyChain chain : keyChainGroup.getDeterministicKeyChains()) {
|
||||||
if (chain.getEarliestKeyCreationTime() >= keyRotationTimestamp)
|
if (chain.getEarliestKeyCreationTime() >= keyRotationTimestamp)
|
||||||
allChainsRotating = false;
|
allChainsRotating = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue