Skip to content

Commit

Permalink
Merge pull request lightningnetwork#6217 from liviu-ln/psbt-finalize-…
Browse files Browse the repository at this point in the history
…check

walletrpc: return an error when finalizing an already complete PSBT
  • Loading branch information
guggero authored Mar 14, 2022
2 parents 41b91bd + 78ee332 commit 95c270d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/release-notes/release-notes-0.15.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
* [Add ForAll implementation for etcd to speed up
graph cache at startup](https://github.com/lightningnetwork/lnd/pull/6136)

* [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).
Expand Down
9 changes: 7 additions & 2 deletions lnrpc/walletrpc/walletkit_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,15 +1254,20 @@ 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,
)
if err != nil {
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.
Expand Down

0 comments on commit 95c270d

Please sign in to comment.