Skip to content

Commit

Permalink
waddrmgr: add MasterKeyFingerprint to new addresses
Browse files Browse the repository at this point in the history
When deriving a new address, we'll want to store the correct master key
fingerprint from the account it's derived from.
This makes sure PSBT signing succeeds even for imported accounts and
their change addresses.
  • Loading branch information
guggero authored and kaloudis committed Apr 8, 2024
1 parent 0615527 commit 141f003
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions waddrmgr/scoped_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,8 @@ func (s *ScopedKeyManager) accountAddrType(acctInfo *accountInfo,
//
// This function MUST be called with the manager lock held for writes.
func (s *ScopedKeyManager) nextAddresses(ns walletdb.ReadWriteBucket,
account uint32, numAddresses uint32, internal bool) ([]ManagedAddress, error) {
account uint32, numAddresses uint32, internal bool) ([]ManagedAddress,
error) {

// The next address can only be generated for accounts that have
// already been created.
Expand Down Expand Up @@ -1089,10 +1090,11 @@ func (s *ScopedKeyManager) nextAddresses(ns walletdb.ReadWriteBucket,
// proper derivation path so this information can be available
// to callers.
derivationPath := DerivationPath{
InternalAccount: account,
Account: acctKey.ChildIndex(),
Branch: branchNum,
Index: nextIndex - 1,
InternalAccount: account,
Account: acctKey.ChildIndex(),
Branch: branchNum,
Index: nextIndex - 1,
MasterKeyFingerprint: acctInfo.masterKeyFingerprint,
}

// Create a new managed address based on the public or private
Expand Down

0 comments on commit 141f003

Please sign in to comment.