Commit Graph

10 Commits

Author SHA1 Message Date
Conner Fromknecht
c2729cbbbd
htlcswitch/hop: parse and validate AMP records 2021-04-07 12:08:33 -07:00
Conner Fromknecht
135a0a9f7f
htlcswitch/hop: make unknown required type const
Currently we use the AMP record type, this allows us to change it easily
as we add new known records. We also bump this to 0x0c instead of 0x0a.
2021-04-07 12:08:33 -07:00
Joost Jager
8b5bb0ac63
record: move CustomRecordSet 2019-12-12 00:12:19 +01:00
Joost Jager
37258c414c
hop: store custom records from payload 2019-12-10 06:54:22 +01:00
Joost Jager
78ecc3d24b
htlcswitch/hop: always accept even custom tlv records
This commit prepares for sending and receiving of application-specific
custom tlv fields.
2019-11-12 16:18:27 +01:00
Conner Fromknecht
4a6f5d8d3d
htlcswitch/hop/payload: parse option_mpp 2019-11-04 15:10:00 -08:00
Conner Fromknecht
cba523ae30
htlcswitch/hop/payload: apply known constraints if required failure
This commit modifies the NewPayloadFromReader to apply known
presence/omission contraints in the event that the tlv parser returns an
unknown required type failure.

Now that the parser has been modified to finished parsing the stream to
obtain a proper parsed type set, we can accurately apply these higher
level validation checks. This overrides required type failures, such
that they are only returned if the sender properly abided by the
constraints on fields for which we know.

The unit tests are updated to create otherwise valid payloads that then
return unknown required type failures. In one case, a test which
previously returned an unknown required type failure is made to return
an included failure for the sid, indicating the unknown required type 0
is being overruled.
2019-10-30 21:21:10 -07:00
Conner Fromknecht
937b781276
htlcswitch/hop/payload: extend tests to required type failures 2019-10-30 21:20:49 -07:00
Conner Fromknecht
3c91c3a8ff
htlcswitch/hop/payload: required failures with ErrInvalidPayload
This commit adds a hop.PayloadViolation enum which encompasses the cases
where the sender omits, includes, or requires a type that causes an
ErrInvalidPayload faiulre.

The existing Omitted bool is converted to this PayloadViolation, and
NewPayloadFromReader is updated to return such a failure with a
RequiredViolation when an unknown required type is detected.

The unit tests are updated to cover the three possible cases of
RequiredViolations, as well as included valid intermediate and final hop
tests.
2019-10-30 21:19:08 -07:00
Conner Fromknecht
6015567927
htlcswitch/iterator: validate presence/omission of payload types
From BOLT 04:

The writer:
 - MUST include amt_to_forward and outgoing_cltv_value for every node.
 - MUST include short_channel_id for every non-final node.
 - MUST NOT include short_channel_id for the final node.
2019-09-05 09:32:03 -07:00