diff --git a/htlcswitch/hop/payload.go b/htlcswitch/hop/payload.go index 0304e2c7..3d15f4e0 100644 --- a/htlcswitch/hop/payload.go +++ b/htlcswitch/hop/payload.go @@ -29,6 +29,12 @@ const ( 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. func (v PayloadViolation) String() string { 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 // payload. We are required to understand a field that we don't // 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 } diff --git a/htlcswitch/hop/payload_test.go b/htlcswitch/hop/payload_test.go index 7ef35e8b..4092ff48 100644 --- a/htlcswitch/hop/payload_test.go +++ b/htlcswitch/hop/payload_test.go @@ -130,6 +130,12 @@ var decodePayloadTests = []decodePayloadTest{ FinalHop: false, }, }, + { + name: "required type in custom range", + payload: []byte{0x02, 0x00, 0x04, 0x00, + 0xfe, 0x00, 0x01, 0x00, 0x00, 0x00, + }, + }, { name: "valid intermediate hop", payload: []byte{0x02, 0x00, 0x04, 0x00, 0x06, 0x08, 0x01, 0x00,