channeldb/invoice: fail extra HTLC sets immeidately

This commit is contained in:
Conner Fromknecht committed 2021-05-10 16:55:18 -07:00
1 parent 70efaa5fe2
commit 8402e346f5
3 files changed
+49

No files matched your search

+17
View File
@@ -1063,6 +1063,23 @@ func (i *InvoiceRegistry) notifyExitHopHtlcLocked(
i.notifyHodlSubscribers(htlcSettleResolution)
}
// If concurrent payments were attempted to this invoice before
// the current one was ultimately settled, cancel back any of
// the HTLCs immediately. As a result of the settle, the HTLCs
// in other HTLC sets are automatically converted to a canceled
// state when updating the invoice.
canceledHtlcSet := invoice.HTLCSetCompliment(
setID, channeldb.HtlcStateCanceled,
)
for key, htlc := range canceledHtlcSet {
htlcFailResolution := NewFailResolution(
key, int32(htlc.AcceptHeight),
ResultInvoiceAlreadySettled,
)
i.notifyHodlSubscribers(htlcFailResolution)
}
// If we accepted the htlc, subscribe to the hodl invoice and return
// an accept resolution with the htlc's accept time on it.
case *htlcAcceptResolution:
+7
View File
@@ -61,6 +61,10 @@ const (
// invoice that is already canceled.
ResultInvoiceAlreadyCanceled
// ResultInvoiceAlreadySettled is returned when trying to pay an invoice
// that is already settled.
ResultInvoiceAlreadySettled
// ResultAmountTooLow is returned when an invoice is underpaid.
ResultAmountTooLow
@@ -133,6 +137,9 @@ func (f FailResolutionResult) FailureString() string {
case ResultInvoiceAlreadyCanceled:
return "invoice already canceled"
case ResultInvoiceAlreadySettled:
return "invoice alread settled"
case ResultAmountTooLow:
return "amount too low"