Browse Source

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

Deprecate the old names.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
fee-tracking2
Rusty Russell 6 years ago
parent
commit
9455331575
  1. 1
      CHANGELOG.md
  2. 3
      lightningd/gossip_control.c
  3. 7
      lightningd/peer_control.c
  4. 16
      tests/test_connection.py

1
CHANGELOG.md

@ -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

3
lightningd/gossip_control.c

@ -206,6 +206,9 @@ 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, "globalfeatures",
nodes[i]->globalfeatures);
if (deprecated_apis)
json_add_hex_talarr(response, "global_features",
nodes[i]->globalfeatures);
json_array_start(response, "addresses");

7
lightningd/peer_control.c

@ -679,12 +679,17 @@ static void json_add_peer(struct lightningd *ld,
struct wireaddr_internal,
&p->addr));
json_array_end(response);
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, "localfeatures",
p->localfeatures);
}
json_array_start(response, "channels");
json_add_uncommitted_channel(response, p->uncommitted_channel);

16
tests/test_connection.py

@ -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'):

Loading…
Cancel
Save