diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 394b64525..dc2432be9 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -51,7 +51,7 @@ void json_add_uncommitted_channel(struct json_stream *response, json_object_start(response, NULL); json_add_string(response, "state", "OPENINGD"); json_add_string(response, "owner", "lightning_openingd"); - json_add_string(response, "funding", "LOCAL"); + json_add_string(response, "opener", "local"); if (uc->transient_billboard) { json_array_start(response, "status"); json_add_string(response, NULL, uc->transient_billboard); diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 47957c1ab..769557cc7 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -498,7 +498,7 @@ static void json_add_htlcs(struct lightningd *ld, json_add_u64(response, "id", hin->key.id); json_add_amount_msat_compat(response, hin->msat, "msatoshi", "amount_msat"); - json_add_u64(response, "expiry", hin->cltv_expiry); + json_add_u32(response, "expiry", hin->cltv_expiry); json_add_sha256(response, "payment_hash", &hin->payment_hash); json_add_string(response, "state", htlc_state_name(hin->hstate)); @@ -744,7 +744,10 @@ static void json_add_channel(struct lightningd *ld, bitcoin_txid(channel->last_tx, &txid); json_add_txid(response, "scratch_txid", &txid); - json_add_amount_sat_only(response, "last_tx_fee", + if (deprecated_apis) + json_add_amount_sat_only(response, "last_tx_fee", + bitcoin_tx_compute_fee(channel->last_tx)); + json_add_amount_sat_only(response, "last_tx_fee_msat", bitcoin_tx_compute_fee(channel->last_tx)); } @@ -847,7 +850,7 @@ static void json_add_channel(struct lightningd *ld, if (channel->closer != NUM_SIDES) json_add_string(response, "closer", channel->closer == LOCAL ? "local" : "remote"); - else + else if (deprecated_apis) json_add_null(response, "closer"); json_array_start(response, "features"); @@ -882,20 +885,27 @@ static void json_add_channel(struct lightningd *ld, our_msats = AMOUNT_MSAT(0); } - json_object_start(response, "funding_allocation_msat"); - json_add_u64(response, node_id_to_hexstr(tmpctx, &p->id), - peer_msats.millisatoshis); /* Raw: JSON field */ - json_add_u64(response, node_id_to_hexstr(tmpctx, &ld->id), - our_msats.millisatoshis); /* Raw: JSON field */ - json_object_end(response); + if (deprecated_apis) { + json_object_start(response, "funding_allocation_msat"); + json_add_u64(response, node_id_to_hexstr(tmpctx, &p->id), + peer_msats.millisatoshis); /* Raw: JSON field */ + json_add_u64(response, node_id_to_hexstr(tmpctx, &ld->id), + our_msats.millisatoshis); /* Raw: JSON field */ + json_object_end(response); - json_object_start(response, "funding_msat"); - json_add_sat_only(response, - node_id_to_hexstr(tmpctx, &p->id), - peer_funded_sats); - json_add_sat_only(response, - node_id_to_hexstr(tmpctx, &ld->id), - channel->our_funds); + json_object_start(response, "funding_msat"); + json_add_sat_only(response, + node_id_to_hexstr(tmpctx, &p->id), + peer_funded_sats); + json_add_sat_only(response, + node_id_to_hexstr(tmpctx, &ld->id), + channel->our_funds); + json_object_end(response); + } + + json_object_start(response, "funding"); + json_add_sat_only(response, "local_msat", channel->our_funds); + json_add_sat_only(response, "remote_msat", peer_funded_sats); json_object_end(response); if (!amount_sat_to_msat(&funding_msat, channel->funding)) { diff --git a/tests/test_connection.py b/tests/test_connection.py index ecadb4b20..413055014 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -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') diff --git a/tests/test_plugin.py b/tests/test_plugin.py index a86d66298..9a714fd8f 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -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)