The base weight of a commitment tx */
| 24 | |
| 25 | /* The base weight of a commitment tx */ |
| 26 | static inline size_t commit_tx_base_weight(size_t num_untrimmed_htlcs, |
| 27 | bool option_anchor_outputs, |
| 28 | bool option_anchors_zero_fee_htlc_tx) |
| 29 | { |
| 30 | size_t weight; |
| 31 | size_t num_outputs; |
| 32 | |
| 33 | /* BOLT #3: |
| 34 | * |
| 35 | * The base fee for a commitment transaction: |
| 36 | * - MUST be calculated to match: |
| 37 | * 1. Start with `weight` = 724 (1124 if `option_anchors` applies). |
| 38 | */ |
| 39 | if (option_anchor_outputs || option_anchors_zero_fee_htlc_tx) { |
| 40 | weight = 1124; |
| 41 | num_outputs = 4; |
| 42 | } else { |
| 43 | weight = 724; |
| 44 | num_outputs = 2; |
| 45 | } |
| 46 | /* BOLT #3: |
| 47 | * |
| 48 | * 2. For each committed HTLC, if that output is not trimmed as |
| 49 | * specified in [Trimmed Outputs](#trimmed-outputs), add 172 |
| 50 | * to `weight`. |
| 51 | */ |
| 52 | weight += 172 * num_untrimmed_htlcs; |
| 53 | num_outputs += num_untrimmed_htlcs; |
| 54 | |
| 55 | /* Extra fields for Elements */ |
| 56 | weight += elements_tx_overhead(chainparams, 1, num_outputs); |
| 57 | |
| 58 | return weight; |
| 59 | } |
| 60 | |
| 61 | /* Helper to calculate the base fee if we have this many htlc outputs */ |
| 62 | static inline struct amount_sat commit_tx_base_fee(u32 feerate_per_kw, |
no test coverage detected