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

Function json_dev_peer_shachain

lightningd/channel_control.c:2843–2879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2841AUTODATA(json_command, &dev_feerate_command);
2842
2843static struct command_result *json_dev_peer_shachain(struct command *cmd,
2844 const char *buffer,
2845 const jsmntok_t *obj UNNEEDED,
2846 const jsmntok_t *params)
2847{
2848 struct sha256 *shachain_seed;
2849 struct node_id *id;
2850 struct peer *peer;
2851 struct channel *channel;
2852 const u8 *msg;
2853 bool more_than_one;
2854
2855 if (!param_check(cmd, buffer, params,
2856 p_req("id", param_node_id, &id),
2857 p_req("seed", param_sha256, &shachain_seed),
2858 NULL))
2859 return command_param_failed();
2860
2861 peer = peer_by_id(cmd->ld, id);
2862 if (!peer)
2863 return command_fail(cmd, LIGHTNINGD, "Peer not connected");
2864
2865 channel = peer_any_channel_bystate(peer, channel_state_can_add_htlc, &more_than_one);
2866 if (!channel || !channel->owner)
2867 return command_fail(cmd, LIGHTNINGD, "Peer bad state");
2868 /* This is a dev command: fix the api if you need this! */
2869 if (more_than_one)
2870 return command_fail(cmd, LIGHTNINGD, "More than one channel");
2871
2872 if (command_check_only(cmd))
2873 return command_check_done(cmd);
2874
2875 msg = towire_channeld_dev_peer_shachain(NULL, shachain_seed);
2876 subd_send_msg(channel->owner, take(msg));
2877
2878 return command_success(cmd, json_stream_success(cmd));
2879}
2880
2881static const struct json_command dev_peer_shachain_command = {
2882 "dev-peer-shachain",

Callers

nothing calls this directly

Calls 10

param_checkFunction · 0.85
peer_by_idFunction · 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
subd_send_msgFunction · 0.70
command_successFunction · 0.70
json_stream_successFunction · 0.70

Tested by

no test coverage detected