ppad-bolt4-0.0.1: BOLT4 (onion routing) for Lightning Network
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellNone
LanguageHaskell2010

Lightning.Protocol.BOLT4.Error

Description

Error packet construction and unwrapping for BOLT4 onion routing.

Failing nodes construct error packets that are wrapped at each intermediate hop on the return path. The origin node unwraps layers to attribute the error to a specific hop.

Synopsis

Types

newtype ErrorPacket Source #

Wrapped error packet ready for return to origin.

Constructors

ErrorPacket ByteString 

Instances

Instances details
Show ErrorPacket Source # 
Instance details

Defined in Lightning.Protocol.BOLT4.Error

Eq ErrorPacket Source # 
Instance details

Defined in Lightning.Protocol.BOLT4.Error

data AttributionResult Source #

Result of error attribution.

Constructors

Attributed !Int !FailureMessage

(hop index, failure)

UnknownOrigin !ByteString

Could not attribute to any hop

minErrorPacketSize :: Int Source #

Minimum error packet size (256 bytes per spec).

Error construction (failing node)

constructError Source #

Arguments

:: SharedSecret

from packet processing

-> FailureMessage

failure details

-> ErrorPacket 

Construct an error packet at a failing node.

Takes the shared secret (from processing) and failure message, and wraps it for return to origin.

Error forwarding (intermediate node)

wrapError Source #

Arguments

:: SharedSecret

this node's shared secret

-> ErrorPacket

error from downstream

-> ErrorPacket 

Wrap an existing error packet for forwarding back.

Each intermediate node wraps the error with its own layer.

Error unwrapping (origin node)

unwrapError Source #

Arguments

:: [SharedSecret]

secrets from construction, in route order

-> ErrorPacket

received error

-> AttributionResult 

Attempt to attribute an error to a specific hop.

Takes the shared secrets from original packet construction (in order from first hop to final) and the error packet.

Tries each hop's keys until HMAC verifies, revealing origin.