mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
JSON: deprecate printing msat fields as strings.
This changes many fields: in non-deprecated mode, they're now raw integers. This was always the intention, but the transition was never completed. Suggested-By: @ShahanaFarooqui Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Changed: JSON-RPC: "_msat" fields can be raw numbers, not "123msat" strings (please handle both!) Changelog-Deprecated: JSON-RPC: "_msat" fields as "123msat" strings (will be only numbers)
This commit is contained in:
parent
5531de99de
commit
60bd70be85
4 changed files with 17 additions and 14 deletions
|
@ -412,8 +412,11 @@ void json_add_amount_msat_only(struct json_stream *result,
|
|||
{
|
||||
if (!deprecated_apis)
|
||||
assert(strends(msatfieldname, "_msat"));
|
||||
json_add_string(result, msatfieldname,
|
||||
type_to_string(tmpctx, struct amount_msat, &msat));
|
||||
if (deprecated_apis)
|
||||
json_add_string(result, msatfieldname,
|
||||
type_to_string(tmpctx, struct amount_msat, &msat));
|
||||
else
|
||||
json_add_u64(result, msatfieldname, msat.millisatoshis); /* Raw: low-level helper */
|
||||
}
|
||||
|
||||
void json_add_amount_sat_compat(struct json_stream *result,
|
||||
|
|
|
@ -969,7 +969,7 @@ def test_cli(node_factory):
|
|||
' "invoices": [',
|
||||
' {',
|
||||
r' "label": "l\"[]{}",',
|
||||
' "amount_msat": "123000msat",',
|
||||
' "amount_msat": 123000,',
|
||||
' "status": "unpaid",',
|
||||
r' "description": "d\"[]{}",',
|
||||
' }',
|
||||
|
|
|
@ -3097,8 +3097,8 @@ def test_partial_payment(node_factory, bitcoind, executor):
|
|||
for i in range(2):
|
||||
line = l4.daemon.wait_for_log('print_htlc_onion.py: Got onion')
|
||||
assert "'type': 'tlv'" in line
|
||||
assert "'forward_msat': '499msat'" in line or "'forward_msat': '501msat'" in line
|
||||
assert "'total_msat': '1000msat'" in line
|
||||
assert "'forward_msat': 499" in line or "'forward_msat': 501" in line
|
||||
assert "'total_msat': 1000" in line
|
||||
assert "'payment_secret': '{}'".format(paysecret) in line
|
||||
|
||||
pay = only_one(l1.rpc.listpays()['pays'])
|
||||
|
|
|
@ -626,11 +626,11 @@ def test_openchannel_hook(node_factory, bitcoind):
|
|||
# Make sure plugin got all the vars we expect
|
||||
expected = {
|
||||
'channel_flags': '1',
|
||||
'dust_limit_msat': '546000msat',
|
||||
'htlc_minimum_msat': '0msat',
|
||||
'dust_limit_msat': 546000,
|
||||
'htlc_minimum_msat': 0,
|
||||
'id': l1.info['id'],
|
||||
'max_accepted_htlcs': '483',
|
||||
'max_htlc_value_in_flight_msat': '18446744073709551615msat',
|
||||
'max_htlc_value_in_flight_msat': 18446744073709551615,
|
||||
'to_self_delay': '5',
|
||||
}
|
||||
|
||||
|
@ -643,15 +643,15 @@ def test_openchannel_hook(node_factory, bitcoind):
|
|||
'feerate_our_max': '150000',
|
||||
'feerate_our_min': '1875',
|
||||
'locktime': '.*',
|
||||
'their_funding_msat': '100000000msat',
|
||||
'channel_max_msat': '16777215000msat',
|
||||
'their_funding_msat': 100000000,
|
||||
'channel_max_msat': 16777215000,
|
||||
})
|
||||
else:
|
||||
expected.update({
|
||||
'channel_reserve_msat': '1000000msat',
|
||||
'channel_reserve_msat': 1000000,
|
||||
'feerate_per_kw': '7500',
|
||||
'funding_msat': '100000000msat',
|
||||
'push_msat': '0msat',
|
||||
'funding_msat': 100000000,
|
||||
'push_msat': 0,
|
||||
})
|
||||
|
||||
l2.daemon.wait_for_log('reject_odd_funding_amounts.py: {} VARS'.format(len(expected)))
|
||||
|
@ -1148,7 +1148,7 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor):
|
|||
assert onion['type'] == 'tlv'
|
||||
assert re.match(r'^11020203e80401..0608................$', onion['payload'])
|
||||
assert len(onion['shared_secret']) == 64
|
||||
assert onion['forward_msat'] == '1000msat'
|
||||
assert onion['forward_msat'] == Millisatoshi(1000)
|
||||
assert len(onion['next_onion']) == 2 * (1300 + 32 + 33 + 1)
|
||||
|
||||
f1.result()
|
||||
|
|
Loading…
Add table
Reference in a new issue