diff --git a/htlcswitch/hop/payload.go b/htlcswitch/hop/payload.go index d8aafd9c..c6a25ba6 100644 --- a/htlcswitch/hop/payload.go +++ b/htlcswitch/hop/payload.go @@ -86,6 +86,10 @@ type Payload struct { // a TLV onion payload. MPP *record.MPP + // AMP holds the info provided in an option_amp record when parsed from + // a TLV onion payload. + AMP *record.AMP + // customRecords are user-defined records in the custom type range that // were included in the payload. customRecords record.CustomSet @@ -250,6 +254,12 @@ func (h *Payload) MultiPath() *record.MPP { return h.MPP } +// AMPRecord returns the record corresponding with option_amp parsed from the +// onion payload. +func (h *Payload) AMPRecord() *record.AMP { + return h.AMP +} + // CustomRecords returns the custom tlv type records that were parsed from the // payload. func (h *Payload) CustomRecords() record.CustomSet { diff --git a/invoices/interface.go b/invoices/interface.go index c511dded..732b39e1 100644 --- a/invoices/interface.go +++ b/invoices/interface.go @@ -11,6 +11,10 @@ type Payload interface { // the onion payload. MultiPath() *record.MPP + // AMPRecord returns the record corresponding to the option_amp record + // parsed from the onion payload. + AMPRecord() *record.AMP + // CustomRecords returns the custom tlv type records that were parsed // from the payload. CustomRecords() record.CustomSet diff --git a/invoices/invoiceregistry.go b/invoices/invoiceregistry.go index cd7ebe8c..dcaa9898 100644 --- a/invoices/invoiceregistry.go +++ b/invoices/invoiceregistry.go @@ -802,6 +802,7 @@ func (i *InvoiceRegistry) NotifyExitHopHtlc(rHash lntypes.Hash, finalCltvRejectDelta: i.cfg.FinalCltvRejectDelta, customRecords: payload.CustomRecords(), mpp: payload.MultiPath(), + amp: payload.AMPRecord(), } // Process keysend if present. Do this outside of the lock, because diff --git a/invoices/test_utils_test.go b/invoices/test_utils_test.go index 63cf8d98..73d41346 100644 --- a/invoices/test_utils_test.go +++ b/invoices/test_utils_test.go @@ -23,6 +23,7 @@ import ( type mockPayload struct { mpp *record.MPP + amp *record.AMP customRecords record.CustomSet } @@ -30,6 +31,10 @@ func (p *mockPayload) MultiPath() *record.MPP { return p.mpp } +func (p *mockPayload) AMPRecord() *record.AMP { + return p.amp +} + func (p *mockPayload) CustomRecords() record.CustomSet { // This function should always return a map instance, but for mock // configuration we do accept nil. diff --git a/invoices/update.go b/invoices/update.go index 8e2fd194..f7eaf4e4 100644 --- a/invoices/update.go +++ b/invoices/update.go @@ -20,6 +20,7 @@ type invoiceUpdateCtx struct { finalCltvRejectDelta int32 customRecords record.CustomSet mpp *record.MPP + amp *record.AMP } // invoiceRef returns an identifier that can be used to lookup or update the @@ -34,8 +35,9 @@ func (i *invoiceUpdateCtx) invoiceRef() channeldb.InvoiceRef { // log logs a message specific to this update context. func (i *invoiceUpdateCtx) log(s string) { - log.Debugf("Invoice%v: %v, amt=%v, expiry=%v, circuit=%v, mpp=%v", - i.invoiceRef, s, i.amtPaid, i.expiry, i.circuitKey, i.mpp) + log.Debugf("Invoice%v: %v, amt=%v, expiry=%v, circuit=%v, mpp=%v, "+ + "amp=%v", i.hash[:], s, i.amtPaid, i.expiry, i.circuitKey, + i.mpp, i.amp) } // failRes is a helper function which creates a failure resolution with