From a7dd28dde75a8086a4d23caa138cd0ad48c0db1d Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 6 May 2024 09:51:17 +0200 Subject: [PATCH] add additional fingerprint check when finding signing nodes from provided psbt input derivation paths --- src/main/java/com/sparrowwallet/drongo/wallet/Keystore.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Keystore.java b/src/main/java/com/sparrowwallet/drongo/wallet/Keystore.java index 7c47553..dd9dd6c 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Keystore.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Keystore.java @@ -246,14 +246,16 @@ public class Keystore extends Persistable { public ECKey getPubKeyForDerivation(KeyDerivation keyDerivation) { if(keyDerivation != null) { List derivation = keyDerivation.getDerivation(); + String fingerprint = Utils.bytesToHex(this.extendedPublicKey.getKey().getFingerprint()); if(derivation.size() > this.keyDerivation.getDerivation().size()) { List xpubDerivation = derivation.subList(0, this.keyDerivation.getDerivation().size()); if(xpubDerivation.equals(this.keyDerivation.getDerivation())) { derivation = derivation.subList(this.keyDerivation.getDerivation().size(), derivation.size()); + fingerprint = this.keyDerivation.getMasterFingerprint(); } } - if(derivation.size() == 2 && KeyPurpose.fromChildNumber(derivation.get(0)) != null) { + if(derivation.size() == 2 && KeyPurpose.fromChildNumber(derivation.get(0)) != null && fingerprint.equals(keyDerivation.getMasterFingerprint())) { return getPubKey(new WalletNode(KeyDerivation.writePath(derivation))); } }