mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
Merge pull request #6525 from Crypt-iQ/amp_preimage_fix
invoices: properly set Preimage field for success resolution
This commit is contained in:
commit
2c4136da1b
1 changed files with 9 additions and 8 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue