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

Function json_dev_feerate

lightningd/channel_control.c:2684–2731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2682AUTODATA(json_command, &abort_channels_command);
2683
2684static struct command_result *json_dev_feerate(struct command *cmd,
2685 const char *buffer,
2686 const jsmntok_t *obj UNNEEDED,
2687 const jsmntok_t *params)
2688{
2689 u32 *feerate;
2690 struct node_id *id;
2691 struct peer *peer;
2692 struct json_stream *response;
2693 struct channel *channel;
2694 const u8 *msg;
2695 bool more_than_one;
2696
2697 if (!param_check(cmd, buffer, params,
2698 p_req("id", param_node_id, &id),
2699 p_req("feerate", param_number, &feerate),
2700 NULL))
2701 return command_param_failed();
2702
2703 peer = peer_by_id(cmd->ld, id);
2704 if (!peer)
2705 return command_fail(cmd, LIGHTNINGD, "Peer not connected");
2706
2707 channel = peer_any_channel_bystate(peer, channel_state_can_add_htlc,
2708 &more_than_one);
2709 if (!channel || !channel->owner)
2710 return command_fail(cmd, LIGHTNINGD, "Peer bad state");
2711 /* This is a dev command: fix the api if you need this! */
2712 if (more_than_one)
2713 return command_fail(cmd, LIGHTNINGD, "More than one channel");
2714
2715 if (command_check_only(cmd))
2716 return command_check_done(cmd);
2717
2718 msg = towire_channeld_feerates(NULL, *feerate,
2719 feerate_min(cmd->ld, NULL),
2720 feerate_max(cmd->ld, NULL),
2721 penalty_feerate(cmd->ld->topology),
2722 opening_feerate(cmd->ld->topology),
2723 splice_feerate(cmd->ld->topology, cmd->ld));
2724 subd_send_msg(channel->owner, take(msg));
2725
2726 response = json_stream_success(cmd);
2727 json_add_node_id(response, "id", id);
2728 json_add_u32(response, "feerate", *feerate);
2729
2730 return command_success(cmd, response);
2731}
2732
2733static const struct json_command dev_feerate_command = {
2734 "dev-feerate",

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
peer_by_idFunction · 0.85
feerate_minFunction · 0.85
feerate_maxFunction · 0.85
splice_feerateFunction · 0.85
json_add_node_idFunction · 0.85
json_add_u32Function · 0.85
command_param_failedFunction · 0.70
command_failFunction · 0.70
peer_any_channel_bystateFunction · 0.70
command_check_onlyFunction · 0.70
command_check_doneFunction · 0.70

Tested by

no test coverage detected