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:
Conner Fromknecht 2019-09-04 08:39:22 -07:00
parent 1b2c9a02b5
commit 278e10a2fd
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -108,8 +108,17 @@ func (h *Hop) PackHopPayload(w io.Writer, nextChanID uint64) error {
combinedRecords := append(h.TLVRecords,
record.NewAmtToFwdRecord(&amt),
record.NewLockTimeRecord(&h.OutgoingTimeLock),
)
// 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
// before encoding them as a stream in the hop payload.