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

Function htlc_success_fee

common/htlc_tx.h:41–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41static inline struct amount_sat htlc_success_fee(u32 feerate_per_kw,
42 bool option_anchor_outputs,
43 bool option_anchors_zero_fee_htlc_tx)
44{
45 /* BOLT #3:
46 *
47 * The fee for an HTLC-success transaction:
48 * - If `option_anchors` applies:
49 * 1. MUST be 0.
50 * - Otherwise, MUST be calculated to match:
51 * 1. Multiply `feerate_per_kw` by 703 and divide by 1000 (rounding down).
52 */
53 u32 base;
54
55 if (option_anchors_zero_fee_htlc_tx)
56 return AMOUNT_SAT(0);
57
58 /* FIXME: older bolt used to say "(706 if `option_anchor_outputs` applies) */
59 if (option_anchor_outputs)
60 base = 706;
61 else
62 base = 703;
63 return amount_tx_fee(base + elements_tx_overhead(chainparams, 1, 1),
64 feerate_per_kw);
65}
66
67/* Create HTLC-success tx to spend a received HTLC commitment tx
68 * output; doesn't fill in input witness. */

Callers 3

json_feeratesFunction · 0.85
htlc_is_trimmedFunction · 0.85
htlc_success_txFunction · 0.85

Calls 2

elements_tx_overheadFunction · 0.85
amount_tx_feeFunction · 0.70

Tested by

no test coverage detected