diff --git a/routing/route/route.go b/routing/route/route.go index e9e159f65..ef9024682 100644 --- a/routing/route/route.go +++ b/routing/route/route.go @@ -104,8 +104,11 @@ func (h *Hop) PackHopPayload(w io.Writer, nextChanID uint64) error { // Otherwise, we'll need to make a new stream that includes our // required routing fields, as well as these optional values. + var records []tlv.Record + + // Every hop must have an amount to forward and CLTV expiry. amt := uint64(h.AmtToForward) - combinedRecords := append(h.TLVRecords, + records = append(records, record.NewAmtToFwdRecord(&amt), record.NewLockTimeRecord(&h.OutgoingTimeLock), ) @@ -115,16 +118,19 @@ func (h *Hop) PackHopPayload(w io.Writer, nextChanID uint64) error { // // TODO(conner): test using hop.Exit once available if nextChanID != 0 { - combinedRecords = append(combinedRecords, + records = append(records, record.NewNextHopIDRecord(&nextChanID), ) } + // Append any custom types destined for this hop. + records = append(records, h.TLVRecords...) + // To ensure we produce a canonical stream, we'll sort the records // before encoding them as a stream in the hop payload. - tlv.SortRecords(combinedRecords) + tlv.SortRecords(records) - tlvStream, err := tlv.NewStream(combinedRecords...) + tlvStream, err := tlv.NewStream(records...) if err != nil { return err }