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

Function htlc_timeout_fee

common/htlc_tx.h:15–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13struct ripemd160;
14
15static inline struct amount_sat htlc_timeout_fee(u32 feerate_per_kw,
16 bool option_anchor_outputs,
17 bool option_anchors_zero_fee_htlc_tx)
18{
19 /* BOLT #3:
20 *
21 * The fee for an HTLC-timeout transaction:
22 * - If `option_anchors` applies:
23 * 1. MUST be 0.
24 * - Otherwise, MUST be calculated to match:
25 * 1. Multiply `feerate_per_kw` by 663 and divide by 1000 (rounding down).
26 */
27 u32 base;
28
29 if (option_anchors_zero_fee_htlc_tx)
30 return AMOUNT_SAT(0);
31
32 /* FIXME: Older bolt had "(666 if `option_anchor_outputs` applies)" */
33 if (option_anchor_outputs)
34 base = 666;
35 else
36 base = 663;
37 return amount_tx_fee(base + elements_tx_overhead(chainparams, 1, 1),
38 feerate_per_kw);
39}
40
41static inline struct amount_sat htlc_success_fee(u32 feerate_per_kw,
42 bool option_anchor_outputs,

Callers 3

json_feeratesFunction · 0.85
htlc_is_trimmedFunction · 0.85
htlc_timeout_txFunction · 0.85

Calls 2

elements_tx_overheadFunction · 0.85
amount_tx_feeFunction · 0.70

Tested by

no test coverage detected