alexbosworth / balanceofsatoshis

Tool for working with the balance of your satoshis on LND
MIT License
554 stars 78 forks source link

bos balance fluctuates with HTLCs #572

Closed zapomatic closed 4 months ago

zapomatic commented 5 months ago

This may be an issue for LND not serving enough info in the APIs, but it seems that bos balance is fluctuating as the HTLCs are adjusting. As a node with dozens of in-flight HTLCs constantly, using bos balance does not provide a reliable snapshot of the funds that belong to the node. Running bos balance repeatedly returns amounts that are +- hundreds or millions of sats.

Is this because one side of the HTLC may be accounted for but not the other? Or is it a timing issue with gathering the stats while an HTLC comes or goes?

To illustrate, running this on my node just now:

for i in {1..10}; do bos balance; done

produces 10 outputs that contain the following numeric diffs from the prior output:

0
131,262
29,475
-183,471
418,886
-45,778
200,202
-19,258
-42,071
-312,242
zapomatic commented 4 months ago

To clarify user expectations, I would think that bos balance would return an answer to the question of "What number of sats does this node own if all current HTLCs are assumed to fail/cancel?"

alexbosworth commented 4 months ago

did you try using bos balance --detailed

zapomatic commented 4 months ago

That seems to be more what I'm looking for (the offchain_balance output from --detailed). Thanks!

alexbosworth commented 4 months ago

bos balance relays the balance sums from lnd directly, detailed does a source analysis of relevant rows and calculates the balance itself, with assumptions that you referenced about the in-flight or potential transfer changes to produce a more stable output