BOLT3.hs (3974B)
1 {-# OPTIONS_HADDOCK prune #-} 2 3 -- | 4 -- Module: Lightning.Protocol.BOLT3 5 -- Copyright: (c) 2025 Jared Tobin 6 -- License: MIT 7 -- Maintainer: Jared Tobin <jared@ppad.tech> 8 -- 9 -- Bitcoin transaction and script formats for the Lightning Network, per 10 -- [BOLT #3](https://github.com/lightning/bolts/blob/master/03-transactions.md) 11 -- (commitment, HTLC and closing transactions, their output scripts and 12 -- witnesses, per-commitment key derivation, and per-commitment secret 13 -- generation and storage). 14 -- 15 -- Amounts, points, hashes and per-commitment secrets are the types of 16 -- ppad-bolt1's "Lightning.Protocol.BOLT1"; transactions convert to 17 -- ppad-tx's "Bitcoin.Prim.Tx" for txids, sighashes and serialization. 18 -- The @option_static_remotekey@ and @option_anchors@ commitment formats 19 -- are supported ('CommitmentFormat'). 20 21 module Lightning.Protocol.BOLT3 ( 22 -- * Commitment transactions 23 CommitmentContext(..) 24 , CommitmentFormat(..) 25 , CommitmentTx(..) 26 , CommitmentOutput(..) 27 , OutputType(..) 28 , build_commitment_tx 29 30 -- ** HTLCs 31 , HTLC(..) 32 , HTLCDirection(..) 33 34 -- ** Channel parameters 35 , CommitmentNumber 36 , commitment_number 37 , un_commitment_number 38 , next_commitment_number 39 , ToSelfDelay(..) 40 , CltvExpiry(..) 41 , DustLimit(..) 42 , FeeratePerKw(..) 43 , Locktime(..) 44 , Sequence(..) 45 46 -- ** Fees and trimming 47 , commitment_fee 48 , htlc_timeout_fee 49 , htlc_success_fee 50 , htlc_trim_threshold 51 , is_trimmed 52 , anchor_output_value 53 54 -- * HTLC transactions 55 , HTLCContext(..) 56 , HTLCTx(..) 57 , build_htlc_tx 58 59 -- * Closing transactions 60 , ClosingTx(..) 61 , ClosingOutput(..) 62 , ClosingContext(..) 63 , ClosingOutputs(..) 64 , build_closing_tx 65 , LegacyClosingContext(..) 66 , build_legacy_closing_tx 67 68 -- ** Dust thresholds 69 , dust_p2pkh 70 , dust_p2sh 71 , dust_p2wpkh 72 , dust_p2wsh 73 74 -- * Serialization 75 , commitment_to_tx 76 , htlc_to_tx 77 , closing_to_tx 78 , encode_commitment_tx 79 , encode_htlc_tx 80 , encode_closing_tx 81 82 -- * Keys 83 -- ** Basepoints and per-commitment points 84 , Basepoints(..) 85 , RevocationBasepoint(..) 86 , PaymentBasepoint(..) 87 , DelayedPaymentBasepoint(..) 88 , HtlcBasepoint(..) 89 , PerCommitmentPoint(..) 90 , derive_per_commitment_point 91 , derive_per_commitment_point' 92 93 -- ** Public keys 94 , CommitmentKeys(..) 95 , derive_commitment_keys 96 , derive_commitment_keys' 97 , RevocationPubkey(..) 98 , LocalDelayedPubkey(..) 99 , LocalHtlcPubkey(..) 100 , RemoteHtlcPubkey(..) 101 , RemotePubkey(..) 102 , FundingPubkey(..) 103 , derive_pubkey 104 , derive_revocationpubkey 105 106 -- ** Private keys 107 , Seckey 108 , seckey 109 , un_seckey 110 , derive_privkey 111 , derive_revocationprivkey 112 113 -- * Per-commitment secrets 114 , Seed 115 , seed 116 , un_seed 117 , SecretIndex 118 , secret_index 119 , un_secret_index 120 , commitment_secret_index 121 , generate_from_seed 122 123 -- ** Storage 124 , SecretStore 125 , empty_secret_store 126 , insert_secret 127 , derive_old_secret 128 , secret_store 129 , un_secret_store 130 131 -- ** Commitment number obscuring 132 , obscured_commitment_number 133 134 -- * Scripts and witnesses 135 , Script(..) 136 , to_p2wsh 137 138 -- ** Funding output 139 , funding_script 140 , funding_witness 141 142 -- ** to_local output 143 , to_local_script 144 , to_local_witness_spend 145 , to_local_witness_revoke 146 147 -- ** to_remote output 148 , to_remote_witness_script 149 , to_remote_script_pubkey 150 , to_remote_witness 151 152 -- ** Anchor outputs 153 , anchor_script 154 , anchor_witness_owner 155 , anchor_witness_anyone 156 157 -- ** Offered HTLC outputs 158 , offered_htlc_script 159 , offered_htlc_witness_preimage 160 , offered_htlc_witness_revoke 161 162 -- ** Received HTLC outputs 163 , received_htlc_script 164 , received_htlc_witness_timeout 165 , received_htlc_witness_revoke 166 167 -- ** HTLC transaction inputs 168 , htlc_success_witness 169 , htlc_timeout_witness 170 , remote_htlc_sighash 171 ) where 172 173 import Lightning.Protocol.BOLT3.Keys 174 import Lightning.Protocol.BOLT3.Scripts 175 import Lightning.Protocol.BOLT3.Tx 176 import Lightning.Protocol.BOLT3.Types