From e11c41ba8f71766f74a9fe201a60a2d64e80ad52 Mon Sep 17 00:00:00 2001 From: Liviu Date: Sun, 30 Jan 2022 21:37:32 -0800 Subject: [PATCH 1/2] walletrpc: return an error when finalizing an already complete PSBT Return an error to the client if attempting to finalize a PSBS with no missing signatures. --- lnrpc/walletrpc/walletkit_server.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lnrpc/walletrpc/walletkit_server.go b/lnrpc/walletrpc/walletkit_server.go index d0e807c6d..71f192537 100644 --- a/lnrpc/walletrpc/walletkit_server.go +++ b/lnrpc/walletrpc/walletkit_server.go @@ -1254,8 +1254,7 @@ func (w *WalletKit) FinalizePsbt(_ context.Context, account = req.Account } - // Parse the funded PSBT. No additional checks are required at this - // level as the wallet will perform all of them. + // Parse the funded PSBT. packet, err := psbt.NewFromRawBytes( bytes.NewReader(req.FundedPsbt), false, ) @@ -1263,6 +1262,12 @@ func (w *WalletKit) FinalizePsbt(_ context.Context, return nil, fmt.Errorf("error parsing PSBT: %v", err) } + // The only check done at this level is to validate that the PSBT is + // not complete. The wallet performs all other checks. + if packet.IsComplete() { + return nil, fmt.Errorf("PSBT is already fully signed") + } + // Let the wallet do the heavy lifting. This will sign all inputs that // we have the UTXO for. If some inputs can't be signed and don't have // witness data attached, this will fail. From 78ee332f96c9013fb7f5e86d9258672a9e309398 Mon Sep 17 00:00:00 2001 From: liviu-ln <96348901+liviu-ln@users.noreply.github.com> Date: Sun, 30 Jan 2022 22:33:39 -0800 Subject: [PATCH 2/2] docs: update release notes --- docs/release-notes/release-notes-0.15.0.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/release-notes-0.15.0.md b/docs/release-notes/release-notes-0.15.0.md index 9f6000be2..a852f5e4a 100644 --- a/docs/release-notes/release-notes-0.15.0.md +++ b/docs/release-notes/release-notes-0.15.0.md @@ -65,6 +65,8 @@ * [Add dev only RPC subserver and the devrpc.ImportGraph call](https://github.com/lightningnetwork/lnd/pull/6149) +* [Improve validation of a PSBT packet when handling a request to finalize it.](https://github.com/lightningnetwork/lnd/pull/6217) + ## Documentation * Improved instructions on [how to build lnd for mobile](https://github.com/lightningnetwork/lnd/pull/6085).