mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
jsonrpc: add json_tok_short_channel_id helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e1e7f289fb
commit
8cf1870465
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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…
Reference in New Issue
Block a user