@@ -221,14 +221,11 @@ func signPsbt(rootKey *hdkeychain.ExtendedKey,
221221func findMatchingDerivationPath (rootKey * hdkeychain.ExtendedKey ,
222222 pIn * psbt.PInput ) ([]uint32 , error ) {
223223
224- pubKey , err := rootKey . ECPubKey ( )
224+ masterFingerprint , _ , err := fingerprint ( rootKey )
225225 if err != nil {
226226 return nil , fmt .Errorf ("error getting public key: %w" , err )
227227 }
228228
229- pubKeyHash := btcutil .Hash160 (pubKey .SerializeCompressed ())
230- fingerprint := binary .LittleEndian .Uint32 (pubKeyHash [:4 ])
231-
232229 if len (pIn .Bip32Derivation ) == 0 {
233230 return nil , errNoPathFound
234231 }
@@ -246,10 +243,21 @@ func findMatchingDerivationPath(rootKey *hdkeychain.ExtendedKey,
246243
247244 // The normal case, where a derivation path has the master
248245 // fingerprint set.
249- if derivation .MasterKeyFingerprint == fingerprint {
246+ if derivation .MasterKeyFingerprint == masterFingerprint {
250247 return derivation .Bip32Path , nil
251248 }
252249 }
253250
254251 return nil , errNoPathFound
255252}
253+
254+ func fingerprint (rootKey * hdkeychain.ExtendedKey ) (uint32 , []byte , error ) {
255+ pubKey , err := rootKey .ECPubKey ()
256+ if err != nil {
257+ return 0 , nil , fmt .Errorf ("error getting public key: %w" , err )
258+ }
259+
260+ pubKeyHash := btcutil .Hash160 (pubKey .SerializeCompressed ())
261+ fpBytes := pubKeyHash [:4 ]
262+ return binary .LittleEndian .Uint32 (fpBytes ), fpBytes , nil
263+ }
0 commit comments