From e1f2ce41ad2ca8771c6e79eaa488b12295ac6b0b Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 9 Jul 2025 10:26:37 +0200 Subject: [PATCH] fix issue of including parent path elements in deterministic key when deriving child xpub from an output descriptor containing more than two child path elements --- src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java index d6b7039..a5fede5 100644 --- a/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java +++ b/src/main/java/com/sparrowwallet/drongo/OutputDescriptor.java @@ -449,7 +449,8 @@ public class OutputDescriptor { keyDerivation = keyDerivation.extend(childPath); childPath.addFirst(extendedKey.getKeyChildNumber()); DeterministicKey derivedKey = extendedKey.getKey(childPath); - extendedKey = new ExtendedKey(derivedKey, derivedKey.getParentFingerprint(), childPath.getLast()); + DeterministicKey pubKey = new DeterministicKey(List.of(derivedKey.getPath().getLast()), derivedKey.getChainCode(), derivedKey.getPubKey(), derivedKey.getDepth(), derivedKey.getParentFingerprint()); + extendedKey = new ExtendedKey(pubKey, pubKey.getParentFingerprint(), childPath.getLast()); } } catch(Exception e) { //ignore and continue