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

@@ -1895,7 +1895,7 @@ def test_multifunding_feerates(node_factory, bitcoind):
assert only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['feerate']['perkw'] == commitment_tx_feerate_int
assert only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['feerate']['perkb'] == commitment_tx_feerate_int * 4
txfee = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['last_tx_fee']
txfee = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['last_tx_fee_msat']
# We get the expected close txid, force close the channel, then fish
# the details about the transaction out of the mempoool entry
@@ -1923,7 +1923,7 @@ def test_multifunding_feerates(node_factory, bitcoind):
expected_fee += 330
assert expected_fee == entry['fees']['base'] * 10 ** 8
assert Millisatoshi(str(expected_fee) + 'sat') == Millisatoshi(txfee)
assert Millisatoshi(str(expected_fee) + 'sat') == txfee
def test_multifunding_param_failures(node_factory):
@@ -3326,8 +3326,8 @@ def test_wumbo_channels(node_factory, bitcoind):
wait_for(lambda: 'CHANNELD_NORMAL' in [c['state'] for c in only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels']])
# Exact amount depends on fees, but it will be wumbo!
amount = [c['funding_msat'][l1.info['id']] for c in only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'] if c['state'] == 'CHANNELD_NORMAL'][0]
assert Millisatoshi(amount) > Millisatoshi(str((1 << 24) - 1) + "sat")
amount = [c['funding']['local_msat'] for c in only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'] if c['state'] == 'CHANNELD_NORMAL'][0]
assert amount > Millisatoshi(str((1 << 24) - 1) + "sat")
@pytest.mark.openchannel('v1')

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)