Skip to content

Commit f20beed

Browse files
committed
lightningd: make option_static_remotekey compulsory.
As suggested in lightning/bolts#1092. We still support channels opened without it, but you can no longer open new ones without it. Signed-off-by: Rusty Russell <[email protected]> Changelog-Changed: Protocol: `option_gossip_queries` is now required (advertized by all but 16 nodes)
1 parent a722d90 commit f20beed

File tree

6 files changed

+92
-47
lines changed

6 files changed

+92
-47
lines changed

lightningd/lightningd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ static struct feature_set *default_features(const tal_t *ctx)
887887
OPTIONAL_FEATURE(OPT_BASIC_MPP),
888888
OPTIONAL_FEATURE(OPT_LARGE_CHANNELS),
889889
OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES_EX),
890-
OPTIONAL_FEATURE(OPT_STATIC_REMOTEKEY),
890+
COMPULSORY_FEATURE(OPT_STATIC_REMOTEKEY),
891891
OPTIONAL_FEATURE(OPT_SHUTDOWN_ANYSEGWIT),
892892
OPTIONAL_FEATURE(OPT_PAYMENT_METADATA),
893893
OPTIONAL_FEATURE(OPT_SCID_ALIAS),

tests/test_connection.py

Lines changed: 76 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,15 +3575,19 @@ def test_channel_features(node_factory, bitcoind, anchors):
35753575

35763576
def test_nonstatic_channel(node_factory, bitcoind):
35773577
"""Smoke test for a channel without option_static_remotekey"""
3578-
l1, l2 = node_factory.line_graph(2,
3579-
opts=[{},
3580-
# needs at least 1, 7 and 15 to connect
3581-
# (and 9 is a dependent)
3582-
{'dev-force-features': '1,7,9,15////////'}])
3578+
l1, l2 = node_factory.get_nodes(2,
3579+
# This forces us to allow send/recv of non-static-remotekey!
3580+
opts={'dev-any-channel-type': None})
3581+
l1.fundwallet(2000000)
3582+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3583+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3584+
bitcoind.generate_block(1, wait_for_mempool=1)
3585+
35833586
chan = only_one(l1.rpc.listpeerchannels()['channels'])
35843587
assert 'option_static_remotekey' not in chan['features']
35853588
assert 'option_anchor' not in chan['features']
35863589
assert 'option_anchors_zero_fee_htlc_tx' not in chan['features']
3590+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
35873591

35883592
l1.pay(l2, 1000)
35893593
l1.rpc.close(l2.info['id'])
@@ -3690,12 +3694,20 @@ def test_openchannel_init_alternate(node_factory, executor):
36903694

36913695
def test_upgrade_statickey(node_factory, executor):
36923696
"""l1 doesn't have option_static_remotekey, l2 offers it."""
3693-
l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True,
3694-
'dev-force-features': ["-13"],
3695-
'experimental-upgrade-protocol': None},
3696-
{'may_reconnect': True,
3697-
'experimental-upgrade-protocol': None}])
3697+
l1, l2 = node_factory.get_nodes(2, opts=[{'may_reconnect': True,
3698+
'experimental-upgrade-protocol': None,
3699+
# This forces us to allow sending non-static-remotekey!
3700+
'dev-any-channel-type': None},
3701+
{'may_reconnect': True,
3702+
# This forces us to accept non-static-remotekey!
3703+
'dev-any-channel-type': None,
3704+
'experimental-upgrade-protocol': None}])
36983705

3706+
l1.fundwallet(2000000)
3707+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3708+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3709+
3710+
# Now reconnect.
36993711
l1.rpc.disconnect(l2.info['id'], force=True)
37003712
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
37013713

@@ -3720,15 +3732,22 @@ def test_upgrade_statickey(node_factory, executor):
37203732

37213733
def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
37223734
"""We test penalty before/after, and unilateral before/after"""
3723-
l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True,
3724-
'dev-no-reconnect': None,
3725-
'dev-force-features': ["-13"],
3726-
'experimental-upgrade-protocol': None,
3727-
# We try to cheat!
3728-
'allow_broken_log': True},
3729-
{'may_reconnect': True,
3730-
'dev-no-reconnect': None,
3731-
'experimental-upgrade-protocol': None}])
3735+
l1, l2 = node_factory.get_nodes(2, opts=[{'may_reconnect': True,
3736+
'experimental-upgrade-protocol': None,
3737+
# This forces us to allow sending non-static-remotekey!
3738+
'dev-any-channel-type': None,
3739+
# We try to cheat!
3740+
'allow_broken_log': True},
3741+
{'may_reconnect': True,
3742+
# This forces us to allow non-static-remotekey!
3743+
'dev-any-channel-type': None,
3744+
'experimental-upgrade-protocol': None}])
3745+
3746+
l1.fundwallet(FUNDAMOUNT + 1000)
3747+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3748+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3749+
bitcoind.generate_block(1, wait_for_mempool=1)
3750+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
37323751

