From 2a069b8b4e2845bc09dbdc441cb4966647cd64c4 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 12 Apr 2022 19:30:11 +0200 Subject: [PATCH 1/3] rpcserver: copy success variable of channel close update Seems this was forgotten in a refactor a while back. --- rpcserver.go | 1 + 1 file changed, 1 insertion(+) diff --git a/rpcserver.go b/rpcserver.go index 6c768d0f9..21e975587 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2539,6 +2539,7 @@ func createRPCCloseUpdate(update interface{}) ( Update: &lnrpc.CloseStatusUpdate_ChanClose{ ChanClose: &lnrpc.ChannelCloseUpdate{ ClosingTxid: u.ClosingTxid, + Success: u.Success, }, }, }, nil From 1e72d6737db704c2b16c09c20b53a49e15362f67 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 12 Apr 2022 19:30:12 +0200 Subject: [PATCH 2/3] lnrpc+itest: fix panic with missing UTXO info Fixes #6396. This commit fixes a panic that occurred when trying to sign for a Taproot output without specifying the full UTXO information for each input. Instead of panicking an error is now returned. --- lnrpc/signrpc/signer_server.go | 18 ++++++++++++++++++ lntest/itest/lnd_taproot_test.go | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/lnrpc/signrpc/signer_server.go b/lnrpc/signrpc/signer_server.go index 1474c0ec9..b191176b3 100644 --- a/lnrpc/signrpc/signer_server.go +++ b/lnrpc/signrpc/signer_server.go @@ -376,6 +376,24 @@ func (s *Server) SignOutputRaw(_ context.Context, in *SignReq) (*SignResp, InputIndex: int(signDesc.InputIndex), PrevOutputFetcher: prevOutputFetcher, }) + + // Are we trying to sign for a Taproot output? Then we need all + // previous outputs being declared, otherwise we'd run into a + // panic later on. + if txscript.IsPayToTaproot(signDesc.Output.PkScript) { + for idx, txIn := range txToSign.TxIn { + utxo := prevOutputFetcher.FetchPrevOutput( + txIn.PreviousOutPoint, + ) + if utxo == nil { + return nil, fmt.Errorf("error signing "+ + "taproot output, transaction "+ + "input %d is missing its "+ + "previous outpoint information", + idx) + } + } + } } // Now that we've mapped all the proper sign descriptors, we can diff --git a/lntest/itest/lnd_taproot_test.go b/lntest/itest/lnd_taproot_test.go index cb0510a49..20d5d37dc 100644 --- a/lntest/itest/lnd_taproot_test.go +++ b/lntest/itest/lnd_taproot_test.go @@ -232,6 +232,29 @@ func testTaprootScriptSpend(ctxt context.Context, t *harnessTest, PkScript: p2trPkScript, Value: 800_000, }} + + // Before we actually sign, we want to make sure that we get an error + // when we try to sign for a Taproot output without specifying all UTXO + // information. + _, err = net.Alice.SignerClient.SignOutputRaw( + ctxt, &signrpc.SignReq{ + RawTxBytes: buf.Bytes(), + SignDescs: []*signrpc.SignDescriptor{{ + Output: utxoInfo[0], + InputIndex: 0, + KeyDesc: keyDesc, + Sighash: uint32(txscript.SigHashDefault), + WitnessScript: leaf2.Script, + }}, + }, + ) + require.Error(t.t, err) + require.Contains( + t.t, err.Error(), "error signing taproot output, transaction "+ + "input 0 is missing its previous outpoint information", + ) + + // Do the actual signing now. signResp, err := net.Alice.SignerClient.SignOutputRaw( ctxt, &signrpc.SignReq{ RawTxBytes: buf.Bytes(), From 9281e7a6927974a4d719e4a2a8b9662aa4883de5 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 12 Apr 2022 19:30:13 +0200 Subject: [PATCH 3/3] docs: add release notes --- docs/release-notes/release-notes-0.15.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes/release-notes-0.15.0.md b/docs/release-notes/release-notes-0.15.0.md index e8c3c3e08..fcee2e324 100644 --- a/docs/release-notes/release-notes-0.15.0.md +++ b/docs/release-notes/release-notes-0.15.0.md @@ -84,6 +84,10 @@ then watch it on chain. Taproot script spends are also supported through the * [Fixed race condition resulting in MPP payments sometimes getting stuck in-flight](https://github.com/lightningnetwork/lnd/pull/6352). +* [Fixed a panic in the Taproot signing part of the `SignOutputRaw` RPC that + occurred when not all UTXO information was + specified](https://github.com/lightningnetwork/lnd/pull/6407). + ## Misc * [An example systemd service file](https://github.com/lightningnetwork/lnd/pull/6033)