mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-23 18:20:06 +02:00
invoices: properly set Preimage for settle resolutions
This fixes a nil-pointer-dereference that would occur if this was called for a settled AMP invoice. Terms.PaymentPreimage is always false for AMP invoices.
This commit is contained in:
parent
6dcec862aa
commit
d76278bc1e
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user