ppad-bolt7-0.0.1: Routing gossip per BOLT #7
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Lightning.Protocol.BOLT7.Validate

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

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

Instances details
NFData ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Validate

Methods

rnf :: ValidationError -> () #

Generic ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Validate

Associated Types

type Rep ValidationError 
Instance details

Defined in Lightning.Protocol.BOLT7.Validate

type Rep ValidationError = D1 ('MetaData "ValidationError" "Lightning.Protocol.BOLT7.Validate" "ppad-bolt7-0.0.1-9AmpjHUse7iEtxOkiaMheY" 'False) ((C1 ('MetaCons "ValidateNodeIdOrdering" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ValidateUnknownEvenFeature" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ValidateHtlcAmounts" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ValidateBlockOverflow" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ValidateScidNotAscending" 'PrefixI 'False) (U1 :: Type -> Type))))
Show ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Validate

Eq ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Validate

type Rep ValidationError Source # 
Instance details

Defined in Lightning.Protocol.BOLT7.Validate

type Rep ValidationError = D1 ('MetaData "ValidationError" "Lightning.Protocol.BOLT7.Validate" "ppad-bolt7-0.0.1-9AmpjHUse7iEtxOkiaMheY" 'False) ((C1 ('MetaCons "ValidateNodeIdOrdering" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ValidateUnknownEvenFeature" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ValidateHtlcAmounts" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ValidateBlockOverflow" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ValidateScidNotAscending" 'PrefixI 'False) (U1 :: Type -> Type))))

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