record/hop: add primitive hop TLV record constructors
This commit is contained in:
parent
c397a2ea78
commit
495f80e0bc
33
record/hop.go
Normal file
33
record/hop.go
Normal file
@ -0,0 +1,33 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
)
|
||||
|
||||
// NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward
|
||||
// (type 2) for an onion payload.
|
||||
func NewAmtToFwdRecord(amt *uint64) tlv.Record {
|
||||
return tlv.MakeDynamicRecord(
|
||||
tlv.AmtOnionType, amt, func() uint64 {
|
||||
return tlv.SizeTUint64(*amt)
|
||||
},
|
||||
tlv.ETUint64, tlv.DTUint64,
|
||||
)
|
||||
}
|
||||
|
||||
// NewLockTimeRecord creates a tlv.Record that encodes the outgoing_cltv_value
|
||||
// (type 4) for an onion payload.
|
||||
func NewLockTimeRecord(lockTime *uint32) tlv.Record {
|
||||
return tlv.MakeDynamicRecord(
|
||||
tlv.LockTimeOnionType, lockTime, func() uint64 {
|
||||
return tlv.SizeTUint32(*lockTime)
|
||||
},
|
||||
tlv.ETUint32, tlv.DTUint32,
|
||||
)
|
||||
}
|
||||
|
||||
// NewNextHopIDRecord creates a tlv.Record that encodes the short_channel_id
|
||||
// (type 6) for an onion payload.
|
||||
func NewNextHopIDRecord(cid *uint64) tlv.Record {
|
||||
return tlv.MakePrimitiveRecord(tlv.NextHopOnionType, cid)
|
||||
}
|
Loading…
Reference in New Issue
Block a user