diff --git a/CHANGELOG.md b/CHANGELOG.md index d22b5f2bc..9ebb36114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ changes. - Protocol: `channel_update` inside error messages now refers to correct channel. - Stripping type prefix from `channel_update`s that are nested in an onion reply to be compatible with eclair and lnd (#1730). +- JSON API: `listnodes`: now correctly prints `addresses` if more than + one is advertised. ### Security diff --git a/lightningd/gossip_msg.c b/lightningd/gossip_msg.c index 6623775e5..c29d9a9c7 100644 --- a/lightningd/gossip_msg.c +++ b/lightningd/gossip_msg.c @@ -27,7 +27,7 @@ struct gossip_getnodes_entry *fromwire_gossip_getnodes_entry(const tal_t *ctx, entry->addresses = tal_arr(entry, struct wireaddr, numaddresses); for (i=0; iaddresses)) { + if (!fromwire_wireaddr(pptr, max, &entry->addresses[i])) { fromwire_fail(pptr, max); return NULL; } diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 51125c654..021d8e00d 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -4332,6 +4332,35 @@ class LightningDTests(BaseLightningDTests): assert not l2.daemon.is_in_log('signature verification failed') assert not l3.daemon.is_in_log('signature verification failed') + def test_gossip_addresses(self): + l1 = self.node_factory.get_node(options={'announce-addr': + ['[::]:3', + '127.0.0.1:2', + 'vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion', + + '3fyb44wdhnd2ghhl.onion:1234']}) + l2 = self.node_factory.get_node() + l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + + self.fund_channel(l1, l2, 100000) + bitcoind.generate_block(6) + l2.daemon.wait_for_log('Received node_announcement for node {}' + .format(l1.info['id'])) + + node = only_one(l2.rpc.listnodes(l1.info['id'])['nodes']) + assert node['addresses'] == [{'type': 'ipv4', + 'address': '127.0.0.1', + 'port': 2}, + {'type': 'ipv6', + 'address': '::', + 'port': 3}, + {'type': 'torv2', + 'address': '3fyb44wdhnd2ghhl.onion', + 'port': 1234}, + {'type': 'torv3', + 'address': 'vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion', + 'port': 9735}] + @unittest.skipIf(not DEVELOPER, "Too slow without --dev-bitcoind-poll") def test_waitinvoice(self): """Test waiting for one invoice will not return if another invoice