~ 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. */
| 12 | * it applied for both the case where they're trying to open a channel, and when |
| 13 | * they've accepted our open. */ |
| 14 | bool 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). */ |
no test coverage detected