diff --git a/src/main/java/com/sparrowwallet/drongo/protocol/ScriptType.java b/src/main/java/com/sparrowwallet/drongo/protocol/ScriptType.java index fe15ca2..43d0490 100644 --- a/src/main/java/com/sparrowwallet/drongo/protocol/ScriptType.java +++ b/src/main/java/com/sparrowwallet/drongo/protocol/ScriptType.java @@ -1154,6 +1154,10 @@ public enum ScriptType { return description; } + public String getDescription(boolean includePolicyType) { + return includePolicyType && !getAllowedPolicyTypes().isEmpty() ? getAllowedPolicyTypes().getFirst().getName().toLowerCase(Locale.ROOT) + " " + description : description; + } + public String getDefaultDerivationPath() { return Network.get() != Network.MAINNET ? defaultDerivationPath.replace("/0'/0'", "/1'/0'") : defaultDerivationPath; } diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 182e824..a255a07 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -1812,15 +1812,19 @@ public class Wallet extends Persistable implements Comparable { } public boolean derivationMatchesAnotherScriptType(String derivationPath) { + return getOtherScriptTypeMatchingDerivation(derivationPath).isPresent(); + } + + public Optional getOtherScriptTypeMatchingDerivation(String derivationPath) { if(Boolean.TRUE.toString().equals(System.getProperty(ALLOW_DERIVATIONS_MATCHING_OTHER_SCRIPT_TYPES_PROPERTY))) { - return false; + return Optional.empty(); } if(scriptType != null && scriptType.getAccount(derivationPath) > -1) { - return false; + return Optional.empty(); } - return Arrays.stream(ScriptType.values()).anyMatch(scriptType -> !scriptType.equals(this.scriptType) && scriptType.getAccount(derivationPath, true) > -1); + return Arrays.stream(ScriptType.values()).filter(scriptType -> !scriptType.equals(this.scriptType) && scriptType.getAccount(derivationPath, true) > -1).findFirst(); } public boolean derivationMatchesAnotherNetwork(String derivationPath) {