37333752
# TEST 1: Cheat from pre-upgrade.
37343753
tx = l1.rpc.dev_sign_last_tx(l2.info['id'])['tx']
@@ -3766,12 +3785,17 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
37663785
wait_for(lambda: l2.rpc.listpeerchannels()['channels'] == [])
37673786

37683787
# TEST 2: Cheat from post-upgrade.
3769-
node_factory.join_nodes([l1, l2])
3788+
l1.fundwallet(FUNDAMOUNT + 1000)
3789+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3790+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3791+
37703792
l1.rpc.disconnect(l2.info['id'], force=True)
37713793
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
37723794

37733795
l1.daemon.wait_for_log('option_static_remotekey enabled at 1/1')
37743796
l2.daemon.wait_for_log('option_static_remotekey enabled at 1/1')
3797+
bitcoind.generate_block(1, wait_for_mempool=1)
3798+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
37753799

37763800
l1.pay(l2, 1000000)
37773801

@@ -3793,7 +3817,11 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
37933817
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)
37943818

37953819
# TEST 3: Unilateral close from pre-upgrade
3796-
node_factory.join_nodes([l1, l2])
3820+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3821+
l1.fundwallet(FUNDAMOUNT + 1000)
3822+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3823+
bitcoind.generate_block(1, wait_for_mempool=1)
3824+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
37973825

37983826
# Give them both something for onchain close.
37993827
l1.pay(l2, 1000000)
@@ -3824,12 +3852,16 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
38243852
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)
38253853

38263854
# TEST 4: Unilateral close from post-upgrade
3827-
node_factory.join_nodes([l1, l2])
3855+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3856+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
38283857

38293858
l1.rpc.disconnect(l2.info['id'], force=True)
38303859
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
38313860
l1.daemon.wait_for_log('option_static_remotekey enabled at 1/1')
38323861

3862+
bitcoind.generate_block(1, wait_for_mempool=1)
3863+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
3864+
38333865
# Move to static_remotekey.
38343866
l1.pay(l2, 1000000)
38353867

@@ -3859,20 +3891,28 @@ def test_upgrade_statickey_fail(node_factory, executor, bitcoind):
38593891
l2_disconnects = ['-WIRE_REVOKE_AND_ACK',
38603892
'-WIRE_COMMITMENT_SIGNED']
38613893

3862-
l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True,
3863-
'dev-no-reconnect': None,
3864-
'disconnect': l1_disconnects,
3865-
'experimental-upgrade-protocol': None,
3866-
'dev-force-features': ["-13"],
3867-
# Don't have feerate changes!
3868-
'feerates': (7500, 7500, 7500, 7500)},
3869-
{'may_reconnect': True,
3870-
'dev-no-reconnect': None,
3871-
'experimental-upgrade-protocol': None,
3872-
'disconnect': l2_disconnects,
3873-
'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py'),
3874-
'hold-time': 10000,
3875-
'hold-result': 'fail'}])
3894+
l1, l2 = node_factory.get_nodes(2, opts=[{'may_reconnect': True,
3895+
'dev-no-reconnect': None,
3896+
'disconnect': l1_disconnects,
3897+
# This allows us to send non-static-remotekey!
3898+
'dev-any-channel-type': None,
3899+
'experimental-upgrade-protocol': None,
3900+
# Don't have feerate changes!
3901+
'feerates': (7500, 7500, 7500, 7500)},
3902+
{'may_reconnect': True,
3903+
'dev-no-reconnect': None,
3904+
'experimental-upgrade-protocol': None,
3905+
# This forces us to accept non-static-remotekey!
3906+
'dev-any-channel-type': None,
3907+
'disconnect': l2_disconnects,
3908+
'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py'),
3909+
'hold-time': 10000,
3910+
'hold-result': 'fail'}])
3911+
l1.fundwallet(FUNDAMOUNT + 1000)
3912+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3913+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3914+
bitcoind.generate_block(1, wait_for_mempool=1)
3915+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
38763916

38773917
# This HTLC will fail
38783918
l1.rpc.sendpay([{'amount_msat': 1000, 'id': l2.info['id'], 'delay': 5, 'channel': first_scid(l1, l2)}], '00' * 32, payment_secret='00' * 32)

tests/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ def test_list_features_only(node_factory):
22482248
'option_gossip_queries/even',
22492249
'option_var_onion_optin/even',
22502250
'option_gossip_queries_ex/odd',
2251-
'option_static_remotekey/odd',
2251+
'option_static_remotekey/even',
22522252
'option_payment_secret/even',
22532253
'option_basic_mpp/odd',
22542254
'option_support_large_channel/odd',

