| Copyright | (c) 2025 Jared Tobin |
|---|---|
| License | MIT |
| Maintainer | Jared Tobin <jared@ppad.tech> |
| Safe Haskell | None |
| Language | Haskell2010 |
Lightning.Protocol.BOLT3.Tx
Description
Transaction assembly for BOLT #3.
Constructs:
- Commitment transactions
- HTLC-timeout transactions
- HTLC-success transactions
- Closing transactions
Synopsis
- 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
- htlc_timeout_fee :: FeeratePerKw -> ChannelFeatures -> Satoshi
- htlc_success_fee :: FeeratePerKw -> ChannelFeatures -> Satoshi
- commitment_weight :: ChannelFeatures -> Word64 -> Word64
- is_trimmed :: DustLimit -> FeeratePerKw -> ChannelFeatures -> HTLC -> Bool
- trimmed_htlcs :: DustLimit -> FeeratePerKw -> ChannelFeatures -> [HTLC] -> [HTLC]
- untrimmed_htlcs :: DustLimit -> FeeratePerKw -> ChannelFeatures -> [HTLC] -> [HTLC]
- htlc_trim_threshold :: DustLimit -> FeeratePerKw -> ChannelFeatures -> HTLCDirection -> Satoshi
- sort_outputs :: [TxOutput] -> [TxOutput]
Commitment transaction
data CommitmentTx Source #
A commitment transaction.
Constructors
| CommitmentTx | |
Fields
| |
Instances
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 transaction
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
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
commitment_weight :: ChannelFeatures -> Word64 -> Word64 Source #
Calculate commitment transaction weight.
weight = base + 172 * num_htlcs
Trimming
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.
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
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)