plugins: use json_scan.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-01-06 16:11:19 +10:30
committed by Christian Decker
parent 35e8949df3
commit b61da8c5a9
4 changed files with 74 additions and 113 deletions

View File

@@ -544,38 +544,17 @@ static void json_peer_sigs(struct command *cmd,
const char *buf,
const jsmntok_t *params)
{
const jsmntok_t *cid_tok, *psbt_tok;
struct channel_id cid;
const struct wally_psbt *psbt;
struct multifundchannel_destination *dest;
cid_tok = json_delve(buf, params, ".openchannel_peer_sigs.channel_id");
if (!cid_tok)
if (!json_scan(buf, params,
"{openchannel_peer_sigs:"
"{channel_id:%,signed_psbt:%}}",
JSON_SCAN(json_to_channel_id, &cid),
JSON_SCAN_TAL(cmd, json_to_psbt, &psbt)))
plugin_err(cmd->plugin,
"`openchannel_peer_sigs` notification did not "
"send 'channel_id'? %.*s",
json_tok_full_len(params),
json_tok_full(buf, params));
if (!json_to_channel_id(buf, cid_tok, &cid))
plugin_err(cmd->plugin,
"Unable to parse openchannel_peer_sigs.channel_id "
"%.*s",
json_tok_full_len(params),
json_tok_full(buf, params));
psbt_tok= json_delve(buf, params, ".openchannel_peer_sigs.signed_psbt");
if (!psbt_tok)
plugin_err(cmd->plugin,
"`openchannel_peer_sigs` notification did not "
"include 'signed_psbt'? %.*s",
json_tok_full_len(params),
json_tok_full(buf, params));
psbt = json_to_psbt(cmd, buf, psbt_tok);
if (!psbt)
plugin_err(cmd->plugin,
"Unable to parse openchannel_peer_sigs.signed_psbt "
"%.*s",
"`openchannel_peer_sigs` did not scan",
json_tok_full_len(params),
json_tok_full(buf, params));