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

BOLT 12 offer parsing #1726

Merged
merged 5 commits into from
Nov 18, 2022
Merged

Commits on Nov 18, 2022

  1. Offer parsing from bech32 strings

    Add common bech32 parsing for BOLT 12 messages. The encoding is similar
    to bech32 only without a checksum and with support for continuing
    messages across multiple parts.
    
    Messages implementing Bech32Encode are parsed into a TLV stream, which
    is converted to the desired message content while performing semantic
    checks. Checking after conversion allows for more elaborate checks of
    data composed of multiple TLV records and for more meaningful error
    messages.
    
    The parsed bytes are also saved to allow creating messages with mirrored
    data, even if TLV records are unknown.
    jkczyz committed Nov 18, 2022
    Configuration menu
    Copy the full SHA
    60d7ffc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3a6d7b8 View commit details
    Browse the repository at this point in the history
  3. Offer parsing tests

    Test semantic errors when parsing offer bytes.
    jkczyz committed Nov 18, 2022
    Configuration menu
    Copy the full SHA
    03d0a4b View commit details
    Browse the repository at this point in the history
  4. Limit TLV stream decoding to type ranges

    BOLT 12 messages are limited to a range of TLV record types. Refactor
    decode_tlv_stream into a decode_tlv_stream_range macro for limiting
    which types are parsed. Requires a SeekReadable trait for rewinding when
    a type outside of the range is seen. This allows for composing TLV
    streams of different ranges.
    
    Updates offer parsing accordingly and adds a test demonstrating failure
    if a type outside of the range is included.
    jkczyz committed Nov 18, 2022
    Configuration menu
    Copy the full SHA
    94a07d9 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    1e26a2b View commit details
    Browse the repository at this point in the history