diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index cc05dcd64..21ec97f40 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -231,15 +232,16 @@ static void json_getnodes_reply(struct subd *gossip UNUSED, const u8 *reply, json_array_start(response, "nodes"); for (i = 0; i < tal_count(nodes); i++) { + struct json_escaped *esc; + json_object_start(response, NULL); json_add_pubkey(response, "nodeid", &nodes[i]->nodeid); if (nodes[i]->last_timestamp < 0) { json_object_end(response); continue; } - json_add_string(response, "alias", - tal_strndup(response, (char *)nodes[i]->alias, - tal_len(nodes[i]->alias))); + esc = json_escape(NULL, (const char *)nodes[i]->alias); + json_add_escaped_string(response, "alias", take(esc)); json_add_hex(response, "color", nodes[i]->color, ARRAY_SIZE(nodes[i]->color)); json_add_u64(response, "last_timestamp", diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index fea7d37f7..3c8ad9b7b 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -2127,10 +2127,9 @@ class LightningDTests(BaseLightningDTests): .format(l1.info['id'])) node = l1.rpc.listnodes(l1.info['id'])['nodes'][0] - # FIXME: We get this wrong! - assert not node['alias'] == weird_name + assert node['alias'] == weird_name node = l2.rpc.listnodes(l1.info['id'])['nodes'][0] - assert not node['alias'] == weird_name + assert node['alias'] == weird_name @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval") def test_gossip_pruning(self):