mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 20:54:23 +01:00
Remove all JSON commands and fields deprecated before 0.6.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
8ee21bc352
commit
9e14d6cf04
@@ -38,6 +38,7 @@ changes.
|
||||
|
||||
- JSON API: `listpeers` results no long have `alias` and `color` fields;
|
||||
they're in `listnodes` (we used to internally merge the information).
|
||||
- Removed all Deprecated options from 0.6.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ static const char *invoice_status_str(const struct invoice_details *inv)
|
||||
}
|
||||
|
||||
static void json_add_invoice(struct json_result *response,
|
||||
const struct invoice_details *inv,
|
||||
bool modern)
|
||||
const struct invoice_details *inv)
|
||||
{
|
||||
json_object_start(response, NULL);
|
||||
json_add_escaped_string(response, "label", inv->label);
|
||||
@@ -42,21 +41,13 @@ static void json_add_invoice(struct json_result *response,
|
||||
json_add_hex(response, "payment_hash", &inv->rhash, sizeof(inv->rhash));
|
||||
if (inv->msatoshi)
|
||||
json_add_u64(response, "msatoshi", *inv->msatoshi);
|
||||
if (modern)
|
||||
json_add_string(response, "status", invoice_status_str(inv));
|
||||
else if (deprecated_apis && !modern)
|
||||
json_add_bool(response, "complete", inv->state == PAID);
|
||||
json_add_string(response, "status", invoice_status_str(inv));
|
||||
if (inv->state == PAID) {
|
||||
json_add_u64(response, "pay_index", inv->pay_index);
|
||||
json_add_u64(response, "msatoshi_received",
|
||||
inv->msatoshi_received);
|
||||
if (deprecated_apis)
|
||||
json_add_u64(response, "paid_timestamp",
|
||||
inv->paid_timestamp);
|
||||
json_add_u64(response, "paid_at", inv->paid_timestamp);
|
||||
}
|
||||
if (deprecated_apis)
|
||||
json_add_u64(response, "expiry_time", inv->expiry_time);
|
||||
json_add_u64(response, "expires_at", inv->expiry_time);
|
||||
|
||||
json_object_end(response);
|
||||
@@ -68,7 +59,7 @@ static void tell_waiter(struct command *cmd, const struct invoice *inv)
|
||||
struct invoice_details details;
|
||||
|
||||
wallet_invoice_details(cmd, cmd->ld->wallet, *inv, &details);
|
||||
json_add_invoice(response, &details, true);
|
||||
json_add_invoice(response, &details);
|
||||
if (details.state == PAID)
|
||||
command_success(cmd, response);
|
||||
else {
|
||||
@@ -159,7 +150,7 @@ static void json_invoice(struct command *cmd,
|
||||
{
|
||||
struct invoice invoice;
|
||||
struct invoice_details details;
|
||||
const jsmntok_t *msatoshi, *label, *desctok, *fallback, *fallbacks;
|
||||
const jsmntok_t *msatoshi, *label, *desctok, *fallbacks;
|
||||
const jsmntok_t *preimagetok;
|
||||
u64 *msatoshi_val;
|
||||
const struct json_escaped *label_val, *desc;
|
||||
@@ -177,7 +168,6 @@ static void json_invoice(struct command *cmd,
|
||||
p_req("label", json_tok_tok, &label),
|
||||
p_req("description", json_tok_tok, &desctok),
|
||||
p_opt_def("expiry", json_tok_u64, &expiry, 3600),
|
||||
p_opt_tok("fallback", &fallback),
|
||||
p_opt_tok("fallbacks", &fallbacks),
|
||||
p_opt_tok("preimage", &preimagetok),
|
||||
NULL))
|
||||
@@ -245,30 +235,10 @@ static void json_invoice(struct command *cmd,
|
||||
return;
|
||||
}
|
||||
|
||||
/* fallback addresses */
|
||||
if (fallback) {
|
||||
if (deprecated_apis) {
|
||||
fallback_scripts = tal_arr(cmd, const u8 *, 1);
|
||||
if (!parse_fallback(cmd, buffer, fallback,
|
||||
&fallback_scripts[0]))
|
||||
return;
|
||||
} else {
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"fallback is deprecated: use fallbacks");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (fallbacks) {
|
||||
const jsmntok_t *i, *end = json_next(fallbacks);
|
||||
size_t n = 0;
|
||||
|
||||
if (fallback) {
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Cannot use fallback and fallbacks");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fallbacks->type != JSMN_ARRAY) {
|
||||
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"fallback must be an array");
|
||||
@@ -350,8 +320,6 @@ static void json_invoice(struct command *cmd,
|
||||
json_object_start(response, NULL);
|
||||
json_add_hex(response, "payment_hash",
|
||||
&details.rhash, sizeof(details.rhash));
|
||||
if (deprecated_apis)
|
||||
json_add_u64(response, "expiry_time", details.expiry_time);
|
||||
json_add_u64(response, "expires_at", details.expiry_time);
|
||||
json_add_string(response, "bolt11", details.bolt11);
|
||||
json_object_end(response);
|
||||
@@ -368,8 +336,7 @@ AUTODATA(json_command, &invoice_command);
|
||||
|
||||
static void json_add_invoices(struct json_result *response,
|
||||
struct wallet *wallet,
|
||||
const struct json_escaped *label,
|
||||
bool modern)
|
||||
const struct json_escaped *label)
|
||||
{
|
||||
struct invoice_iterator it;
|
||||
struct invoice_details details;
|
||||
@@ -380,7 +347,7 @@ static void json_add_invoices(struct json_result *response,
|
||||
if (wallet_invoice_find_by_label(wallet, &invoice, label)) {
|
||||
wallet_invoice_details(response, wallet, invoice,
|
||||
&details);
|
||||
json_add_invoice(response, &details, modern);
|
||||
json_add_invoice(response, &details);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -388,14 +355,12 @@ static void json_add_invoices(struct json_result *response,
|
||||
memset(&it, 0, sizeof(it));
|
||||
while (wallet_invoice_iterate(wallet, &it)) {
|
||||
wallet_invoice_iterator_deref(response, wallet, &it, &details);
|
||||
json_add_invoice(response, &details, modern);
|
||||
json_add_invoice(response, &details);
|
||||
}
|
||||
}
|
||||
|
||||
static void json_listinvoice_internal(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *params,
|
||||
bool modern)
|
||||
static void json_listinvoices(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t *params)
|
||||
{
|
||||
jsmntok_t *labeltok;
|
||||
struct json_escaped *label;
|
||||
@@ -419,39 +384,14 @@ static void json_listinvoice_internal(struct command *cmd,
|
||||
} else
|
||||
label = NULL;
|
||||
|
||||
if (modern) {
|
||||
json_object_start(response, NULL);
|
||||
json_array_start(response, "invoices");
|
||||
} else
|
||||
json_array_start(response, NULL);
|
||||
json_add_invoices(response, wallet, label, modern);
|
||||
json_object_start(response, NULL);
|
||||
json_array_start(response, "invoices");
|
||||
json_add_invoices(response, wallet, label);
|
||||
json_array_end(response);
|
||||
if (modern)
|
||||
json_object_end(response);
|
||||
json_object_end(response);
|
||||
command_success(cmd, response);
|
||||
}
|
||||
|
||||
/* FIXME: Deprecated! */
|
||||
static void json_listinvoice(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t *params)
|
||||
{
|
||||
return json_listinvoice_internal(cmd, buffer, params, false);
|
||||
}
|
||||
|
||||
static const struct json_command listinvoice_command = {
|
||||
"listinvoice",
|
||||
json_listinvoice,
|
||||
"(DEPRECATED) Show invoice {label} (or all, if no {label}))",
|
||||
.deprecated = true
|
||||
};
|
||||
AUTODATA(json_command, &listinvoice_command);
|
||||
|
||||
static void json_listinvoices(struct command *cmd,
|
||||
const char *buffer, const jsmntok_t *params)
|
||||
{
|
||||
return json_listinvoice_internal(cmd, buffer, params, true);
|
||||
}
|
||||
|
||||
static const struct json_command listinvoices_command = {
|
||||
"listinvoices",
|
||||
json_listinvoices,
|
||||
@@ -503,7 +443,7 @@ static void json_delinvoice(struct command *cmd,
|
||||
|
||||
/* Get invoice details before attempting to delete, as
|
||||
* otherwise the invoice will be freed. */
|
||||
json_add_invoice(response, &details, true);
|
||||
json_add_invoice(response, &details);
|
||||
|
||||
if (!wallet_invoice_delete(wallet, i)) {
|
||||
log_broken(cmd->ld->log,
|
||||
@@ -731,8 +671,6 @@ static void json_decodepay(struct command *cmd,
|
||||
json_object_start(response, NULL);
|
||||
|
||||
json_add_string(response, "currency", b11->chain->bip173_name);
|
||||
if (deprecated_apis)
|
||||
json_add_u64(response, "timestamp", b11->timestamp);
|
||||
json_add_u64(response, "created_at", b11->timestamp);
|
||||
json_add_u64(response, "expiry", b11->expiry);
|
||||
json_add_pubkey(response, "payee", &b11->receiver_id);
|
||||
@@ -749,9 +687,6 @@ static void json_decodepay(struct command *cmd,
|
||||
json_add_num(response, "min_final_cltv_expiry",
|
||||
b11->min_final_cltv_expiry);
|
||||
if (tal_count(b11->fallbacks)) {
|
||||
if (deprecated_apis)
|
||||
json_add_fallback(response, "fallback",
|
||||
b11->fallbacks[0], b11->chain);
|
||||
json_array_start(response, "fallbacks");
|
||||
for (size_t i = 0; i < tal_count(b11->fallbacks); i++)
|
||||
json_add_fallback(response, NULL,
|
||||
|
||||
@@ -49,8 +49,6 @@ json_add_payment_fields(struct json_result *response,
|
||||
json_add_pubkey(response, "destination", &t->destination);
|
||||
json_add_u64(response, "msatoshi", t->msatoshi);
|
||||
json_add_u64(response, "msatoshi_sent", t->msatoshi_sent);
|
||||
if (deprecated_apis)
|
||||
json_add_u64(response, "timestamp", t->timestamp);
|
||||
json_add_u64(response, "created_at", t->timestamp);
|
||||
|
||||
switch (t->status) {
|
||||
|
||||
@@ -153,9 +153,6 @@ static void json_getinfo(struct command *cmd,
|
||||
json_add_string(response, "alias", (const char *)cmd->ld->alias);
|
||||
json_add_hex(response, "color", (const void *)cmd->ld->rgb, tal_len(cmd->ld->rgb));
|
||||
if (cmd->ld->listen) {
|
||||
if (deprecated_apis)
|
||||
json_add_num(response, "port", cmd->ld->portnum);
|
||||
|
||||
/* These are the addresses we're announcing */
|
||||
json_array_start(response, "address");
|
||||
for (size_t i = 0; i < tal_count(cmd->ld->announcable); i++)
|
||||
|
||||
@@ -664,8 +664,6 @@ static void json_getlog(struct command *cmd,
|
||||
return;
|
||||
|
||||
json_object_start(response, NULL);
|
||||
if (deprecated_apis)
|
||||
json_add_time(response, "creation_time", log_init_time(lr)->ts);
|
||||
json_add_time(response, "created_at", log_init_time(lr)->ts);
|
||||
json_add_num(response, "bytes_used", (unsigned int)log_used(lr));
|
||||
json_add_num(response, "bytes_max", (unsigned int)log_max_mem(lr));
|
||||
|
||||
@@ -102,32 +102,6 @@ static char *opt_set_u32(const char *arg, u32 *u)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_set_port(const char *arg, struct lightningd *ld)
|
||||
{
|
||||
char *endp;
|
||||
unsigned long l;
|
||||
|
||||
log_broken(ld->log, "--port has been deprecated, use --autolisten=0 or --addr=:<port>");
|
||||
if (!deprecated_apis)
|
||||
return "--port is deprecated";
|
||||
|
||||
assert(arg != NULL);
|
||||
|
||||
/* This is how the manpage says to do it. Yech. */
|
||||
errno = 0;
|
||||
l = strtoul(arg, &endp, 0);
|
||||
if (*endp || !arg[0])
|
||||
return tal_fmt(NULL, "'%s' is not a number", arg);
|
||||
ld->portnum = l;
|
||||
if (errno || ld->portnum != l)
|
||||
return tal_fmt(NULL, "'%s' is out of range", arg);
|
||||
|
||||
if (ld->portnum == 0)
|
||||
ld->autolisten = false;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_set_s32(const char *arg, s32 *u)
|
||||
{
|
||||
char *endp;
|
||||
@@ -214,14 +188,6 @@ static char *opt_add_announce_addr(const char *arg, struct lightningd *ld)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_add_ipaddr(const char *arg, struct lightningd *ld)
|
||||
{
|
||||
log_broken(ld->log, "--ipaddr has been deprecated, use --addr");
|
||||
if (!deprecated_apis)
|
||||
return "--ipaddr is deprecated";
|
||||
return opt_add_addr(arg, ld);
|
||||
}
|
||||
|
||||
static void opt_show_u64(char buf[OPT_SHOW_LEN], const u64 *u)
|
||||
{
|
||||
snprintf(buf, OPT_SHOW_LEN, "%"PRIu64, *u);
|
||||
@@ -322,22 +288,6 @@ static char *opt_add_proxy_addr(const char *arg, struct lightningd *ld)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_set_anchor(const char *arg, u32 *u)
|
||||
{
|
||||
if (!deprecated_apis)
|
||||
return "--anchor-confirms is now --funding-confirms";
|
||||
|
||||
return opt_set_u32(arg, u);
|
||||
}
|
||||
|
||||
static char *opt_set_locktime(const char *arg, u32 *u)
|
||||
{
|
||||
if (!deprecated_apis)
|
||||
return "--locktime-blocks is now --watchtime-blocks";
|
||||
|
||||
return opt_set_u32(arg, u);
|
||||
}
|
||||
|
||||
static void config_register_opts(struct lightningd *ld)
|
||||
{
|
||||
opt_register_early_arg("--conf=<file>", opt_set_talstr, NULL,
|
||||
@@ -351,16 +301,12 @@ static void config_register_opts(struct lightningd *ld)
|
||||
opt_register_arg("--watchtime-blocks", opt_set_u32, opt_show_u32,
|
||||
&ld->config.locktime_blocks,
|
||||
"Blocks before peer can unilaterally spend funds");
|
||||
opt_register_arg("--locktime-blocks", opt_set_locktime, NULL,
|
||||
&ld->config.locktime_blocks, opt_hidden);
|
||||
opt_register_arg("--max-locktime-blocks", opt_set_u32, opt_show_u32,
|
||||
&ld->config.locktime_max,
|
||||
"Maximum blocks funds may be locked for");
|
||||
opt_register_arg("--funding-confirms", opt_set_u32, opt_show_u32,
|
||||
&ld->config.anchor_confirms,
|
||||
"Confirmations required for funding transaction");
|
||||
opt_register_arg("--anchor-confirms", opt_set_anchor, NULL,
|
||||
&ld->config.anchor_confirms, opt_hidden);
|
||||
opt_register_arg("--commit-fee-min=<percent>", opt_set_u32, opt_show_u32,
|
||||
&ld->config.commitment_fee_min_percent,
|
||||
"Minimum percentage of fee to accept for commitment");
|
||||
@@ -393,8 +339,6 @@ static void config_register_opts(struct lightningd *ld)
|
||||
opt_register_arg("--fee-per-satoshi", opt_set_s32, opt_show_s32,
|
||||
&ld->config.fee_per_satoshi,
|
||||
"Microsatoshi fee for every satoshi in HTLC");
|
||||
opt_register_arg("--ipaddr", opt_add_ipaddr, NULL,
|
||||
ld, opt_hidden);
|
||||
opt_register_arg("--addr", opt_add_addr, NULL,
|
||||
ld,
|
||||
"Set an IP address (v4 or v6) to listen on and announce to the network for incoming connections");
|
||||
@@ -781,10 +725,6 @@ void register_opts(struct lightningd *ld)
|
||||
test_daemons_and_exit,
|
||||
ld, opt_hidden);
|
||||
|
||||
/* --port needs to be an early arg to force it being parsed
|
||||
* before --ipaddr which may depend on it */
|
||||
opt_register_early_arg("--port", opt_set_port, NULL, ld,
|
||||
opt_hidden);
|
||||
opt_register_arg("--bitcoin-datadir", opt_set_talstr, NULL,
|
||||
&ld->topology->bitcoind->datadir,
|
||||
"-datadir arg for bitcoin-cli");
|
||||
@@ -1012,11 +952,6 @@ static void add_config(struct lightningd *ld,
|
||||
answer = (const char *)ld->alias;
|
||||
} else if (opt->cb_arg == (void *)arg_log_to_file) {
|
||||
answer = ld->logfile;
|
||||
} else if (opt->cb_arg == (void *)opt_set_port) {
|
||||
if (!deprecated_apis)
|
||||
answer = tal_fmt(name0, "%u", ld->portnum);
|
||||
} else if (opt->cb_arg == (void *)opt_add_ipaddr) {
|
||||
/* Covered by opt_add_addr below */
|
||||
} else if (opt->cb_arg == (void *)opt_add_addr) {
|
||||
json_add_opt_addrs(response, name0,
|
||||
ld->proposed_wireaddr,
|
||||
|
||||
@@ -821,9 +821,6 @@ static void connectd_getpeers_complete(struct subd *connectd, const u8 *msg,
|
||||
channel->our_config.channel_reserve_satoshis);
|
||||
json_add_u64(response, "our_channel_reserve_satoshis",
|
||||
channel->channel_info.their_config.channel_reserve_satoshis);
|
||||
if (deprecated_apis)
|
||||
json_add_u64(response, "channel_reserve_satoshis",
|
||||
channel->our_config.channel_reserve_satoshis);
|
||||
/* Compute how much we can send via this channel. */
|
||||
if (channel->our_msatoshi <= our_reserve_msat)
|
||||
json_add_u64(response, "spendable_msatoshi", 0);
|
||||
@@ -840,9 +837,6 @@ static void connectd_getpeers_complete(struct subd *connectd, const u8 *msg,
|
||||
channel->our_config.to_self_delay);
|
||||
json_add_num(response, "our_to_self_delay",
|
||||
channel->channel_info.their_config.to_self_delay);
|
||||
if (deprecated_apis)
|
||||
json_add_num(response, "to_self_delay",
|
||||
channel->our_config.to_self_delay);
|
||||
json_add_num(response, "max_accepted_htlcs",
|
||||
channel->our_config.max_accepted_htlcs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user