diff --git a/invoices/update.go b/invoices/update.go index 011e4b620..dc4b42e87 100644 --- a/invoices/update.go +++ b/invoices/update.go @@ -108,8 +108,16 @@ func updateInvoice(ctx *invoiceUpdateCtx, inv *channeldb.Invoice) ( return nil, ctx.acceptRes(resultReplayToAccepted), nil case channeldb.HtlcStateSettled: + pre := inv.Terms.PaymentPreimage + + // Terms.PaymentPreimage will be nil for AMP invoices. + // Set it to the HTLC's AMP Preimage instead. + if pre == nil { + pre = htlc.AMP.Preimage + } + return nil, ctx.settleRes( - *inv.Terms.PaymentPreimage, + *pre, ResultReplayToSettled, ), nil @@ -196,13 +204,6 @@ func updateMpp(ctx *invoiceUpdateCtx, // Check whether total amt matches other htlcs in the set. var newSetTotal lnwire.MilliSatoshi for _, htlc := range htlcSet { - // Only consider accepted mpp htlcs. It is possible that there - // are htlcs registered in the invoice database that previously - // timed out and are in the canceled state now. - if htlc.State != channeldb.HtlcStateAccepted { - continue - } - if ctx.mpp.TotalMsat() != htlc.MppTotalAmt { return nil, ctx.failRes(ResultHtlcSetTotalMismatch), nil }