routing/route/route: omit next_hop_id for final hop
BOLT04 says to omit this field for final hops, but must be present on all other hops.
This commit is contained in:
parent
1b2c9a02b5
commit
278e10a2fd
@ -108,9 +108,18 @@ func (h *Hop) PackHopPayload(w io.Writer, nextChanID uint64) error {
|
|||||||
combinedRecords := append(h.TLVRecords,
|
combinedRecords := append(h.TLVRecords,
|
||||||
record.NewAmtToFwdRecord(&amt),
|
record.NewAmtToFwdRecord(&amt),
|
||||||
record.NewLockTimeRecord(&h.OutgoingTimeLock),
|
record.NewLockTimeRecord(&h.OutgoingTimeLock),
|
||||||
record.NewNextHopIDRecord(&nextChanID),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BOLT 04 says the next_hop_id should be omitted for the final hop,
|
||||||
|
// but present for all others.
|
||||||
|
//
|
||||||
|
// TODO(conner): test using hop.Exit once available
|
||||||
|
if nextChanID != 0 {
|
||||||
|
combinedRecords = append(combinedRecords,
|
||||||
|
record.NewNextHopIDRecord(&nextChanID),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// To ensure we produce a canonical stream, we'll sort the records
|
// To ensure we produce a canonical stream, we'll sort the records
|
||||||
// before encoding them as a stream in the hop payload.
|
// before encoding them as a stream in the hop payload.
|
||||||
tlv.SortRecords(combinedRecords)
|
tlv.SortRecords(combinedRecords)
|
||||||
|
Loading…
Reference in New Issue
Block a user