Skip to content

Commit fb05a06

Browse files
committed
lightningd: Update 'listpeers' command to print alt-addrs for a peer
1 parent 39e20f2 commit fb05a06

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

contrib/msggen/msggen/schema.json

+22
Original file line numberDiff line numberDiff line change
@@ -4080,6 +4080,9 @@
40804080
"netaddr": [
40814081
"127.0.0.1:40119"
40824082
],
4083+
"alt_addrs": [
4084+
"127.0.0.1:34321"
4085+
],
40834086
"features": "08a0000a8a5961",
40844087
"log": [
40854088
{
@@ -21202,6 +21205,19 @@
2120221205
]
2120321206
}
2120421207
},
21208+
"alt_addrs": {
21209+
"type": "array",
21210+
"description": [
21211+
"An array containing zero or more alternative addresses for the peer."
21212+
],
21213+
"items": {
21214+
"type": "string",
21215+
"description": [
21216+
"Address, e.g. 1.2.3.4:1234."
21217+
]
21218+
},
21219+
"added": "v24.08"
21220+
},
2120521221
"remote_addr": {
2120621222
"type": "string",
2120721223
"description": [
@@ -21258,6 +21274,9 @@
2125821274
"netaddr": [
2125921275
"127.0.0.1:44619"
2126021276
],
21277+
"alt_addrs": [
21278+
"127.0.0.1:34321"
21279+
],
2126121280
"features": "08a0000a0a69a2"
2126221281
}
2126321282
]
@@ -21278,6 +21297,9 @@
2127821297
"netaddr": [
2127921298
"127.0.0.1:48862"
2128021299
],
21300+
"alt_addrs": [
21301+
"127.0.0.1:34321"
21302+
],
2128121303
"features": "08a0000a0a69a2"
2128221304
}
2128321305
]

doc/schemas/lightning-commando.json

+3
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
"netaddr": [
148148
"127.0.0.1:40119"
149149
],
150+
"alt_addrs": [
151+
"127.0.0.1:34321"
152+
],
150153
"features": "08a0000a8a5961",
151154
"log": [
152155
{

doc/schemas/lightning-listpeers.json

+19
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,19 @@
279279
]
280280
}
281281
},
282+
"alt_addrs": {
283+
"type": "array",
284+
"description": [
285+
"An array containing zero or more alternative addresses for the peer."
286+
],
287+
"items": {
288+
"type": "string",
289+
"description": [
290+
"Address, e.g. 1.2.3.4:1234."
291+
]
292+
},
293+
"added": "v24.08"
294+
},
282295
"remote_addr": {
283296
"type": "string",
284297
"description": [
@@ -335,6 +348,9 @@
335348
"netaddr": [
336349
"127.0.0.1:44619"
337350
],
351+
"alt_addrs": [
352+
"127.0.0.1:34321"
353+
],
338354
"features": "08a0000a0a69a2"
339355
}
340356
]
@@ -355,6 +371,9 @@
355371
"netaddr": [
356372
"127.0.0.1:48862"
357373
],
374+
"alt_addrs": [
375+
"127.0.0.1:34321"
376+
],
358377
"features": "08a0000a0a69a2"
359378
}
360379
]

lightningd/peer_control.c

+10
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,7 @@ static void json_add_peer(struct lightningd *ld,
22322232
const enum log_level *ll)
22332233
{
22342234
struct channel *channel;
2235+
struct wireaddr_internal *peer_alt_addr;
22352236
u32 num_channels;
22362237

22372238
json_object_start(response, NULL);
@@ -2254,6 +2255,15 @@ static void json_add_peer(struct lightningd *ld,
22542255
fmt_wireaddr(response, p->remote_addr));
22552256
}
22562257

2258+
peer_alt_addr = wallet_get_alt_addr(ld->wallet, &p->id, false);
2259+
if (peer_alt_addr) {
2260+
json_array_start(response, "alt_addrs");
2261+
for (size_t i = 0; i < tal_count(peer_alt_addr); i++)
2262+
json_add_string(response, NULL,
2263+
fmt_wireaddr_internal(tmpctx, &peer_alt_addr[i]));
2264+
json_array_end(response);
2265+
}
2266+
22572267
/* Note: If !PEER_CONNECTED, peer may use different features on reconnect */
22582268
json_add_hex_talarr(response, "features", p->their_features);
22592269

tests/test_plugin.py

+7
Original file line numberDiff line numberDiff line change
@@ -3710,6 +3710,13 @@ def test_sql(node_factory, bitcoind):
37103710
'type': 'string'},
37113711
{'name': 'features',
37123712
'type': 'hex'}]},
3713+
'peers_alt_addrs': {
3714+
'columns': [{'name': 'peer_id',
3715+
'type': 'pubkey'},
3716+
{'name': 'alt_addr',
3717+
'type': 'string'},
3718+
{'name': 'port',
3719+
'type': 'u16'}]},
37133720
'peers_netaddr': {
37143721
'columns': [{'name': 'row',
37153722
'type': 'u64'},

0 commit comments

Comments
 (0)