| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Lightning.Protocol.BOLT4.Types
Description
Core data types for BOLT4 onion routing.
Synopsis
- data OnionPacket = OnionPacket {
- opVersion :: !Word8
- opEphemeralKey :: !ByteString
- opHopPayloads :: !ByteString
- opHmac :: !ByteString
- data HopPayload = HopPayload {
- hpAmtToForward :: !(Maybe Word64)
- hpOutgoingCltv :: !(Maybe Word32)
- hpShortChannelId :: !(Maybe ShortChannelId)
- hpPaymentData :: !(Maybe PaymentData)
- hpEncryptedData :: !(Maybe ByteString)
- hpCurrentPathKey :: !(Maybe ByteString)
- hpUnknownTlvs :: ![TlvRecord]
- data ShortChannelId = ShortChannelId {
- sciBlockHeight :: !Word32
- sciTxIndex :: !Word32
- sciOutputIndex :: !Word16
- data PaymentData = PaymentData {}
- data TlvRecord = TlvRecord {
- tlvType :: !Word64
- tlvValue :: !ByteString
- data FailureMessage = FailureMessage {
- fmCode :: !FailureCode
- fmData :: !ByteString
- fmTlvs :: ![TlvRecord]
- newtype FailureCode = FailureCode Word16
- pattern BADONION :: Word16
- pattern PERM :: Word16
- pattern NODE :: Word16
- pattern UPDATE :: Word16
- pattern InvalidRealm :: FailureCode
- pattern TemporaryNodeFailure :: FailureCode
- pattern PermanentNodeFailure :: FailureCode
- pattern RequiredNodeFeatureMissing :: FailureCode
- pattern InvalidOnionVersion :: FailureCode
- pattern InvalidOnionHmac :: FailureCode
- pattern InvalidOnionKey :: FailureCode
- pattern TemporaryChannelFailure :: FailureCode
- pattern PermanentChannelFailure :: FailureCode
- pattern AmountBelowMinimum :: FailureCode
- pattern FeeInsufficient :: FailureCode
- pattern IncorrectCltvExpiry :: FailureCode
- pattern ExpiryTooSoon :: FailureCode
- pattern IncorrectOrUnknownPaymentDetails :: FailureCode
- pattern FinalIncorrectCltvExpiry :: FailureCode
- pattern FinalIncorrectHtlcAmount :: FailureCode
- pattern ChannelDisabled :: FailureCode
- pattern ExpiryTooFar :: FailureCode
- pattern InvalidOnionPayload :: FailureCode
- pattern MppTimeout :: FailureCode
- data ProcessResult
- data ForwardInfo = ForwardInfo {}
- data ReceiveInfo = ReceiveInfo {}
- onionPacketSize :: Int
- hopPayloadsSize :: Int
- hmacSize :: Int
- pubkeySize :: Int
- versionByte :: Word8
- maxPayloadSize :: Int
Packet types
data OnionPacket Source #
Complete onion packet (1366 bytes).
Constructors
| OnionPacket | |
Fields
| |
Instances
data HopPayload Source #
Parsed hop payload after decryption.
Constructors
| HopPayload | |
Fields
| |
Instances
| Generic HopPayload Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
| |||||
| Show HopPayload Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> HopPayload -> ShowS # show :: HopPayload -> String # showList :: [HopPayload] -> ShowS # | |||||
| Eq HopPayload Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types | |||||
| type Rep HopPayload Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep HopPayload = D1 ('MetaData "HopPayload" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "HopPayload" 'PrefixI 'True) ((S1 ('MetaSel ('Just "hpAmtToForward") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Word64)) :*: (S1 ('MetaSel ('Just "hpOutgoingCltv") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Word32)) :*: S1 ('MetaSel ('Just "hpShortChannelId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe ShortChannelId)))) :*: ((S1 ('MetaSel ('Just "hpPaymentData") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe PaymentData)) :*: S1 ('MetaSel ('Just "hpEncryptedData") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe ByteString))) :*: (S1 ('MetaSel ('Just "hpCurrentPathKey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe ByteString)) :*: S1 ('MetaSel ('Just "hpUnknownTlvs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [TlvRecord]))))) | |||||
data ShortChannelId Source #
Short channel ID (8 bytes): block height, tx index, output index.
Constructors
| ShortChannelId | |
Fields
| |
Instances
| Generic ShortChannelId Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
Methods from :: ShortChannelId -> Rep ShortChannelId x # to :: Rep ShortChannelId x -> ShortChannelId # | |||||
| Show ShortChannelId Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> ShortChannelId -> ShowS # show :: ShortChannelId -> String # showList :: [ShortChannelId] -> ShowS # | |||||
| Eq ShortChannelId Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods (==) :: ShortChannelId -> ShortChannelId -> Bool # (/=) :: ShortChannelId -> ShortChannelId -> Bool # | |||||
| type Rep ShortChannelId Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep ShortChannelId = D1 ('MetaData "ShortChannelId" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "ShortChannelId" 'PrefixI 'True) (S1 ('MetaSel ('Just "sciBlockHeight") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "sciTxIndex") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Just "sciOutputIndex") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word16)))) | |||||
data PaymentData Source #
Payment data for final hop (TLV type 8).
Constructors
| PaymentData | |
Fields
| |
Instances
| Generic PaymentData Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
| |||||
| Show PaymentData Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> PaymentData -> ShowS # show :: PaymentData -> String # showList :: [PaymentData] -> ShowS # | |||||
| Eq PaymentData Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types | |||||
| type Rep PaymentData Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep PaymentData = D1 ('MetaData "PaymentData" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "PaymentData" 'PrefixI 'True) (S1 ('MetaSel ('Just "pdPaymentSecret") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "pdTotalMsat") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64))) | |||||
Generic TLV record for unknown/extension types.
Constructors
| TlvRecord | |
Fields
| |
Instances
| Generic TlvRecord Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
| |||||
| Show TlvRecord Source # | |||||
| Eq TlvRecord Source # | |||||
| type Rep TlvRecord Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep TlvRecord = D1 ('MetaData "TlvRecord" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "TlvRecord" 'PrefixI 'True) (S1 ('MetaSel ('Just "tlvType") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "tlvValue") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
Error types
data FailureMessage Source #
Failure message from intermediate or final node.
Constructors
| FailureMessage | |
Fields
| |
Instances
| Generic FailureMessage Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
Methods from :: FailureMessage -> Rep FailureMessage x # to :: Rep FailureMessage x -> FailureMessage # | |||||
| Show FailureMessage Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> FailureMessage -> ShowS # show :: FailureMessage -> String # showList :: [FailureMessage] -> ShowS # | |||||
| Eq FailureMessage Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods (==) :: FailureMessage -> FailureMessage -> Bool # (/=) :: FailureMessage -> FailureMessage -> Bool # | |||||
| type Rep FailureMessage Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep FailureMessage = D1 ('MetaData "FailureMessage" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "FailureMessage" 'PrefixI 'True) (S1 ('MetaSel ('Just "fmCode") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 FailureCode) :*: (S1 ('MetaSel ('Just "fmData") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "fmTlvs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [TlvRecord])))) | |||||
newtype FailureCode Source #
2-byte failure code with flag bits.
Constructors
| FailureCode Word16 |
Instances
| Show FailureCode Source # | |
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> FailureCode -> ShowS # show :: FailureCode -> String # showList :: [FailureCode] -> ShowS # | |
| Eq FailureCode Source # | |
Defined in Lightning.Protocol.BOLT4.Types | |
Flag bits
Common failure codes
pattern InvalidRealm :: FailureCode Source #
Invalid realm byte in onion.
pattern TemporaryNodeFailure :: FailureCode Source #
Temporary node failure.
pattern PermanentNodeFailure :: FailureCode Source #
Permanent node failure.
pattern RequiredNodeFeatureMissing :: FailureCode Source #
Required node feature missing.
pattern InvalidOnionVersion :: FailureCode Source #
Invalid onion version.
pattern InvalidOnionHmac :: FailureCode Source #
Invalid HMAC in onion.
pattern InvalidOnionKey :: FailureCode Source #
Invalid ephemeral key in onion.
pattern TemporaryChannelFailure :: FailureCode Source #
Temporary channel failure.
pattern PermanentChannelFailure :: FailureCode Source #
Permanent channel failure.
pattern AmountBelowMinimum :: FailureCode Source #
Amount below minimum for channel.
pattern FeeInsufficient :: FailureCode Source #
Fee insufficient.
pattern IncorrectCltvExpiry :: FailureCode Source #
Incorrect CLTV expiry.
pattern ExpiryTooSoon :: FailureCode Source #
Expiry too soon.
pattern IncorrectOrUnknownPaymentDetails :: FailureCode Source #
Payment details incorrect or unknown.
pattern FinalIncorrectCltvExpiry :: FailureCode Source #
Final incorrect CLTV expiry.
pattern FinalIncorrectHtlcAmount :: FailureCode Source #
Final incorrect HTLC amount.
pattern ChannelDisabled :: FailureCode Source #
Channel disabled.
pattern ExpiryTooFar :: FailureCode Source #
Expiry too far.
pattern InvalidOnionPayload :: FailureCode Source #
Invalid onion payload.
pattern MppTimeout :: FailureCode Source #
MPP timeout.
Processing results
data ProcessResult Source #
Result of processing an onion packet.
Constructors
| Forward !ForwardInfo | Forward to next hop |
| Receive !ReceiveInfo | Final destination reached |
Instances
| Generic ProcessResult Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
| |||||
| Show ProcessResult Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> ProcessResult -> ShowS # show :: ProcessResult -> String # showList :: [ProcessResult] -> ShowS # | |||||
| Eq ProcessResult Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods (==) :: ProcessResult -> ProcessResult -> Bool # (/=) :: ProcessResult -> ProcessResult -> Bool # | |||||
| type Rep ProcessResult Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep ProcessResult = D1 ('MetaData "ProcessResult" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "Forward" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ForwardInfo)) :+: C1 ('MetaCons "Receive" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ReceiveInfo))) | |||||
data ForwardInfo Source #
Information for forwarding to next hop.
Constructors
| ForwardInfo | |
Fields
| |
Instances
| Generic ForwardInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
| |||||
| Show ForwardInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> ForwardInfo -> ShowS # show :: ForwardInfo -> String # showList :: [ForwardInfo] -> ShowS # | |||||
| Eq ForwardInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types | |||||
| type Rep ForwardInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep ForwardInfo = D1 ('MetaData "ForwardInfo" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "ForwardInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "fiNextPacket") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OnionPacket) :*: (S1 ('MetaSel ('Just "fiPayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HopPayload) :*: S1 ('MetaSel ('Just "fiSharedSecret") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString)))) | |||||
data ReceiveInfo Source #
Information for receiving at final destination.
Constructors
| ReceiveInfo | |
Fields
| |
Instances
| Generic ReceiveInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Associated Types
| |||||
| Show ReceiveInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types Methods showsPrec :: Int -> ReceiveInfo -> ShowS # show :: ReceiveInfo -> String # showList :: [ReceiveInfo] -> ShowS # | |||||
| Eq ReceiveInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types | |||||
| type Rep ReceiveInfo Source # | |||||
Defined in Lightning.Protocol.BOLT4.Types type Rep ReceiveInfo = D1 ('MetaData "ReceiveInfo" "Lightning.Protocol.BOLT4.Types" "ppad-bolt4-0.0.1-33TgaKMcRznIG3ThlfUxBs" 'False) (C1 ('MetaCons "ReceiveInfo" 'PrefixI 'True) (S1 ('MetaSel ('Just "riPayload") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HopPayload) :*: S1 ('MetaSel ('Just "riSharedSecret") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString))) | |||||
Constants
onionPacketSize :: Int Source #
Total onion packet size (1366 bytes).
hopPayloadsSize :: Int Source #
Hop payloads section size (1300 bytes).
pubkeySize :: Int Source #
Compressed public key size (33 bytes).
versionByte :: Word8 Source #
Version byte for onion packets.
maxPayloadSize :: Int Source #
Maximum payload size (1300 - 32 - 1 = 1267 bytes).