From aaa26d5a3fa6335dee1fc639a014e34f19ed24f4 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 25 Mar 2020 11:27:28 +1030 Subject: [PATCH 1/5] lightningd: remove deprecated 'description' parameter. Signed-off-by: Rusty Russell Changelog-Removed: JSON: `sendpay` `description` parameter removed (renamed to `label` in 0.7.0). --- lightningd/pay.c | 54 ++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/lightningd/pay.c b/lightningd/pay.c index f61117ca7155..28980e038a0a 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -1206,53 +1206,21 @@ static struct command_result *json_sendpay(struct command *cmd, struct sha256 *rhash; struct route_hop *route; struct amount_msat *msat; - const char *b11str, *label = NULL; + const char *b11str, *label; u64 *partid; struct secret *payment_secret; /* For generating help, give new-style. */ - if (!params || !deprecated_apis) { - 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), - p_opt("payment_secret", param_secret, - &payment_secret), - p_opt_def("partid", param_u64, &partid, 0), - NULL)) - return command_param_failed(); - } else if (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_or_description", param_escaped_string, &label), - p_opt("msatoshi", param_msat, &msat), - p_opt("bolt11", param_string, &b11str), - p_opt("payment_secret", param_secret, - &payment_secret), - p_opt_def("partid", param_u64, &partid, 0), - NULL)) - return command_param_failed(); - } else { - const char *desc = NULL; - 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, &desc), - p_opt("msatoshi", param_msat, &msat), - p_opt("bolt11", param_string, &b11str), - p_opt("payment_secret", param_secret, - &payment_secret), - p_opt_def("partid", param_u64, &partid, 0), - NULL)) - return command_param_failed(); - - if (!label && desc) - label = desc; - } + 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), + p_opt("payment_secret", param_secret, &payment_secret), + p_opt_def("partid", param_u64, &partid, 0), + NULL)) + return command_param_failed(); if (routetok->size == 0) return command_fail(cmd, JSONRPC2_INVALID_PARAMS, "Empty route"); From ce5b3be6b29d7eea94ad7d040244d80dbc933d5c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 25 Mar 2020 14:09:34 +1030 Subject: [PATCH 2/5] fundchannel/fundchannel_start: remove deprecated `satoshi` parameter Signed-off-by: Rusty Russell Changelog-Removed: JSON: `fundchannel` and `fundchannel_start` `satoshi` parameter removed (renamed to `amount` in 0.7.3). --- lightningd/opening_control.c | 46 ++++------------- plugins/fundchannel.c | 44 ++++------------ tests/test_connection.py | 97 +----------------------------------- 3 files changed, 20 insertions(+), 167 deletions(-) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 4654b0b63229..d10f7ed3b63f 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -1128,43 +1128,15 @@ static struct command_result *json_fund_channel_start(struct command *cmd, fc->uc = NULL; fc->inflight = false; - /* For generating help, give new-style. */ - if (!params || !deprecated_apis || params->type == JSMN_ARRAY) { - if (!param(fc->cmd, buffer, params, - p_req("id", param_node_id, &id), - p_req("amount", param_sat, &amount), - p_opt("feerate", param_feerate, &feerate_per_kw), - p_opt_def("announce", param_bool, &announce_channel, true), - p_opt("close_to", param_bitcoin_address, &fc->our_upfront_shutdown_script), - p_opt("push_msat", param_msat, &push_msat), - NULL)) - return command_param_failed(); - } else { - /* For json object type when allow deprecated api, 'check' command - * can't find the error if we don't set 'amount' nor 'satoshi'. - */ - struct amount_sat *satoshi; - if (!param(fc->cmd, buffer, params, - p_req("id", param_node_id, &id), - p_opt("amount", param_sat, &amount), - p_opt("satoshi", param_sat, &satoshi), - p_opt("feerate", param_feerate, &feerate_per_kw), - p_opt_def("announce", param_bool, &announce_channel, true), - p_opt("push_msat", param_msat, &push_msat), - NULL)) - return command_param_failed(); - - if (!amount) { - if (satoshi) - amount = satoshi; - else - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Need set 'amount' field"); - } - - /* No upfront shutdown script option for deprecated API */ - fc->our_upfront_shutdown_script = NULL; - } + if (!param(fc->cmd, buffer, params, + p_req("id", param_node_id, &id), + p_req("amount", param_sat, &amount), + p_opt("feerate", param_feerate, &feerate_per_kw), + p_opt_def("announce", param_bool, &announce_channel, true), + p_opt("close_to", param_bitcoin_address, &fc->our_upfront_shutdown_script), + p_opt("push_msat", param_msat, &push_msat), + NULL)) + return command_param_failed(); if (amount_sat_greater(*amount, chainparams->max_funding)) return command_fail(cmd, FUND_MAX_EXCEEDED, diff --git a/plugins/fundchannel.c b/plugins/fundchannel.c index 1faa4a47116e..6348706289dd 100644 --- a/plugins/fundchannel.c +++ b/plugins/fundchannel.c @@ -393,40 +393,16 @@ static struct command_result *json_fundchannel(struct command *cmd, { struct funding_req *fr = tal(cmd, struct funding_req); - /* For generating help, give new-style. */ - if (!params || !deprecated_apis || params->type == JSMN_ARRAY) { - if (!param(cmd, buf, params, - p_req("id", param_node_id, &fr->id), - p_req("amount", param_string_check_sat, &fr->funding_str), - p_opt("feerate", param_string, &fr->feerate_str), - p_opt_def("announce", param_bool, &fr->announce_channel, true), - p_opt_def("minconf", param_number, &fr->minconf, 1), - p_opt("utxos", param_string, &fr->utxo_str), - p_opt("push_msat", param_msat, &fr->push_msat), - NULL)) - return command_param_failed(); - } else { - const char *satoshi_str; - if (!param(cmd, buf, params, - p_req("id", param_node_id, &fr->id), - p_opt("amount", param_string, &fr->funding_str), - p_opt("satoshi", param_string, &satoshi_str), - p_opt("feerate", param_string, &fr->feerate_str), - p_opt_def("announce", param_bool, &fr->announce_channel, true), - p_opt_def("minconf", param_number, &fr->minconf, 1), - p_opt("utxos", param_string, &fr->utxo_str), - p_opt("push_msat", param_msat, &fr->push_msat), - NULL)) - return command_param_failed(); - - if (!fr->funding_str) { - if (satoshi_str) - fr->funding_str = satoshi_str; - else - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Need set 'amount' field"); - } - } + if (!param(cmd, buf, params, + p_req("id", param_node_id, &fr->id), + p_req("amount", param_string_check_sat, &fr->funding_str), + p_opt("feerate", param_string, &fr->feerate_str), + p_opt_def("announce", param_bool, &fr->announce_channel, true), + p_opt_def("minconf", param_number, &fr->minconf, 1), + p_opt("utxos", param_string, &fr->utxo_str), + p_opt("push_msat", param_msat, &fr->push_msat), + NULL)) + return command_param_failed(); fr->funding_all = streq(fr->funding_str, "all"); diff --git a/tests/test_connection.py b/tests/test_connection.py index 930a8bc232b9..aaa6b5a2ce36 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -6,7 +6,7 @@ from pyln.client import RpcError from utils import ( DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT, - SLOW_MACHINE, COMPAT, expected_features + SLOW_MACHINE, expected_features ) from bitcoin.core import CMutableTransaction, CMutableTxOut @@ -704,101 +704,6 @@ def test_shutdown_awaiting_lockin(node_factory, bitcoind): wait_for(lambda: l2.rpc.listpeers()['peers'] == []) -@unittest.skipIf(not COMPAT, "needs COMPAT=1") -def test_deprecated_fundchannel_start(node_factory, bitcoind): - """Test the deprecated old-style: - fundchannel {id} {satoshi} {feerate} {announce} - """ - l1, l2 = node_factory.get_nodes(2, opts=[{'allow-deprecated-apis': True}, {}]) - nodeid = l2.info['id'] - - # New style(object type) - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, amount=10**6, feerate='2000perkw', announce=True) - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, amount=10**6, announce=True) - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, amount=10**6, feerate='2000perkw') - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, amount=10**6) - - # Array type - l1.rpc.call('check', ['fundchannel_start', nodeid, 10**6, '2000perkw', True]) - l1.rpc.call('check', ['fundchannel_start', nodeid, 10**6, None, True]) - l1.rpc.call('check', ['fundchannel_start', nodeid, 10**6, 'slow']) - l1.rpc.call('check', ['fundchannel_start', nodeid, 10**6]) - - # No 'amount' nor 'satoshi'(array type) - with pytest.raises(RpcError, match=r'missing required parameter: amount'): - l1.rpc.call('check', ['fundchannel_start', nodeid]) - with pytest.raises(RpcError, match=r'.*should be a satoshi amount, not.*'): - l1.rpc.call('check', ['fundchannel_start', nodeid, '2000perkw']) - - # Old style(object type) - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, satoshi=10**6, feerate='2000perkw', announce=False) - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, satoshi=10**6, feerate='slow') - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, satoshi=10**6, announce=True) - l1.rpc.check(command_to_check='fundchannel_start', id=nodeid, satoshi=10**6) - - # For json object type when allow deprecated api, 'check' command can't find - # the error if we don't set 'amount' nor 'satoshi'. - l1.rpc.connect(nodeid, 'localhost', l2.port) - # No 'amount' nor 'satoshi'(object type) - with pytest.raises(RpcError, match=r'Need set \'amount\' field'): - l1.rpc.call('fundchannel_start', {'id': nodeid, 'feerate': '2000perkw'}) - - -@unittest.skipIf(not COMPAT, "needs COMPAT=1") -def test_deprecated_fundchannel(node_factory, bitcoind): - """Test the deprecated old-style: - fundchannel {id} {satoshi} {feerate} {announce} {minconf} {utxos} - """ - l1 = node_factory.get_node(options={'allow-deprecated-apis': True}) - - # FIXME: Use 'check' command after libplugin(C language) supports 'check' mode for command - nodes = node_factory.get_nodes(8) - amount = int(0.0005 * 10**8) - - for n in nodes: - l1.rpc.connect(n.info['id'], 'localhost', n.port) - - # Get 8 utxos - for i in range(8): - l1.fundwallet(10**8) - - bitcoind.generate_block(1) - sync_blockheight(bitcoind, [l1]) - wait_for(lambda: len(l1.rpc.listfunds()["outputs"]) == 8) - - # No 'amount' nor 'satoshi'(array type) - with pytest.raises(RpcError, match=r'missing required parameter: amount'): - l1.rpc.call('fundchannel', [nodes[0].info['id']]) - - with pytest.raises(RpcError, match=r'.* should be a satoshi amount, not .*'): - l1.rpc.call('fundchannel', [nodes[0].info['id'], 'slow']) - - def get_utxo(node): - """Get an unspent but confirmed output - """ - outputs = node.rpc.listfunds()['outputs'] - for o in outputs: - if o['status'] == 'confirmed': - return "{}:{}".format(o['txid'], o['output']) - - # Array type - l1.rpc.call('fundchannel', [nodes[0].info['id'], amount, '2000perkw', False, 1, [get_utxo(l1)]]) - l1.rpc.call('fundchannel', [nodes[1].info['id'], amount, '2000perkw', False, None, [get_utxo(l1)]]) - l1.rpc.call('fundchannel', [nodes[2].info['id'], amount, '2000perkw', None, None, [get_utxo(l1)]]) - l1.rpc.call('fundchannel', [nodes[3].info['id'], amount, '2000perkw', True, 1]) - - # No 'amount' nor 'satoshi'(object type) - with pytest.raises(RpcError, match=r'Need set \'amount\' field'): - l1.rpc.call('fundchannel', {'id': nodes[4].info['id'], 'feerate': '2000perkw'}) - - # Old style(object type) - l1.rpc.call('fundchannel', {'id': nodes[4].info['id'], 'satoshi': 'all', 'feerate': 'slow', - 'announce': True, 'minconf': 1, 'utxos': [get_utxo(l1)]}) - l1.rpc.call('fundchannel', {'id': nodes[5].info['id'], 'satoshi': 'all', 'feerate': 'slow', 'minconf': 1}) - l1.rpc.call('fundchannel', {'id': nodes[6].info['id'], 'satoshi': 'all', 'feerate': 'slow'}) - l1.rpc.call('fundchannel', {'id': nodes[7].info['id'], 'satoshi': 'all'}) - - def test_funding_change(node_factory, bitcoind): """Add some funds, fund a channel, and make sure we remember the change """ From 49e21538cc99e8f7340d174f02b853cc582dfd2a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 25 Mar 2020 14:09:40 +1030 Subject: [PATCH 3/5] fundchannel_start: We can't deprecate 'satoshi' here, since 'amount' wasn't sent So we can't tell people they should use amount, until v0.8.2 is released. Another 6 months before we can deprecated the 'satoshi' field here :( Fixes: d149ba2f3adef535b7ee55090bcc57837989863b Signed-off-by: Rusty Russell Changelog-Fixed: JSON: `fundchannel_start` returns `amount` even when deprecated APIs are enabled. Changelog-Deprecated: JSON: `fundchannel_start` `satoshi` field really deprecated now (use `amount`). --- plugins/fundchannel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/fundchannel.c b/plugins/fundchannel.c index 6348706289dd..a2c1ad884c2c 100644 --- a/plugins/fundchannel.c +++ b/plugins/fundchannel.c @@ -272,8 +272,7 @@ static struct command_result *fundchannel_start(struct command *cmd, if (deprecated_apis) json_add_string(req->js, "satoshi", fr->funding_str); - else - json_add_string(req->js, "amount", fr->funding_str); + json_add_string(req->js, "amount", fr->funding_str); if (fr->feerate_str) json_add_string(req->js, "feerate", fr->feerate_str); From 75dfe10b6ad57e73f4ba4baef4b74c58e6e12d3e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 25 Mar 2020 14:09:41 +1030 Subject: [PATCH 4/5] listnodes/listpeers/peer_connected: remove deprecated `globalfeatures` and `localfeatures` Signed-off-by: Rusty Russell Changelog-Removed: JSON: `listnodes` `globalfeatures` output (`features` since in 0.7.3). Changelog-Removed: JSON: `listpeers` `localfeatures` and `globalfeatures` output (`features` since in 0.7.3). Changelog-Removed: JSON: `peer_connected` hook `localfeatures` and `globalfeatures` output (`features` since in 0.7.3). --- lightningd/gossip_control.c | 3 --- lightningd/peer_control.c | 9 --------- 2 files changed, 12 deletions(-) diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index e7a53f92c252..58d2ee347bd6 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -267,9 +267,6 @@ static void json_getnodes_reply(struct subd *gossip UNUSED, const u8 *reply, nodes[i]->color, ARRAY_SIZE(nodes[i]->color)); json_add_u64(response, "last_timestamp", nodes[i]->last_timestamp); - if (deprecated_apis) - json_add_hex_talarr(response, "globalfeatures", - nodes[i]->features); json_add_hex_talarr(response, "features", nodes[i]->features); json_array_start(response, "addresses"); for (j=0; jaddresses); j++) { diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index d484a278638c..4b5f1bbb141f 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -798,10 +798,6 @@ peer_connected_serialize(struct peer_connected_hook_payload *payload, json_add_string( stream, "addr", type_to_string(stream, struct wireaddr_internal, &payload->addr)); - if (deprecated_apis) { - json_add_hex_talarr(stream, "globalfeatures", NULL); - json_add_hex_talarr(stream, "localfeatures", p->features); - } json_add_hex_talarr(stream, "features", p->features); json_object_end(stream); /* .peer */ } @@ -1124,11 +1120,6 @@ static void json_add_peer(struct lightningd *ld, struct wireaddr_internal, &p->addr)); json_array_end(response); - if (deprecated_apis) { - json_add_hex_talarr(response, "globalfeatures", NULL); - json_add_hex_talarr(response, "localfeatures", - p->features); - } json_add_hex_talarr(response, "features", p->features); } From 1649a72868264f4fdc6c8369e207203110fd2bb7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 25 Mar 2020 14:09:43 +1030 Subject: [PATCH 5/5] lightningd: remove json_close `force` option. Signed-off-by: Rusty Russell Changelog-Removed: JSON: `close` `force` parameter removed (deprecated in 0.7.2.1) --- lightningd/peer_control.c | 196 ++------------------------------------ tests/test_closing.py | 35 +------ 2 files changed, 10 insertions(+), 221 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 4b5f1bbb141f..6681d35502c3 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1218,61 +1218,6 @@ command_find_channel(struct command *cmd, } } -/* param_tok_timeout_or_force and param_tok_dest_or_timeout are made to - * support 'check' command for array type parameters. - * - * But the parameters are mixed with the old style and new style(like - * close {id} {force} {destination}), 'check' is unable to tell the error. - */ -static struct command_result *param_tok_timeout_or_force( - struct command *cmd, const char *name, - const char *buffer, const jsmntok_t * tok, - const jsmntok_t **out) -{ - if (command_check_only(cmd)) { - unsigned int timeout; - bool force; - if (!json_to_bool(buffer, tok, &force)) { - if (!json_to_number(buffer, tok, &timeout)) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Expected unilerataltimeout to be a number"); - } - return NULL; - } - - *out = tok; - return NULL; -} - -static struct command_result *param_tok_dest_or_timeout( - struct command *cmd, const char *name, - const char *buffer, const jsmntok_t * tok, - const jsmntok_t **out) -{ - if (command_check_only(cmd)) { - unsigned int timeout; - const u8 *script; - if (!json_to_number(buffer, tok, &timeout)) { - enum address_parse_result res; - res = json_to_address_scriptpubkey(cmd, - chainparams, - buffer, tok, - &script); - if (res == ADDRESS_PARSE_UNRECOGNIZED) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Could not parse destination address"); - else if (res == ADDRESS_PARSE_WRONG_NETWORK) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Destination address is not on network %s", - chainparams->network_name); - } - return NULL; - } - - *out = tok; - return NULL; -} - static struct command_result *json_close(struct command *cmd, const char *buffer, const jsmntok_t *obj UNNEEDED, @@ -1285,140 +1230,17 @@ static struct command_result *json_close(struct command *cmd, bool force = true; bool do_timeout; const u8 *close_to_script = NULL; - unsigned int *old_timeout; - bool *old_force, close_script_set; - - /* For generating help, give new-style. */ - if (!params || !deprecated_apis) { - if (!param(cmd, buffer, params, - p_req("id", param_tok, &idtok), - p_opt_def("unilateraltimeout", param_number, - &timeout, 48 * 3600), - p_opt("destination", param_bitcoin_address, - &close_to_script), - NULL)) - return command_param_failed(); - do_timeout = (*timeout != 0); - } else if (params->type == JSMN_ARRAY) { - const jsmntok_t *firsttok, *secondtok; - bool old_style; - - /* Could be new or old style; get as tok. */ - if (!param(cmd, buffer, params, - p_req("id", param_tok, &idtok), - p_opt("unilateraltimeout_or_force", - param_tok_timeout_or_force, &firsttok), - p_opt("destination_or_timeout", - param_tok_dest_or_timeout, &secondtok), - NULL)) - return command_param_failed(); - - if (firsttok) { - /* old-style force bool? */ - if (json_to_bool(buffer, firsttok, &force)) { - old_style = true; - timeout = tal(cmd, unsigned int); - - /* Old default timeout */ - if (!secondtok) - *timeout = 30; - else { - if (!json_to_number(buffer, secondtok, timeout)) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "close: Expected timeout to be a number. " - "This argument ordering is deprecated!"); - } - /* New-style timeout */ - } else { - old_style = false; - timeout = tal(cmd, unsigned int); - if (!json_to_number(buffer, firsttok, timeout)) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Expected unilerataltimeout to be a number"); - - if (secondtok) { - enum address_parse_result res; - res = json_to_address_scriptpubkey(cmd, - chainparams, - buffer, secondtok, - &close_to_script); - if (res == ADDRESS_PARSE_UNRECOGNIZED) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Could not parse destination address"); - else if (res == ADDRESS_PARSE_WRONG_NETWORK) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Destination address is not on network %s", - chainparams->network_name); - } - } - } else if (secondtok) { - unsigned int *tmp_timeout = tal(tmpctx, unsigned int); - - if (json_to_number(buffer, secondtok, tmp_timeout)) { - old_style = true; - timeout = tal_steal(cmd, tmp_timeout); - } else { - old_style = false; - enum address_parse_result res; - - res = json_to_address_scriptpubkey(cmd, - chainparams, - buffer, secondtok, - &close_to_script); - if (res == ADDRESS_PARSE_UNRECOGNIZED) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Could not parse destination address"); - else if (res == ADDRESS_PARSE_WRONG_NETWORK) - return command_fail(cmd, JSONRPC2_INVALID_PARAMS, - "Destination address is not on network %s", - chainparams->network_name); - } - } else - old_style = false; + bool close_script_set; - /* If they didn't specify timeout, it's the (new) default */ - if (!timeout) { - timeout = tal(cmd, unsigned int); - *timeout = 48 * 3600; - } - /* New style: do_timeout unless it's 0 */ - if (!old_style) - do_timeout = (*timeout != 0); - else - do_timeout = true; - } else { - /* Named parameters are easy to distinguish */ - if (!param(cmd, buffer, params, - p_req("id", param_tok, &idtok), - p_opt_def("unilateraltimeout", param_number, - &timeout, 48 * 3600), - p_opt("destination", param_bitcoin_address, - &close_to_script), - p_opt("force", param_bool, &old_force), - p_opt("timeout", param_number, &old_timeout), - NULL)) - return command_param_failed(); - - /* Old style has lower priority. */ - if (!close_to_script) { - /* Old style. */ - if (old_timeout) { - *timeout = *old_timeout; - } - if (old_force) { - /* Use old default */ - if (!old_timeout) - *timeout = 30; - force = *old_force; - } - } + if (!param(cmd, buffer, params, + p_req("id", param_tok, &idtok), + p_opt_def("unilateraltimeout", param_number, &timeout, + 48 * 3600), + p_opt("destination", param_bitcoin_address, &close_to_script), + NULL)) + return command_param_failed(); - /* New style: do_timeout unless it's 0 */ - if (!old_timeout && !old_force) - do_timeout = (*timeout != 0); - else - do_timeout = true; - } + do_timeout = (*timeout != 0); peer = peer_from_json(cmd->ld, buffer, idtok); if (peer) diff --git a/tests/test_closing.py b/tests/test_closing.py index 13ab6b1441e5..e91d99acbccd 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -3,7 +3,7 @@ from pyln.client import RpcError from utils import ( only_one, sync_blockheight, wait_for, DEVELOPER, TIMEOUT, VALGRIND, - SLOW_MACHINE, COMPAT + SLOW_MACHINE ) import os @@ -360,39 +360,6 @@ def test_closing_specified_destination(node_factory, bitcoind, chainparams): assert 1 == bitcoind.rpc.gettxout(closetx, output_num1)['confirmations'] -@unittest.skipIf(not COMPAT, "needs COMPAT=1") -def test_deprecated_closing_compat(node_factory, bitcoind, chainparams): - """ The old-style close command is: - close {id} {force} {timeout} - """ - l1, l2 = node_factory.get_nodes(2, opts=[{'allow-deprecated-apis': True}, {}]) - addr = chainparams['example_addr'] - nodeid = l2.info['id'] - - l1.rpc.check(command_to_check='close', id=nodeid) - # New-style - l1.rpc.check(command_to_check='close', id=nodeid, unilateraltimeout=10, destination=addr) - l1.rpc.check(command_to_check='close', id=nodeid, unilateraltimeout=0) - l1.rpc.check(command_to_check='close', id=nodeid, destination=addr) - # Old-style - l1.rpc.check(command_to_check='close', id=nodeid, force=False) - l1.rpc.check(command_to_check='close', id=nodeid, force=False, timeout=10) - l1.rpc.check(command_to_check='close', id=nodeid, timeout=10) - - l1.rpc.call('check', ['close', nodeid]) - # Array(new-style) - l1.rpc.call('check', ['close', nodeid, 10]) - l1.rpc.call('check', ['close', nodeid, 0, addr]) - l1.rpc.call('check', ['close', nodeid, None, addr]) - # Array(old-style) - l1.rpc.call('check', ['close', nodeid, True, 10]) - l1.rpc.call('check', ['close', nodeid, False]) - l1.rpc.call('check', ['close', nodeid, None, 10]) - # Not new-style nor old-style - with pytest.raises(RpcError, match=r'Expected unilerataltimeout to be a number'): - l1.rpc.call('check', ['close', nodeid, "Given enough eyeballs, all bugs are shallow."]) - - def closing_fee(node_factory, bitcoind, chainparams, opts): rate = opts['funder_feerate_per_kw'] funder = node_factory.get_node(feerates=(rate, rate, rate))