MCPcopy Create free account
hub / github.com/ElementsProject/lightning / commit_tx_base_weight

Function commit_tx_base_weight

common/initial_commit_tx.h:27–55  ·  view source on GitHub ↗

The base weight of a commitment tx */

Source from the content-addressed store, hash-verified

25
26/* The base weight of a commitment tx */
27static 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 */
58static inline struct amount_sat commit_tx_base_fee(u32 feerate_per_kw,

Callers 2

approx_max_feerateFunction · 0.85
commit_tx_base_feeFunction · 0.85

Calls 1

elements_tx_overheadFunction · 0.85

Tested by

no test coverage detected