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

Function set_channel_config

lightningd/peer_control.c:2518–2610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2516}
2517
2518static void set_channel_config(struct command *cmd, struct channel *channel,
2519 u32 *base,
2520 u32 *ppm,
2521 struct amount_msat *htlc_min,
2522 struct amount_msat *htlc_max,
2523 u32 delaysecs,
2524 struct json_stream *response,
2525 bool add_details)
2526{
2527 bool warn_cannot_set_min = false, warn_cannot_set_max = false;
2528
2529 /* We only need to defer values if we *increase* fees (or drop
2530 * max, increase min); we always allow users to overpay fees. */
2531 if ((base && *base > channel->feerate_base)
2532 || (ppm && *ppm > channel->feerate_ppm)
2533 || (htlc_min
2534 && amount_msat_greater(*htlc_min, channel->htlc_minimum_msat))
2535 || (htlc_max
2536 && amount_msat_less(*htlc_max, channel->htlc_maximum_msat))) {
2537 channel->old_feerate_timeout
2538 = timeabs_add(time_now(), time_from_sec(delaysecs));
2539 channel->old_feerate_base = channel->feerate_base;
2540 channel->old_feerate_ppm = channel->feerate_ppm;
2541 channel->old_htlc_minimum_msat = channel->htlc_minimum_msat;
2542 channel->old_htlc_maximum_msat = channel->htlc_maximum_msat;
2543 }
2544
2545 /* set new values */
2546 if (base)
2547 channel->feerate_base = *base;
2548 if (ppm)
2549 channel->feerate_ppm = *ppm;
2550 if (htlc_min) {
2551 struct amount_msat actual_min;
2552
2553 /* We can't send something they'll refuse: check that here. */
2554 actual_min = channel->channel_info.their_config.htlc_minimum;
2555 if (amount_msat_less(*htlc_min, actual_min)) {
2556 warn_cannot_set_min = true;
2557 channel->htlc_minimum_msat = actual_min;
2558 } else
2559 channel->htlc_minimum_msat = *htlc_min;
2560 }
2561 if (htlc_max) {
2562 struct amount_msat actual_max;
2563
2564 /* Can't set it greater than actual capacity. */
2565 actual_max = htlc_max_possible_send(channel);
2566 if (amount_msat_greater(*htlc_max, actual_max)) {
2567 warn_cannot_set_max = true;
2568 channel->htlc_maximum_msat = actual_max;
2569 } else
2570 channel->htlc_maximum_msat = *htlc_max;
2571 }
2572
2573 /* tell channeld to make a send_channel_update */
2574 if (channel->owner && streq(channel->owner->name, "channeld"))
2575 subd_send_msg(channel->owner,

Callers 2

json_setchannelfeeFunction · 0.85
json_setchannelFunction · 0.85

Calls 15

amount_msat_greaterFunction · 0.85
amount_msat_lessFunction · 0.85
timeabs_addFunction · 0.85
time_nowFunction · 0.85
time_from_secFunction · 0.85
htlc_max_possible_sendFunction · 0.70
subd_send_msgFunction · 0.70
amount_msatClass · 0.70
wallet_channel_saveFunction · 0.50
json_object_startFunction · 0.50
json_add_node_idFunction · 0.50

Tested by

no test coverage detected