diff --git a/doc/lightningd-config.5.txt b/doc/lightningd-config.5.txt index fea93b9edbd5..c4673beceed2 100644 --- a/doc/lightningd-config.5.txt +++ b/doc/lightningd-config.5.txt @@ -150,15 +150,16 @@ Lightning node customization options: Lightning channel and HTLC options: -*locktime-blocks*='BLOCKS':: - How long we need to spot an outdated close attempt, which is also - how long the peer would need to wait if they perform a unilateral - close. +*watchtime-blocks*='BLOCKS':: + How long we need to spot an outdated close attempt: on opening a channel + we tell our peer that this is how long they'll have to wait if they perform + a unilateral close. *max-locktime-blocks*='BLOCKS':: - The longest we'll ever allow a peer to hold up payments, in the worst - case. If they ask for longer, we'll refuse to create a channel, - and if an HTLC asks for longer, we'll refuse it. + The longest our funds can be delayed (ie. the longest *watchtime-blocks* + our peer can ask for, and also the longest HTLC timeout we will accept). + If our peer asks for longer, we'll refuse to create a channel, and if an + HTLC asks for longer, we'll refuse it. *funding-confirms*='BLOCKS':: Confirmations required for the funding transaction when the other side diff --git a/lightningd/options.c b/lightningd/options.c index 6128b9b58bd6..524fc2153bfc 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -298,6 +298,14 @@ static char *opt_set_anchor(const char *arg, u32 *u) 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_noarg("--daemon", opt_set_bool, &ld->daemon, @@ -305,9 +313,11 @@ static void config_register_opts(struct lightningd *ld) opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool, &ld->config.ignore_fee_limits, "(DANGEROUS) allow peer to set any feerate"); - opt_register_arg("--locktime-blocks", opt_set_u32, opt_show_u32, + 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 a peer can lock up our funds"); @@ -891,7 +901,9 @@ static void add_config(struct lightningd *ld, abort(); } } else if (opt->type & OPT_HASARG) { - if (opt->show) { + if (opt->desc == opt_hidden) { + /* Ignore hidden options (deprecated) */ + } else if (opt->show) { char *buf = tal_arr(name0, char, OPT_SHOW_LEN+1); opt->show(buf, opt->u.carg); diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index eeb057f2bbed..62f1a11f83ca 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -1286,7 +1286,7 @@ def fund_from_to_payer(lsrc, ldst, lpayer): def test_bad_opening(self): # l1 asks for a too-long locktime - l1 = self.node_factory.get_node(options={'locktime-blocks': 100}) + l1 = self.node_factory.get_node(options={'watchtime-blocks': 100}) l2 = self.node_factory.get_node(options={'max-locktime-blocks': 99}) ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.port) @@ -1617,7 +1617,7 @@ def test_onchain_first_commit(self): disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail'] l1 = self.node_factory.get_node(disconnect=disconnects) # Make locktime different, as we once had them reversed! - l2 = self.node_factory.get_node(options={'locktime-blocks': 10}) + l2 = self.node_factory.get_node(options={'watchtime-blocks': 10}) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) @@ -1701,7 +1701,7 @@ def test_onchain_unwatch(self): @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_onchaind_replay(self): disconnects = ['+WIRE_REVOKE_AND_ACK', 'permfail'] - options = {'locktime-blocks': 201, 'cltv-delta': 101} + options = {'watchtime-blocks': 201, 'cltv-delta': 101} l1 = self.node_factory.get_node(options=options, disconnect=disconnects) l2 = self.node_factory.get_node(options=options) @@ -3624,7 +3624,7 @@ def test_funding_fail(self): # Previous runs with same bitcoind can leave funds! l1 = self.node_factory.get_node(random_hsm=True) max_locktime = 5 * 6 * 24 - l2 = self.node_factory.get_node(options={'locktime-blocks': max_locktime + 1}) + l2 = self.node_factory.get_node(options={'watchtime-blocks': max_locktime + 1}) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) funds = 1000000 @@ -3643,7 +3643,7 @@ def test_funding_fail(self): assert l2.rpc.listpeers()['peers'][0]['connected'] # Restart l2 without ridiculous locktime. - del l2.daemon.opts['locktime-blocks'] + del l2.daemon.opts['watchtime-blocks'] l2.restart() l1.rpc.connect(l2.info['id'], 'localhost', l2.port) diff --git a/tests/utils.py b/tests/utils.py index 98dcabc17bd9..6557426505be 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -22,7 +22,7 @@ "log-level": "debug", "cltv-delta": 6, "cltv-final": 5, - "locktime-blocks": 5, + "watchtime-blocks": 5, "rescan": 1, }