From b3f14d66f0423a8512d1c55e2b5233fc77425bd7 Mon Sep 17 00:00:00 2001 From: eugene Date: Thu, 22 Apr 2021 12:18:04 -0400 Subject: [PATCH] lnwallet/chanfunding: assert PSBT Inputs have WitnessUtxo --- lnwallet/chanfunding/psbt_assembler.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lnwallet/chanfunding/psbt_assembler.go b/lnwallet/chanfunding/psbt_assembler.go index 4d15ff53..75b0e708 100644 --- a/lnwallet/chanfunding/psbt_assembler.go +++ b/lnwallet/chanfunding/psbt_assembler.go @@ -249,6 +249,15 @@ func (i *PsbtIntent) Verify(packet *psbt.Packet) error { "output amount sum") } + // SumUtxoInputValues checks that packet.Inputs is non-empty. Here we + // check that each Input has a WitnessUtxo field, to avoid possible + // malleability. + for _, in := range packet.Inputs { + if in.WitnessUtxo == nil { + return fmt.Errorf("not all inputs are segwit spends") + } + } + i.PendingPsbt = packet i.State = PsbtVerified return nil