get account from derivation path

This commit is contained in:
Craig Raw 2020-05-14 13:36:19 +02:00
parent 766a986abb
commit 0c9a100c6d

View file

@ -409,6 +409,21 @@ public enum ScriptType {
return Collections.unmodifiableList(copy); return Collections.unmodifiableList(copy);
} }
public int getAccount(String derivationPath) {
if(KeyDerivation.isValid(derivationPath)) {
List<ChildNumber> derivation = new ArrayList<>(KeyDerivation.parsePath(derivationPath));
if(derivation.size() > 2) {
int account = derivation.get(2).num();
List<ChildNumber> defaultDerivation = getDefaultDerivation(account);
if(defaultDerivation.equals(derivation)) {
return account;
}
}
}
return -1;
}
public abstract List<PolicyType> getAllowedPolicyTypes(); public abstract List<PolicyType> getAllowedPolicyTypes();
public boolean isAllowed(PolicyType policyType) { public boolean isAllowed(PolicyType policyType) {