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

Function check_config_bounds

openingd/common.c:16–169  ·  view source on GitHub ↗

~ This is the key function that checks that their configuration is reasonable: * it applied for both the case where they're trying to open a channel, and when * they've accepted our open. */

Source from the content-addressed store, hash-verified

14 * it applied for both the case where they're trying to open a channel, and when
15 * they've accepted our open. */
16bool check_config_bounds(const tal_t *ctx,
17 struct amount_sat funding,
18 u32 feerate_per_kw,
19 u32 max_to_self_delay,
20 struct amount_msat min_effective_htlc_capacity,
21 const struct channel_config *remoteconf,
22 const struct channel_config *localconf,
23 bool option_anchors_zero_fee_htlc_tx,
24 char **err_reason)
25{
26 struct amount_sat capacity;
27 struct amount_sat reserve;
28 struct amount_sat fee;
29
30 /* BOLT #2:
31 *
32 * The receiving node MUST fail the channel if:
33 *...
34 * - `to_self_delay` is unreasonably large.
35 */
36 if (remoteconf->to_self_delay > max_to_self_delay) {
37 *err_reason = tal_fmt(ctx,
38 "to_self_delay %u larger than %u",
39 remoteconf->to_self_delay,
40 max_to_self_delay);
41 return false;
42 }
43
44 /* BOLT #2:
45 *
46 * The receiving node MAY fail the channel if:
47 *...
48 * - `funding_satoshis` is too small.
49 * - it considers `htlc_minimum_msat` too large.
50 * - it considers `max_htlc_value_in_flight_msat` too small.
51 * - it considers `channel_reserve_satoshis` too large.
52 * - it considers `max_accepted_htlcs` too small.
53 */
54 /* We accumulate this into an effective bandwidth minimum. */
55
56 /* Add both reserves to deduct from capacity. */
57 if (!amount_sat_add(&reserve,
58 remoteconf->channel_reserve,
59 localconf->channel_reserve)) {
60 *err_reason = tal_fmt(ctx,
61 "channel_reserve_satoshis %s"
62 " too large",
63 fmt_amount_sat(ctx, remoteconf->channel_reserve));
64 return false;
65 }
66
67 /* BOLT #2:
68 * - if `option_anchors` applies to this commitment
69 * transaction and the sending node is the funder:
70 * - MUST be able to additionally pay for `to_local_anchor` and
71 * `to_remote_anchor` above its reserve.
72 */
73 /* (We simply include in "reserve" here if they opened). */

Callers 6

funder_channel_startFunction · 0.85
fundee_channelFunction · 0.85
accepter_startFunction · 0.85
opener_startFunction · 0.85
rbf_local_startFunction · 0.85
rbf_remote_startFunction · 0.85

Calls 8

commit_tx_base_feeFunction · 0.85
amount_sat_greaterFunction · 0.85
amount_msat_greater_satFunction · 0.85
amount_sat_addFunction · 0.50
fmt_amount_satFunction · 0.50
amount_sat_subFunction · 0.50
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected