diff --git a/common/json_helpers.c b/common/json_helpers.c index 0cf60ba82..c3dfdaf38 100644 --- a/common/json_helpers.c +++ b/common/json_helpers.c @@ -140,11 +140,10 @@ bool json_to_preimage(const char *buffer, const jsmntok_t *tok, struct preimage return hex_decode(buffer + tok->start, hexlen, preimage->r, sizeof(preimage->r)); } -bool json_to_psbt(const tal_t *ctx, const char *buffer, - const jsmntok_t *tok, struct wally_psbt **dest) +struct wally_psbt *json_to_psbt(const tal_t *ctx, const char *buffer, + const jsmntok_t *tok) { - *dest = psbt_from_b64(ctx, buffer + tok->start, tok->end - tok->start); - return dest != NULL; + return psbt_from_b64(ctx, buffer + tok->start, tok->end - tok->start); } void json_add_node_id(struct json_stream *response, diff --git a/common/json_helpers.h b/common/json_helpers.h index 0c8322947..f72f3a30e 100644 --- a/common/json_helpers.h +++ b/common/json_helpers.h @@ -26,8 +26,8 @@ bool json_to_preimage(const char *buffer, const jsmntok_t *tok, struct preimage bool json_to_secret(const char *buffer, const jsmntok_t *tok, struct secret *dest); /* Extract a psbt from this. */ -bool json_to_psbt(const tal_t *ctx, const char *buffer, - const jsmntok_t *tok, struct wally_psbt **dest); +struct wally_psbt *json_to_psbt(const tal_t *ctx, const char *buffer, + const jsmntok_t *tok); /* Extract a pubkey from this */ bool json_to_pubkey(const char *buffer, const jsmntok_t *tok, diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 0de1ed308..54d0d45d7 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -218,8 +218,6 @@ hook_extract_psbt(const tal_t *ctx, struct subd *dualopend, const char *buffer, bool allow_empty, struct wally_psbt **out) { - struct wally_psbt *returned_psbt; - if (!buffer) fatal("Plugin must return a valid response to %s", hook_name); @@ -250,13 +248,13 @@ hook_extract_psbt(const tal_t *ctx, struct subd *dualopend, const char *buffer, return true; } - if (!json_to_psbt(ctx, buffer, psbt_tok, &returned_psbt)) + *out = json_to_psbt(ctx, buffer, psbt_tok); + if (!*out) fatal("Plugin must return a valid 'psbt' to a 'continue'd" "%s %.*s", hook_name, toks[0].end - toks[0].start, buffer + toks[0].start); - *out = returned_psbt; return true; } diff --git a/plugins/spender/openchannel.c b/plugins/spender/openchannel.c index b8cb77a71..72884e3f2 100644 --- a/plugins/spender/openchannel.c +++ b/plugins/spender/openchannel.c @@ -571,8 +571,8 @@ static void json_peer_sigs(struct command *cmd, json_tok_full_len(params), json_tok_full(buf, params)); - if (!json_to_psbt(cmd, buf, psbt_tok, - cast_const2(struct wally_psbt **, &psbt))) + psbt = json_to_psbt(cmd, buf, psbt_tok); + if (!psbt) plugin_err(cmd->plugin, "Unable to parse openchannel_peer_sigs.signed_psbt " "%.*s", @@ -705,7 +705,8 @@ openchannel_update_ok(struct command *cmd, json_tok_full_len(result), json_tok_full(buf, result)); - if (!json_to_psbt(dest->mfc, buf, psbt_tok, &dest->updated_psbt)) + dest->updated_psbt = json_to_psbt(dest->mfc, buf, psbt_tok); + if (!dest->updated_psbt) plugin_err(cmd->plugin, "`openchannel_update` returned invalid " "'psbt': %.*s", @@ -939,7 +940,8 @@ openchannel_init_ok(struct command *cmd, "'psbt': %.*s", json_tok_full_len(result), json_tok_full(buf, result)); - if (!json_to_psbt(dest->mfc, buf, psbt_tok, &dest->updated_psbt)) + dest->updated_psbt = json_to_psbt(dest->mfc, buf, psbt_tok); + if (!dest->updated_psbt) plugin_err(cmd->plugin, "openchannel_init returned invalid " "'psbt': %.*s",