| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Lightning.Protocol.BOLT5.Types
Description
Types for BOLT #5 on-chain transaction handling.
Synopsis
- data CloseType
- data UnresolvedOutput = UnresolvedOutput {
- uo_outpoint :: !OutPoint
- uo_value :: !Satoshi
- uo_type :: !OutputResolution
- data OutputResolution
- = Resolved
- | SpendToLocal !ToSelfDelay !RevocationPubkey !LocalDelayedPubkey
- | SpendHTLCTimeout !HTLC !CommitmentKeys !ChannelFeatures
- | SpendHTLCSuccess !HTLC !CommitmentKeys !ChannelFeatures
- | SpendHTLCTimeoutDirect !HTLC
- | SpendHTLCPreimageDirect !HTLC
- | Revoke !RevocationPubkey
- | RevokeHTLC !RevocationPubkey !OutputType
- | AnchorSpend !FundingPubkey
- data SpendingTx = SpendingTx {
- stx_tx :: !Tx
- stx_input_script :: !Script
- stx_input_value :: !Satoshi
- stx_sighash_type :: !SighashType
- data PenaltyContext = PenaltyContext {}
- to_local_penalty_witness_weight :: Word64
- offered_htlc_penalty_witness_weight :: Word64
- accepted_htlc_penalty_witness_weight :: Word64
- to_local_penalty_input_weight :: Word64
- offered_htlc_penalty_input_weight :: Word64
- accepted_htlc_penalty_input_weight :: Word64
- to_remote_input_weight :: Word64
- penalty_tx_base_weight :: Word64
- max_standard_weight :: Word64
- spending_fee :: FeeratePerKw -> Word64 -> Satoshi
Close identification
What kind of close was detected on chain.
Constructors
| MutualClose | Cooperative closure agreed by both parties. |
| LocalCommitClose | Our commitment transaction was broadcast. |
| RemoteCommitClose | The remote party's commitment transaction was broadcast. |
| RevokedCommitClose | A revoked (outdated) commitment transaction was broadcast. |
Instances
| Generic CloseType Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Associated Types
| |||||
| Show CloseType Source # | |||||
| Eq CloseType Source # | |||||
| type Rep CloseType Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types type Rep CloseType = D1 ('MetaData "CloseType" "Lightning.Protocol.BOLT5.Types" "ppad-bolt5-0.0.1-5N7Wen1sZDiBgqKJHrpe1Z" 'False) ((C1 ('MetaCons "MutualClose" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LocalCommitClose" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "RemoteCommitClose" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RevokedCommitClose" 'PrefixI 'False) (U1 :: Type -> Type))) | |||||
Output classification
data UnresolvedOutput Source #
An unresolved commitment transaction output.
Constructors
| UnresolvedOutput | |
Fields
| |
Instances
data OutputResolution Source #
How to resolve an output, per BOLT #5 rules.
Constructors
| Resolved | Already resolved (e.g. to_remote on local commit). |
| SpendToLocal !ToSelfDelay !RevocationPubkey !LocalDelayedPubkey | Spend to_local after CSV delay. |
| SpendHTLCTimeout !HTLC !CommitmentKeys !ChannelFeatures | Spend via HTLC-timeout second-stage tx (local commit, local offer). |
| SpendHTLCSuccess !HTLC !CommitmentKeys !ChannelFeatures | Spend via HTLC-success second-stage tx (local commit, remote offer). |
| SpendHTLCTimeoutDirect !HTLC | Spend HTLC directly after timeout (remote commit, local offer). |
| SpendHTLCPreimageDirect !HTLC | Spend HTLC directly with preimage (remote commit, remote offer). |
| Revoke !RevocationPubkey | Spend revoked to_local with revocation key. |
| RevokeHTLC !RevocationPubkey !OutputType | Spend revoked HTLC output with revocation key. |
| AnchorSpend !FundingPubkey | Spend anchor output. |
Instances
| Generic OutputResolution Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Associated Types
Methods from :: OutputResolution -> Rep OutputResolution x # to :: Rep OutputResolution x -> OutputResolution # | |||||
| Show OutputResolution Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Methods showsPrec :: Int -> OutputResolution -> ShowS # show :: OutputResolution -> String # showList :: [OutputResolution] -> ShowS # | |||||
| Eq OutputResolution Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Methods (==) :: OutputResolution -> OutputResolution -> Bool # (/=) :: OutputResolution -> OutputResolution -> Bool # | |||||
| type Rep OutputResolution Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types type Rep OutputResolution = D1 ('MetaData "OutputResolution" "Lightning.Protocol.BOLT5.Types" "ppad-bolt5-0.0.1-5N7Wen1sZDiBgqKJHrpe1Z" 'False) (((C1 ('MetaCons "Resolved" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SpendToLocal" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ToSelfDelay) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocalDelayedPubkey)))) :+: (C1 ('MetaCons "SpendHTLCTimeout" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLC) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CommitmentKeys) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChannelFeatures))) :+: C1 ('MetaCons "SpendHTLCSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLC) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CommitmentKeys) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ChannelFeatures))))) :+: ((C1 ('MetaCons "SpendHTLCTimeoutDirect" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLC)) :+: C1 ('MetaCons "SpendHTLCPreimageDirect" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 HTLC))) :+: (C1 ('MetaCons "Revoke" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey)) :+: (C1 ('MetaCons "RevokeHTLC" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OutputType)) :+: C1 ('MetaCons "AnchorSpend" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FundingPubkey)))))) | |||||
Spending transactions
data SpendingTx Source #
Unsigned spending transaction, ready for caller to sign.
The caller uses bolt3 witness constructors to assemble the final witness after signing.
Constructors
| SpendingTx | |
Fields
| |
Instances
| Generic SpendingTx Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Associated Types
| |||||
| Show SpendingTx Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Methods showsPrec :: Int -> SpendingTx -> ShowS # show :: SpendingTx -> String # showList :: [SpendingTx] -> ShowS # | |||||
| Eq SpendingTx Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types | |||||
| type Rep SpendingTx Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types type Rep SpendingTx = D1 ('MetaData "SpendingTx" "Lightning.Protocol.BOLT5.Types" "ppad-bolt5-0.0.1-5N7Wen1sZDiBgqKJHrpe1Z" 'False) (C1 ('MetaCons "SpendingTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "stx_tx") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Tx) :*: S1 ('MetaSel ('Just "stx_input_script") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script)) :*: (S1 ('MetaSel ('Just "stx_input_value") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Just "stx_sighash_type") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SighashType)))) | |||||
Penalty batching
data PenaltyContext Source #
Context for constructing batched penalty transactions.
Constructors
| PenaltyContext | |
Fields
| |
Instances
| Generic PenaltyContext Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Associated Types
Methods from :: PenaltyContext -> Rep PenaltyContext x # to :: Rep PenaltyContext x -> PenaltyContext # | |||||
| Show PenaltyContext Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Methods showsPrec :: Int -> PenaltyContext -> ShowS # show :: PenaltyContext -> String # showList :: [PenaltyContext] -> ShowS # | |||||
| Eq PenaltyContext Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types Methods (==) :: PenaltyContext -> PenaltyContext -> Bool # (/=) :: PenaltyContext -> PenaltyContext -> Bool # | |||||
| type Rep PenaltyContext Source # | |||||
Defined in Lightning.Protocol.BOLT5.Types type Rep PenaltyContext = D1 ('MetaData "PenaltyContext" "Lightning.Protocol.BOLT5.Types" "ppad-bolt5-0.0.1-5N7Wen1sZDiBgqKJHrpe1Z" 'False) (C1 ('MetaCons "PenaltyContext" 'PrefixI 'True) ((S1 ('MetaSel ('Just "pc_outputs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (NonEmpty UnresolvedOutput)) :*: S1 ('MetaSel ('Just "pc_revocation_key") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RevocationPubkey)) :*: (S1 ('MetaSel ('Just "pc_destination") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Script) :*: S1 ('MetaSel ('Just "pc_feerate") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 FeeratePerKw)))) | |||||
Weight constants (Appendix A)
to_local_penalty_witness_weight :: Word64 Source #
Expected weight of the to_local penalty transaction witness (160 bytes).
offered_htlc_penalty_witness_weight :: Word64 Source #
Expected weight of the offered_htlc penalty transaction witness (243 bytes).
accepted_htlc_penalty_witness_weight :: Word64 Source #
Expected weight of the accepted_htlc penalty transaction witness (249 bytes).
to_local_penalty_input_weight :: Word64 Source #
Weight of a to_local penalty input (164 + 160 = 324 bytes).
offered_htlc_penalty_input_weight :: Word64 Source #
Weight of an offered_htlc penalty input (164 + 243 = 407 bytes).
accepted_htlc_penalty_input_weight :: Word64 Source #
Weight of an accepted_htlc penalty input (164 + 249 = 413 bytes).
to_remote_input_weight :: Word64 Source #
Weight of a to_remote P2WPKH input (108 + 164 = 272 bytes).
penalty_tx_base_weight :: Word64 Source #
Base weight of a penalty transaction (4*53 + 2 = 214 bytes).
Non-witness: version(4) + input_count(1) + output_count(1) + value(8) + script_len(1) + p2wsh_script(34) + locktime(4) = 53 Witness header: 2 bytes.
max_standard_weight :: Word64 Source #
Maximum standard transaction weight (400,000 bytes).
Fee calculation
spending_fee :: FeeratePerKw -> Word64 -> Satoshi Source #
Calculate the fee for a spending transaction given its weight.
fee = feerate_per_kw * weight / 1000