locktime-blocks: rename to watchtime-blocks.

And clarify the descriptions for end users.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-05-17 14:16:22 +09:30
parent babfddeb3e
commit a2dc3d02a8
4 changed files with 28 additions and 15 deletions

View File

@@ -150,15 +150,16 @@ Lightning node customization options:
Lightning channel and HTLC options: Lightning channel and HTLC options:
*locktime-blocks*='BLOCKS':: *watchtime-blocks*='BLOCKS'::
How long we need to spot an outdated close attempt, which is also How long we need to spot an outdated close attempt: on opening a channel
how long the peer would need to wait if they perform a unilateral we tell our peer that this is how long they'll have to wait if they perform
close. a unilateral close.
*max-locktime-blocks*='BLOCKS':: *max-locktime-blocks*='BLOCKS'::
The longest we'll ever allow a peer to hold up payments, in the worst The longest our funds can be delayed (ie. the longest *watchtime-blocks*
case. If they ask for longer, we'll refuse to create a channel, our peer can ask for, and also the longest HTLC timeout we will accept).
and if an HTLC asks for longer, we'll refuse it. 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':: *funding-confirms*='BLOCKS'::
Confirmations required for the funding transaction when the other side Confirmations required for the funding transaction when the other side

View File

@@ -298,6 +298,14 @@ static char *opt_set_anchor(const char *arg, u32 *u)
return opt_set_u32(arg, 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) static void config_register_opts(struct lightningd *ld)
{ {
opt_register_noarg("--daemon", opt_set_bool, &ld->daemon, 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, opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool,
&ld->config.ignore_fee_limits, &ld->config.ignore_fee_limits,
"(DANGEROUS) allow peer to set any feerate"); "(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, &ld->config.locktime_blocks,
"Blocks before peer can unilaterally spend funds"); "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, opt_register_arg("--max-locktime-blocks", opt_set_u32, opt_show_u32,
&ld->config.locktime_max, &ld->config.locktime_max,
"Maximum blocks a peer can lock up our funds"); "Maximum blocks a peer can lock up our funds");
@@ -891,7 +901,9 @@ static void add_config(struct lightningd *ld,
abort(); abort();
} }
} else if (opt->type & OPT_HASARG) { } 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); char *buf = tal_arr(name0, char, OPT_SHOW_LEN+1);
opt->show(buf, opt->u.carg); opt->show(buf, opt->u.carg);

View File

@@ -1286,7 +1286,7 @@ class LightningDTests(BaseLightningDTests):
def test_bad_opening(self): def test_bad_opening(self):
# l1 asks for a too-long locktime # 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}) l2 = self.node_factory.get_node(options={'max-locktime-blocks': 99})
ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.port) ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -1617,7 +1617,7 @@ class LightningDTests(BaseLightningDTests):
disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail'] disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail']
l1 = self.node_factory.get_node(disconnect=disconnects) l1 = self.node_factory.get_node(disconnect=disconnects)
# Make locktime different, as we once had them reversed! # 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) l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -1701,7 +1701,7 @@ class LightningDTests(BaseLightningDTests):
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
def test_onchaind_replay(self): def test_onchaind_replay(self):
disconnects = ['+WIRE_REVOKE_AND_ACK', 'permfail'] 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) l1 = self.node_factory.get_node(options=options, disconnect=disconnects)
l2 = self.node_factory.get_node(options=options) l2 = self.node_factory.get_node(options=options)
@@ -3624,7 +3624,7 @@ class LightningDTests(BaseLightningDTests):
# Previous runs with same bitcoind can leave funds! # Previous runs with same bitcoind can leave funds!
l1 = self.node_factory.get_node(random_hsm=True) l1 = self.node_factory.get_node(random_hsm=True)
max_locktime = 5 * 6 * 24 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) l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
funds = 1000000 funds = 1000000
@@ -3643,7 +3643,7 @@ class LightningDTests(BaseLightningDTests):
assert l2.rpc.listpeers()['peers'][0]['connected'] assert l2.rpc.listpeers()['peers'][0]['connected']
# Restart l2 without ridiculous locktime. # Restart l2 without ridiculous locktime.
del l2.daemon.opts['locktime-blocks'] del l2.daemon.opts['watchtime-blocks']
l2.restart() l2.restart()
l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.rpc.connect(l2.info['id'], 'localhost', l2.port)

View File

@@ -22,7 +22,7 @@ LIGHTNINGD_CONFIG = {
"log-level": "debug", "log-level": "debug",
"cltv-delta": 6, "cltv-delta": 6,
"cltv-final": 5, "cltv-final": 5,
"locktime-blocks": 5, "watchtime-blocks": 5,
"rescan": 1, "rescan": 1,
} }