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

Function check_config_bounds

openingd/common.c:14–167  ·  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

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