mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
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
1 changed files with 10 additions and 1 deletions
|
@ -108,9 +108,18 @@ func (h *Hop) PackHopPayload(w io.Writer, nextChanID uint64) error {
|
|||
combinedRecords := append(h.TLVRecords,
|
||||
record.NewAmtToFwdRecord(&amt),
|
||||
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
|
||||
// before encoding them as a stream in the hop payload.
|
||||
tlv.SortRecords(combinedRecords)
|
||||
|
|
Loading…
Add table
Reference in a new issue