Skip to content

Commit

Permalink
locktime-blocks: rename to watchtime-blocks.
Browse files Browse the repository at this point in the history
And clarify the descriptions for end users.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed May 20, 2018
1 parent babfdde commit a2dc3d0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
15 changes: 8 additions & 7 deletions doc/lightningd-config.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,26 @@ 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,
"Run in the background, suppress stdout/stderr");
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");
Expand Down Expand Up @@ -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);

Expand Down
10 changes: 5 additions & 5 deletions tests/test_lightningd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"log-level": "debug",
"cltv-delta": 6,
"cltv-final": 5,
"locktime-blocks": 5,
"watchtime-blocks": 5,
"rescan": 1,
}

Expand Down

0 comments on commit a2dc3d0

Please sign in to comment.