Merge pull request #6611 from Roasbeef/psbt-validation-fix

lnrpc/walletrpc: reject PSBT packets w/o any UTXO input info
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2022-06-02 14:44:59 -07:00
commit 622c8402a0
2 files changed
+15

No files matched your search

@@ -183,6 +183,8 @@ from occurring that would result in an erroneous force close.](https://github.co
* [Fixes an issue related to HTLCs on lease enforced channels that can lead to itest flakes](https://github.com/lightningnetwork/lnd/pull/6605/files)
* [Fixes a bug that would cause `SignPsbt` to panic w/ an underspecified packet](https://github.com/lightningnetwork/lnd/pull/6611)
## Routing
* [Add a new `time_pref` parameter to the QueryRoutes and SendPayment APIs](https://github.com/lightningnetwork/lnd/pull/6024) that
+13
View File
@@ -1234,6 +1234,19 @@ func (w *WalletKit) SignPsbt(_ context.Context, req *SignPsbtRequest) (
return nil, fmt.Errorf("error parsing PSBT: %v", err)
}
// Before we attempt to sign the packet, ensure that every input either
// has a witness UTXO, or a non witness UTXO.
for idx := range packet.UnsignedTx.TxIn {
in := packet.Inputs[idx]
// Doesn't have either a witness or non witness UTXO so we need
// to exit here as otherwise signing will fail.
if in.WitnessUtxo == nil && in.NonWitnessUtxo == nil {
return nil, fmt.Errorf("input (index=%v) doesn't "+
"specify any UTXO info", idx)
}
}
// 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, they will just be skipped.