mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01: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
1 changed files with 9 additions and 1 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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue