From 884f4fa6d09aca7a58d37126afabe12bab2dbc62 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 6 Sep 2019 16:11:43 +0930 Subject: [PATCH] JSON: Remove description fields. Signed-off-by: Rusty Russell --- CHANGELOG.md | 2 ++ lightningd/pay.c | 49 ++++++++------------------------------- plugins/pay.c | 60 +++++++++++------------------------------------- 3 files changed, 24 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0f12aac..7d995e6d3 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/lightningd/pay.c b/lightningd/pay.c index 1ea819155..34ecd8e81 100644 --- a/lightningd/pay.c +++ b/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"); diff --git a/plugins/pay.c b/plugins/pay.c index 31ef8bf36..a1d2b7bc2 100644 --- a/plugins/pay.c +++ b/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);