json: use bolt naming for features arrays in listnodes, listpeers.

Deprecate the old names.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-09-28 12:54:25 +09:30
parent 41b0872f58
commit 9455331575
4 changed files with 21 additions and 12 deletions

View File

@ -24,6 +24,7 @@ Note: You should always set `allow-deprecated-apis=false` to test for
changes.
- JSON RPC: `listchannels`' `flags` field. This has been split into two fields, see Added.
- JSON RPC: `global_features` and `local_features` fields: use `globalfeatures` and `localfeatures` as per BOLT #1.
### Removed

View File

@ -206,8 +206,11 @@ static void json_getnodes_reply(struct subd *gossip UNUSED, const u8 *reply,
nodes[i]->color, ARRAY_SIZE(nodes[i]->color));
json_add_u64(response, "last_timestamp",
nodes[i]->last_timestamp);
json_add_hex_talarr(response, "global_features",
json_add_hex_talarr(response, "globalfeatures",
nodes[i]->globalfeatures);
if (deprecated_apis)
json_add_hex_talarr(response, "global_features",
nodes[i]->globalfeatures);
json_array_start(response, "addresses");
for (j=0; j<tal_count(nodes[i]->addresses); j++) {
json_add_address(response, NULL, &nodes[i]->addresses[j]);

View File

@ -679,10 +679,15 @@ static void json_add_peer(struct lightningd *ld,
struct wireaddr_internal,
&p->addr));
json_array_end(response);
json_add_hex_talarr(response, "global_features",
if (deprecated_apis) {
json_add_hex_talarr(response, "global_features",
p->globalfeatures);
json_add_hex_talarr(response, "local_features",
p->localfeatures);
}
json_add_hex_talarr(response, "globalfeatures",
p->globalfeatures);
json_add_hex_talarr(response, "local_features",
json_add_hex_talarr(response, "localfeatures",
p->localfeatures);
}

View File

@ -991,8 +991,8 @@ def test_peerinfo(node_factory, bitcoind):
# Gossiping but no node announcement yet
assert l1.rpc.getpeer(l2.info['id'])['connected']
assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0
assert l1.rpc.getpeer(l2.info['id'])['local_features'] == '8a'
assert l1.rpc.getpeer(l2.info['id'])['global_features'] == ''
assert l1.rpc.getpeer(l2.info['id'])['localfeatures'] == '8a'
assert l1.rpc.getpeer(l2.info['id'])['globalfeatures'] == ''
# Fund a channel to force a node announcement
chan = l1.fund_channel(l2, 10**6)
@ -1006,18 +1006,18 @@ def test_peerinfo(node_factory, bitcoind):
nodes2 = l2.rpc.listnodes(l2.info['id'])['nodes']
peer1 = l1.rpc.getpeer(l2.info['id'])
peer2 = l2.rpc.getpeer(l1.info['id'])
assert only_one(nodes1)['global_features'] == peer1['global_features']
assert only_one(nodes2)['global_features'] == peer2['global_features']
assert only_one(nodes1)['globalfeatures'] == peer1['globalfeatures']
assert only_one(nodes2)['globalfeatures'] == peer2['globalfeatures']
assert l1.rpc.getpeer(l2.info['id'])['local_features'] == '8a'
assert l2.rpc.getpeer(l1.info['id'])['local_features'] == '8a'
assert l1.rpc.getpeer(l2.info['id'])['localfeatures'] == '8a'
assert l2.rpc.getpeer(l1.info['id'])['localfeatures'] == '8a'
# If it reconnects after db load, it should know features.
l1.restart()
wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'])
wait_for(lambda: l2.rpc.getpeer(l1.info['id'])['connected'])
assert l1.rpc.getpeer(l2.info['id'])['local_features'] == '8a'
assert l2.rpc.getpeer(l1.info['id'])['local_features'] == '8a'
assert l1.rpc.getpeer(l2.info['id'])['localfeatures'] == '8a'
assert l2.rpc.getpeer(l1.info['id'])['localfeatures'] == '8a'
# Close the channel to forget the peer
with pytest.raises(RpcError, match=r'Channel close negotiation not finished'):