Skip to content

Commit

Permalink
Merge pull request btcsuite#852 from ziggie1984/psbt-nil-pointer-bug
Browse files Browse the repository at this point in the history
Verify psbt input data before finalizing
  • Loading branch information
guggero authored and buck54321 committed Apr 21, 2024
1 parent b5f12f3 commit d6d229d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions wallet/psbt.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,9 @@ func (w *Wallet) FinalizePsbt(keyScope *waddrmgr.KeyScope, account uint32,
packet *psbt.Packet) error {

// Let's check that this is actually something we can and want to sign.
// We need at least one input and one output.
err := psbt.VerifyInputOutputLen(packet, true, true)
// We need at least one input and one output. In addition each
// input needs nonWitness Utxo or witness Utxo data specified.
err := psbt.InputsReadyToSign(packet)
if err != nil {
return err
}
Expand Down Expand Up @@ -462,9 +463,9 @@ func (w *Wallet) FinalizePsbt(keyScope *waddrmgr.KeyScope, account uint32,
if keyScope == nil {
// If a key scope wasn't specified, then coin
// selection was performed from the default
// wallet accounts (NP2WKH, P2WKH), so any key
// scope provided doesn't impact the result of
// this call.
// wallet accounts (NP2WKH, P2WKH, P2TR), so any
// key scope provided doesn't impact the result
// of this call.
watchOnly, err = w.Manager.IsWatchOnlyAccount(
ns, waddrmgr.KeyScopeBIP0084, account,
)
Expand Down

0 comments on commit d6d229d

Please sign in to comment.