ppad-bolt5-0.0.1: On-chain transaction handling per BOLT #5
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellNone
LanguageHaskell2010

Lightning.Protocol.BOLT5.Types

Description

Types for BOLT #5 on-chain transaction handling.

Synopsis

Close identification

data CloseType Source #

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

Instances details
Generic CloseType Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Associated Types

type Rep CloseType 
Instance details

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)))
Show CloseType Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Eq CloseType Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

type Rep CloseType Source # 
Instance details

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.

Instances

Instances details
Generic UnresolvedOutput Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Associated Types

type Rep UnresolvedOutput 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

type Rep UnresolvedOutput = D1 ('MetaData "UnresolvedOutput" "Lightning.Protocol.BOLT5.Types" "ppad-bolt5-0.0.1-5N7Wen1sZDiBgqKJHrpe1Z" 'False) (C1 ('MetaCons "UnresolvedOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "uo_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OutPoint) :*: (S1 ('MetaSel ('Just "uo_value") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Just "uo_type") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OutputResolution))))
Show UnresolvedOutput Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Eq UnresolvedOutput Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

type Rep UnresolvedOutput Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

type Rep UnresolvedOutput = D1 ('MetaData "UnresolvedOutput" "Lightning.Protocol.BOLT5.Types" "ppad-bolt5-0.0.1-5N7Wen1sZDiBgqKJHrpe1Z" 'False) (C1 ('MetaCons "UnresolvedOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "uo_outpoint") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OutPoint) :*: (S1 ('MetaSel ('Just "uo_value") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Satoshi) :*: S1 ('MetaSel ('Just "uo_type") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 OutputResolution))))

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

Instances details
Generic OutputResolution Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Associated Types

type Rep OutputResolution 
Instance details

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))))))
Show OutputResolution Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Eq OutputResolution Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

type Rep OutputResolution Source # 
Instance details

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

Instances details
Generic SpendingTx Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Associated Types

type Rep SpendingTx 
Instance details

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))))
Show SpendingTx Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Eq SpendingTx Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

type Rep SpendingTx Source # 
Instance details

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

Instances details
Generic PenaltyContext Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Associated Types

type Rep PenaltyContext 
Instance details

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))))
Show PenaltyContext Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

Eq PenaltyContext Source # 
Instance details

Defined in Lightning.Protocol.BOLT5.Types

type Rep PenaltyContext Source # 
Instance details

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