Browse Source

JSON: Remove description fields.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pull/2803/head
Rusty Russell 5 years ago
committed by Christian Decker
parent
commit
884f4fa6d0
  1. 2
      CHANGELOG.md
  2. 49
      lightningd/pay.c
  3. 60
      plugins/pay.c

2
CHANGELOG.md

@ -23,6 +23,8 @@ changes.
### Removed
- JSON API: `short_channel_id` parameters in JSON commands with `:` separators (deprecated since 0.7.0).
- JSON API: `description` parameters in `pay` and `sendpay` (deprecated since 0.7.0).
- JSON API: `description` output field in `waitsendpay` and `sendpay` (deprecated since 0.7.0).
### Fixed

49
lightningd/pay.c

@ -101,11 +101,8 @@ json_add_payment_fields(struct json_stream *response,
json_add_hex(response, "payment_preimage",
t->payment_preimage,
sizeof(*t->payment_preimage));
if (t->label) {
if (deprecated_apis)
json_add_string(response, "description", t->label);
if (t->label)
json_add_string(response, "label", t->label);
}
if (t->bolt11)
json_add_string(response, "bolt11", t->bolt11);
}
@ -778,42 +775,14 @@ static struct command_result *json_sendpay(struct command *cmd,
const char *b11str, *label;
struct command_result *res;
/* If by array, or 'check' command, use 'label' as param name */
if (!params || params->type == JSMN_ARRAY) {
if (!param(cmd, buffer, params,
p_req("route", param_array, &routetok),
p_req("payment_hash", param_sha256, &rhash),
p_opt("label", param_escaped_string, &label),
p_opt("msatoshi", param_msat, &msat),
p_opt("bolt11", param_string, &b11str),
NULL))
return command_param_failed();
} else {
const char *description_deprecated;
/* If by keyword, treat description and label as
* separate parameters. */
if (!param(cmd, buffer, params,
p_req("route", param_array, &routetok),
p_req("payment_hash", param_sha256, &rhash),
p_opt("label", param_escaped_string, &label),
p_opt("description", param_escaped_string,
&description_deprecated),
p_opt("msatoshi", param_msat, &msat),
p_opt("bolt11", param_string, &b11str),
NULL))
return command_param_failed();
if (description_deprecated) {
if (!deprecated_apis)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Deprecated parameter description, use label");
if (label)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Cannot specify both description and label");
label = description_deprecated;
}
}
if (!param(cmd, buffer, params,
p_req("route", param_array, &routetok),
p_req("payment_hash", param_sha256, &rhash),
p_opt("label", param_escaped_string, &label),
p_opt("msatoshi", param_msat, &msat),
p_opt("bolt11", param_string, &b11str),
NULL))
return command_param_failed();
if (routetok->size == 0)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS, "Empty route");

60
plugins/pay.c

@ -955,7 +955,7 @@ static struct command_result *json_pay(struct command *cmd,
{
struct amount_msat *msat;
struct bolt11 *b11;
const char *b11str, *description_deprecated;
const char *b11str;
char *fail;
double *riskfactor;
unsigned int *retryfor;
@ -964,54 +964,20 @@ static struct command_result *json_pay(struct command *cmd,
unsigned int *maxdelay;
struct amount_msat *exemptfee;
/* If params is array, label takes place of description. For
* keywords, its a separate parameter. */
if (!params || params->type == JSMN_ARRAY) {
if (!param(cmd, buf, params,
p_req("bolt11", param_string, &b11str),
p_opt("msatoshi", param_msat, &msat),
p_opt("label", param_string, &pc->label),
p_opt_def("riskfactor", param_double, &riskfactor, 10),
p_opt_def("maxfeepercent", param_percent, &maxfeepercent, 0.5),
p_opt_def("retry_for", param_number, &retryfor, 60),
p_opt_def("maxdelay", param_number, &maxdelay,
maxdelay_default),
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
NULL))
return NULL;
/* This works because bolt11_decode ignores unneeded descriptions */
if (deprecated_apis)
description_deprecated = pc->label;
else
description_deprecated = NULL;
} else {
/* If by keyword, treat description and label as
* separate parameters. */
if (!param(cmd, buf, params,
p_req("bolt11", param_string, &b11str),
p_opt("msatoshi", param_msat, &msat),
p_opt("description", param_string,
&description_deprecated),
p_opt_def("riskfactor", param_double, &riskfactor, 10),
p_opt_def("maxfeepercent", param_percent, &maxfeepercent, 0.5),
p_opt_def("retry_for", param_number, &retryfor, 60),
p_opt_def("maxdelay", param_number, &maxdelay,
maxdelay_default),
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
p_opt("label", param_string, &pc->label),
NULL))
if (!param(cmd, buf, params,
p_req("bolt11", param_string, &b11str),
p_opt("msatoshi", param_msat, &msat),
p_opt("label", param_string, &pc->label),
p_opt_def("riskfactor", param_double, &riskfactor, 10),
p_opt_def("maxfeepercent", param_percent, &maxfeepercent, 0.5),
p_opt_def("retry_for", param_number, &retryfor, 60),
p_opt_def("maxdelay", param_number, &maxdelay,
maxdelay_default),
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
NULL))
return NULL;
if (description_deprecated && !deprecated_apis)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Deprecated parameter description, use label");
if (description_deprecated && pc->label)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Cannot specify both description and label");
}
b11 = bolt11_decode(cmd, b11str, description_deprecated, &fail);
b11 = bolt11_decode(cmd, b11str, NULL, &fail);
if (!b11) {
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Invalid bolt11: %s", fail);

Loading…
Cancel
Save