listpeers: include the pushed_msat amount

Useful for accounting for missed/historical channel opens, to figure out
what the actual sat contribution from each peer is at a utxo level

Changelog-Added: JSONRPC: `listpeers` now includes a `pushed_msat` value. For leased channels, is the total lease_fee.
This commit is contained in:
niftynei 2022-02-08 14:43:51 -06:00 committed by Rusty Russell
parent ecb19ba6f2
commit 590f12145b
3 changed files with 9 additions and 2 deletions

View file

@ -73,6 +73,7 @@ On success, an object containing **peers** is returned. It is an array of objec
- **funding** (object, optional):
- **local_msat** (msat): Amount of channel we funded
- **remote_msat** (msat): Amount of channel they funded
- **pushed_msat** (msat): Amount pushed from opener to peer
- **to_us_msat** (msat, optional): how much of channel is owed to us
- **min_to_us_msat** (msat, optional): least amount owed to us ever
- **max_to_us_msat** (msat, optional): most amount owed to us ever
@ -377,4 +378,4 @@ Main web site: <https://github.com/ElementsProject/lightning> Lightning
RFC site (BOLT \#9):
<https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md>
[comment]: # ( SHA256STAMP:d45de73a968bcc3e7fb699f0acd7a27a4c70d9e9fded8af8c684a71fe012f1ce)
[comment]: # ( SHA256STAMP:001e3cf495571bb09fe29f74adde8a6e40e69ddb1169934924eaf901a1e5f3c0)

View file

@ -342,7 +342,8 @@
"additionalProperties": false,
"required": [
"local_msat",
"remote_msat"
"remote_msat",
"pushed_msat"
],
"properties": {
"local_msat": {
@ -352,6 +353,10 @@
"remote_msat": {
"type": "msat",
"description": "Amount of channel they funded"
},
"pushed_msat": {
"type": "msat",
"description": "Amount pushed from opener to peer"
}
}
},

View file

@ -791,6 +791,7 @@ static void json_add_channel(struct lightningd *ld,
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_add_amount_msat_only(response, "pushed_msat", channel->push);
json_object_end(response);
if (!amount_sat_to_msat(&funding_msat, channel->funding_sats)) {