add output descriptor accessors and copy function

This commit is contained in:
Craig Raw 2024-11-19 10:46:22 +02:00
parent 817458a0c3
commit d5393bd436

View file

@ -73,6 +73,10 @@ public class OutputDescriptor {
return Collections.unmodifiableSet(extendedPublicKeys.keySet()); return Collections.unmodifiableSet(extendedPublicKeys.keySet());
} }
public Map<ExtendedKey, KeyDerivation> getExtendedPublicKeysMap() {
return Collections.unmodifiableMap(extendedPublicKeys);
}
public KeyDerivation getKeyDerivation(ExtendedKey extendedPublicKey) { public KeyDerivation getKeyDerivation(ExtendedKey extendedPublicKey) {
return extendedPublicKeys.get(extendedPublicKey); return extendedPublicKeys.get(extendedPublicKey);
} }
@ -81,6 +85,10 @@ public class OutputDescriptor {
return multisigThreshold; return multisigThreshold;
} }
public Map<ExtendedKey, String> getChildDerivationsMap() {
return Collections.unmodifiableMap(mapChildrenDerivations);
}
public String getChildDerivationPath(ExtendedKey extendedPublicKey) { public String getChildDerivationPath(ExtendedKey extendedPublicKey) {
return mapChildrenDerivations.get(extendedPublicKey); return mapChildrenDerivations.get(extendedPublicKey);
} }
@ -671,4 +679,9 @@ public class OutputDescriptor {
public int hashCode() { public int hashCode() {
return toString().hashCode(); return toString().hashCode();
} }
public OutputDescriptor copy(boolean includeChildDerivations) {
return new OutputDescriptor(scriptType, multisigThreshold, extendedPublicKeys,
includeChildDerivations ? mapChildrenDerivations : Collections.emptyMap(), mapExtendedPublicKeyLabels, extendedMasterPrivateKeys);
}
} }