Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split the TLV payload processing into parsing and validation #3278

Merged
merged 9 commits into from
Nov 22, 2019

Commits on Nov 21, 2019

  1. Configuration menu
    Copy the full SHA
    6ce68c6 View commit details
    Browse the repository at this point in the history
  2. tlv: Add typesafe fromwire codegen for TLV namespaces

    We were weaving in and out of generic code through `fromwire_tlvs` with custom
    parameters defining the types in that namespace. This hard-wires the parser
    with the namespace's types. Slowly trying to deprecate `fromwire_tlvs` in
    favor of this typesafe variant.
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    482f914 View commit details
    Browse the repository at this point in the history
  3. tlv: Add validity check codegen for the tlv namespaces

    Since the parser itself just parses and doesn't include validation anymore we
    need to put that functionality somewhere. The validation consists of enforcing
    that the types are in monotonically increasing order without duplicates and
    that for the even types we know how to handle it.
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    02fb929 View commit details
    Browse the repository at this point in the history
  4. sphinx: Use the new fromwire_tlv_payload function

    We wire in the code-generated function, which removes the upfront validation
    and add the validation back after the `htlc_accepted` hook returns. If a
    plugin wanted to handle the onion in a special way it'll not have told us to
    just continue.
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    0799d4a View commit details
    Browse the repository at this point in the history
  5. sphinx: Decode payload and place shortcuts in the route-step

    We'll need to pass them around anyway, so just make them easier to access by
    doing a bit more to `process_onionpacket`.
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    af37d6e View commit details
    Browse the repository at this point in the history
  6. htlcs: Make necessary payload fields optional and derfer validation

    We make the fields in `htlc_accepted_payload` optional (NULL if not present in
    the payload) and defer validation till after the hook call.
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    cc484fa View commit details
    Browse the repository at this point in the history
  7. htlc: Consolidate validation after the htlc_accepted hook returns

    This now enforces all rules for validity, both for the TLV format and checking
    that the required fields have been provided.
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    98e7c0f View commit details
    Browse the repository at this point in the history
  8. sphinx: Cleanup route_step_decode_* functions

    We have consolidated the two functions into a single `route_step_decode`
    function, and made it static since we call it in the `process_onionpacket`
    function. We remove the two exposed functions since they're no longer useful.
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    2feb28e View commit details
    Browse the repository at this point in the history
  9. htlc: Add a checker function tellung us whether we can continue

    This function ensures we have all the infos we need to continue if the
    htlc_accepted hook tells us to. It also enforces well-formedness of the TLV
    payload if we have a TLV payload.
    
    Suggested-by: List Neigut <@niftynei>
    Signed-off-by: Christian Decker <@cdecker>
    cdecker committed Nov 21, 2019
    Configuration menu
    Copy the full SHA
    df4c187 View commit details
    Browse the repository at this point in the history