Browse Source

jsonrpc: rename "id" to "peerid" everywhere.

To be distinct from HTLC ids.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
ab1176d218
  1. 90
      daemon/peer.c

90
daemon/peer.c

@ -1254,7 +1254,7 @@ static void json_getpeers(struct command *cmd,
/* This is only valid after crypto setup. */ /* This is only valid after crypto setup. */
if (p->state != STATE_INIT) if (p->state != STATE_INIT)
json_add_hex(response, "id", json_add_hex(response, "peerid",
p->id.der, pubkey_derlen(&p->id)); p->id.der, pubkey_derlen(&p->id));
if (p->cstate) { if (p->cstate) {
@ -1395,32 +1395,32 @@ static void json_newhtlc(struct command *cmd,
const char *buffer, const jsmntok_t *params) const char *buffer, const jsmntok_t *params)
{ {
struct peer *peer; struct peer *peer;
jsmntok_t *idtok, *msatoshistok, *expirytok, *rhashtok; jsmntok_t *peeridtok, *msatoshistok, *expirytok, *rhashtok;
struct pubkey id; struct pubkey peerid;
unsigned int expiry; unsigned int expiry;
struct newhtlc *newhtlc; struct newhtlc *newhtlc;
json_get_params(buffer, params, json_get_params(buffer, params,
"id", &idtok, "peerid", &peeridtok,
"msatoshis", &msatoshistok, "msatoshis", &msatoshistok,
"expiry", &expirytok, "expiry", &expirytok,
"rhash", &rhashtok, "rhash", &rhashtok,
NULL); NULL);
if (!idtok || !msatoshistok || !expirytok || !rhashtok) { if (!peeridtok || !msatoshistok || !expirytok || !rhashtok) {
command_fail(cmd, "Need id, msatoshis, expiry and rhash"); command_fail(cmd, "Need peerid, msatoshis, expiry and rhash");
return; return;
} }
if (!pubkey_from_hexstr(cmd->dstate->secpctx, if (!pubkey_from_hexstr(cmd->dstate->secpctx,
buffer + idtok->start, buffer + peeridtok->start,
idtok->end - idtok->start, &id)) { peeridtok->end - peeridtok->start, &peerid)) {
command_fail(cmd, "Not a valid id"); command_fail(cmd, "Not a valid peerid");
return; return;
} }
peer = find_peer(cmd->dstate, &id); peer = find_peer(cmd->dstate, &peerid);
if (!peer) { if (!peer) {
command_fail(cmd, "Could not find peer with that id"); command_fail(cmd, "Could not find peer with that peerid");
return; return;
} }
@ -1478,7 +1478,7 @@ static void json_newhtlc(struct command *cmd,
const struct json_command newhtlc_command = { const struct json_command newhtlc_command = {
"newhtlc", "newhtlc",
json_newhtlc, json_newhtlc,
"Offer {id} an HTLC worth {msatoshis} in {expiry} (in seconds since Jan 1 1970) with {rhash}", "Offer {peerid} an HTLC worth {msatoshis} in {expiry} (in seconds since Jan 1 1970) with {rhash}",
"Returns an empty result on success" "Returns an empty result on success"
}; };
@ -1527,29 +1527,29 @@ static void json_fulfillhtlc(struct command *cmd,
const char *buffer, const jsmntok_t *params) const char *buffer, const jsmntok_t *params)
{ {
struct peer *peer; struct peer *peer;
jsmntok_t *idtok, *rtok; jsmntok_t *peeridtok, *rtok;
struct pubkey id; struct pubkey peerid;
struct fulfillhtlc *fulfillhtlc; struct fulfillhtlc *fulfillhtlc;
json_get_params(buffer, params, json_get_params(buffer, params,
"id", &idtok, "peerid", &peeridtok,
"r", &rtok, "r", &rtok,
NULL); NULL);
if (!idtok || !rtok) { if (!peeridtok || !rtok) {
command_fail(cmd, "Need id and r"); command_fail(cmd, "Need peerid and r");
return; return;
} }
if (!pubkey_from_hexstr(cmd->dstate->secpctx, if (!pubkey_from_hexstr(cmd->dstate->secpctx,
buffer + idtok->start, buffer + peeridtok->start,
idtok->end - idtok->start, &id)) { peeridtok->end - peeridtok->start, &peerid)) {
command_fail(cmd, "Not a valid id"); command_fail(cmd, "Not a valid peerid");
return; return;
} }
peer = find_peer(cmd->dstate, &id); peer = find_peer(cmd->dstate, &peerid);
if (!peer) { if (!peer) {
command_fail(cmd, "Could not find peer with that id"); command_fail(cmd, "Could not find peer with that peerid");
return; return;
} }
@ -1572,7 +1572,7 @@ static void json_fulfillhtlc(struct command *cmd,
const struct json_command fulfillhtlc_command = { const struct json_command fulfillhtlc_command = {
"fulfillhtlc", "fulfillhtlc",
json_fulfillhtlc, json_fulfillhtlc,
"Redeem htlc proposed by {id} using {r}", "Redeem htlc proposed by {peerid} using {r}",
"Returns an empty result on success" "Returns an empty result on success"
}; };
@ -1618,29 +1618,29 @@ static void json_failhtlc(struct command *cmd,
const char *buffer, const jsmntok_t *params) const char *buffer, const jsmntok_t *params)
{ {
struct peer *peer; struct peer *peer;
jsmntok_t *idtok, *rhashtok; jsmntok_t *peeridtok, *rhashtok;
struct pubkey id; struct pubkey peerid;
struct failhtlc *failhtlc; struct failhtlc *failhtlc;
json_get_params(buffer, params, json_get_params(buffer, params,
"id", &idtok, "peerid", &peeridtok,
"rhash", &rhashtok, "rhash", &rhashtok,
NULL); NULL);
if (!idtok || !rhashtok) { if (!peeridtok || !rhashtok) {
command_fail(cmd, "Need id and rhash"); command_fail(cmd, "Need peerid and rhash");
return; return;
} }
if (!pubkey_from_hexstr(cmd->dstate->secpctx, if (!pubkey_from_hexstr(cmd->dstate->secpctx,
buffer + idtok->start, buffer + peeridtok->start,
idtok->end - idtok->start, &id)) { peeridtok->end - peeridtok->start, &peerid)) {
command_fail(cmd, "Not a valid id"); command_fail(cmd, "Not a valid peerid");
return; return;
} }
peer = find_peer(cmd->dstate, &id); peer = find_peer(cmd->dstate, &peerid);
if (!peer) { if (!peer) {
command_fail(cmd, "Could not find peer with that id"); command_fail(cmd, "Could not find peer with that peerid");
return; return;
} }
@ -1663,7 +1663,7 @@ static void json_failhtlc(struct command *cmd,
const struct json_command failhtlc_command = { const struct json_command failhtlc_command = {
"failhtlc", "failhtlc",
json_failhtlc, json_failhtlc,
"Fail htlc proposed by {id} which has redeem hash {rhash}", "Fail htlc proposed by {peerid} which has redeem hash {rhash}",
"Returns an empty result on success" "Returns an empty result on success"
}; };
@ -1671,27 +1671,27 @@ static void json_close(struct command *cmd,
const char *buffer, const jsmntok_t *params) const char *buffer, const jsmntok_t *params)
{ {
struct peer *peer; struct peer *peer;
jsmntok_t *idtok; jsmntok_t *peeridtok;
struct pubkey id; struct pubkey peerid;
json_get_params(buffer, params, json_get_params(buffer, params,
"id", &idtok, "peerid", &peeridtok,
NULL); NULL);
if (!idtok) { if (!peeridtok) {
command_fail(cmd, "Need id"); command_fail(cmd, "Need peerid");
return; return;
} }
if (!pubkey_from_hexstr(cmd->dstate->secpctx, if (!pubkey_from_hexstr(cmd->dstate->secpctx,
buffer + idtok->start, buffer + peeridtok->start,
idtok->end - idtok->start, &id)) { peeridtok->end - peeridtok->start, &peerid)) {
command_fail(cmd, "Not a valid id"); command_fail(cmd, "Not a valid peerid");
return; return;
} }
peer = find_peer(cmd->dstate, &id); peer = find_peer(cmd->dstate, &peerid);
if (!peer) { if (!peer) {
command_fail(cmd, "Could not find peer with that id"); command_fail(cmd, "Could not find peer with that peerid");
return; return;
} }
if (peer->cond == PEER_CLOSING) { if (peer->cond == PEER_CLOSING) {
@ -1708,6 +1708,6 @@ static void json_close(struct command *cmd,
const struct json_command close_command = { const struct json_command close_command = {
"close", "close",
json_close, json_close,
"Close the channel with peer {id}", "Close the channel with peer {peerid}",
"Returns an empty result on success" "Returns an empty result on success"
}; };

Loading…
Cancel
Save