Browse Source

Merge remote-tracking branch 'origin/pr/43'

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
a9df84145e
  1. 1
      daemon/jsonrpc.c
  2. 1
      daemon/jsonrpc.h
  3. 36
      daemon/routing.c

1
daemon/jsonrpc.c

@ -294,6 +294,7 @@ static const struct json_command *cmdlist[] = {
&listinvoice_command,
&delinvoice_command,
&waitinvoice_command,
&getchannels_command,
&getroute_command,
&sendpay_command,
&getinfo_command,

1
daemon/jsonrpc.h

@ -60,6 +60,7 @@ void setup_jsonrpc(struct lightningd_state *dstate, const char *rpc_filename);
extern const struct json_command newaddr_command;
extern const struct json_command connect_command;
extern const struct json_command close_command;
extern const struct json_command getchannels_command;
extern const struct json_command getpeers_command;
/* Invoice management. */

36
daemon/routing.c

@ -459,6 +459,42 @@ const struct json_command dev_add_route_command = {
"Returns an empty result on success"
};
static void json_getchannels(struct command *cmd,
const char *buffer, const jsmntok_t *params)
{
struct json_result *response = new_json_result(cmd);
struct node_map_iter it;
struct node *n;
struct node_map *nodes = cmd->dstate->nodes;
struct node_connection *c;
int num_conn, i;
json_object_start(response, NULL);
json_array_start(response, "channels");
for (n = node_map_first(nodes, &it); n; n = node_map_next(nodes, &it)) {
num_conn = tal_count(n->out);
for (i = 0; i < num_conn; i++){
c = n->out[i];
json_object_start(response, NULL);
json_add_pubkey(response, cmd->dstate->secpctx, "from", &n->id);
json_add_pubkey(response, cmd->dstate->secpctx, "to", &c->dst->id);
json_add_num(response, "base_fee", c->base_fee);
json_add_num(response, "proportional_fee", c->proportional_fee);
json_object_end(response);
}
}
json_array_end(response);
json_object_end(response);
command_success(cmd, response);
}
const struct json_command getchannels_command = {
"getchannels",
json_getchannels,
"List all known channels.",
"Returns a 'channels' array with all known channels including their fees."
};
static void json_routefail(struct command *cmd,
const char *buffer, const jsmntok_t *params)
{

Loading…
Cancel
Save