Inconsistent balance in home screen
On iOS, there's an inconsistency where the spendable balance of a channel is rounded down in the channels screen, but rounded up in the home screen:

This channel actually has a balance of 790 millisatoshis. Since we don't display millisatoshis, I think the balance in the home screen should be rounded down.
This was a well-timed issue. I was thinking about this the other day, and how we might go about fixing it.
I think part of the problem is that the current codebase is inflexible. It only supports 2 policies:
- Show millisatoshis
- Hide millisatoshis
And if msats are hidden, then it rounds to the nearest satoshi amount - unless that amount is zero, in which case it rounds up to one.
But I think the app needs the flexibility to support additional policies. That is, the above rounding policy probably makes sense for the transaction history table. But maybe not for the wallet balance.
So I've pushed a commit that moves the codebase in the direction of supporting additional policies. As a side benefit, I think it makes the code more readable:
// before:
Utils.format(currencyPrefs, msat: msat, hideMsats: false)
// after
Utils.format(currencyPrefs, msat: msat, policy: .showMsats)
And now we can add new policies:
Utils.format(currencyPrefs, msat: msat, policy: .showMsatsIfZeroSats)
So for the primary balance, we only show msats if:
0 < msats < 1_000
I'm not sure if this fully fixes the issue. What do you think? There's also a question regarding the balances within the channels-configuration screen. Should we display millisatoshi's there? Or is there some additional logic we use, for example:
- if any channel has a local or remote balance where:
0 < msat < 1_000 - then show millisatoshis for all channels
So for the primary balance, we only show msats if:
0 < msats < 1_000
I think that makes a lot of sense. We should use that policy for the balance display in the home screen and for the user's balance in the channels-configuration screen (only for the user's balance, not for the capacity or for the remote's balance).
Note that in the legacy and the phoenix-android apps no millisat amounts are displayed whatsoever. We should probably change that and follow the same rule than on iOS. Also, in the details screen of a payment, the actual amount including millisatoshis should be displayed somewhere, perhaps in the technical section.
Also, in the details screen of a payment, the actual amount including millisatoshis should be displayed somewhere, perhaps in the technical section.
This is implemented:
Note that currently iOS is also displaying msats in the Payment Details screen:
I don't have any strong feelings about this, one way or the other. We could limit millisatoshis to only the technical details screen. Or keep it the way it is. Or even some other policy that might make more sense here.