Browse Source

jsonrpc: add json_tok_short_channel_id helper.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
8cf1870465
  1. 8
      lightningd/jsonrpc.c
  2. 4
      lightningd/jsonrpc.h
  3. 3
      lightningd/pay.c

8
lightningd/jsonrpc.c

@ -388,6 +388,14 @@ void json_add_short_channel_id(struct json_result *response,
type_to_string(response, struct short_channel_id, id));
}
bool json_tok_short_channel_id(const char *buffer, const jsmntok_t *tok,
struct short_channel_id *scid)
{
return short_channel_id_from_str(buffer + tok->start,
tok->end - tok->start,
scid);
}
void json_add_address(struct json_result *response, const char *fieldname,
const struct wireaddr *addr)
{

4
lightningd/jsonrpc.h

@ -76,6 +76,10 @@ void json_add_txid(struct json_result *result, const char *fieldname,
bool json_tok_pubkey(const char *buffer, const jsmntok_t *tok,
struct pubkey *pubkey);
/* Extract a short_channel_id from this */
bool json_tok_short_channel_id(const char *buffer, const jsmntok_t *tok,
struct short_channel_id *scid);
/* '"fieldname" : "1234:5:6"' */
void json_add_short_channel_id(struct json_result *response,
const char *fieldname,

3
lightningd/pay.c

@ -299,8 +299,7 @@ static void json_sendpay(struct command *cmd,
return;
}
if (!short_channel_id_from_str(buffer + chantok->start,
chantok->end - chantok->start,
if (!json_tok_short_channel_id(buffer, chantok,
&route[n_hops].channel_id)) {
command_fail(cmd, "route %zu invalid channel_id", n_hops);
return;

Loading…
Cancel
Save