diff --git a/contrib/msggen/msggen/schema.json b/contrib/msggen/msggen/schema.json index 92e56b5c5c84..4368442ea992 100644 --- a/contrib/msggen/msggen/schema.json +++ b/contrib/msggen/msggen/schema.json @@ -5524,7 +5524,16 @@ "netaddr": [ "127.0.0.1:34785" ], - "features": "08a0802a8a59a1" + "alt_addrs": [ + "127.0.0.1:34321" + ], + "features": "08a0000a8a5961", + "log": [ + { + "type": "SKIPPED", + "num_skipped": 30 + } + ] } ] } @@ -23963,6 +23972,19 @@ ] } }, + "alt_addrs": { + "type": "array", + "description": [ + "An array containing zero or more alternative addresses for the peer." + ], + "items": { + "type": "string", + "description": [ + "Address, e.g. 1.2.3.4:1234." + ] + }, + "added": "v24.11" + }, "remote_addr": { "type": "string", "description": [ @@ -24019,7 +24041,10 @@ "netaddr": [ "127.0.0.1:34785" ], - "features": "08a0802a8a59a1" + "alt_addrs": [ + "127.0.0.1:34321" + ], + "features": "08a0000a0a69a2" } ] } @@ -24057,7 +24082,10 @@ "netaddr": [ "127.0.0.1:47032" ], - "features": "08a0802a8a59a1" + "alt_addrs": [ + "127.0.0.1:34321" + ], + "features": "08a0000a0a69a2" } ] } diff --git a/doc/schemas/lightning-commando.json b/doc/schemas/lightning-commando.json index 3db442e701b1..68b483655c97 100644 --- a/doc/schemas/lightning-commando.json +++ b/doc/schemas/lightning-commando.json @@ -146,7 +146,16 @@ "netaddr": [ "127.0.0.1:34785" ], - "features": "08a0802a8a59a1" + "alt_addrs": [ + "127.0.0.1:34321" + ], + "features": "08a0000a8a5961", + "log": [ + { + "type": "SKIPPED", + "num_skipped": 30 + } + ] } ] } diff --git a/doc/schemas/lightning-listpeers.json b/doc/schemas/lightning-listpeers.json index 1aa5837e96f3..340de13f0899 100644 --- a/doc/schemas/lightning-listpeers.json +++ b/doc/schemas/lightning-listpeers.json @@ -282,6 +282,19 @@ ] } }, + "alt_addrs": { + "type": "array", + "description": [ + "An array containing zero or more alternative addresses for the peer." + ], + "items": { + "type": "string", + "description": [ + "Address, e.g. 1.2.3.4:1234." + ] + }, + "added": "v24.11" + }, "remote_addr": { "type": "string", "description": [ @@ -338,7 +351,10 @@ "netaddr": [ "127.0.0.1:34785" ], - "features": "08a0802a8a59a1" + "alt_addrs": [ + "127.0.0.1:34321" + ], + "features": "08a0000a0a69a2" } ] } @@ -376,7 +392,10 @@ "netaddr": [ "127.0.0.1:47032" ], - "features": "08a0802a8a59a1" + "alt_addrs": [ + "127.0.0.1:34321" + ], + "features": "08a0000a0a69a2" } ] } diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 3b8c633d742c..11e418b00e46 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2236,6 +2236,7 @@ static void json_add_peer(struct lightningd *ld, const enum log_level *ll) { struct channel *channel; + struct wireaddr_internal *peer_alt_addr; u32 num_channels; json_object_start(response, NULL); @@ -2258,6 +2259,15 @@ static void json_add_peer(struct lightningd *ld, fmt_wireaddr(response, p->remote_addr)); } + peer_alt_addr = wallet_get_alt_addr(ld->wallet, &p->id, false); + if (peer_alt_addr) { + json_array_start(response, "alt_addrs"); + for (size_t i = 0; i < tal_count(peer_alt_addr); i++) + json_add_string(response, NULL, + fmt_wireaddr_internal(tmpctx, &peer_alt_addr[i])); + json_array_end(response); + } + /* Note: If !PEER_CONNECTED, peer may use different features on reconnect */ json_add_hex_talarr(response, "features", p->their_features); diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 97c2c6d8e6de..d939eeda9613 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -3709,6 +3709,13 @@ def test_sql(node_factory, bitcoind): 'type': 'string'}, {'name': 'features', 'type': 'hex'}]}, + 'peers_alt_addrs': { + 'columns': [{'name': 'row', + 'type': 'u64'}, + {'name': 'arrindex', + 'type': 'u64'}, + {'name': 'alt_addrs', + 'type': 'string'}]}, 'peers_netaddr': { 'columns': [{'name': 'row', 'type': 'u64'}, @@ -4128,6 +4135,9 @@ def test_sql(node_factory, bitcoind): for table, schema in expected_schemas.items(): ret = l2.rpc.sql("SELECT * FROM {};".format(table)) + if table == 'peers_alt_addrs' and not ret['rows']: + print(f"Skipping empty check for table {table} as it's expected to be empty.") + continue assert len(ret['rows'][0]) == 1 + len(schema['columns']) # First column is always rowid!