htlcswitch/hop: always accept even custom tlv records
This commit prepares for sending and receiving of application-specific custom tlv fields.
This commit is contained in:
parent
048971b40b
commit
78ecc3d24b
@ -29,6 +29,12 @@ const (
|
|||||||
RequiredViolation
|
RequiredViolation
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// customTypeStart is the start of the custom tlv type range as defined
|
||||||
|
// in BOLT 01.
|
||||||
|
customTypeStart = 65536
|
||||||
|
)
|
||||||
|
|
||||||
// String returns a human-readable description of the violation as a verb.
|
// String returns a human-readable description of the violation as a verb.
|
||||||
func (v PayloadViolation) String() string {
|
func (v PayloadViolation) String() string {
|
||||||
switch v {
|
switch v {
|
||||||
@ -240,7 +246,10 @@ func getMinRequiredViolation(set tlv.TypeSet) *tlv.Type {
|
|||||||
// If a type is even but not known to us, we cannot process the
|
// If a type is even but not known to us, we cannot process the
|
||||||
// payload. We are required to understand a field that we don't
|
// payload. We are required to understand a field that we don't
|
||||||
// support.
|
// support.
|
||||||
if known || t%2 != 0 {
|
//
|
||||||
|
// We always accept custom fields, because a higher level
|
||||||
|
// application may understand them.
|
||||||
|
if known || t%2 != 0 || t >= customTypeStart {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,12 @@ var decodePayloadTests = []decodePayloadTest{
|
|||||||
FinalHop: false,
|
FinalHop: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "required type in custom range",
|
||||||
|
payload: []byte{0x02, 0x00, 0x04, 0x00,
|
||||||
|
0xfe, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "valid intermediate hop",
|
name: "valid intermediate hop",
|
||||||
payload: []byte{0x02, 0x00, 0x04, 0x00, 0x06, 0x08, 0x01, 0x00,
|
payload: []byte{0x02, 0x00, 0x04, 0x00, 0x06, 0x08, 0x01, 0x00,
|
||||||
|
Loading…
Reference in New Issue
Block a user