tests/test_opening.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,24 +2599,22 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
25992599
ZEROCONF = 50
26002600

26012601
for zeroconf in ([], [ZEROCONF]):
2602-
for ctype in ([],
2603-
[STATIC_REMOTEKEY],
2602+
for ctype in ([STATIC_REMOTEKEY],
26042603
[ANCHORS_ZERO_FEE_HTLC_TX, STATIC_REMOTEKEY]):
26052604
l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT,
26062605
channel_type=ctype + zeroconf)
26072606
l1.rpc.fundchannel_cancel(l2.info['id'])
26082607
# FIXME: Check type is actually correct!
26092608

26102609
# Zeroconf is refused to l4.
2611-
for ctype in ([],
2612-
[STATIC_REMOTEKEY],
2610+
for ctype in ([STATIC_REMOTEKEY],
26132611
[ANCHORS_ZERO_FEE_HTLC_TX, STATIC_REMOTEKEY]):
26142612
with pytest.raises(RpcError, match=r'not on our allowlist'):
26152613
l1.rpc.fundchannel_start(l4.info['id'], FUNDAMOUNT,
26162614
channel_type=ctype + [ZEROCONF])
26172615

26182616
psbt = l1.rpc.fundpsbt(FUNDAMOUNT - 1000, '253perkw', 250, reserve=0)['psbt']
2619-
for ctype in ([], [12], [22, 12]):
2617+
for ctype in ([12], [22, 12]):
26202618
cid = l1.rpc.openchannel_init(l3.info['id'], FUNDAMOUNT - 1000, psbt, channel_type=ctype)['channel_id']
26212619
l1.rpc.openchannel_abort(cid)
26222620

@@ -2627,6 +2625,13 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
26272625
with pytest.raises(RpcError, match=r'channel_type not supported'):
26282626
l1.rpc.openchannel_init(l3.info['id'], FUNDAMOUNT - 1000, psbt, channel_type=[STATIC_REMOTEKEY, ANCHORS_OLD])
26292627

2628+
# We need static_remotekey now, too
2629+
with pytest.raises(RpcError, match=r'channel_type not supported'):
2630+
l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT, channel_type=[])
2631+
2632+
with pytest.raises(RpcError, match=r'channel_type not supported'):
2633+
l1.rpc.openchannel_init(l3.info['id'], FUNDAMOUNT - 1000, psbt, channel_type=[])
2634+
26302635
# l1 will try, with dev-any-channel-type, l2 will reject.
26312636
l1.stop()
26322637
l1.daemon.opts['dev-any-channel-type'] = None
@@ -2635,7 +2640,7 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
26352640

26362641
with pytest.raises(RpcError, match=r'They sent ERROR .*: You gave bad parameters: Did not support channel_type 12,20'):
26372642
l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT, channel_type=[STATIC_REMOTEKEY, ANCHORS_OLD])
2638-
2643+
26392644
# Now make l2 accept it!
26402645
l2.stop()
26412646
l2.daemon.opts['dev-any-channel-type'] = None

tests/test_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ def test_plugin_feature_announce(node_factory):
16601660

16611661
# Check the featurebits we've set in the `init` message from
16621662
# feature-test.py.
1663-
assert l1.daemon.is_in_log(r'\[OUT\] 001000022100....{}'
1663+
assert l1.daemon.is_in_log(r'\[OUT\] 001000021100....{}'
16641664
.format(expected_peer_features(extra=[201])))
16651665

16661666
# Check the invoice featurebit we set in feature-test.py

tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def hex_bits(features):
3636

3737
def expected_peer_features(extra=[]):
3838
"""Return the expected peer features hexstring for this configuration"""
39-
features = [0, 5, 6, 8, 11, 13, 14, 17, 19, 25, 27, 45, 47, 51]
39+
features = [0, 5, 6, 8, 11, 12, 14, 17, 19, 25, 27, 45, 47, 51]
4040
if EXPERIMENTAL_DUAL_FUND:
4141
# option_dual_fund
4242
features += [29]
@@ -50,7 +50,7 @@ def expected_peer_features(extra=[]):
5050
# features for the 'node' and the 'peer' feature sets
5151
def expected_node_features(extra=[]):
5252
"""Return the expected node features hexstring for this configuration"""
53-
features = [0, 5, 6, 8, 11, 13, 14, 17, 19, 25, 27, 45, 47, 51, 55]
53+
features = [0, 5, 6, 8, 11, 12, 14, 17, 19, 25, 27, 45, 47, 51, 55]
5454
if EXPERIMENTAL_DUAL_FUND:
5555
# option_dual_fund
5656
features += [29]

0 commit comments

Comments
 (0)