mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-02 18:26:43 +00:00
add additional fingerprint check when finding signing nodes from provided psbt input derivation paths
This commit is contained in:
parent
e298033cbb
commit
a7dd28dde7
1 changed files with 3 additions and 1 deletions
|
@ -246,14 +246,16 @@ public class Keystore extends Persistable {
|
||||||
public ECKey getPubKeyForDerivation(KeyDerivation keyDerivation) {
|
public ECKey getPubKeyForDerivation(KeyDerivation keyDerivation) {
|
||||||
if(keyDerivation != null) {
|
if(keyDerivation != null) {
|
||||||
List<ChildNumber> derivation = keyDerivation.getDerivation();
|
List<ChildNumber> derivation = keyDerivation.getDerivation();
|
||||||
|
String fingerprint = Utils.bytesToHex(this.extendedPublicKey.getKey().getFingerprint());
|
||||||
if(derivation.size() > this.keyDerivation.getDerivation().size()) {
|
if(derivation.size() > this.keyDerivation.getDerivation().size()) {
|
||||||
List<ChildNumber> xpubDerivation = derivation.subList(0, this.keyDerivation.getDerivation().size());
|
List<ChildNumber> xpubDerivation = derivation.subList(0, this.keyDerivation.getDerivation().size());
|
||||||
if(xpubDerivation.equals(this.keyDerivation.getDerivation())) {
|
if(xpubDerivation.equals(this.keyDerivation.getDerivation())) {
|
||||||
derivation = derivation.subList(this.keyDerivation.getDerivation().size(), derivation.size());
|
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)));
|
return getPubKey(new WalletNode(KeyDerivation.writePath(derivation)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue