mirror of
https://github.com/sparrowwallet/drongo.git
synced 2025-11-05 11:56:38 +00:00
support invalid script type warnings
This commit is contained in:
parent
5fd8e9416a
commit
66ff275f46
2 changed files with 11 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1812,15 +1812,19 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
|
|||
}
|
||||
|
||||
public boolean derivationMatchesAnotherScriptType(String derivationPath) {
|
||||
return getOtherScriptTypeMatchingDerivation(derivationPath).isPresent();
|
||||
}
|
||||
|
||||
public Optional<ScriptType> 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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue