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