mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
fundchannel/fundchannel_start: remove deprecated satoshi
parameter
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Removed: JSON: `fundchannel` and `fundchannel_start` `satoshi` parameter removed (renamed to `amount` in 0.7.3).
This commit is contained in:
parent
0007af0a4e
commit
75838341a7
3 changed files with 20 additions and 167 deletions
|
@ -1133,8 +1133,6 @@ 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),
|
||||
|
@ -1144,32 +1142,6 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
|
|||
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 (amount_sat_greater(*amount, chainparams->max_funding))
|
||||
return command_fail(cmd, FUND_MAX_EXCEEDED,
|
||||
|
|
|
@ -393,8 +393,6 @@ 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),
|
||||
|
@ -405,28 +403,6 @@ static struct command_result *json_fundchannel(struct command *cmd,
|
|||
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");
|
||||
}
|
||||
}
|
||||
|
||||
fr->funding_all = streq(fr->funding_str, "all");
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from flaky import flaky # noqa: F401
|
|||
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
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue