bkpr/listpeeers: add lease_fees back to funds; separate out in listpeers

First, how we record "our_funds" and then apply pushes vs lease_fees
(for liquidity ad buys/sales) was exactly opposite.

For pushes we were reporting the total funded into the channel, with the
push representing how much we'd later moved to the peer.

For lease_fees we were rerporting the total in the channel, with the
push representing how much was already moved to the peer.

We fix this (from a view perspective) by re-adding lease fees to what's
reported in the channel funding totals. Since this is now new behavior
(for leased channel values), we added new fields so we can take the old
field names thru a deprecation cycle.

We also make it possible to differentiate btw a push and a lease_fee
(before they were all the same), by adding to new fields to `listpeers`:
`fee_paid_msat` and `fee_rcvd_msat`.

This allows us to avoid math in the bookkeeper, instead we just pick
the numbers out directly and record them.

Fixes #5472

Changelog-Added: JSON-RPC: `listpeers` now has a few new fields for `funding` (`remote_funds_msat`, `local_funds_msat`, `fee_paid_msat`, `fee_rcvd_msat`).
Changelog-Deprecated: JSON-RPC: `listpeers`.`funded` fields `local_msat` and `remote_msat` are now deprecated.
This commit is contained in:
niftynei
2022-07-28 22:44:17 -05:00
committed by Rusty Russell
parent a675f4c24e
commit 4e503f7d0a
13 changed files with 646 additions and 364 deletions

View File

@@ -71,9 +71,13 @@ On success, an object containing **peers** is returned. It is an array of objec
- **private** (boolean, optional): if False, we will not announce this channel
- **closer** (string, optional): Who initiated the channel close (one of "local", "remote")
- **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
- **local_funds_msat** (msat): Amount of channel we funded
- **remote_funds_msat** (msat): Amount of channel they funded
- **local_msat** (msat, optional): Amount of channel we funded (deprecated)
- **remote_msat** (msat, optional): Amount of channel they funded (deprecated)
- **pushed_msat** (msat, optional): Amount pushed from opener to peer
- **fee_paid_msat** (msat, optional): Amount we paid peer at open
- **fee_rcvd_msat** (msat, optional): Amount we were paid by peer at open
- **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
@@ -384,4 +388,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:c26d3094925387ee935efc6351400bca374c361e5956ff13f10b228773f8e389)
[comment]: # ( SHA256STAMP:971c71befa1b6968a66b65e2aab4a2d1707f14c9af5d6ebc2dc00604d1d91294)

View File

@@ -337,22 +337,37 @@
"type": "object",
"additionalProperties": false,
"required": [
"local_msat",
"remote_msat",
"pushed_msat"
"local_funds_msat",
"remote_funds_msat"
],
"properties": {
"local_msat": {
"type": "msat",
"description": "Amount of channel we funded"
"description": "Amount of channel we funded (deprecated)"
},
"remote_msat": {
"type": "msat",
"description": "Amount of channel they funded"
"description": "Amount of channel they funded (deprecated)"
},
"pushed_msat": {
"type": "msat",
"description": "Amount pushed from opener to peer"
},
"local_funds_msat": {
"type": "msat",
"description": "Amount of channel we funded"
},
"remote_funds_msat": {
"type": "msat",
"description": "Amount of channel they funded"
},
"fee_paid_msat": {
"type": "msat",
"description": "Amount we paid peer at open"
},
"fee_rcvd_msat": {
"type": "msat",
"description": "Amount we were paid by peer at open"
}
}
},