From 9eb531868f0e11b34d4e0c665555369130d69066 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 13 Jul 2021 06:18:58 +0930 Subject: [PATCH] lightningd: make invoices insist on payment_secret. In fact, we make it compulsory, which means if you don't understand it you'll hang up on us! Add some logging for that in future. Changelog-Changed: Protocol: All new invoices require a payment_secret (i.e. modern TLV format onion) Changelog-Changed: Protocol: We can no longer connect to peers which don't support `payment_secret`. Signed-off-by: Rusty Russell --- connectd/connectd.c | 3 +++ lightningd/lightningd.c | 2 +- tests/test_connection.py | 4 +++- tests/test_misc.py | 2 +- tests/utils.py | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/connectd/connectd.c b/connectd/connectd.c index f9ccdafab..80f97661f 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -479,6 +479,7 @@ struct io_plan *peer_connected(struct io_conn *conn, unsup = features_unsupported(daemon->our_features, their_features, INIT_FEATURE); if (unsup != -1) { + status_peer_unusual(id, "Unsupported feature %u", unsup); msg = towire_warningfmt(NULL, NULL, "Unsupported feature %u", unsup); msg = cryptomsg_encrypt_msg(tmpctx, cs, take(msg)); @@ -486,6 +487,8 @@ struct io_plan *peer_connected(struct io_conn *conn, } if (!feature_check_depends(their_features, &depender, &missing)) { + status_peer_unusual(id, "Feature %zu requires feature %zu", + depender, missing); msg = towire_warningfmt(NULL, NULL, "Feature %zu requires feature %zu", depender, missing); diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 96303dc75..d68598d8c 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -811,7 +811,7 @@ static struct feature_set *default_features(const tal_t *ctx) OPTIONAL_FEATURE(OPT_UPFRONT_SHUTDOWN_SCRIPT), OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES), OPTIONAL_FEATURE(OPT_VAR_ONION), - OPTIONAL_FEATURE(OPT_PAYMENT_SECRET), + COMPULSORY_FEATURE(OPT_PAYMENT_SECRET), OPTIONAL_FEATURE(OPT_BASIC_MPP), OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES_EX), OPTIONAL_FEATURE(OPT_STATIC_REMOTEKEY), diff --git a/tests/test_connection.py b/tests/test_connection.py index 631a9d799..ad008fd27 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -3376,7 +3376,9 @@ def test_nonstatic_channel(node_factory, bitcoind): """Smoke test for a channel without option_static_remotekey""" l1, l2 = node_factory.line_graph(2, opts=[{}, - {'dev-force-features': '////'}]) + # needs at least 15 to connect + # (and 9 is a dependent) + {'dev-force-features': '9,15////'}]) chan = only_one(only_one(l1.rpc.listpeers()['peers'])['channels']) assert 'option_static_remotekey' not in chan['features'] assert 'option_anchor_outputs' not in chan['features'] diff --git a/tests/test_misc.py b/tests/test_misc.py index 71ac07417..486d2b37b 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1893,7 +1893,7 @@ def test_list_features_only(node_factory): 'option_var_onion_optin/odd', 'option_gossip_queries_ex/odd', 'option_static_remotekey/odd', - 'option_payment_secret/odd', + 'option_payment_secret/even', 'option_basic_mpp/odd', ] if EXPERIMENTAL_FEATURES: diff --git a/tests/utils.py b/tests/utils.py index 446ec0c81..81f34f111 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -20,7 +20,7 @@ def hex_bits(features): def expected_peer_features(wumbo_channels=False, extra=[]): """Return the expected peer features hexstring for this configuration""" - features = [1, 5, 7, 9, 11, 13, 15, 17, 27] + features = [1, 5, 7, 9, 11, 13, 14, 17, 27] if EXPERIMENTAL_FEATURES: # OPT_ONION_MESSAGES features += [39] @@ -40,7 +40,7 @@ def expected_peer_features(wumbo_channels=False, extra=[]): # features for the 'node' and the 'peer' feature sets def expected_node_features(wumbo_channels=False, extra=[]): """Return the expected node features hexstring for this configuration""" - features = [1, 5, 7, 9, 11, 13, 15, 17, 27, 55] + features = [1, 5, 7, 9, 11, 13, 14, 17, 27, 55] if EXPERIMENTAL_FEATURES: # OPT_ONION_MESSAGES features += [39]