listpeers: clean up JSON output.

In general, it's better to omit a field than put in a 'null', and
putting variable-named fields in an object is also a bad idea.

This is reflected in how hard this is to express in JSON schema, too.

Others:
1. Remove the obsolete "funding": "LOCAL" from unopened channels, but add
   "opener": "local" as used in normal channels.
2. htlc cltv_expiry is a u16.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `funding_allocation_msat` and `funding_msat`: use `funding`.
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `last_tx_fee`: use `last_tx_fee_msat`.
Changelog-Deprecated: JSON-RPC: `listfunds` `channels` `closer` is now omitted if it does not apply, not JSON `null`.
This commit is contained in:
Rusty Russell
2021-06-16 10:30:17 +09:30
parent edee0793d3
commit d8136d856b
4 changed files with 34 additions and 24 deletions

View File

@@ -720,9 +720,9 @@ def test_channel_state_changed_bilateral(node_factory, bitcoind):
# check channel 'opener' and 'closer' within this testcase ...
assert(l1.rpc.listpeers()['peers'][0]['channels'][0]['opener'] == 'local')
assert(l2.rpc.listpeers()['peers'][0]['channels'][0]['opener'] == 'remote')
# the 'closer' should be null initially
assert(l2.rpc.listpeers()['peers'][0]['channels'][0]['closer'] is None)
assert(l2.rpc.listpeers()['peers'][0]['channels'][0]['closer'] is None)
# the 'closer' should be missing initially
assert 'closer' not in l1.rpc.listpeers()['peers'][0]['channels'][0]
assert 'closer' not in l2.rpc.listpeers()['peers'][0]['channels'][0]
event1 = wait_for_event(l1)
event2 = wait_for_event(l2)