record+tlv/onion_types: move type constants to route/hop
This commit is contained in:
parent
dc0f429271
commit
1b2c9a02b5
@ -4,11 +4,25 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/tlv"
|
"github.com/lightningnetwork/lnd/tlv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// AmtOnionType is the type used in the onion to refrence the amount to
|
||||||
|
// send to the next hop.
|
||||||
|
AmtOnionType tlv.Type = 2
|
||||||
|
|
||||||
|
// LockTimeTLV is the type used in the onion to refenernce the CLTV
|
||||||
|
// value that should be used for the next hop's HTLC.
|
||||||
|
LockTimeOnionType tlv.Type = 4
|
||||||
|
|
||||||
|
// NextHopOnionType is the type used in the onion to reference the ID
|
||||||
|
// of the next hop.
|
||||||
|
NextHopOnionType tlv.Type = 6
|
||||||
|
)
|
||||||
|
|
||||||
// NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward
|
// NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward
|
||||||
// (type 2) for an onion payload.
|
// (type 2) for an onion payload.
|
||||||
func NewAmtToFwdRecord(amt *uint64) tlv.Record {
|
func NewAmtToFwdRecord(amt *uint64) tlv.Record {
|
||||||
return tlv.MakeDynamicRecord(
|
return tlv.MakeDynamicRecord(
|
||||||
tlv.AmtOnionType, amt, func() uint64 {
|
AmtOnionType, amt, func() uint64 {
|
||||||
return tlv.SizeTUint64(*amt)
|
return tlv.SizeTUint64(*amt)
|
||||||
},
|
},
|
||||||
tlv.ETUint64, tlv.DTUint64,
|
tlv.ETUint64, tlv.DTUint64,
|
||||||
@ -19,7 +33,7 @@ func NewAmtToFwdRecord(amt *uint64) tlv.Record {
|
|||||||
// (type 4) for an onion payload.
|
// (type 4) for an onion payload.
|
||||||
func NewLockTimeRecord(lockTime *uint32) tlv.Record {
|
func NewLockTimeRecord(lockTime *uint32) tlv.Record {
|
||||||
return tlv.MakeDynamicRecord(
|
return tlv.MakeDynamicRecord(
|
||||||
tlv.LockTimeOnionType, lockTime, func() uint64 {
|
LockTimeOnionType, lockTime, func() uint64 {
|
||||||
return tlv.SizeTUint32(*lockTime)
|
return tlv.SizeTUint32(*lockTime)
|
||||||
},
|
},
|
||||||
tlv.ETUint32, tlv.DTUint32,
|
tlv.ETUint32, tlv.DTUint32,
|
||||||
@ -29,5 +43,5 @@ func NewLockTimeRecord(lockTime *uint32) tlv.Record {
|
|||||||
// NewNextHopIDRecord creates a tlv.Record that encodes the short_channel_id
|
// NewNextHopIDRecord creates a tlv.Record that encodes the short_channel_id
|
||||||
// (type 6) for an onion payload.
|
// (type 6) for an onion payload.
|
||||||
func NewNextHopIDRecord(cid *uint64) tlv.Record {
|
func NewNextHopIDRecord(cid *uint64) tlv.Record {
|
||||||
return tlv.MakePrimitiveRecord(tlv.NextHopOnionType, cid)
|
return tlv.MakePrimitiveRecord(NextHopOnionType, cid)
|
||||||
}
|
}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package tlv
|
|
||||||
|
|
||||||
const (
|
|
||||||
// AmtOnionType is the type used in the onion to refrence the amount to
|
|
||||||
// send to the next hop.
|
|
||||||
AmtOnionType Type = 2
|
|
||||||
|
|
||||||
// LockTimeTLV is the type used in the onion to refenernce the CLTV
|
|
||||||
// value that should be used for the next hop's HTLC.
|
|
||||||
LockTimeOnionType Type = 4
|
|
||||||
|
|
||||||
// NextHopOnionType is the type used in the onion to reference the ID
|
|
||||||
// of the next hop.
|
|
||||||
NextHopOnionType Type = 6
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user