mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
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:
parent
41b0872f58
commit
9455331575
@ -24,6 +24,7 @@ Note: You should always set `allow-deprecated-apis=false` to test for
|
|||||||
changes.
|
changes.
|
||||||
|
|
||||||
- JSON RPC: `listchannels`' `flags` field. This has been split into two fields, see Added.
|
- 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
|
### Removed
|
||||||
|
|
||||||
|
@ -206,8 +206,11 @@ static void json_getnodes_reply(struct subd *gossip UNUSED, const u8 *reply,
|
|||||||
nodes[i]->color, ARRAY_SIZE(nodes[i]->color));
|
nodes[i]->color, ARRAY_SIZE(nodes[i]->color));
|
||||||
json_add_u64(response, "last_timestamp",
|
json_add_u64(response, "last_timestamp",
|
||||||
nodes[i]->last_timestamp);
|
nodes[i]->last_timestamp);
|
||||||
json_add_hex_talarr(response, "global_features",
|
json_add_hex_talarr(response, "globalfeatures",
|
||||||
nodes[i]->globalfeatures);
|
nodes[i]->globalfeatures);
|
||||||
|
if (deprecated_apis)
|
||||||
|
json_add_hex_talarr(response, "global_features",
|
||||||
|
nodes[i]->globalfeatures);
|
||||||
json_array_start(response, "addresses");
|
json_array_start(response, "addresses");
|
||||||
for (j=0; j<tal_count(nodes[i]->addresses); j++) {
|
for (j=0; j<tal_count(nodes[i]->addresses); j++) {
|
||||||
json_add_address(response, NULL, &nodes[i]->addresses[j]);
|
json_add_address(response, NULL, &nodes[i]->addresses[j]);
|
||||||
|
@ -679,10 +679,15 @@ static void json_add_peer(struct lightningd *ld,
|
|||||||
struct wireaddr_internal,
|
struct wireaddr_internal,
|
||||||
&p->addr));
|
&p->addr));
|
||||||
json_array_end(response);
|
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);
|
p->globalfeatures);
|
||||||
|
json_add_hex_talarr(response, "localfeatures",
|
||||||
json_add_hex_talarr(response, "local_features",
|
|
||||||
p->localfeatures);
|
p->localfeatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,8 +991,8 @@ def test_peerinfo(node_factory, bitcoind):
|
|||||||
# Gossiping but no node announcement yet
|
# Gossiping but no node announcement yet
|
||||||
assert l1.rpc.getpeer(l2.info['id'])['connected']
|
assert l1.rpc.getpeer(l2.info['id'])['connected']
|
||||||
assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0
|
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'])['localfeatures'] == '8a'
|
||||||
assert l1.rpc.getpeer(l2.info['id'])['global_features'] == ''
|
assert l1.rpc.getpeer(l2.info['id'])['globalfeatures'] == ''
|
||||||
|
|
||||||
# Fund a channel to force a node announcement
|
# Fund a channel to force a node announcement
|
||||||
chan = l1.fund_channel(l2, 10**6)
|
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']
|
nodes2 = l2.rpc.listnodes(l2.info['id'])['nodes']
|
||||||
peer1 = l1.rpc.getpeer(l2.info['id'])
|
peer1 = l1.rpc.getpeer(l2.info['id'])
|
||||||
peer2 = l2.rpc.getpeer(l1.info['id'])
|
peer2 = l2.rpc.getpeer(l1.info['id'])
|
||||||
assert only_one(nodes1)['global_features'] == peer1['global_features']
|
assert only_one(nodes1)['globalfeatures'] == peer1['globalfeatures']
|
||||||
assert only_one(nodes2)['global_features'] == peer2['global_features']
|
assert only_one(nodes2)['globalfeatures'] == peer2['globalfeatures']
|
||||||
|
|
||||||
assert l1.rpc.getpeer(l2.info['id'])['local_features'] == '8a'
|
assert l1.rpc.getpeer(l2.info['id'])['localfeatures'] == '8a'
|
||||||
assert l2.rpc.getpeer(l1.info['id'])['local_features'] == '8a'
|
assert l2.rpc.getpeer(l1.info['id'])['localfeatures'] == '8a'
|
||||||
|
|
||||||
# If it reconnects after db load, it should know features.
|
# If it reconnects after db load, it should know features.
|
||||||
l1.restart()
|
l1.restart()
|
||||||
wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'])
|
wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'])
|
||||||
wait_for(lambda: l2.rpc.getpeer(l1.info['id'])['connected'])
|
wait_for(lambda: l2.rpc.getpeer(l1.info['id'])['connected'])
|
||||||
assert l1.rpc.getpeer(l2.info['id'])['local_features'] == '8a'
|
assert l1.rpc.getpeer(l2.info['id'])['localfeatures'] == '8a'
|
||||||
assert l2.rpc.getpeer(l1.info['id'])['local_features'] == '8a'
|
assert l2.rpc.getpeer(l1.info['id'])['localfeatures'] == '8a'
|
||||||
|
|
||||||
# Close the channel to forget the peer
|
# Close the channel to forget the peer
|
||||||
with pytest.raises(RpcError, match=r'Channel close negotiation not finished'):
|
with pytest.raises(RpcError, match=r'Channel close negotiation not finished'):
|
||||||
|
Loading…
Reference in New Issue
Block a user