htlcswitch: abtract invoice from link

This commit detaches signaling the invoice registry that an htlc was
locked in from the actually settling of the htlc.

It is a preparation for hodl invoices.
This commit is contained in:
Joost Jager committed 2019-03-15 10:09:15 +01:00
1 parent aeb35d9898
commit 1f41a2abce
6 files changed
+162 -98

No files matched your search

+7 -4
View File
@@ -178,8 +178,10 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
}
// With the HTLC claimed, we can attempt to settle its
// corresponding invoice if we were the original destination.
err = h.Registry.SettleInvoice(h.payHash, h.htlcAmt)
// corresponding invoice if we were the original destination. As
// the htlc is already settled at this point, we don't need to
// process the result.
_, err = h.Registry.NotifyExitHopHtlc(h.payHash, h.htlcAmt)
if err != nil && err != channeldb.ErrInvoiceNotFound {
log.Errorf("Unable to settle invoice with payment "+
"hash %x: %v", h.payHash, err)
@@ -251,8 +253,9 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
}
// With the HTLC claimed, we can attempt to settle its corresponding
// invoice if we were the original destination.
err = h.Registry.SettleInvoice(h.payHash, h.htlcAmt)
// invoice if we were the original destination. As the htlc is already
// settled at this point, we don't need to read the result.
_, err = h.Registry.NotifyExitHopHtlc(h.payHash, h.htlcAmt)
if err != nil && err != channeldb.ErrInvoiceNotFound {
log.Errorf("Unable to settle invoice with payment "+
"hash %x: %v", h.payHash, err)