diff --git a/contractcourt/interfaces.go b/contractcourt/interfaces.go index c928f4289..c73a23a03 100644 --- a/contractcourt/interfaces.go +++ b/contractcourt/interfaces.go @@ -21,7 +21,7 @@ type Registry interface { NotifyExitHopHtlc(payHash lntypes.Hash, paidAmount lnwire.MilliSatoshi, expiry uint32, currentHeight int32, circuitKey channeldb.CircuitKey, hodlChan chan<- interface{}, - eob []byte) (*invoices.HodlEvent, error) + payload invoices.Payload) (*invoices.HodlEvent, error) // HodlUnsubscribeAll unsubscribes from all hodl events. HodlUnsubscribeAll(subscriber chan<- interface{}) diff --git a/contractcourt/mock_registry_test.go b/contractcourt/mock_registry_test.go index e45022893..43195249c 100644 --- a/contractcourt/mock_registry_test.go +++ b/contractcourt/mock_registry_test.go @@ -24,7 +24,7 @@ type mockRegistry struct { func (r *mockRegistry) NotifyExitHopHtlc(payHash lntypes.Hash, paidAmount lnwire.MilliSatoshi, expiry uint32, currentHeight int32, circuitKey channeldb.CircuitKey, hodlChan chan<- interface{}, - eob []byte) (*invoices.HodlEvent, error) { + payload invoices.Payload) (*invoices.HodlEvent, error) { r.notifyChan <- notifyExitHopData{ hodlChan: hodlChan, diff --git a/htlcswitch/hop/payload.go b/htlcswitch/hop/payload.go index ad164e287..e05b4ee98 100644 --- a/htlcswitch/hop/payload.go +++ b/htlcswitch/hop/payload.go @@ -233,3 +233,9 @@ func ValidateParsedPayloadTypes(parsedTypes tlv.TypeSet, return nil } + +// MultiPath returns the record corresponding the option_mpp parsed from the +// onion payload. +func (h *Payload) MultiPath() *record.MPP { + return h.MPP +} diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index cd050856c..3b9ac6dff 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -27,7 +27,7 @@ type InvoiceDatabase interface { NotifyExitHopHtlc(payHash lntypes.Hash, paidAmount lnwire.MilliSatoshi, expiry uint32, currentHeight int32, circuitKey channeldb.CircuitKey, hodlChan chan<- interface{}, - eob []byte) (*invoices.HodlEvent, error) + payload invoices.Payload) (*invoices.HodlEvent, error) // CancelInvoice attempts to cancel the invoice corresponding to the // passed payment hash. diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 4593d0420..4da9c0db6 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -2676,8 +2676,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg, switch fwdInfo.NextHop { case hop.Exit: updated, err := l.processExitHop( - pd, obfuscator, fwdInfo, heightNow, - chanIterator.ExtraOnionBlob(), + pd, obfuscator, fwdInfo, heightNow, pld, ) if err != nil { l.fail(LinkFailureError{code: ErrInternalError}, @@ -2846,7 +2845,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg, // returns a boolean indicating whether the commitment tx needs an update. func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor, obfuscator hop.ErrorEncrypter, fwdInfo hop.ForwardingInfo, - heightNow uint32, eob []byte) (bool, error) { + heightNow uint32, payload invoices.Payload) (bool, error) { // If hodl.ExitSettle is requested, we will not validate the final hop's // ADD, nor will we settle the corresponding invoice or respond with the @@ -2897,7 +2896,7 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor, event, err := l.cfg.Registry.NotifyExitHopHtlc( invoiceHash, pd.Amount, pd.Timeout, int32(heightNow), - circuitKey, l.hodlQueue.ChanIn(), eob, + circuitKey, l.hodlQueue.ChanIn(), payload, ) switch err { diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 7701846e1..3dc1160df 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -814,10 +814,11 @@ func (i *mockInvoiceRegistry) SettleHodlInvoice(preimage lntypes.Preimage) error func (i *mockInvoiceRegistry) NotifyExitHopHtlc(rhash lntypes.Hash, amt lnwire.MilliSatoshi, expiry uint32, currentHeight int32, circuitKey channeldb.CircuitKey, hodlChan chan<- interface{}, - eob []byte) (*invoices.HodlEvent, error) { + payload invoices.Payload) (*invoices.HodlEvent, error) { event, err := i.registry.NotifyExitHopHtlc( - rhash, amt, expiry, currentHeight, circuitKey, hodlChan, eob, + rhash, amt, expiry, currentHeight, circuitKey, hodlChan, + payload, ) if err != nil { return nil, err diff --git a/invoices/interface.go b/invoices/interface.go new file mode 100644 index 000000000..8bbe2ec9f --- /dev/null +++ b/invoices/interface.go @@ -0,0 +1,11 @@ +package invoices + +import "github.com/lightningnetwork/lnd/record" + +// Payload abstracts access to any additional fields provided in the final hop's +// TLV onion payload. +type Payload interface { + // MultiPath returns the record corresponding the option_mpp parsed from + // the onion payload. + MultiPath() *record.MPP +} diff --git a/invoices/invoiceregistry.go b/invoices/invoiceregistry.go index 3f35954f8..61f0feaf2 100644 --- a/invoices/invoiceregistry.go +++ b/invoices/invoiceregistry.go @@ -429,7 +429,7 @@ func (i *InvoiceRegistry) LookupInvoice(rHash lntypes.Hash) (channeldb.Invoice, func (i *InvoiceRegistry) NotifyExitHopHtlc(rHash lntypes.Hash, amtPaid lnwire.MilliSatoshi, expiry uint32, currentHeight int32, circuitKey channeldb.CircuitKey, hodlChan chan<- interface{}, - eob []byte) (*HodlEvent, error) { + payload Payload) (*HodlEvent, error) { i.Lock() defer i.Unlock()