| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
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
- newtype ErrorPacket = ErrorPacket ByteString
- data AttributionResult
- minErrorPacketSize :: Int
- constructError :: SharedSecret -> FailureMessage -> ErrorPacket
- wrapError :: SharedSecret -> ErrorPacket -> ErrorPacket
- unwrapError :: [SharedSecret] -> ErrorPacket -> AttributionResult
Types
newtype ErrorPacket Source #
Wrapped error packet ready for return to origin.
Constructors
| ErrorPacket ByteString |
Instances
| Show ErrorPacket Source # | |
Defined in Lightning.Protocol.BOLT4.Error Methods showsPrec :: Int -> ErrorPacket -> ShowS # show :: ErrorPacket -> String # showList :: [ErrorPacket] -> ShowS # | |
| Eq ErrorPacket Source # | |
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 |
Instances
| Show AttributionResult Source # | |
Defined in Lightning.Protocol.BOLT4.Error Methods showsPrec :: Int -> AttributionResult -> ShowS # show :: AttributionResult -> String # showList :: [AttributionResult] -> ShowS # | |
| Eq AttributionResult Source # | |
Defined in Lightning.Protocol.BOLT4.Error Methods (==) :: AttributionResult -> AttributionResult -> Bool # (/=) :: AttributionResult -> AttributionResult -> Bool # | |
minErrorPacketSize :: Int Source #
Minimum error packet size (256 bytes per spec).
Error construction (failing node)
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)
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)
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.