Skip to content

Commit 15e6e35

Browse files
committed
invoices: fix log entries and add a TODO.
We need to make sure if we cancel an AMP invoice we also cancel all remaining HTLCs back.
1 parent 46f3260 commit 15e6e35

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

invoices/invoiceregistry.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,9 @@ func (i *InvoiceRegistry) cancelSingleHtlc(invoiceRef InvoiceRef,
659659

660660
// Only allow individual htlc cancellation on open invoices.
661661
if invoice.State != ContractOpen {
662-
log.Debugf("cancelSingleHtlc: invoice %v no longer "+
663-
"open", invoiceRef)
662+
log.Debugf("CancelSingleHtlc: cannot cancel htlc %v "+
663+
"on invoice %v, invoice is no longer open", key,
664+
invoiceRef)
664665

665666
return nil, nil
666667
}
@@ -678,13 +679,13 @@ func (i *InvoiceRegistry) cancelSingleHtlc(invoiceRef InvoiceRef,
678679
// Cancellation is only possible if the htlc wasn't already
679680
// resolved.
680681
if htlcState != HtlcStateAccepted {
681-
log.Debugf("cancelSingleHtlc: htlc %v on invoice %v "+
682+
log.Debugf("CancelSingleHtlc: htlc %v on invoice %v "+
682683
"is already resolved", key, invoiceRef)
683684

684685
return nil, nil
685686
}
686687

687-
log.Debugf("cancelSingleHtlc: cancelling htlc %v on invoice %v",
688+
log.Debugf("CancelSingleHtlc: cancelling htlc %v on invoice %v",
688689
key, invoiceRef)
689690

690691
// Return an update descriptor that cancels htlc and keeps
@@ -737,8 +738,9 @@ func (i *InvoiceRegistry) cancelSingleHtlc(invoiceRef InvoiceRef,
737738
key, int32(htlc.AcceptHeight), result,
738739
)
739740

740-
log.Debugf("Cancelling htlc (%v) of invoice(%v) with "+
741-
"resolution: %v", key, invoiceRef, result)
741+
log.Debugf("Signaling htlc(%v) cancellation of invoice(%v) "+
742+
"with resolution(%v) to the link subsystem", key,
743+
invoiceRef, result)
742744

743745
i.notifyHodlSubscribers(resolution)
744746
}
@@ -1457,6 +1459,8 @@ func (i *InvoiceRegistry) cancelInvoiceImpl(ctx context.Context,
14571459
}
14581460

14591461
invoiceRef := InvoiceRefByHash(payHash)
1462+
1463+
// We pass a nil setID which means no HTLCs will be read out.
14601464
invoice, err := i.idb.UpdateInvoice(ctx, invoiceRef, nil, updateInvoice)
14611465

14621466
// Implement idempotency by returning success if the invoice was already
@@ -1483,6 +1487,8 @@ func (i *InvoiceRegistry) cancelInvoiceImpl(ctx context.Context,
14831487
// that are waiting for resolution. Any htlcs that were already canceled
14841488
// before, will be notified again. This isn't necessary but doesn't hurt
14851489
// either.
1490+
//
1491+
// TODO(ziggie): Also consider AMP HTLCs here.
14861492
for key, htlc := range invoice.Htlcs {
14871493
if htlc.State != HtlcStateCanceled {
14881494
continue

0 commit comments

Comments
 (0)