| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Lightning.Protocol.BOLT3
Description
Bitcoin transaction formats for the Lightning Network, per BOLT #3.
Overview
This library implements the transaction and script formats defined in BOLT #3, including:
- Commitment transactions with to_local, to_remote, anchor, and HTLC outputs
- HTLC-timeout and HTLC-success second-stage transactions
- Closing transactions (legacy and option_simple_close)
- Per-commitment key derivation and secret storage
- Transaction serialization and parsing
- Stateless validation
Quick Start
import Lightning.Protocol.BOLT3
-- Build a commitment transaction
let ctx = CommitmentContext { ... }
tx = build_commitment_tx ctx
-- Serialize for signing
let bytes = encode_tx tx
-- Validate the transaction
case validate_commitment_tx dustLimit features tx of
Right () -> putStrLn Valid
Left err -> print err
Modules
- Lightning.Protocol.BOLT3.Types - Core types (Satoshi, Pubkey, HTLC, etc.)
- Lightning.Protocol.BOLT3.Keys - Per-commitment key derivation and secret storage
- Lightning.Protocol.BOLT3.Scripts - Witness script templates (funding, to_local, HTLC, anchor)
- Lightning.Protocol.BOLT3.Tx - Transaction assembly
- Lightning.Protocol.BOLT3.Encode - Transaction serialization
- Lightning.Protocol.BOLT3.Decode - Transaction parsing
- Lightning.Protocol.BOLT3.Validate - Stateless validation
Synopsis
- newtype Satoshi = Satoshi {}
- newtype MilliSatoshi = MilliSatoshi {}
- msat_to_sat :: MilliSatoshi -> Satoshi
- sat_to_msat :: Satoshi -> MilliSatoshi
- newtype Pubkey = Pubkey {}
- pubkey :: ByteString -> Maybe Pubkey
- newtype Seckey = Seckey {}
- seckey :: ByteString -> Maybe Seckey
- newtype Point = Point {}
- point :: ByteString -> Maybe Point
- newtype PaymentHash = PaymentHash {}
- payment_hash :: ByteString -> Maybe PaymentHash
- newtype PaymentPreimage = PaymentPreimage {}
- payment_preimage :: ByteString -> Maybe PaymentPreimage
- newtype TxId = TxId {
- unTxId :: ByteString
- txid :: ByteString -> Maybe TxId
- data Outpoint = Outpoint {
- outpoint_txid :: !TxId
- outpoint_index :: !Word32
- newtype Sequence = Sequence {
- unSequence :: Word32
- newtype Locktime = Locktime {
- unLocktime :: Word32
- newtype CommitmentNumber = CommitmentNumber {}
- commitment_number :: Word64 -> Maybe CommitmentNumber
- newtype ToSelfDelay = ToSelfDelay {}
- newtype CltvExpiry = CltvExpiry {}
- newtype DustLimit = DustLimit {}
- newtype FeeratePerKw = FeeratePerKw {}
- data HTLC = HTLC {}
- data HTLCDirection
- data Basepoints = Basepoints {}
- newtype PerCommitmentPoint = PerCommitmentPoint {}
- newtype PerCommitmentSecret = PerCommitmentSecret {}
- per_commitment_secret :: ByteString -> Maybe PerCommitmentSecret
- newtype RevocationBasepoint = RevocationBasepoint {}
- newtype PaymentBasepoint = PaymentBasepoint {}
- newtype DelayedPaymentBasepoint = DelayedPaymentBasepoint {}
- newtype HtlcBasepoint = HtlcBasepoint {}
- newtype LocalPubkey = LocalPubkey {}
- newtype RemotePubkey = RemotePubkey {}
- newtype LocalDelayedPubkey = LocalDelayedPubkey {}
- newtype RemoteDelayedPubkey = RemoteDelayedPubkey {}
- newtype LocalHtlcPubkey = LocalHtlcPubkey {}
- newtype RemoteHtlcPubkey = RemoteHtlcPubkey {}
- newtype RevocationPubkey = RevocationPubkey {}
- newtype FundingPubkey = FundingPubkey {}
- newtype Script = Script {}
- newtype Witness = Witness {
- unWitness :: [ByteString]
- data ChannelFeatures = ChannelFeatures {}
- has_anchors :: ChannelFeatures -> Bool
- commitment_weight_no_anchors :: Word64
- commitment_weight_anchors :: Word64
- htlc_timeout_weight_no_anchors :: Word64
- htlc_timeout_weight_anchors :: Word64
- htlc_success_weight_no_anchors :: Word64
- htlc_success_weight_anchors :: Word64
- htlc_output_weight :: Word64
- dust_p2pkh :: Satoshi
- dust_p2sh :: Satoshi
- dust_p2wpkh :: Satoshi
- dust_p2wsh :: Satoshi
- anchor_output_value :: Satoshi
- derive_per_commitment_point :: PerCommitmentSecret -> Maybe PerCommitmentPoint
- derive_pubkey :: Point -> PerCommitmentPoint -> Maybe Pubkey
- derive_localpubkey :: PaymentBasepoint -> PerCommitmentPoint -> Maybe LocalPubkey
- derive_local_htlcpubkey :: HtlcBasepoint -> PerCommitmentPoint -> Maybe LocalHtlcPubkey
- derive_remote_htlcpubkey :: HtlcBasepoint -> PerCommitmentPoint -> Maybe RemoteHtlcPubkey
- derive_local_delayedpubkey :: DelayedPaymentBasepoint -> PerCommitmentPoint -> Maybe LocalDelayedPubkey
- derive_remote_delayedpubkey :: DelayedPaymentBasepoint -> PerCommitmentPoint -> Maybe RemoteDelayedPubkey
- derive_revocationpubkey :: RevocationBasepoint -> PerCommitmentPoint -> Maybe RevocationPubkey
- generate_from_seed :: ByteString -> Word64 -> ByteString
- derive_secret :: ByteString -> Int -> Word64 -> ByteString
- data SecretStore
- empty_store :: SecretStore
- insert_secret :: ByteString -> Word64 -> SecretStore -> Maybe SecretStore
- derive_old_secret :: Word64 -> SecretStore -> Maybe ByteString
- obscured_commitment_number :: PaymentBasepoint -> PaymentBasepoint -> CommitmentNumber -> Word64
- funding_script :: FundingPubkey -> FundingPubkey -> Script
- funding_witness :: ByteString -> ByteString -> Witness
- to_local_script :: RevocationPubkey -> ToSelfDelay -> LocalDelayedPubkey -> Script
- to_local_witness_spend :: ByteString -> Witness
- to_local_witness_revoke :: ByteString -> Witness
- to_remote_script :: RemotePubkey -> ChannelFeatures -> Script
- to_remote_witness :: ByteString -> RemotePubkey -> ChannelFeatures -> Witness
- anchor_script :: FundingPubkey -> Script
- anchor_witness_owner :: ByteString -> Witness
- anchor_witness_anyone :: Witness
- offered_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> ChannelFeatures -> Script
- offered_htlc_witness_preimage :: ByteString -> PaymentPreimage -> Witness
- offered_htlc_witness_revoke :: ByteString -> Pubkey -> Witness
- received_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> CltvExpiry -> ChannelFeatures -> Script
- received_htlc_witness_timeout :: ByteString -> Witness
- received_htlc_witness_revoke :: ByteString -> Pubkey -> Witness
- htlc_output_script :: RevocationPubkey -> ToSelfDelay -> LocalDelayedPubkey -> Script
- htlc_output_witness_spend :: ByteString -> Witness
- htlc_output_witness_revoke :: ByteString -> Witness
- to_p2wsh :: Script -> Script
- witness_script_hash :: Script -> ByteString
- data CommitmentTx = CommitmentTx {}
- data CommitmentContext = CommitmentContext {
- cc_funding_outpoint :: !Outpoint
- cc_commitment_number :: !CommitmentNumber
- cc_local_payment_bp :: !PaymentBasepoint
- cc_remote_payment_bp :: !PaymentBasepoint
- cc_to_self_delay :: !ToSelfDelay
- cc_dust_limit :: !DustLimit
- cc_feerate :: !FeeratePerKw
- cc_features :: !ChannelFeatures
- cc_is_funder :: !Bool
- cc_to_local_msat :: !MilliSatoshi
- cc_to_remote_msat :: !MilliSatoshi
- cc_htlcs :: ![HTLC]
- cc_keys :: !CommitmentKeys
- data CommitmentKeys = CommitmentKeys {}
- build_commitment_tx :: CommitmentContext -> CommitmentTx
- data HTLCTx = HTLCTx {}
- data HTLCContext = HTLCContext {}
- build_htlc_timeout_tx :: HTLCContext -> HTLCTx
- build_htlc_success_tx :: HTLCContext -> HTLCTx
- data ClosingTx = ClosingTx {}
- data ClosingContext = ClosingContext {
- clc_funding_outpoint :: !Outpoint
- clc_local_amount :: !Satoshi
- clc_remote_amount :: !Satoshi
- clc_local_script :: !Script
- clc_remote_script :: !Script
- clc_local_dust_limit :: !DustLimit
- clc_remote_dust_limit :: !DustLimit
- clc_fee :: !Satoshi
- clc_is_funder :: !Bool
- clc_locktime :: !Locktime
- clc_funding_script :: !Script
- build_closing_tx :: ClosingContext -> ClosingTx
- build_legacy_closing_tx :: ClosingContext -> ClosingTx
- data TxOutput = TxOutput {
- txout_value :: !Satoshi
- txout_script :: !Script
- txout_type :: !OutputType
- data OutputType
- commitment_fee :: FeeratePerKw -> ChannelFeatures -> Word64 -> Satoshi
- commitment_weight :: ChannelFeatures -> Word64 -> Word64
- htlc_timeout_fee :: FeeratePerKw -> ChannelFeatures -> Satoshi
- htlc_success_fee :: FeeratePerKw -> ChannelFeatures -> Satoshi
- htlc_trim_threshold :: DustLimit -> FeeratePerKw -> ChannelFeatures -> HTLCDirection -> Satoshi
- is_trimmed :: DustLimit -> FeeratePerKw -> ChannelFeatures -> HTLC -> Bool
- trimmed_htlcs :: DustLimit -> FeeratePerKw -> ChannelFeatures -> [HTLC] -> [HTLC]
- untrimmed_htlcs :: DustLimit -> FeeratePerKw -> ChannelFeatures -> [HTLC] -> [HTLC]
- sort_outputs :: [TxOutput] -> [TxOutput]
- encode_tx :: CommitmentTx -> ByteString
- encode_htlc_tx :: HTLCTx -> ByteString
- encode_closing_tx :: ClosingTx -> ByteString
- encode_tx_for_signing :: CommitmentTx -> ByteString
- encode_varint :: Word64 -> ByteString
- encode_le32 :: Word32 -> ByteString
- encode_le64 :: Word64 -> ByteString
- encode_outpoint :: Outpoint -> ByteString
- encode_output :: TxOutput -> ByteString
- encode_witness :: Witness -> ByteString
- encode_funding_witness :: ByteString -> ByteString -> Script -> ByteString
- data DecodeError
- data RawTx = RawTx {
- rtx_version :: !Word32
- rtx_inputs :: ![RawInput]
- rtx_outputs :: ![RawOutput]
- rtx_witness :: ![[ByteString]]
- rtx_locktime :: !Locktime
- data RawInput = RawInput {}
- data RawOutput = RawOutput {}
- decode_tx :: ByteString -> Either DecodeError RawTx
- decode_varint :: ByteString -> Either DecodeError (Word64, ByteString)
- decode_le32 :: ByteString -> Either DecodeError (Word32, ByteString)
- decode_le64 :: ByteString -> Either DecodeError (Word64, ByteString)
- decode_outpoint :: ByteString -> Either DecodeError (Outpoint, ByteString)
- decode_output :: ByteString -> Either DecodeError (RawOutput, ByteString)
- decode_witness :: ByteString -> Either DecodeError (Witness, ByteString)
- data ValidationError
- = InvalidVersion !Word32 !Word32
- | InvalidLocktime !Word32
- | InvalidSequence !Word32
- | InvalidOutputOrdering
- | DustLimitViolation !Int !Satoshi !Satoshi
- | MissingAnchorOutput
- | InvalidAnchorValue !Satoshi
- | InvalidFee !Satoshi !Satoshi
- | InvalidHTLCLocktime !Word32 !Word32
- | InvalidHTLCSequence !Word32 !Word32
- | NoOutputs
- | TooManyOutputs !Int
- validate_commitment_tx :: DustLimit -> ChannelFeatures -> CommitmentTx -> Either ValidationError ()
- validate_commitment_locktime :: Locktime -> Either ValidationError ()
- validate_commitment_sequence :: Sequence -> Either ValidationError ()
- validate_htlc_tx :: HTLCTx -> Either ValidationError ()
- validate_htlc_timeout_tx :: ChannelFeatures -> CltvExpiry -> HTLCTx -> Either ValidationError ()
- validate_htlc_success_tx :: ChannelFeatures -> HTLCTx -> Either ValidationError ()
- validate_closing_tx :: ClosingTx -> Either ValidationError ()
- validate_legacy_closing_tx :: ClosingTx -> Either ValidationError ()
- validate_output_ordering :: [TxOutput] -> Either ValidationError ()
- validate_dust_limits :: DustLimit -> [TxOutput] -> Either ValidationError ()
- validate_anchor_outputs :: [TxOutput] -> Either ValidationError ()
- validate_commitment_fee :: FeeratePerKw -> ChannelFeatures -> Word64 -> Satoshi -> Either ValidationError ()
- validate_htlc_fee :: FeeratePerKw -> ChannelFeatures -> HTLCDirection -> Satoshi -> Either ValidationError ()
Types
Monetary amounts
Amount in satoshis.
Instances
| Generic Satoshi Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Num Satoshi Source # | |||||
| Show Satoshi Source # | |||||
| Eq Satoshi Source # | |||||
| Ord Satoshi Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Satoshi Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
newtype MilliSatoshi Source #
Amount in millisatoshis.
Constructors
| MilliSatoshi | |
Fields | |
Instances
msat_to_sat :: MilliSatoshi -> Satoshi Source #
Convert millisatoshis to satoshis (rounds down).
sat_to_msat :: Satoshi -> MilliSatoshi Source #
Convert satoshis to millisatoshis.
Keys and points
Compressed public key (33 bytes).
Constructors
| Pubkey | |
Fields | |
Instances
| Generic Pubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Pubkey Source # | |||||
| Eq Pubkey Source # | |||||
| Ord Pubkey Source # | |||||
| type Rep Pubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Pubkey = D1 ('MetaData "Pubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "Pubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
pubkey :: ByteString -> Maybe Pubkey Source #
Parse a 33-byte compressed public key.
Returns Nothing if the input is not exactly 33 bytes.
>>>pubkey (BS.replicate 33 0x02)Just (Pubkey ...)>>>pubkey (BS.replicate 32 0x02)Nothing
Secret key (32 bytes).
Constructors
| Seckey | |
Fields | |
Instances
| Generic Seckey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Seckey Source # | |||||
| Eq Seckey Source # | |||||
| type Rep Seckey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Seckey = D1 ('MetaData "Seckey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "Seckey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSeckey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
seckey :: ByteString -> Maybe Seckey Source #
Parse a 32-byte secret key.
Returns Nothing if the input is not exactly 32 bytes.
Elliptic curve point (33-byte compressed form).
Constructors
| Point | |
Fields | |
Instances
| Generic Point Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Point Source # | |||||
| Eq Point Source # | |||||
| Ord Point Source # | |||||
| type Rep Point Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Point = D1 ('MetaData "Point" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "Point" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
point :: ByteString -> Maybe Point Source #
Parse a 33-byte elliptic curve point.
Returns Nothing if the input is not exactly 33 bytes.
Hashes
newtype PaymentHash Source #
Payment hash (32 bytes, SHA256 of preimage).
Constructors
| PaymentHash | |
Fields | |
Instances
| Generic PaymentHash Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show PaymentHash Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> PaymentHash -> ShowS # show :: PaymentHash -> String # showList :: [PaymentHash] -> ShowS # | |||||
| Eq PaymentHash Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord PaymentHash Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: PaymentHash -> PaymentHash -> Ordering # (<) :: PaymentHash -> PaymentHash -> Bool # (<=) :: PaymentHash -> PaymentHash -> Bool # (>) :: PaymentHash -> PaymentHash -> Bool # (>=) :: PaymentHash -> PaymentHash -> Bool # max :: PaymentHash -> PaymentHash -> PaymentHash # min :: PaymentHash -> PaymentHash -> PaymentHash # | |||||
| type Rep PaymentHash Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep PaymentHash = D1 ('MetaData "PaymentHash" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "PaymentHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPaymentHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
payment_hash :: ByteString -> Maybe PaymentHash Source #
Parse a 32-byte payment hash.
Returns Nothing if the input is not exactly 32 bytes.
newtype PaymentPreimage Source #
Payment preimage (32 bytes).
Constructors
| PaymentPreimage | |
Fields | |
Instances
| Generic PaymentPreimage Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: PaymentPreimage -> Rep PaymentPreimage x # to :: Rep PaymentPreimage x -> PaymentPreimage # | |||||
| Show PaymentPreimage Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> PaymentPreimage -> ShowS # show :: PaymentPreimage -> String # showList :: [PaymentPreimage] -> ShowS # | |||||
| Eq PaymentPreimage Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: PaymentPreimage -> PaymentPreimage -> Bool # (/=) :: PaymentPreimage -> PaymentPreimage -> Bool # | |||||
| type Rep PaymentPreimage Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep PaymentPreimage = D1 ('MetaData "PaymentPreimage" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "PaymentPreimage" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPaymentPreimage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
payment_preimage :: ByteString -> Maybe PaymentPreimage Source #
Parse a 32-byte payment preimage.
Returns Nothing if the input is not exactly 32 bytes.
Transaction primitives
Transaction ID (32 bytes, little-endian hash).
Constructors
| TxId | |
Fields
| |
Instances
| Generic TxId Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show TxId Source # | |||||
| Eq TxId Source # | |||||
| Ord TxId Source # | |||||
| type Rep TxId Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep TxId = D1 ('MetaData "TxId" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "TxId" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
txid :: ByteString -> Maybe TxId Source #
Parse a 32-byte transaction ID.
Returns Nothing if the input is not exactly 32 bytes.
Transaction outpoint (txid + output index).
Constructors
| Outpoint | |
Fields
| |
Instances
| Generic Outpoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Outpoint Source # | |||||
| Eq Outpoint Source # | |||||
| Ord Outpoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Outpoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Outpoint = D1 ('MetaData "Outpoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "Outpoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "outpoint_txid") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 TxId) :*: S1 ('MetaSel ('Just "outpoint_index") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32))) | |||||
Transaction input sequence number.
Constructors
| Sequence | |
Fields
| |
Instances
| Generic Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Num Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Show Sequence Source # | |||||
| Eq Sequence Source # | |||||
| Ord Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Sequence Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
Transaction locktime.
Constructors
| Locktime | |
Fields
| |
Instances
| Generic Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Num Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Show Locktime Source # | |||||
| Eq Locktime Source # | |||||
| Ord Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Locktime Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
Channel parameters
newtype CommitmentNumber Source #
48-bit commitment number.
Constructors
| CommitmentNumber | |
Fields | |
Instances
| Generic CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: CommitmentNumber -> Rep CommitmentNumber x # to :: Rep CommitmentNumber x -> CommitmentNumber # | |||||
| Num CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (+) :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber # (-) :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber # (*) :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber # negate :: CommitmentNumber -> CommitmentNumber # abs :: CommitmentNumber -> CommitmentNumber # signum :: CommitmentNumber -> CommitmentNumber # fromInteger :: Integer -> CommitmentNumber # | |||||
| Show CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> CommitmentNumber -> ShowS # show :: CommitmentNumber -> String # showList :: [CommitmentNumber] -> ShowS # | |||||
| Eq CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: CommitmentNumber -> CommitmentNumber -> Bool # (/=) :: CommitmentNumber -> CommitmentNumber -> Bool # | |||||
| Ord CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: CommitmentNumber -> CommitmentNumber -> Ordering # (<) :: CommitmentNumber -> CommitmentNumber -> Bool # (<=) :: CommitmentNumber -> CommitmentNumber -> Bool # (>) :: CommitmentNumber -> CommitmentNumber -> Bool # (>=) :: CommitmentNumber -> CommitmentNumber -> Bool # max :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber # min :: CommitmentNumber -> CommitmentNumber -> CommitmentNumber # | |||||
| type Rep CommitmentNumber Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep CommitmentNumber = D1 ('MetaData "CommitmentNumber" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "CommitmentNumber" 'PrefixI 'True) (S1 ('MetaSel ('Just "unCommitmentNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) | |||||
commitment_number :: Word64 -> Maybe CommitmentNumber Source #
Parse a 48-bit commitment number.
Returns Nothing if the value exceeds 2^48 - 1.
newtype ToSelfDelay Source #
CSV delay for to_local outputs.
Constructors
| ToSelfDelay | |
Fields | |
Instances
| Generic ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Num ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (+) :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay # (-) :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay # (*) :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay # negate :: ToSelfDelay -> ToSelfDelay # abs :: ToSelfDelay -> ToSelfDelay # signum :: ToSelfDelay -> ToSelfDelay # fromInteger :: Integer -> ToSelfDelay # | |||||
| Show ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> ToSelfDelay -> ShowS # show :: ToSelfDelay -> String # showList :: [ToSelfDelay] -> ShowS # | |||||
| Eq ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: ToSelfDelay -> ToSelfDelay -> Ordering # (<) :: ToSelfDelay -> ToSelfDelay -> Bool # (<=) :: ToSelfDelay -> ToSelfDelay -> Bool # (>) :: ToSelfDelay -> ToSelfDelay -> Bool # (>=) :: ToSelfDelay -> ToSelfDelay -> Bool # max :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay # min :: ToSelfDelay -> ToSelfDelay -> ToSelfDelay # | |||||
| type Rep ToSelfDelay Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep ToSelfDelay = D1 ('MetaData "ToSelfDelay" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "ToSelfDelay" 'PrefixI 'True) (S1 ('MetaSel ('Just "unToSelfDelay") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16))) | |||||
newtype CltvExpiry Source #
CLTV expiry for HTLCs.
Constructors
| CltvExpiry | |
Fields | |
Instances
| Generic CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Num CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (+) :: CltvExpiry -> CltvExpiry -> CltvExpiry # (-) :: CltvExpiry -> CltvExpiry -> CltvExpiry # (*) :: CltvExpiry -> CltvExpiry -> CltvExpiry # negate :: CltvExpiry -> CltvExpiry # abs :: CltvExpiry -> CltvExpiry # signum :: CltvExpiry -> CltvExpiry # fromInteger :: Integer -> CltvExpiry # | |||||
| Show CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> CltvExpiry -> ShowS # show :: CltvExpiry -> String # showList :: [CltvExpiry] -> ShowS # | |||||
| Eq CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: CltvExpiry -> CltvExpiry -> Ordering # (<) :: CltvExpiry -> CltvExpiry -> Bool # (<=) :: CltvExpiry -> CltvExpiry -> Bool # (>) :: CltvExpiry -> CltvExpiry -> Bool # (>=) :: CltvExpiry -> CltvExpiry -> Bool # max :: CltvExpiry -> CltvExpiry -> CltvExpiry # min :: CltvExpiry -> CltvExpiry -> CltvExpiry # | |||||
| type Rep CltvExpiry Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep CltvExpiry = D1 ('MetaData "CltvExpiry" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "CltvExpiry" 'PrefixI 'True) (S1 ('MetaSel ('Just "unCltvExpiry") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32))) | |||||
Dust limit threshold.
Constructors
| DustLimit | |
Fields | |
Instances
| Generic DustLimit Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show DustLimit Source # | |||||
| Eq DustLimit Source # | |||||
| Ord DustLimit Source # | |||||
| type Rep DustLimit Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
newtype FeeratePerKw Source #
Fee rate in satoshis per 1000 weight units.
Constructors
| FeeratePerKw | |
Fields | |
Instances
| Generic FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Num FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (+) :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw # (-) :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw # (*) :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw # negate :: FeeratePerKw -> FeeratePerKw # abs :: FeeratePerKw -> FeeratePerKw # signum :: FeeratePerKw -> FeeratePerKw # fromInteger :: Integer -> FeeratePerKw # | |||||
| Show FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> FeeratePerKw -> ShowS # show :: FeeratePerKw -> String # showList :: [FeeratePerKw] -> ShowS # | |||||
| Eq FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: FeeratePerKw -> FeeratePerKw -> Ordering # (<) :: FeeratePerKw -> FeeratePerKw -> Bool # (<=) :: FeeratePerKw -> FeeratePerKw -> Bool # (>) :: FeeratePerKw -> FeeratePerKw -> Bool # (>=) :: FeeratePerKw -> FeeratePerKw -> Bool # max :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw # min :: FeeratePerKw -> FeeratePerKw -> FeeratePerKw # | |||||
| type Rep FeeratePerKw Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep FeeratePerKw = D1 ('MetaData "FeeratePerKw" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "FeeratePerKw" 'PrefixI 'True) (S1 ('MetaSel ('Just "unFeeratePerKw") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32))) | |||||
HTLC types
HTLC output details.
NOTE: No Ord instance is provided. BOLT #3 requires output ordering by
amount then scriptPubKey, but scriptPubKey depends on derived keys which
are not available here. Use sort_outputs in Tx module for proper BIP69
output ordering.
Constructors
| HTLC | |
Fields | |
Instances
| Generic HTLC Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show HTLC Source # | |||||
| Eq HTLC Source # | |||||
| type Rep HTLC Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep HTLC = D1 ('MetaData "HTLC" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "HTLC" 'PrefixI 'True) ((S1 ('MetaSel ('Just "htlc_direction") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLCDirection) :*: S1 ('MetaSel ('Just "htlc_amount_msat") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi)) :*: (S1 ('MetaSel ('Just "htlc_payment_hash") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 PaymentHash) :*: S1 ('MetaSel ('Just "htlc_cltv_expiry") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 CltvExpiry)))) | |||||
data HTLCDirection Source #
Direction of an HTLC from the commitment tx owner's perspective.
Constructors
| HTLCOffered | We offered this HTLC (outgoing) |
| HTLCReceived | We received this HTLC (incoming) |
Instances
| Generic HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> HTLCDirection -> ShowS # show :: HTLCDirection -> String # showList :: [HTLCDirection] -> ShowS # | |||||
| Eq HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: HTLCDirection -> HTLCDirection -> Bool # (/=) :: HTLCDirection -> HTLCDirection -> Bool # | |||||
| Ord HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: HTLCDirection -> HTLCDirection -> Ordering # (<) :: HTLCDirection -> HTLCDirection -> Bool # (<=) :: HTLCDirection -> HTLCDirection -> Bool # (>) :: HTLCDirection -> HTLCDirection -> Bool # (>=) :: HTLCDirection -> HTLCDirection -> Bool # max :: HTLCDirection -> HTLCDirection -> HTLCDirection # min :: HTLCDirection -> HTLCDirection -> HTLCDirection # | |||||
| type Rep HTLCDirection Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
Basepoints
data Basepoints Source #
Collection of all basepoints for one party.
Constructors
| Basepoints | |
Instances
| Generic Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> Basepoints -> ShowS # show :: Basepoints -> String # showList :: [Basepoints] -> ShowS # | |||||
| Eq Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Basepoints Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Basepoints = D1 ('MetaData "Basepoints" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "Basepoints" 'PrefixI 'True) ((S1 ('MetaSel ('Just "bp_revocation") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationBasepoint) :*: S1 ('MetaSel ('Just "bp_payment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PaymentBasepoint)) :*: (S1 ('MetaSel ('Just "bp_delayed_payment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DelayedPaymentBasepoint) :*: S1 ('MetaSel ('Just "bp_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HtlcBasepoint)))) | |||||
newtype PerCommitmentPoint Source #
Per-commitment point (used to derive keys).
Constructors
| PerCommitmentPoint | |
Fields | |
Instances
| Generic PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: PerCommitmentPoint -> Rep PerCommitmentPoint x # to :: Rep PerCommitmentPoint x -> PerCommitmentPoint # | |||||
| Show PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> PerCommitmentPoint -> ShowS # show :: PerCommitmentPoint -> String # showList :: [PerCommitmentPoint] -> ShowS # | |||||
| Eq PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (/=) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # | |||||
| Ord PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: PerCommitmentPoint -> PerCommitmentPoint -> Ordering # (<) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (<=) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (>) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # (>=) :: PerCommitmentPoint -> PerCommitmentPoint -> Bool # max :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint # min :: PerCommitmentPoint -> PerCommitmentPoint -> PerCommitmentPoint # | |||||
| type Rep PerCommitmentPoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep PerCommitmentPoint = D1 ('MetaData "PerCommitmentPoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "PerCommitmentPoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPerCommitmentPoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype PerCommitmentSecret Source #
Per-commitment secret (32 bytes).
Constructors
| PerCommitmentSecret | |
Fields | |
Instances
| Generic PerCommitmentSecret Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: PerCommitmentSecret -> Rep PerCommitmentSecret x # to :: Rep PerCommitmentSecret x -> PerCommitmentSecret # | |||||
| Show PerCommitmentSecret Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> PerCommitmentSecret -> ShowS # show :: PerCommitmentSecret -> String # showList :: [PerCommitmentSecret] -> ShowS # | |||||
| Eq PerCommitmentSecret Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: PerCommitmentSecret -> PerCommitmentSecret -> Bool # (/=) :: PerCommitmentSecret -> PerCommitmentSecret -> Bool # | |||||
| type Rep PerCommitmentSecret Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep PerCommitmentSecret = D1 ('MetaData "PerCommitmentSecret" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "PerCommitmentSecret" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPerCommitmentSecret") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
per_commitment_secret :: ByteString -> Maybe PerCommitmentSecret Source #
Parse a 32-byte per-commitment secret.
Returns Nothing if the input is not exactly 32 bytes.
newtype RevocationBasepoint Source #
Revocation basepoint.
Constructors
| RevocationBasepoint | |
Fields | |
Instances
| Generic RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: RevocationBasepoint -> Rep RevocationBasepoint x # to :: Rep RevocationBasepoint x -> RevocationBasepoint # | |||||
| Show RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RevocationBasepoint -> ShowS # show :: RevocationBasepoint -> String # showList :: [RevocationBasepoint] -> ShowS # | |||||
| Eq RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (/=) :: RevocationBasepoint -> RevocationBasepoint -> Bool # | |||||
| Ord RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RevocationBasepoint -> RevocationBasepoint -> Ordering # (<) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (<=) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (>) :: RevocationBasepoint -> RevocationBasepoint -> Bool # (>=) :: RevocationBasepoint -> RevocationBasepoint -> Bool # max :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint # min :: RevocationBasepoint -> RevocationBasepoint -> RevocationBasepoint # | |||||
| type Rep RevocationBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RevocationBasepoint = D1 ('MetaData "RevocationBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "RevocationBasepoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "unRevocationBasepoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype PaymentBasepoint Source #
Payment basepoint.
Constructors
| PaymentBasepoint | |
Fields | |
Instances
| Generic PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: PaymentBasepoint -> Rep PaymentBasepoint x # to :: Rep PaymentBasepoint x -> PaymentBasepoint # | |||||
| Show PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> PaymentBasepoint -> ShowS # show :: PaymentBasepoint -> String # showList :: [PaymentBasepoint] -> ShowS # | |||||
| Eq PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (/=) :: PaymentBasepoint -> PaymentBasepoint -> Bool # | |||||
| Ord PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: PaymentBasepoint -> PaymentBasepoint -> Ordering # (<) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (<=) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (>) :: PaymentBasepoint -> PaymentBasepoint -> Bool # (>=) :: PaymentBasepoint -> PaymentBasepoint -> Bool # max :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint # min :: PaymentBasepoint -> PaymentBasepoint -> PaymentBasepoint # | |||||
| type Rep PaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep PaymentBasepoint = D1 ('MetaData "PaymentBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "PaymentBasepoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPaymentBasepoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype DelayedPaymentBasepoint Source #
Delayed payment basepoint.
Constructors
| DelayedPaymentBasepoint | |
Fields | |
Instances
| Generic DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: DelayedPaymentBasepoint -> Rep DelayedPaymentBasepoint x # to :: Rep DelayedPaymentBasepoint x -> DelayedPaymentBasepoint # | |||||
| Show DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> DelayedPaymentBasepoint -> ShowS # show :: DelayedPaymentBasepoint -> String # showList :: [DelayedPaymentBasepoint] -> ShowS # | |||||
| Eq DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (/=) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # | |||||
| Ord DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Ordering # (<) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (<=) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (>) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # (>=) :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> Bool # max :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> DelayedPaymentBasepoint # min :: DelayedPaymentBasepoint -> DelayedPaymentBasepoint -> DelayedPaymentBasepoint # | |||||
| type Rep DelayedPaymentBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep DelayedPaymentBasepoint = D1 ('MetaData "DelayedPaymentBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "DelayedPaymentBasepoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "unDelayedPaymentBasepoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
newtype HtlcBasepoint Source #
HTLC basepoint.
Constructors
| HtlcBasepoint | |
Fields | |
Instances
| Generic HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> HtlcBasepoint -> ShowS # show :: HtlcBasepoint -> String # showList :: [HtlcBasepoint] -> ShowS # | |||||
| Eq HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (/=) :: HtlcBasepoint -> HtlcBasepoint -> Bool # | |||||
| Ord HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: HtlcBasepoint -> HtlcBasepoint -> Ordering # (<) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (<=) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (>) :: HtlcBasepoint -> HtlcBasepoint -> Bool # (>=) :: HtlcBasepoint -> HtlcBasepoint -> Bool # max :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint # min :: HtlcBasepoint -> HtlcBasepoint -> HtlcBasepoint # | |||||
| type Rep HtlcBasepoint Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep HtlcBasepoint = D1 ('MetaData "HtlcBasepoint" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "HtlcBasepoint" 'PrefixI 'True) (S1 ('MetaSel ('Just "unHtlcBasepoint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Point))) | |||||
Derived keys
newtype LocalPubkey Source #
Local pubkey (derived from payment_basepoint + per_commitment_point).
Constructors
| LocalPubkey | |
Fields | |
Instances
| Generic LocalPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show LocalPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> LocalPubkey -> ShowS # show :: LocalPubkey -> String # showList :: [LocalPubkey] -> ShowS # | |||||
| Eq LocalPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord LocalPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: LocalPubkey -> LocalPubkey -> Ordering # (<) :: LocalPubkey -> LocalPubkey -> Bool # (<=) :: LocalPubkey -> LocalPubkey -> Bool # (>) :: LocalPubkey -> LocalPubkey -> Bool # (>=) :: LocalPubkey -> LocalPubkey -> Bool # max :: LocalPubkey -> LocalPubkey -> LocalPubkey # min :: LocalPubkey -> LocalPubkey -> LocalPubkey # | |||||
| type Rep LocalPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep LocalPubkey = D1 ('MetaData "LocalPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "LocalPubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unLocalPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
newtype RemotePubkey Source #
Remote pubkey (simply the remote's payment_basepoint).
Constructors
| RemotePubkey | |
Fields | |
Instances
| Generic RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RemotePubkey -> ShowS # show :: RemotePubkey -> String # showList :: [RemotePubkey] -> ShowS # | |||||
| Eq RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| Ord RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RemotePubkey -> RemotePubkey -> Ordering # (<) :: RemotePubkey -> RemotePubkey -> Bool # (<=) :: RemotePubkey -> RemotePubkey -> Bool # (>) :: RemotePubkey -> RemotePubkey -> Bool # (>=) :: RemotePubkey -> RemotePubkey -> Bool # max :: RemotePubkey -> RemotePubkey -> RemotePubkey # min :: RemotePubkey -> RemotePubkey -> RemotePubkey # | |||||
| type Rep RemotePubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RemotePubkey = D1 ('MetaData "RemotePubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "RemotePubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unRemotePubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
newtype LocalDelayedPubkey Source #
Local delayed pubkey.
Constructors
| LocalDelayedPubkey | |
Fields | |
Instances
| Generic LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: LocalDelayedPubkey -> Rep LocalDelayedPubkey x # to :: Rep LocalDelayedPubkey x -> LocalDelayedPubkey # | |||||
| Show LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> LocalDelayedPubkey -> ShowS # show :: LocalDelayedPubkey -> String # showList :: [LocalDelayedPubkey] -> ShowS # | |||||
| Eq LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (/=) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # | |||||
| Ord LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: LocalDelayedPubkey -> LocalDelayedPubkey -> Ordering # (<) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (<=) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (>) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # (>=) :: LocalDelayedPubkey -> LocalDelayedPubkey -> Bool # max :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey # min :: LocalDelayedPubkey -> LocalDelayedPubkey -> LocalDelayedPubkey # | |||||
| type Rep LocalDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep LocalDelayedPubkey = D1 ('MetaData "LocalDelayedPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "LocalDelayedPubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unLocalDelayedPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
newtype RemoteDelayedPubkey Source #
Remote delayed pubkey.
Constructors
| RemoteDelayedPubkey | |
Fields | |
Instances
| Generic RemoteDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: RemoteDelayedPubkey -> Rep RemoteDelayedPubkey x # to :: Rep RemoteDelayedPubkey x -> RemoteDelayedPubkey # | |||||
| Show RemoteDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RemoteDelayedPubkey -> ShowS # show :: RemoteDelayedPubkey -> String # showList :: [RemoteDelayedPubkey] -> ShowS # | |||||
| Eq RemoteDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool # (/=) :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool # | |||||
| Ord RemoteDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Ordering # (<) :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool # (<=) :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool # (>) :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool # (>=) :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> Bool # max :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> RemoteDelayedPubkey # min :: RemoteDelayedPubkey -> RemoteDelayedPubkey -> RemoteDelayedPubkey # | |||||
| type Rep RemoteDelayedPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RemoteDelayedPubkey = D1 ('MetaData "RemoteDelayedPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "RemoteDelayedPubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unRemoteDelayedPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
newtype LocalHtlcPubkey Source #
Local HTLC pubkey.
Constructors
| LocalHtlcPubkey | |
Fields | |
Instances
| Generic LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: LocalHtlcPubkey -> Rep LocalHtlcPubkey x # to :: Rep LocalHtlcPubkey x -> LocalHtlcPubkey # | |||||
| Show LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> LocalHtlcPubkey -> ShowS # show :: LocalHtlcPubkey -> String # showList :: [LocalHtlcPubkey] -> ShowS # | |||||
| Eq LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (/=) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # | |||||
| Ord LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: LocalHtlcPubkey -> LocalHtlcPubkey -> Ordering # (<) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (<=) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (>) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # (>=) :: LocalHtlcPubkey -> LocalHtlcPubkey -> Bool # max :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey # min :: LocalHtlcPubkey -> LocalHtlcPubkey -> LocalHtlcPubkey # | |||||
| type Rep LocalHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep LocalHtlcPubkey = D1 ('MetaData "LocalHtlcPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "LocalHtlcPubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unLocalHtlcPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
newtype RemoteHtlcPubkey Source #
Remote HTLC pubkey.
Constructors
| RemoteHtlcPubkey | |
Fields | |
Instances
| Generic RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: RemoteHtlcPubkey -> Rep RemoteHtlcPubkey x # to :: Rep RemoteHtlcPubkey x -> RemoteHtlcPubkey # | |||||
| Show RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RemoteHtlcPubkey -> ShowS # show :: RemoteHtlcPubkey -> String # showList :: [RemoteHtlcPubkey] -> ShowS # | |||||
| Eq RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (/=) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # | |||||
| Ord RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Ordering # (<) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (<=) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (>) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # (>=) :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> Bool # max :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey # min :: RemoteHtlcPubkey -> RemoteHtlcPubkey -> RemoteHtlcPubkey # | |||||
| type Rep RemoteHtlcPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RemoteHtlcPubkey = D1 ('MetaData "RemoteHtlcPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "RemoteHtlcPubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unRemoteHtlcPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
newtype RevocationPubkey Source #
Revocation pubkey (derived from revocation_basepoint + per_commitment).
Constructors
| RevocationPubkey | |
Fields | |
Instances
| Generic RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: RevocationPubkey -> Rep RevocationPubkey x # to :: Rep RevocationPubkey x -> RevocationPubkey # | |||||
| Show RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> RevocationPubkey -> ShowS # show :: RevocationPubkey -> String # showList :: [RevocationPubkey] -> ShowS # | |||||
| Eq RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: RevocationPubkey -> RevocationPubkey -> Bool # (/=) :: RevocationPubkey -> RevocationPubkey -> Bool # | |||||
| Ord RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: RevocationPubkey -> RevocationPubkey -> Ordering # (<) :: RevocationPubkey -> RevocationPubkey -> Bool # (<=) :: RevocationPubkey -> RevocationPubkey -> Bool # (>) :: RevocationPubkey -> RevocationPubkey -> Bool # (>=) :: RevocationPubkey -> RevocationPubkey -> Bool # max :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey # min :: RevocationPubkey -> RevocationPubkey -> RevocationPubkey # | |||||
| type Rep RevocationPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep RevocationPubkey = D1 ('MetaData "RevocationPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "RevocationPubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unRevocationPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
newtype FundingPubkey Source #
Funding pubkey (used in 2-of-2 multisig).
Constructors
| FundingPubkey | |
Fields | |
Instances
| Generic FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> FundingPubkey -> ShowS # show :: FundingPubkey -> String # showList :: [FundingPubkey] -> ShowS # | |||||
| Eq FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: FundingPubkey -> FundingPubkey -> Bool # (/=) :: FundingPubkey -> FundingPubkey -> Bool # | |||||
| Ord FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods compare :: FundingPubkey -> FundingPubkey -> Ordering # (<) :: FundingPubkey -> FundingPubkey -> Bool # (<=) :: FundingPubkey -> FundingPubkey -> Bool # (>) :: FundingPubkey -> FundingPubkey -> Bool # (>=) :: FundingPubkey -> FundingPubkey -> Bool # max :: FundingPubkey -> FundingPubkey -> FundingPubkey # min :: FundingPubkey -> FundingPubkey -> FundingPubkey # | |||||
| type Rep FundingPubkey Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep FundingPubkey = D1 ('MetaData "FundingPubkey" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "FundingPubkey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unFundingPubkey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pubkey))) | |||||
Script and witness
Bitcoin script (serialized).
Constructors
| Script | |
Fields | |
Instances
| Generic Script Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Script Source # | |||||
| Eq Script Source # | |||||
| Ord Script Source # | |||||
| type Rep Script Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Script = D1 ('MetaData "Script" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "Script" 'PrefixI 'True) (S1 ('MetaSel ('Just "unScript") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
Transaction witness stack.
Constructors
| Witness | |
Fields
| |
Instances
| Generic Witness Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
| |||||
| Show Witness Source # | |||||
| Eq Witness Source # | |||||
| Ord Witness Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types | |||||
| type Rep Witness Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep Witness = D1 ('MetaData "Witness" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'True) (C1 ('MetaCons "Witness" 'PrefixI 'True) (S1 ('MetaSel ('Just "unWitness") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ByteString]))) | |||||
Channel features
data ChannelFeatures Source #
Channel feature flags relevant to BOLT #3.
Constructors
| ChannelFeatures | |
Fields | |
Instances
| Generic ChannelFeatures Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Associated Types
Methods from :: ChannelFeatures -> Rep ChannelFeatures x # to :: Rep ChannelFeatures x -> ChannelFeatures # | |||||
| Show ChannelFeatures Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods showsPrec :: Int -> ChannelFeatures -> ShowS # show :: ChannelFeatures -> String # showList :: [ChannelFeatures] -> ShowS # | |||||
| Eq ChannelFeatures Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types Methods (==) :: ChannelFeatures -> ChannelFeatures -> Bool # (/=) :: ChannelFeatures -> ChannelFeatures -> Bool # | |||||
| type Rep ChannelFeatures Source # | |||||
Defined in Lightning.Protocol.BOLT3.Types type Rep ChannelFeatures = D1 ('MetaData "ChannelFeatures" "Lightning.Protocol.BOLT3.Types" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "ChannelFeatures" 'PrefixI 'True) (S1 ('MetaSel ('Just "cf_option_anchors") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))) | |||||
has_anchors :: ChannelFeatures -> Bool Source #
Check if option_anchors is enabled.
Constants
commitment_weight_no_anchors :: Word64 Source #
Base commitment tx weight without option_anchors.
commitment_weight_anchors :: Word64 Source #
Base commitment tx weight with option_anchors.
htlc_timeout_weight_no_anchors :: Word64 Source #
HTLC-timeout tx weight without option_anchors.
htlc_timeout_weight_anchors :: Word64 Source #
HTLC-timeout tx weight with option_anchors.
htlc_success_weight_no_anchors :: Word64 Source #
HTLC-success tx weight without option_anchors.
htlc_success_weight_anchors :: Word64 Source #
HTLC-success tx weight with option_anchors.
htlc_output_weight :: Word64 Source #
Weight added per HTLC output in commitment tx.
dust_p2pkh :: Satoshi Source #
P2PKH dust threshold (546 satoshis).
dust_p2wpkh :: Satoshi Source #
P2WPKH dust threshold (294 satoshis).
dust_p2wsh :: Satoshi Source #
P2WSH dust threshold (330 satoshis).
anchor_output_value :: Satoshi Source #
Fixed anchor output value (330 satoshis).
Key derivation
derive_per_commitment_point :: PerCommitmentSecret -> Maybe PerCommitmentPoint Source #
Derive the per-commitment point from a per-commitment secret.
per_commitment_point = per_commitment_secret * G
>>>let secret = PerCommitmentSecret (BS.replicate 32 0x01)>>>derive_per_commitment_point secretJust (PerCommitmentPoint ...)
Arguments
| :: Point | basepoint |
| -> PerCommitmentPoint | per_commitment_point |
| -> Maybe Pubkey |
Derive a pubkey from a basepoint and per-commitment point.
pubkey = basepoint + SHA256(per_commitment_point || basepoint) * G
This is the general derivation formula used for localpubkey, local_htlcpubkey, remote_htlcpubkey, local_delayedpubkey, and remote_delayedpubkey.
>>>derive_pubkey basepoint per_commitment_pointJust (Pubkey ...)
derive_localpubkey :: PaymentBasepoint -> PerCommitmentPoint -> Maybe LocalPubkey Source #
Derive localpubkey from payment_basepoint and per_commitment_point.
>>>derive_localpubkey payment_basepoint per_commitment_pointJust (LocalPubkey ...)
derive_local_htlcpubkey :: HtlcBasepoint -> PerCommitmentPoint -> Maybe LocalHtlcPubkey Source #
Derive local_htlcpubkey from htlc_basepoint and per_commitment_point.
>>>derive_local_htlcpubkey htlc_basepoint per_commitment_pointJust (LocalHtlcPubkey ...)
derive_remote_htlcpubkey :: HtlcBasepoint -> PerCommitmentPoint -> Maybe RemoteHtlcPubkey Source #
Derive remote_htlcpubkey from htlc_basepoint and per_commitment_point.
>>>derive_remote_htlcpubkey htlc_basepoint per_commitment_pointJust (RemoteHtlcPubkey ...)
derive_local_delayedpubkey :: DelayedPaymentBasepoint -> PerCommitmentPoint -> Maybe LocalDelayedPubkey Source #
Derive local_delayedpubkey from delayed_payment_basepoint and per_commitment_point.
>>>derive_local_delayedpubkey delayed_payment_basepoint per_commitment_pointJust (LocalDelayedPubkey ...)
derive_remote_delayedpubkey :: DelayedPaymentBasepoint -> PerCommitmentPoint -> Maybe RemoteDelayedPubkey Source #
Derive remote_delayedpubkey from delayed_payment_basepoint and per_commitment_point.
>>>derive_remote_delayedpubkey delayed_payment_basepoint pcpJust (RemoteDelayedPubkey ...)
derive_revocationpubkey :: RevocationBasepoint -> PerCommitmentPoint -> Maybe RevocationPubkey Source #
Derive revocationpubkey from revocation_basepoint and per_commitment_point.
revocationpubkey = revocation_basepoint
* SHA256(revocation_basepoint || per_commitment_point)
+ per_commitment_point
* SHA256(per_commitment_point || revocation_basepoint)
>>>derive_revocationpubkey revocation_basepoint per_commitment_pointJust (RevocationPubkey ...)
Secret generation
Arguments
| :: ByteString | seed (32 bytes) |
| -> Word64 | index I (max 2^48 - 1) |
| -> ByteString | per-commitment secret (32 bytes) |
Generate the I'th per-commitment secret from a seed.
Implements the generate_from_seed algorithm from BOLT #3:
generate_from_seed(seed, I):
P = seed
for B in 47 down to 0:
if B set in I:
flip(B) in P
P = SHA256(P)
return P
>>>generate_from_seed seed 281474976710655<32-byte secret>
Arguments
| :: ByteString | base secret |
| -> Int | bits (number of trailing bits to process) |
| -> Word64 | target index I |
| -> ByteString | derived secret |
Derive a secret from a base secret.
This is a generalization of generate_from_seed used for efficient secret storage. Given a base secret whose index has bits..47 the same as target index I, derive the I'th secret.
derive_secret(base, bits, I):
P = base
for B in bits - 1 down to 0:
if B set in I:
flip(B) in P
P = SHA256(P)
return P
Secret storage
data SecretStore Source #
Compact storage for per-commitment secrets.
Stores up to 49 (value, index) pairs, allowing efficient derivation of any previously-received secret. This is possible because for a given secret on a 2^X boundary, all secrets up to the next 2^X boundary can be derived from it.
Instances
| Generic SecretStore Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys Associated Types
| |||||
| Show SecretStore Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys Methods showsPrec :: Int -> SecretStore -> ShowS # show :: SecretStore -> String # showList :: [SecretStore] -> ShowS # | |||||
| Eq SecretStore Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys | |||||
| type Rep SecretStore Source # | |||||
Defined in Lightning.Protocol.BOLT3.Keys | |||||
empty_store :: SecretStore Source #
Empty secret store.
Arguments
| :: ByteString | secret (32 bytes) |
| -> Word64 | index |
| -> SecretStore | current store |
| -> Maybe SecretStore |
Insert a secret into the store, validating against existing secrets.
Returns Nothing if the secret doesn't derive correctly from known secrets (indicating the secrets weren't generated from the same seed).
>>>insert_secret secret 281474976710655 empty_storeJust (SecretStore ...)
Arguments
| :: Word64 | target index |
| -> SecretStore | store |
| -> Maybe ByteString |
Derive a previously-received secret from the store.
Iterates over known secrets to find one whose index is a prefix of the target index, then derives the target secret from it.
>>>derive_old_secret 281474976710654 storeJust <32-byte secret>
Commitment number
obscured_commitment_number Source #
Arguments
| :: PaymentBasepoint | opener's payment_basepoint |
| -> PaymentBasepoint | accepter's payment_basepoint |
| -> CommitmentNumber | commitment number (48-bit) |
| -> Word64 | obscured commitment number |
Calculate the obscured commitment number.
The 48-bit commitment number is obscured by XOR with the lower 48 bits of SHA256(payment_basepoint from open_channel || payment_basepoint from accept_channel).
>>>obscured_commitment_number local_payment_bp remote_payment_bp cn<obscured value>
Scripts
Funding output
funding_script :: FundingPubkey -> FundingPubkey -> Script Source #
funding_witness :: ByteString -> ByteString -> Witness Source #
to_local output
to_local_script :: RevocationPubkey -> ToSelfDelay -> LocalDelayedPubkey -> Script Source #
to_local witness script (revocable with CSV delay).
Script:
OP_IF
revocationpubkey
OP_ELSE
to_self_delay
OP_CHECKSEQUENCEVERIFY
OP_DROP
local_delayedpubkey
OP_ENDIF
OP_CHECKSIG
>>>to_local_script revpk delay localpkScript "c!<revpk>g<delay>\xb2u!<localpk>h\xac"
to_local_witness_spend :: ByteString -> Witness Source #
Witness for delayed spend of to_local output.
Input nSequence must be set to to_self_delay.
Witness: local_delayedsig <>
>>>to_local_witness_spend sigWitness [sig, ""]
to_local_witness_revoke :: ByteString -> Witness Source #
Witness for revocation spend of to_local output.
Witness: revocation_sig 1
>>>to_local_witness_revoke sigWitness [sig, "\x01"]
to_remote output
to_remote_script :: RemotePubkey -> ChannelFeatures -> Script Source #
to_remote witness script.
With option_anchors:
remotepubkey OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY
Without option_anchors: P2WPKH (just the pubkey hash).
>>>to_remote_script pk (ChannelFeatures True)Script "!<pk>\xadQ\xb2"
to_remote_witness :: ByteString -> RemotePubkey -> ChannelFeatures -> Witness Source #
Witness for spending to_remote output.
With option_anchors (P2WSH), input nSequence must be 1.
Witness: remote_sig (witness script appended by caller)
Without option_anchors (P2WPKH):
Witness: remote_sig remotepubkey
>>>to_remote_witness sig pk (ChannelFeatures False)Witness [sig, pk]
Anchor outputs
anchor_script :: FundingPubkey -> Script Source #
Anchor output witness script.
Script:
funding_pubkey OP_CHECKSIG OP_IFDUP OP_NOTIF OP_16 OP_CHECKSEQUENCEVERIFY OP_ENDIF
>>>anchor_script fundpkScript "!<fundpk>\xac\x73d`\xb2h"
anchor_witness_anyone :: Witness Source #
Witness for anyone to sweep anchor output after 16 blocks.
Witness: <>
>>>anchor_witness_anyoneWitness [""]
Offered HTLC
offered_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> ChannelFeatures -> Script Source #
Offered HTLC witness script.
Without option_anchors:
OP_DUP OP_HASH160 RIPEMD160(SHA256(revocationpubkey)) OP_EQUAL OP_IF OP_CHECKSIG OP_ELSE remote_htlcpubkey OP_SWAP OP_SIZE 32 OP_EQUAL OP_NOTIF OP_DROP 2 OP_SWAP local_htlcpubkey 2 OP_CHECKMULTISIG OP_ELSE OP_HASH160 RIPEMD160(payment_hash) OP_EQUALVERIFY OP_CHECKSIG OP_ENDIF OP_ENDIF
With option_anchors, adds 1 OP_CHECKSEQUENCEVERIFY OP_DROP before
final OP_ENDIF.
offered_htlc_witness_preimage :: ByteString -> PaymentPreimage -> Witness Source #
Witness for remote node to claim offered HTLC with preimage.
With option_anchors, input nSequence must be 1.
Witness: remotehtlcsig payment_preimage
>>>offered_htlc_witness_preimage sig preimageWitness [sig, preimage]
offered_htlc_witness_revoke :: ByteString -> Pubkey -> Witness Source #
Witness for revocation spend of offered HTLC.
Witness: revocation_sig revocationpubkey
>>>offered_htlc_witness_revoke sig revpkWitness [sig, revpk]
Received HTLC
received_htlc_script :: RevocationPubkey -> RemoteHtlcPubkey -> LocalHtlcPubkey -> PaymentHash -> CltvExpiry -> ChannelFeatures -> Script Source #
Received HTLC witness script.
Without option_anchors:
OP_DUP OP_HASH160 RIPEMD160(SHA256(revocationpubkey)) OP_EQUAL OP_IF OP_CHECKSIG OP_ELSE remote_htlcpubkey OP_SWAP OP_SIZE 32 OP_EQUAL OP_IF OP_HASH160 RIPEMD160(payment_hash) OP_EQUALVERIFY 2 OP_SWAP local_htlcpubkey 2 OP_CHECKMULTISIG OP_ELSE OP_DROP cltv_expiry OP_CHECKLOCKTIMEVERIFY OP_DROP OP_CHECKSIG OP_ENDIF OP_ENDIF
With option_anchors, adds 1 OP_CHECKSEQUENCEVERIFY OP_DROP before
final OP_ENDIF.
received_htlc_witness_timeout :: ByteString -> Witness Source #
Witness for remote node to timeout received HTLC.
With option_anchors, input nSequence must be 1.
Witness: remotehtlcsig <>
>>>received_htlc_witness_timeout sigWitness [sig, ""]
received_htlc_witness_revoke :: ByteString -> Pubkey -> Witness Source #
Witness for revocation spend of received HTLC.
Witness: revocation_sig revocationpubkey
>>>received_htlc_witness_revoke sig revpkWitness [sig, revpk]
HTLC output (same as to_local)
htlc_output_script :: RevocationPubkey -> ToSelfDelay -> LocalDelayedPubkey -> Script Source #
HTLC output witness script (same structure as to_local).
Used for HTLC-timeout and HTLC-success transaction outputs.
Script:
OP_IF
revocationpubkey
OP_ELSE
to_self_delay
OP_CHECKSEQUENCEVERIFY
OP_DROP
local_delayedpubkey
OP_ENDIF
OP_CHECKSIG
htlc_output_witness_spend :: ByteString -> Witness Source #
Witness for delayed spend of HTLC output.
Input nSequence must be set to to_self_delay.
Witness: local_delayedsig 0
htlc_output_witness_revoke :: ByteString -> Witness Source #
Witness for revocation spend of HTLC output.
Witness: revocationsig 1
P2WSH helpers
to_p2wsh :: Script -> Script Source #
Convert a witness script to P2WSH scriptPubKey.
P2WSH format: OP_0 32-byte-hash
>>>to_p2wsh some_witness_scriptScript "\x00\x20<32-byte-hash>"
witness_script_hash :: Script -> ByteString Source #
Compute SHA256 hash of a witness script.
>>>witness_script_hash (Script "some_script")<32-byte SHA256 hash>
Transaction assembly
Commitment transactions
data CommitmentTx Source #
A commitment transaction.
Constructors
| CommitmentTx | |
Fields
| |
Instances
| Generic CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> CommitmentTx -> ShowS # show :: CommitmentTx -> String # showList :: [CommitmentTx] -> ShowS # | |||||
| Eq CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| type Rep CommitmentTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep CommitmentTx = D1 ('MetaData "CommitmentTx" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "CommitmentTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "ctx_version") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "ctx_locktime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Locktime) :*: S1 ('MetaSel ('Just "ctx_input_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Outpoint))) :*: (S1 ('MetaSel ('Just "ctx_input_sequence") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Sequence) :*: (S1 ('MetaSel ('Just "ctx_outputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [TxOutput]) :*: S1 ('MetaSel ('Just "ctx_funding_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))))) | |||||
data CommitmentContext Source #
Context for building a commitment transaction.
Constructors
| CommitmentContext | |
Fields
| |
Instances
| Generic CommitmentContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
Methods from :: CommitmentContext -> Rep CommitmentContext x # to :: Rep CommitmentContext x -> CommitmentContext # | |||||
| Show CommitmentContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> CommitmentContext -> ShowS # show :: CommitmentContext -> String # showList :: [CommitmentContext] -> ShowS # | |||||
| Eq CommitmentContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: CommitmentContext -> CommitmentContext -> Bool # (/=) :: CommitmentContext -> CommitmentContext -> Bool # | |||||
| type Rep CommitmentContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep CommitmentContext = D1 ('MetaData "CommitmentContext" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "CommitmentContext" 'PrefixI 'True) (((S1 ('MetaSel ('Just "cc_funding_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Outpoint) :*: (S1 ('MetaSel ('Just "cc_commitment_number") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CommitmentNumber) :*: S1 ('MetaSel ('Just "cc_local_payment_bp") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PaymentBasepoint))) :*: (S1 ('MetaSel ('Just "cc_remote_payment_bp") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PaymentBasepoint) :*: (S1 ('MetaSel ('Just "cc_to_self_delay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ToSelfDelay) :*: S1 ('MetaSel ('Just "cc_dust_limit") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DustLimit)))) :*: ((S1 ('MetaSel ('Just "cc_feerate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FeeratePerKw) :*: (S1 ('MetaSel ('Just "cc_features") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChannelFeatures) :*: S1 ('MetaSel ('Just "cc_is_funder") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))) :*: ((S1 ('MetaSel ('Just "cc_to_local_msat") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi) :*: S1 ('MetaSel ('Just "cc_to_remote_msat") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MilliSatoshi)) :*: (S1 ('MetaSel ('Just "cc_htlcs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [HTLC]) :*: S1 ('MetaSel ('Just "cc_keys") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CommitmentKeys)))))) | |||||
data CommitmentKeys Source #
Derived keys needed for commitment transaction outputs.
Constructors
| CommitmentKeys | |
Instances
| Generic CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
Methods from :: CommitmentKeys -> Rep CommitmentKeys x # to :: Rep CommitmentKeys x -> CommitmentKeys # | |||||
| Show CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> CommitmentKeys -> ShowS # show :: CommitmentKeys -> String # showList :: [CommitmentKeys] -> ShowS # | |||||
| Eq CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: CommitmentKeys -> CommitmentKeys -> Bool # (/=) :: CommitmentKeys -> CommitmentKeys -> Bool # | |||||
| type Rep CommitmentKeys Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep CommitmentKeys = D1 ('MetaData "CommitmentKeys" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "CommitmentKeys" 'PrefixI 'True) (((S1 ('MetaSel ('Just "ck_revocation_pubkey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey) :*: S1 ('MetaSel ('Just "ck_local_delayed") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalDelayedPubkey)) :*: (S1 ('MetaSel ('Just "ck_local_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalHtlcPubkey) :*: S1 ('MetaSel ('Just "ck_remote_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RemoteHtlcPubkey))) :*: ((S1 ('MetaSel ('Just "ck_local_payment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalPubkey) :*: S1 ('MetaSel ('Just "ck_remote_payment") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RemotePubkey)) :*: (S1 ('MetaSel ('Just "ck_local_funding") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FundingPubkey) :*: S1 ('MetaSel ('Just "ck_remote_funding") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FundingPubkey))))) | |||||
build_commitment_tx :: CommitmentContext -> CommitmentTx Source #
Build a commitment transaction.
Follows the algorithm from BOLT #3:
- Initialize input and locktime with obscured commitment number
- Calculate which HTLCs are trimmed
- Calculate base fee and subtract from funder
- Add untrimmed HTLC outputs
- Add to_local output if above dust
- Add to_remote output if above dust
- Add anchor outputs if option_anchors
- Sort outputs per BIP69+CLTV
HTLC transactions
An HTLC transaction (timeout or success).
Constructors
| HTLCTx | |
Fields
| |
Instances
| Generic HTLCTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show HTLCTx Source # | |||||
| Eq HTLCTx Source # | |||||
| type Rep HTLCTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep HTLCTx = D1 ('MetaData "HTLCTx" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "HTLCTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "htx_version") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "htx_locktime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Locktime) :*: S1 ('MetaSel ('Just "htx_input_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Outpoint))) :*: (S1 ('MetaSel ('Just "htx_input_sequence") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Sequence) :*: (S1 ('MetaSel ('Just "htx_output_value") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Just "htx_output_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))))) | |||||
data HTLCContext Source #
Context for building HTLC transactions.
Constructors
| HTLCContext | |
Fields | |
Instances
| Generic HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> HTLCContext -> ShowS # show :: HTLCContext -> String # showList :: [HTLCContext] -> ShowS # | |||||
| Eq HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| type Rep HTLCContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep HTLCContext = D1 ('MetaData "HTLCContext" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "HTLCContext" 'PrefixI 'True) (((S1 ('MetaSel ('Just "hc_commitment_txid") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TxId) :*: S1 ('MetaSel ('Just "hc_output_index") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32)) :*: (S1 ('MetaSel ('Just "hc_htlc") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLC) :*: S1 ('MetaSel ('Just "hc_to_self_delay") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ToSelfDelay))) :*: ((S1 ('MetaSel ('Just "hc_feerate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FeeratePerKw) :*: S1 ('MetaSel ('Just "hc_features") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChannelFeatures)) :*: (S1 ('MetaSel ('Just "hc_revocation_pubkey") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey) :*: S1 ('MetaSel ('Just "hc_local_delayed") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalDelayedPubkey))))) | |||||
build_htlc_timeout_tx :: HTLCContext -> HTLCTx Source #
Build an HTLC-timeout transaction.
- locktime: cltv_expiry
- sequence: 0 (or 1 with option_anchors)
- output: to_local style script with revocation and delayed paths
build_htlc_success_tx :: HTLCContext -> HTLCTx Source #
Build an HTLC-success transaction.
- locktime: 0
- sequence: 0 (or 1 with option_anchors)
- output: to_local style script with revocation and delayed paths
Closing transactions
A closing transaction.
Constructors
| ClosingTx | |
Fields
| |
Instances
| Generic ClosingTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show ClosingTx Source # | |||||
| Eq ClosingTx Source # | |||||
| type Rep ClosingTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep ClosingTx = D1 ('MetaData "ClosingTx" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "ClosingTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "cltx_version") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: (S1 ('MetaSel ('Just "cltx_locktime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Locktime) :*: S1 ('MetaSel ('Just "cltx_input_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Outpoint))) :*: (S1 ('MetaSel ('Just "cltx_input_sequence") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Sequence) :*: (S1 ('MetaSel ('Just "cltx_outputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [TxOutput]) :*: S1 ('MetaSel ('Just "cltx_funding_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))))) | |||||
data ClosingContext Source #
Context for building closing transactions.
Constructors
| ClosingContext | |
Fields
| |
Instances
| Generic ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
Methods from :: ClosingContext -> Rep ClosingContext x # to :: Rep ClosingContext x -> ClosingContext # | |||||
| Show ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> ClosingContext -> ShowS # show :: ClosingContext -> String # showList :: [ClosingContext] -> ShowS # | |||||
| Eq ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods (==) :: ClosingContext -> ClosingContext -> Bool # (/=) :: ClosingContext -> ClosingContext -> Bool # | |||||
| type Rep ClosingContext Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep ClosingContext = D1 ('MetaData "ClosingContext" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "ClosingContext" 'PrefixI 'True) (((S1 ('MetaSel ('Just "clc_funding_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Outpoint) :*: S1 ('MetaSel ('Just "clc_local_amount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Satoshi)) :*: (S1 ('MetaSel ('Just "clc_remote_amount") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: (S1 ('MetaSel ('Just "clc_local_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script) :*: S1 ('MetaSel ('Just "clc_remote_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script)))) :*: ((S1 ('MetaSel ('Just "clc_local_dust_limit") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DustLimit) :*: (S1 ('MetaSel ('Just "clc_remote_dust_limit") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DustLimit) :*: S1 ('MetaSel ('Just "clc_fee") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Satoshi))) :*: (S1 ('MetaSel ('Just "clc_is_funder") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "clc_locktime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Locktime) :*: S1 ('MetaSel ('Just "clc_funding_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script)))))) | |||||
build_closing_tx :: ClosingContext -> ClosingTx Source #
Build a closing transaction (option_simple_close).
- locktime: from closing_complete message
- sequence: 0xFFFFFFFD
- outputs: sorted per BIP69
build_legacy_closing_tx :: ClosingContext -> ClosingTx Source #
Build a legacy closing transaction (closing_signed).
- locktime: 0
- sequence: 0xFFFFFFFF
- outputs: sorted per BIP69
Transaction outputs
A transaction output with value, script, and type information.
Constructors
| TxOutput | |
Fields
| |
Instances
| Generic TxOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show TxOutput Source # | |||||
| Eq TxOutput Source # | |||||
| type Rep TxOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep TxOutput = D1 ('MetaData "TxOutput" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "TxOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "txout_value") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: (S1 ('MetaSel ('Just "txout_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script) :*: S1 ('MetaSel ('Just "txout_type") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OutputType)))) | |||||
data OutputType Source #
Type of output in a commitment transaction.
Constructors
| OutputToLocal | |
| OutputToRemote | |
| OutputLocalAnchor | |
| OutputRemoteAnchor | |
| OutputOfferedHTLC !CltvExpiry | |
| OutputReceivedHTLC !CltvExpiry |
Instances
| Generic OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Associated Types
| |||||
| Show OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx Methods showsPrec :: Int -> OutputType -> ShowS # show :: OutputType -> String # showList :: [OutputType] -> ShowS # | |||||
| Eq OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx | |||||
| type Rep OutputType Source # | |||||
Defined in Lightning.Protocol.BOLT3.Tx type Rep OutputType = D1 ('MetaData "OutputType" "Lightning.Protocol.BOLT3.Tx" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) ((C1 ('MetaCons "OutputToLocal" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OutputToRemote" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "OutputLocalAnchor" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "OutputRemoteAnchor" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OutputOfferedHTLC" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 CltvExpiry)) :+: C1 ('MetaCons "OutputReceivedHTLC" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 CltvExpiry))))) | |||||
Fee calculation
commitment_fee :: FeeratePerKw -> ChannelFeatures -> Word64 -> Satoshi Source #
Calculate the base commitment transaction fee.
fee = feerate_per_kw * weight / 1000
where weight = base_weight + 172 * num_htlcs
commitment_weight :: ChannelFeatures -> Word64 -> Word64 Source #
Calculate commitment transaction weight.
weight = base + 172 * num_htlcs
htlc_timeout_fee :: FeeratePerKw -> ChannelFeatures -> Satoshi Source #
Calculate HTLC-timeout transaction fee.
With option_anchors, fee is 0 (CPFP).
Otherwise, fee = feerate_per_kw * 663 / 1000
htlc_success_fee :: FeeratePerKw -> ChannelFeatures -> Satoshi Source #
Calculate HTLC-success transaction fee.
With option_anchors, fee is 0 (CPFP).
Otherwise, fee = feerate_per_kw * 703 / 1000
Trimming
htlc_trim_threshold :: DustLimit -> FeeratePerKw -> ChannelFeatures -> HTLCDirection -> Satoshi Source #
Calculate the trim threshold for an HTLC.
An HTLC is trimmed if:
amount < dust_limit + htlc_tx_fee
is_trimmed :: DustLimit -> FeeratePerKw -> ChannelFeatures -> HTLC -> Bool Source #
Check if an HTLC should be trimmed.
An HTLC is trimmed if its amount minus the HTLC tx fee is below the dust limit.
trimmed_htlcs :: DustLimit -> FeeratePerKw -> ChannelFeatures -> [HTLC] -> [HTLC] Source #
Filter HTLCs that are trimmed.
untrimmed_htlcs :: DustLimit -> FeeratePerKw -> ChannelFeatures -> [HTLC] -> [HTLC] Source #
Filter HTLCs that are not trimmed.
Output ordering
sort_outputs :: [TxOutput] -> [TxOutput] Source #
Sort outputs per BOLT #3 ordering.
Outputs are sorted by: 1. Value (smallest first) 2. ScriptPubKey (lexicographic) 3. CLTV expiry (for HTLCs)
Serialization
encode_tx :: CommitmentTx -> ByteString Source #
Encode a commitment transaction (SegWit format with witness).
SegWit format:
- version (4 bytes LE)
- marker (0x00)
- flag (0x01)
- input count (varint)
- inputs
- output count (varint)
- outputs
- witness data
- locktime (4 bytes LE)
Note: The witness is empty (just count=0) since the commitment tx spending the funding output requires external signatures.
encode_htlc_tx :: HTLCTx -> ByteString Source #
Encode an HTLC transaction (SegWit format with witness).
HTLC transactions have a single input (the commitment tx HTLC output) and a single output (the to_local-style delayed output).
encode_closing_tx :: ClosingTx -> ByteString Source #
Encode a closing transaction (SegWit format with witness).
Closing transactions have a single input (the funding output) and one or two outputs (to_local and/or to_remote).
encode_tx_for_signing :: CommitmentTx -> ByteString Source #
Encode a commitment transaction for signing (stripped format).
The stripped format omits the SegWit marker, flag, and witness data. This is the format used to compute the sighash for signing.
Format:
- version (4 bytes LE)
- input count (varint)
- inputs
- output count (varint)
- outputs
- locktime (4 bytes LE)
encode_varint :: Word64 -> ByteString Source #
Encode a value as a Bitcoin varint (CompactSize).
Encoding scheme:
- 0-252: 1 byte
- 253-65535: 0xFD followed by 2 bytes LE
- 65536-4294967295: 0xFE followed by 4 bytes LE
- larger: 0xFF followed by 8 bytes LE
>>>encode_varint 100"\x64">>>encode_varint 1000"\xFD\xE8\x03"
encode_le32 :: Word32 -> ByteString Source #
Encode a 32-bit value in little-endian format.
>>>encode_le32 0x12345678"\x78\x56\x34\x12"
encode_le64 :: Word64 -> ByteString Source #
Encode a 64-bit value in little-endian format.
>>>encode_le64 0x123456789ABCDEF0"\xF0\xDE\xBC\x9A\x78\x56\x34\x12"
encode_outpoint :: Outpoint -> ByteString Source #
Encode an outpoint (txid + output index).
Format: 32 bytes txid (already LE in TxId) + 4 bytes output index LE
>>>encode_outpoint (Outpoint txid 0)<32-byte txid><4-byte index>
encode_output :: TxOutput -> ByteString Source #
Encode a transaction output.
Format: 8 bytes value LE + varint scriptPubKey length + scriptPubKey
>>>encode_output (TxOutput (Satoshi 100000) script OutputToLocal)<8-byte value><varint length><scriptPubKey>
encode_witness :: Witness -> ByteString Source #
Encode a witness stack.
Format: varint item count + (varint length + data) for each item
>>>encode_witness (Witness [sig, pubkey])<varint 2><varint sigLen><sig><varint pkLen><pubkey>
encode_funding_witness Source #
Arguments
| :: ByteString | Signature for pubkey1 (lexicographically lesser) |
| -> ByteString | Signature for pubkey2 (lexicographically greater) |
| -> Script | The funding witness script |
| -> ByteString |
Encode a funding witness (2-of-2 multisig).
The witness stack is: 0 sig1 sig2 witnessScript
Signatures must be ordered to match pubkey order in the funding script.
>>>encode_funding_witness sig1 sig2 fundingScript<witness with 4 items: empty, sig1, sig2, script>
Parsing
data DecodeError Source #
Errors that can occur during transaction decoding.
Constructors
| InsufficientBytes !Int !Int | Expected bytes, actual bytes available |
| InvalidMarker !Word8 | Invalid SegWit marker byte (expected 0x00) |
| InvalidFlag !Word8 | Invalid SegWit flag byte (expected 0x01) |
| InvalidVarint | Malformed varint encoding |
| EmptyInput | No bytes to decode |
Instances
| Generic DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode Associated Types
| |||||
| Show DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode Methods showsPrec :: Int -> DecodeError -> ShowS # show :: DecodeError -> String # showList :: [DecodeError] -> ShowS # | |||||
| Eq DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode | |||||
| type Rep DecodeError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode type Rep DecodeError = D1 ('MetaData "DecodeError" "Lightning.Protocol.BOLT3.Decode" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) ((C1 ('MetaCons "InsufficientBytes" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :+: C1 ('MetaCons "InvalidMarker" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word8))) :+: (C1 ('MetaCons "InvalidFlag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word8)) :+: (C1 ('MetaCons "InvalidVarint" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EmptyInput" 'PrefixI 'False) (U1 :: Type -> Type)))) | |||||
A raw transaction as parsed from bytes.
Supports both legacy and SegWit transaction formats.
Constructors
| RawTx | |
Fields
| |
Instances
| Generic RawTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode Associated Types
| |||||
| Show RawTx Source # | |||||
| Eq RawTx Source # | |||||
| type Rep RawTx Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode type Rep RawTx = D1 ('MetaData "RawTx" "Lightning.Protocol.BOLT3.Decode" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "RawTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "rtx_version") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Just "rtx_inputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [RawInput])) :*: (S1 ('MetaSel ('Just "rtx_outputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [RawOutput]) :*: (S1 ('MetaSel ('Just "rtx_witness") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [[ByteString]]) :*: S1 ('MetaSel ('Just "rtx_locktime") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Locktime))))) | |||||
A raw transaction input as parsed from bytes.
Constructors
| RawInput | |
Fields
| |
Instances
| Generic RawInput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode Associated Types
| |||||
| Show RawInput Source # | |||||
| Eq RawInput Source # | |||||
| type Rep RawInput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode type Rep RawInput = D1 ('MetaData "RawInput" "Lightning.Protocol.BOLT3.Decode" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "RawInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "ri_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Outpoint) :*: (S1 ('MetaSel ('Just "ri_script_sig") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Just "ri_sequence") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Sequence)))) | |||||
A raw transaction output as parsed from bytes.
Instances
| Generic RawOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode Associated Types
| |||||
| Show RawOutput Source # | |||||
| Eq RawOutput Source # | |||||
| type Rep RawOutput Source # | |||||
Defined in Lightning.Protocol.BOLT3.Decode type Rep RawOutput = D1 ('MetaData "RawOutput" "Lightning.Protocol.BOLT3.Decode" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (C1 ('MetaCons "RawOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "ro_value") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Just "ro_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script))) | |||||
decode_tx :: ByteString -> Either DecodeError RawTx Source #
Decode a raw Bitcoin transaction from bytes.
Handles both legacy and SegWit transaction formats.
SegWit format: * version (4 bytes LE) * marker (0x00) + flag (0x01) * input count (varint) * inputs: outpoint (32+4), scriptSig length (varint), scriptSig, sequence * output count (varint) * outputs: value (8 LE), scriptPubKey length (varint), scriptPubKey * witness data (for each input) * locktime (4 bytes LE)
>>>decode_tx rawTxBytesRight (RawTx {...})
decode_varint :: ByteString -> Either DecodeError (Word64, ByteString) Source #
Decode a Bitcoin varint (CompactSize).
Encoding: * 0x00-0xFC: 1 byte * 0xFD: 2 bytes little-endian follow * 0xFE: 4 bytes little-endian follow * 0xFF: 8 bytes little-endian follow
>>>decode_varint (BS.pack [0x01])Right (1, "")>>>decode_varint (BS.pack [0xfd, 0x00, 0x01])Right (256, "")
decode_le32 :: ByteString -> Either DecodeError (Word32, ByteString) Source #
Decode a little-endian 32-bit integer.
>>>decode_le32 (BS.pack [0x01, 0x00, 0x00, 0x00])Right (1, "")
decode_le64 :: ByteString -> Either DecodeError (Word64, ByteString) Source #
Decode a little-endian 64-bit integer.
>>>decode_le64 (BS.pack [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])Right (1, "")
decode_outpoint :: ByteString -> Either DecodeError (Outpoint, ByteString) Source #
Decode a transaction outpoint (txid + output index).
Format: 32 bytes txid (little-endian) + 4 bytes index (little-endian)
>>>let txid = BS.replicate 32 0>>>let idx = BS.pack [0x01, 0x00, 0x00, 0x00]>>>decode_outpoint (txid <> idx)Right (Outpoint {outpoint_txid = ..., outpoint_index = 1}, "")
decode_output :: ByteString -> Either DecodeError (RawOutput, ByteString) Source #
Decode a transaction output (value + scriptPubKey).
Format: 8 bytes value (little-endian) + varint script length + script
decode_witness :: ByteString -> Either DecodeError (Witness, ByteString) Source #
Decode a witness stack for one input.
Format: varint num_items + (varint length + data) for each item
Validation
data ValidationError Source #
Errors that can occur during validation.
Constructors
| InvalidVersion !Word32 !Word32 | Expected version, actual version |
| InvalidLocktime !Word32 | Invalid locktime format |
| InvalidSequence !Word32 | Invalid sequence format |
| InvalidOutputOrdering | Outputs not in BIP69+CLTV order |
| DustLimitViolation !Int !Satoshi !Satoshi | Output index, actual value, dust limit |
| MissingAnchorOutput | Expected anchor output not present |
| InvalidAnchorValue !Satoshi | Anchor value not 330 satoshis |
| InvalidFee !Satoshi !Satoshi | Expected fee, actual fee |
| InvalidHTLCLocktime !Word32 !Word32 | Expected locktime, actual locktime |
| InvalidHTLCSequence !Word32 !Word32 | Expected sequence, actual sequence |
| NoOutputs | Transaction has no outputs |
| TooManyOutputs !Int | More outputs than expected |
Instances
| Generic ValidationError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Validate Associated Types
Methods from :: ValidationError -> Rep ValidationError x # to :: Rep ValidationError x -> ValidationError # | |||||
| Show ValidationError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Validate Methods showsPrec :: Int -> ValidationError -> ShowS # show :: ValidationError -> String # showList :: [ValidationError] -> ShowS # | |||||
| Eq ValidationError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Validate Methods (==) :: ValidationError -> ValidationError -> Bool # (/=) :: ValidationError -> ValidationError -> Bool # | |||||
| type Rep ValidationError Source # | |||||
Defined in Lightning.Protocol.BOLT3.Validate type Rep ValidationError = D1 ('MetaData "ValidationError" "Lightning.Protocol.BOLT3.Validate" "ppad-bolt3-0.0.1-BTVAwWY46FT4MsZtX0EtFp" 'False) (((C1 ('MetaCons "InvalidVersion" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32)) :+: (C1 ('MetaCons "InvalidLocktime" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32)) :+: C1 ('MetaCons "InvalidSequence" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32)))) :+: (C1 ('MetaCons "InvalidOutputOrdering" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DustLimitViolation" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Satoshi))) :+: C1 ('MetaCons "MissingAnchorOutput" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "InvalidAnchorValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi)) :+: (C1 ('MetaCons "InvalidFee" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi)) :+: C1 ('MetaCons "InvalidHTLCLocktime" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32)))) :+: (C1 ('MetaCons "InvalidHTLCSequence" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32)) :+: (C1 ('MetaCons "NoOutputs" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TooManyOutputs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int)))))) | |||||
validate_commitment_tx :: DustLimit -> ChannelFeatures -> CommitmentTx -> Either ValidationError () Source #
Validate a commitment transaction.
Checks:
- Version is 2
- Locktime format (upper 8 bits = 0x20)
- Sequence format (upper 8 bits = 0x80)
- Output ordering per BIP69+CLTV
- Dust limit compliance
- Anchor outputs if option_anchors
validate_commitment_locktime :: Locktime -> Either ValidationError () Source #
Validate commitment transaction locktime format.
Upper 8 bits must be 0x20.
validate_commitment_sequence :: Sequence -> Either ValidationError () Source #
Validate commitment transaction sequence format.
Upper 8 bits must be 0x80.
validate_htlc_tx :: HTLCTx -> Either ValidationError () Source #
Validate an HTLC transaction (timeout or success).
Checks:
- Version is 2
- Single output
validate_htlc_timeout_tx :: ChannelFeatures -> CltvExpiry -> HTLCTx -> Either ValidationError () Source #
Validate an HTLC-timeout transaction.
Checks:
- Base HTLC validation
- Locktime equals HTLC cltv_expiry
- Sequence is 0 (or 1 with option_anchors)
validate_htlc_success_tx :: ChannelFeatures -> HTLCTx -> Either ValidationError () Source #
Validate an HTLC-success transaction.
Checks:
- Base HTLC validation
- Locktime is 0
- Sequence is 0 (or 1 with option_anchors)
validate_closing_tx :: ClosingTx -> Either ValidationError () Source #
Validate a closing transaction (option_simple_close).
Checks:
- Version is 2
- Sequence is 0xFFFFFFFD
- At least one output
- Output ordering per BIP69
validate_legacy_closing_tx :: ClosingTx -> Either ValidationError () Source #
Validate a legacy closing transaction (closing_signed).
Checks:
- Version is 2
- Locktime is 0
- Sequence is 0xFFFFFFFF
- At least one output
- Output ordering per BIP69
validate_output_ordering :: [TxOutput] -> Either ValidationError () Source #
Validate output ordering per BIP69+CLTV.
Outputs must be sorted by: 1. Value (smallest first) 2. ScriptPubKey (lexicographic) 3. CLTV expiry (for HTLC outputs)
validate_dust_limits :: DustLimit -> [TxOutput] -> Either ValidationError () Source #
Validate that no output violates dust limits.
validate_anchor_outputs :: [TxOutput] -> Either ValidationError () Source #
Validate anchor outputs are present and correctly valued.
validate_commitment_fee Source #
Arguments
| :: FeeratePerKw | |
| -> ChannelFeatures | |
| -> Word64 | Number of untrimmed HTLCs |
| -> Satoshi | Actual fee |
| -> Either ValidationError () |
Validate commitment transaction fee.
Checks that the fee matches the expected calculation.
Arguments
| :: FeeratePerKw | |
| -> ChannelFeatures | |
| -> HTLCDirection | |
| -> Satoshi | Actual fee |
| -> Either ValidationError () |
Validate HTLC transaction fee.