Repository navigation
Add last_local_balance_msats field - #3235
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3235 +/- ##
==========================================
+ Coverage 89.64% 90.87% +1.23%
==========================================
Files 126 127 +1
Lines 102399 116414 +14015
Branches 102399 116414 +14015
==========================================
+ Hits 91793 105792 +13999
- Misses 7881 7993 +112
+ Partials 2725 2629 -96 ☔ View full report in Codecov by Sentry. |
|
Does it look good? |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Basically looks good, just needs better docs.
|
When you update the docs, please feel free to squash the commits down into one, but include more detail in the commit message - why was this change needed, what did the change do, any details about why the change was done in the way it was, etc. |
|
This basically LGTM, modulo the indentation note and the git commit message being missing. See https://cbea.ms/git-commit/ for a much, much, much longer discussion of how to write good commit messages. |
|
Addressed all your points above, ready for review. |
TheBlueMatt
left a comment
There was a problem hiding this comment.
Basicaly LGTM. Can you word-wrap your commit message so that no line is longer than ~70 chars? See-also https://cbea.ms/git-commit/ for commit message writing.
| /// Local balance in msats when a channel is closed. | ||
| /// | ||
| /// May overstate balance by pending outbound HTLCs and transaction fees. | ||
| /// For more accurate balances including fee information see [ChainMonitor::get_claimable_balances] |
There was a problem hiding this comment.
nit, we usually tick our links so that they show up monospace
| /// For more accurate balances including fee information see [ChainMonitor::get_claimable_balances] | |
| /// For more accurate balances including fee information see [`ChainMonitor::get_claimable_balances`] |
vincenzopalazzo
left a comment
There was a problem hiding this comment.
What Matt said regarding the commit, otherwise LGTM
TheBlueMatt
left a comment
There was a problem hiding this comment.
Went ahead and pushed the updates myself. They're docs-only so just gonna land:
$ git diff-tree -U2 2557e6b7e 3cd6ada3d
diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs
index ebac6e4a9..2384a49db 100644
--- a/lightning/src/events/mod.rs
+++ b/lightning/src/events/mod.rs
@@ -1277,8 +1277,12 @@ pub enum Event {
/// Note that for instances serialized in v0.0.119 or prior this will be missing (None).
channel_funding_txo: Option<transaction::OutPoint>,
- /// Local balance in msats when a channel is closed.
+ /// An upper bound on the our last local balance in msats before the channel was closed.
///
- /// May overstate balance by pending outbound HTLCs and transaction fees.
- /// For more accurate balances including fee information see [ChainMonitor::get_claimable_balances]
+ /// Will overstate our balance as it ignores pending outbound HTLCs and transaction fees.
+ ///
+ /// For more accurate balances including fee information see
+ /// [`ChainMonitor::get_claimable_balances`].
+ ///
+ /// This field will be `None` only for objects serialized prior to LDK 0.1.
last_local_balance_msats: Option<u64>,
},
@@ -1562,5 +1566,5 @@ impl Writeable for Event {
&Event::ChannelClosed { ref channel_id, ref user_channel_id, ref reason,
ref counterparty_node_id, ref channel_capacity_sats, ref channel_funding_txo,
- ref last_local_balance_msats
+ ref last_local_balance_msats,
} => {
9u8.write(writer)?;
tnull
left a comment
There was a problem hiding this comment.
LGTM other than the field naming mentioned.
Users commonly want to know what their balance was when a channel was closed, which this provides in a somewhat simplified manner. It does not consider pending HTLCs and will always overstate our balance by transaction fees.
|
Done |
|
@TheBlueMatt Thank you very much |
This PR adds
last_local_balance_msatsfield. Solves #1898 .I have a few open questions:
last_local_balance_msats, in filechannel.rsat https://github.com/Mirebella/rust-lightning/blob/3eba0e2bbcb8547d561b175b1f19dd19565911b3/lightning/src/ln/channel.rs#L9591C1-L9591C33mod.rsat https://github.com/Mirebella/rust-lightning/blob/3eba0e2bbcb8547d561b175b1f19dd19565911b3/lightning/src/events/mod.rs#L1538C6-L1538C44I saw that tlv fields are numbered differently(sometimes even numbers, sometimes odd numbers). I added my variable under number 11. Is that correct?