Merge pull request #6525 from Crypt-iQ/amp_preimage_fix

invoices: properly set Preimage field for success resolution
This commit is contained in:
Olaoluwa Osuntokun 2022-05-13 15:15:03 -07:00 committed by GitHub
commit 2c4136da1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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