phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

Inconsistent balance in home screen

Open dpad85 opened this issue 4 years ago • 3 comments

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:

image

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.

dpad85 avatar Feb 07 '22 10:02 dpad85

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

Screen Shot 2022-02-15 at 15 52 50

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

robbiehanson avatar Feb 15 '22 19:02 robbiehanson

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.

dpad85 avatar May 30 '22 11:05 dpad85

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:

Screen Shot 2022-06-02 at 15 41 31

Note that currently iOS is also displaying msats in the Payment Details screen:

Screen Shot 2022-06-02 at 11 12 15

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.

robbiehanson avatar Jun 02 '22 20:06 robbiehanson