mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
listpeers: add latest feerate and actual last fee amount.
Users have no idea what they would pay for unilateral closes. At least this gives them a clue! Reported-by: @az0re on IRC. Changelog-Added: JSON-RPC: `listpeers` now shows latest feerate and unilaral close fee. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
4deb9311ce
commit
4dcd4ca155
9
doc/lightning-listpeers.7
generated
9
doc/lightning-listpeers.7
generated
@ -272,6 +272,13 @@ successfully claimed\fR over this channel\.
|
||||
outgoing HTLCs offered \fIand successfully claimed\fR over this channel;
|
||||
a number followed by a string unit\.
|
||||
.IP \[bu]
|
||||
\fIscratch_txid\fR: The txid of the latest transaction (what we would sign and
|
||||
send to chain if the channel were to fail now)\.
|
||||
.IP \[bu]
|
||||
\fIlast_tx_fee\fR: The fee on that latest transaction\.
|
||||
.IP \[bu]
|
||||
\fIfeerate\fR: An object containing the latest feerate as both \fIperkw\fR and \fIperkb\fR\.
|
||||
.IP \[bu]
|
||||
\fIhtlcs\fR: An array of objects describing the HTLCs currently in-flight
|
||||
in the channel\.
|
||||
|
||||
@ -334,4 +341,4 @@ Main web site: \fIhttps://github.com/ElementsProject/lightning\fR Lightning
|
||||
RFC site (BOLT #9):
|
||||
\fIhttps://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md\fR
|
||||
|
||||
\" SHA256STAMP:9e2ed8ce1612c02a6251db7da1d62e2d12f8e0648a54888687f177f0784ef2e6
|
||||
\" SHA256STAMP:1163bde5a9f836ba7bd142559cd3bab893ab3159a99041a88ac8b31556b67905
|
||||
|
@ -202,6 +202,10 @@ state, or in various circumstances:
|
||||
* *out\_fulfilled\_msat*: A string describing the total amount of all
|
||||
outgoing HTLCs offered *and successfully claimed* over this channel;
|
||||
a number followed by a string unit.
|
||||
* *scratch_txid*: The txid of the latest transaction (what we would sign and
|
||||
send to chain if the channel were to fail now).
|
||||
* *last_tx_fee*: The fee on that latest transaction.
|
||||
* *feerate*: An object containing the latest feerate as both *perkw* and *perkb*.
|
||||
* *htlcs*: An array of objects describing the HTLCs currently in-flight
|
||||
in the channel.
|
||||
|
||||
|
@ -698,6 +698,7 @@ static void json_add_channel(struct lightningd *ld,
|
||||
struct amount_sat peer_funded_sats;
|
||||
struct peer *p = channel->peer;
|
||||
struct state_change_entry *state_changes;
|
||||
u32 feerate;
|
||||
|
||||
json_object_start(response, key);
|
||||
json_add_string(response, "state", channel_state_name(channel));
|
||||
@ -706,7 +707,17 @@ 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",
|
||||
bitcoin_tx_compute_fee(channel->last_tx));
|
||||
}
|
||||
|
||||
json_object_start(response, "feerate");
|
||||
feerate = get_feerate(channel->fee_states, channel->opener, LOCAL);
|
||||
json_add_u32(response, feerate_style_name(FEERATE_PER_KSIPA), feerate);
|
||||
json_add_u32(response, feerate_style_name(FEERATE_PER_KBYTE),
|
||||
feerate_to_style(feerate, FEERATE_PER_KBYTE));
|
||||
json_object_end(response);
|
||||
|
||||
if (channel->owner)
|
||||
json_add_string(response, "owner", channel->owner->name);
|
||||
|
||||
|
@ -267,6 +267,12 @@ void json_add_amount_sat_compat(struct json_stream *result UNNEEDED,
|
||||
const char *msatfieldname)
|
||||
|
||||
{ fprintf(stderr, "json_add_amount_sat_compat called!\n"); abort(); }
|
||||
/* Generated stub for json_add_amount_sat_only */
|
||||
void json_add_amount_sat_only(struct json_stream *result UNNEEDED,
|
||||
const char *msatfieldname UNNEEDED,
|
||||
struct amount_sat sat)
|
||||
|
||||
{ fprintf(stderr, "json_add_amount_sat_only called!\n"); abort(); }
|
||||
/* Generated stub for json_add_bolt11 */
|
||||
void json_add_bolt11(struct json_stream *response UNNEEDED,
|
||||
const struct bolt11 *b11 UNNEEDED)
|
||||
|
@ -1606,7 +1606,8 @@ def test_multifunding_feerates(node_factory, bitcoind):
|
||||
Test feerate parameters for multifundchannel
|
||||
'''
|
||||
funding_tx_feerate = '10000perkw'
|
||||
commitment_tx_feerate = '2000perkw'
|
||||
commitment_tx_feerate_int = 2000
|
||||
commitment_tx_feerate = str(commitment_tx_feerate_int) + 'perkw'
|
||||
|
||||
l1, l2, l3 = node_factory.get_nodes(3, opts={'log-level': 'debug'})
|
||||
|
||||
@ -1626,6 +1627,11 @@ def test_multifunding_feerates(node_factory, bitcoind):
|
||||
expected_fee = int(funding_tx_feerate[:-5]) * weight // 1000
|
||||
assert expected_fee == entry['fees']['base'] * 10 ** 8
|
||||
|
||||
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']
|
||||
|
||||
# We get the expected close txid, force close the channel, then fish
|
||||
# the details about the transaction out of the mempoool entry
|
||||
close_txid = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['scratch_txid']
|
||||
@ -1652,6 +1658,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)
|
||||
|
||||
|
||||
def test_multifunding_param_failures(node_factory):
|
||||
|
2
wallet/db_postgres_sqlgen.c
generated
2
wallet/db_postgres_sqlgen.c
generated
@ -1834,4 +1834,4 @@ struct db_query db_postgres_queries[] = {
|
||||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
|
||||
|
||||
// SHA256STAMP:6b28c95645d860341a96102fc5f9240eaae6d10c30feb69459f42e78026de2b6
|
||||
// SHA256STAMP:9556cf46f2cbd29da75f53004ff8910b55604d5f9888d1a953c12cfa508e6f7f
|
||||
|
2
wallet/db_sqlite3_sqlgen.c
generated
2
wallet/db_sqlite3_sqlgen.c
generated
@ -1834,4 +1834,4 @@ struct db_query db_sqlite3_queries[] = {
|
||||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
|
||||
|
||||
// SHA256STAMP:6b28c95645d860341a96102fc5f9240eaae6d10c30feb69459f42e78026de2b6
|
||||
// SHA256STAMP:9556cf46f2cbd29da75f53004ff8910b55604d5f9888d1a953c12cfa508e6f7f
|
||||
|
6
wallet/statements_gettextgen.po
generated
6
wallet/statements_gettextgen.po
generated
@ -1202,11 +1202,11 @@ msgstr ""
|
||||
msgid "not a valid SQL statement"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/test/run-wallet.c:1404
|
||||
#: wallet/test/run-wallet.c:1410
|
||||
msgid "SELECT COUNT(1) FROM channel_funding_inflights WHERE channel_id = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/test/run-wallet.c:1602
|
||||
#: wallet/test/run-wallet.c:1608
|
||||
msgid "INSERT INTO channels (id) VALUES (1);"
|
||||
msgstr ""
|
||||
# SHA256STAMP:b9f3498738d18d7ed02f83699d902e480e8d75289b18deb5c2d5fe9d1f66c149
|
||||
# SHA256STAMP:033aa14057e8777fff79f9dfb1b469f72c9665f58e011b4cd907a976ce0f4ea4
|
||||
|
@ -268,6 +268,12 @@ void json_add_amount_sat_compat(struct json_stream *result UNNEEDED,
|
||||
const char *msatfieldname)
|
||||
|
||||
{ fprintf(stderr, "json_add_amount_sat_compat called!\n"); abort(); }
|
||||
/* Generated stub for json_add_amount_sat_only */
|
||||
void json_add_amount_sat_only(struct json_stream *result UNNEEDED,
|
||||
const char *msatfieldname UNNEEDED,
|
||||
struct amount_sat sat)
|
||||
|
||||
{ fprintf(stderr, "json_add_amount_sat_only called!\n"); abort(); }
|
||||
/* Generated stub for json_add_bool */
|
||||
void json_add_bool(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,
|
||||
bool value UNNEEDED)
|
||||
|
Loading…
Reference in New Issue
Block a user