| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Lightning.Protocol.BOLT7.Validate
Contents
Description
Validation functions for BOLT #7 gossip messages.
These functions check message invariants as specified in BOLT #7. They do NOT verify cryptographic signatures; that requires the actual public keys and is left to the caller.
Synopsis
- data ValidationError
- validateChannelAnnouncement :: ChannelAnnouncement -> Either ValidationError ()
- validateNodeAnnouncement :: NodeAnnouncement -> Either ValidationError ()
- validateChannelUpdate :: ChannelUpdate -> Either ValidationError ()
- validateQueryChannelRange :: QueryChannelRange -> Either ValidationError ()
- validateReplyChannelRange :: ReplyChannelRange -> Either ValidationError ()
Error types
data ValidationError Source #
Validation errors.
Constructors
| ValidateNodeIdOrdering | node_id_1 must be < node_id_2 |
| ValidateUnknownEvenFeature | Unknown even feature bit set |
| ValidateHtlcAmounts | htlc_minimum_msat > htlc_maximum_msat |
| ValidateBlockOverflow | first_blocknum + number_of_blocks overflow |
| ValidateScidNotAscending | short_channel_ids not in ascending order |
Instances
Validation functions
validateChannelAnnouncement :: ChannelAnnouncement -> Either ValidationError () Source #
Validate channel_announcement message.
Checks:
- node_id_1 < node_id_2 (lexicographic ordering)
- Feature bits do not contain unknown even bits
validateNodeAnnouncement :: NodeAnnouncement -> Either ValidationError () Source #
Validate node_announcement message.
Checks:
- Feature bits do not contain unknown even bits
Note: Address list validation (duplicate DNS entries) and alias UTF-8 validation are not enforced; the spec allows non-UTF-8 aliases.
validateChannelUpdate :: ChannelUpdate -> Either ValidationError () Source #
Validate channel_update message.
Checks:
- htlc_minimum_msat <= htlc_maximum_msat (if htlc_maximum_msat present)
Note: The spec says message_flags bit 0 MUST be set if htlc_maximum_msat is advertised. We don't enforce this at validation time since the codec already handles the conditional field based on the flag.
validateQueryChannelRange :: QueryChannelRange -> Either ValidationError () Source #
Validate query_channel_range message.
Checks:
- first_blocknum + number_of_blocks does not overflow
validateReplyChannelRange :: ReplyChannelRange -> Either ValidationError () Source #
Validate reply_channel_range message.
Checks:
- Encoded short_channel_ids are in ascending order