Skip to content

Commit ba7bf33

Browse files
rustyrussellvincenzopalazzo
authored andcommitted
fetchinvoice: check better.
We do a lot more parameter checking than simply parsing, so use param_check(). Signed-off-by: Rusty Russell <[email protected]>
1 parent e76a334 commit ba7bf33

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

plugins/fetchinvoice.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -827,18 +827,18 @@ struct command_result *json_fetchinvoice(struct command *cmd,
827827
u64 *quantity;
828828
u32 *recurrence_counter, *recurrence_start;
829829

830-
if (!param(cmd, buffer, params,
831-
p_req("offer", param_offer, &sent->offer),
832-
p_opt("amount_msat", param_msat, &msat),
833-
p_opt("quantity", param_u64, &quantity),
834-
p_opt("recurrence_counter", param_number, &recurrence_counter),
835-
p_opt("recurrence_start", param_number, &recurrence_start),
836-
p_opt("recurrence_label", param_string, &rec_label),
837-
p_opt_def("timeout", param_number, &timeout, 60),
838-
p_opt("payer_note", param_string, &payer_note),
839-
p_opt("payer_metadata", param_bin_from_hex, &payer_metadata),
840-
p_opt("dev_path_use_scidd", param_dev_scidd, &sent->dev_path_use_scidd),
841-
p_opt("dev_reply_path", param_dev_reply_path, &sent->dev_reply_path),
830+
if (!param_check(cmd, buffer, params,
831+
p_req("offer", param_offer, &sent->offer),
832+
p_opt("amount_msat", param_msat, &msat),
833+
p_opt("quantity", param_u64, &quantity),
834+
p_opt("recurrence_counter", param_number, &recurrence_counter),
835+
p_opt("recurrence_start", param_number, &recurrence_start),
836+
p_opt("recurrence_label", param_string, &rec_label),
837+
p_opt_def("timeout", param_number, &timeout, 60),
838+
p_opt("payer_note", param_string, &payer_note),
839+
p_opt("payer_metadata", param_bin_from_hex, &payer_metadata),
840+
p_opt("dev_path_use_scidd", param_dev_scidd, &sent->dev_path_use_scidd),
841+
p_opt("dev_reply_path", param_dev_reply_path, &sent->dev_reply_path),
842842
NULL))
843843
return command_param_failed();
844844

@@ -1055,6 +1055,11 @@ struct command_result *json_fetchinvoice(struct command *cmd,
10551055
payer_note,
10561056
strlen(payer_note),
10571057
0);
1058+
1059+
/* If only checking, we're done now */
1060+
if (command_check_only(cmd))
1061+
return command_check_done(cmd);
1062+
10581063
/* Make the invoice request (fills in payer_key and payer_info) */
10591064
req = jsonrpc_request_start(cmd, "createinvoicerequest",
10601065
&invreq_done,

0 commit comments

Comments
 (0)