invoices+channeldb: Fix AMP invoices behaviour.
We now cancel all HTLCs of an AMP invoice as soon as it expires. Otherwise because we mark the invoice as cancelled we would not allow accepted HTLCs to be resolved via the invoiceEventLoop.
This commit is contained in:
6 files changed
+205
-24
No files matched your search
+16
-4
@@ -1406,14 +1406,26 @@ func (i *SQLStore) UpdateInvoice(ctx context.Context, ref InvoiceRef,
|
||||
|
||||
txOpt := SQLInvoiceQueriesTxOptions{readOnly: false}
|
||||
txErr := i.db.ExecTx(ctx, &txOpt, func(db SQLInvoiceQueries) error {
|
||||
if setID != nil {
|
||||
// Make sure to use the set ID if this is an AMP update.
|
||||
switch {
|
||||
// For the default case we fetch all HTLCs.
|
||||
case setID == nil:
|
||||
ref.refModifier = DefaultModifier
|
||||
|
||||
// If the setID is the blank but NOT nil, we set the
|
||||
// refModifier to HtlcSetBlankModifier to fetch no HTLC for the
|
||||
// AMP invoice.
|
||||
case *setID == BlankPayAddr:
|
||||
ref.refModifier = HtlcSetBlankModifier
|
||||
|
||||
// A setID is provided, we use the refModifier to fetch only
|
||||
// the HTLCs for the given setID and also make sure we add the
|
||||
// setID to the ref.
|
||||
default:
|
||||
var setIDBytes [32]byte
|
||||
copy(setIDBytes[:], setID[:])
|
||||
ref.setID = &setIDBytes
|
||||
|
||||
// If we're updating an AMP invoice, we'll also only
|
||||
// need to fetch the HTLCs for the given set ID.
|
||||
// We only fetch the HTLCs for the given setID.
|
||||
ref.refModifier = HtlcSetOnlyModifier
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user