invoices: expose AMPRecord() method on Payload

This commit is contained in:
Conner Fromknecht 2021-03-03 09:54:11 -08:00
parent 055db6b9ac
commit 464dff09ac
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
5 changed files with 24 additions and 2 deletions

@ -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 {

@ -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

@ -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

@ -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.

@ -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