Skip to content

Commit 1eca73a

Browse files
rustyrussellgudnuf
authored andcommitted
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 d095b19 commit 1eca73a

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
@@ -896,7 +896,7 @@ static struct feature_set *default_features(const tal_t *ctx)
896896
OPTIONAL_FEATURE(OPT_BASIC_MPP),
897897
OPTIONAL_FEATURE(OPT_LARGE_CHANNELS),
898898
OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES_EX),
899-
OPTIONAL_FEATURE(OPT_STATIC_REMOTEKEY),
899+
COMPULSORY_FEATURE(OPT_STATIC_REMOTEKEY),
900900
OPTIONAL_FEATURE(OPT_SHUTDOWN_ANYSEGWIT),
901901
OPTIONAL_FEATURE(OPT_PAYMENT_METADATA),
902902
OPTIONAL_FEATURE(OPT_SCID_ALIAS),

tests/test_connection.py

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

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

35913595
l1.pay(l2, 1000)
35923596
l1.rpc.close(l2.info['id'])
@@ -3693,12 +3697,20 @@ def test_openchannel_init_alternate(node_factory, executor):
36933697

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

3709+
l1.fundwallet(2000000)
3710+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3711+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3712+
3713+
# Now reconnect.
37023714
l1.rpc.disconnect(l2.info['id'], force=True)
37033715
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
37043716

@@ -3723,15 +3735,22 @@ def test_upgrade_statickey(node_factory, executor):
37233735

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

37363755
# TEST 1: Cheat from pre-upgrade.
37373756
tx = l1.rpc.dev_sign_last_tx(l2.info['id'])['tx']
@@ -3769,12 +3788,17 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
37693788
wait_for(lambda: l2.rpc.listpeerchannels()['channels'] == [])
37703789

37713790
# TEST 2: Cheat from post-upgrade.
3772-
node_factory.join_nodes([l1, l2])
3791+
l1.fundwallet(FUNDAMOUNT + 1000)
3792+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3793+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
3794+
37733795
l1.rpc.disconnect(l2.info['id'], force=True)
37743796
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
37753797

37763798
l1.daemon.wait_for_log('option_static_remotekey enabled at 1/1')
37773799
l2.daemon.wait_for_log('option_static_remotekey enabled at 1/1')
3800+
bitcoind.generate_block(1, wait_for_mempool=1)
3801+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
37783802

37793803
l1.pay(l2, 1000000)
37803804

@@ -3796,7 +3820,11 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
37963820
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)
37973821

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

38013829
# Give them both something for onchain close.
38023830
l1.pay(l2, 1000000)
@@ -3827,12 +3855,16 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
38273855
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)
38283856

38293857
# TEST 4: Unilateral close from post-upgrade
3830-
node_factory.join_nodes([l1, l2])
3858+
l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port)
3859+
l1.rpc.fundchannel(l2.info['id'], 'all', channel_type=[])
38313860

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

3865+
bitcoind.generate_block(1, wait_for_mempool=1)
3866+
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
3867+
38363868
# Move to static_remotekey.
38373869
l1.pay(l2, 1000000)
38383870

@@ -3862,20 +3894,28 @@ def test_upgrade_statickey_fail(node_factory, executor, bitcoind):
38623894
l2_disconnects = ['-WIRE_REVOKE_AND_ACK',
38633895
'-WIRE_COMMITMENT_SIGNED']
38643896

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

38803920
# This HTLC will fail
38813921
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
@@ -2608,24 +2608,22 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
26082608
ZEROCONF = 50
26092609

26102610
for zeroconf in ([], [ZEROCONF]):
2611-
for ctype in ([],
2612-
[STATIC_REMOTEKEY],
2611+
for ctype in ([STATIC_REMOTEKEY],
26132612
[ANCHORS_ZERO_FEE_HTLC_TX, STATIC_REMOTEKEY]):
26142613
l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT,
26152614
channel_type=ctype + zeroconf)
26162615
l1.rpc.fundchannel_cancel(l2.info['id'])
26172616
# FIXME: Check type is actually correct!
26182617

26192618
# Zeroconf is refused to l4.
2620-
for ctype in ([],
2621-
[STATIC_REMOTEKEY],
2619+
for ctype in ([STATIC_REMOTEKEY],
26222620
[ANCHORS_ZERO_FEE_HTLC_TX, STATIC_REMOTEKEY]):
26232621
with pytest.raises(RpcError, match=r'not on our allowlist'):
26242622
l1.rpc.fundchannel_start(l4.info['id'], FUNDAMOUNT,
26252623
channel_type=ctype + [ZEROCONF])
26262624

26272625
psbt = l1.rpc.fundpsbt(FUNDAMOUNT - 1000, '253perkw', 250, reserve=0)['psbt']
2628-
for ctype in ([], [12], [22, 12]):
2626+
for ctype in ([12], [22, 12]):
26292627
cid = l1.rpc.openchannel_init(l3.info['id'], FUNDAMOUNT - 1000, psbt, channel_type=ctype)['channel_id']
26302628
l1.rpc.openchannel_abort(cid)
26312629

@@ -2636,6 +2634,13 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
26362634
with pytest.raises(RpcError, match=r'channel_type not supported'):
26372635
l1.rpc.openchannel_init(l3.info['id'], FUNDAMOUNT - 1000, psbt, channel_type=[STATIC_REMOTEKEY, ANCHORS_OLD])
26382636

2637+
# We need static_remotekey now, too
2638+
with pytest.raises(RpcError, match=r'channel_type not supported'):
2639+
l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT, channel_type=[])
2640+
2641+
with pytest.raises(RpcError, match=r'channel_type not supported'):
2642+
l1.rpc.openchannel_init(l3.info['id'], FUNDAMOUNT - 1000, psbt, channel_type=[])
2643+
26392644
# l1 will try, with dev-any-channel-type, l2 will reject.
26402645
l1.stop()
26412646
l1.daemon.opts['dev-any-channel-type'] = None
@@ -2644,7 +2649,7 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
26442649

26452650
with pytest.raises(RpcError, match=r'They sent ERROR .*: You gave bad parameters: Did not support channel_type 12,20'):
26462651
l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT, channel_type=[STATIC_REMOTEKEY, ANCHORS_OLD])
2647-
2652+
26482653
# Now make l2 accept it!
26492654
l2.stop()
26502655
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
@@ -1661,7 +1661,7 @@ def test_plugin_feature_announce(node_factory):
16611661

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

16671667
# 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)