From d5393bd436636bccfcb846192370fbfef4f2a194 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 19 Nov 2024 10:46:22 +0200 Subject: [PATCH] add output descriptor accessors and copy function --- .../com/sparrowwallet/drongo/OutputDescriptor.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java index 4857971..292f878 100644 --- a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java +++ b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java @@ -73,6 +73,10 @@ public class OutputDescriptor { return Collections.unmodifiableSet(extendedPublicKeys.keySet()); } + public Map getExtendedPublicKeysMap() { + return Collections.unmodifiableMap(extendedPublicKeys); + } + public KeyDerivation getKeyDerivation(ExtendedKey extendedPublicKey) { return extendedPublicKeys.get(extendedPublicKey); } @@ -81,6 +85,10 @@ public class OutputDescriptor { return multisigThreshold; } + public Map getChildDerivationsMap() { + return Collections.unmodifiableMap(mapChildrenDerivations); + } + public String getChildDerivationPath(ExtendedKey extendedPublicKey) { return mapChildrenDerivations.get(extendedPublicKey); } @@ -671,4 +679,9 @@ public class OutputDescriptor { public int hashCode() { return toString().hashCode(); } + + public OutputDescriptor copy(boolean includeChildDerivations) { + return new OutputDescriptor(scriptType, multisigThreshold, extendedPublicKeys, + includeChildDerivations ? mapChildrenDerivations : Collections.emptyMap(), mapExtendedPublicKeyLabels, extendedMasterPrivateKeys); + } }