lnrpc/walletrpc: reject PSBT packets w/o any UTXO input info

Fixes https://github.com/lightningnetwork/lnd/issues/6567
This commit is contained in:
Olaoluwa Osuntokun 2022-06-01 13:26:01 -07:00
parent 1017efe18b
commit 2298ef81ab
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306
2 changed files with 15 additions and 0 deletions

View file

@ -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

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.