From ed2e5425151f02664caa33b126c6aa8e462d70c0 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 10 Nov 2022 13:10:54 +0100 Subject: [PATCH] rpcwallet: don't re-use sign desc in loop This commit fixes an issue with signing for mixed inputs in a remote signing setup where the re-use of the sign descriptor would lead to the sign method not being reset correctly if a p2wkh input is following a p2tr input. --- lnwallet/rpcwallet/rpcwallet.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index 6ae9af166..71d74e7e8 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -139,12 +139,15 @@ func (r *RPCKeyRing) SendOutputs(outputs []*wire.TxOut, // We know at this point that we only have inputs from our own wallet. // So we can just compute the input script using the remote signer. outputFetcher := lnwallet.NewWalletPrevOutputFetcher(r.WalletController) - signDesc := input.SignDescriptor{ - HashType: txscript.SigHashAll, - SigHashes: txscript.NewTxSigHashes(tx, outputFetcher), - PrevOutputFetcher: outputFetcher, - } for i, txIn := range tx.TxIn { + signDesc := input.SignDescriptor{ + HashType: txscript.SigHashAll, + SigHashes: txscript.NewTxSigHashes( + tx, outputFetcher, + ), + PrevOutputFetcher: outputFetcher, + } + // We can only sign this input if it's ours, so we'll ask the // watch-only wallet if it can map this outpoint into a coin we // own. If not, then we can't continue because our wallet state