From 4da26fb65a669fbee68fa36e60259a8da8ef6d3b Mon Sep 17 00:00:00 2001 From: ziggie Date: Mon, 20 Mar 2023 22:43:15 +0100 Subject: [PATCH] btcwallet+rpcwallet: verify input data for psbt package Use the new method in the psbt package InputsReadyToSign which makes sure that each input has either nonWitness Utxo or witness Utxo data specified. --- lnwallet/btcwallet/psbt.go | 5 +++-- lnwallet/rpcwallet/rpcwallet.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lnwallet/btcwallet/psbt.go b/lnwallet/btcwallet/psbt.go index 7dbe12c2b..395c5667c 100644 --- a/lnwallet/btcwallet/psbt.go +++ b/lnwallet/btcwallet/psbt.go @@ -135,8 +135,9 @@ func (b *BtcWallet) SignPsbt(packet *psbt.Packet) ([]uint32, error) { var signedInputs []uint32 // 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 nil, err } diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index 38f345c14..536ce6260 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -255,8 +255,9 @@ func (r *RPCKeyRing) SignPsbt(packet *psbt.Packet) ([]uint32, error) { // parameter in FinalizePsbt so we can get rid of this code duplication. func (r *RPCKeyRing) FinalizePsbt(packet *psbt.Packet, _ string) 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 }