From 5395a0fe6b7c637ea3d4cae0eaa645bb04eae438 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 27 Apr 2022 21:05:38 +0200 Subject: [PATCH] rpcwallet: attempt to locate UTXO information in prev output fetcher Since we might now be given a whole list of UTXOs in the PrevOutputs field of the SignOutputRaw RPC, the previous output fetcher might contain the information we require for the remote signing case. So instead of failing if our wallet doesn't know each input that's being spent, we fall back to the UTXO information contained in the previous outputs. --- lnwallet/rpcwallet/rpcwallet.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index a13c72635..4613b5223 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -803,6 +803,19 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor, &txIn.PreviousOutPoint, ) if err != nil { + // Maybe we have an UTXO in the previous output fetcher? + if signDesc.PrevOutputFetcher != nil { + utxo := signDesc.PrevOutputFetcher.FetchPrevOutput( + txIn.PreviousOutPoint, + ) + if utxo != nil && utxo.Value != 0 && + len(utxo.PkScript) > 0 { + + packet.Inputs[idx].WitnessUtxo = utxo + continue + } + } + log.Warnf("No UTXO info found for index %d "+ "(prev_outpoint=%v), won't be able to sign "+ "for taproot output!", idx,