Uh oh!
There was an error while loading. Please reload this page.
SpendingAmountScreen state handling improvement - #264
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jvsena42
commented
Jul 29, 2025
I'll do the TransferViewModel clean up and Unit tests in other branch to don't obfuscate the fixes from this one |
ovitrif
left a comment
There was a problem hiding this comment.
Very nice work!
Found only an issue which needs to be addressed IMHO, related to the max amount fee calculation
| val totalFeeFromAvailableAmount = lightningRepo.calculateTotalFee(amountSats = onChainBalance) | ||
| .getOrDefault(DEFAULT_TX_FEE.toULong()) | ||
| // Get the max available balance discounting onChain fee | ||
| val availableAmount = onChainBalance - totalFeeFromAvailableAmount |
There was a problem hiding this comment.
We always get NodeException.InsufficientFunds exception when trying to calculateTotalFee for the entire onChainBalance.
That's the reason I added walletRepo.getMaxSendAmount(), which is not perfect either (I got sometimes failure for the onChainBalance - 1000sat buffer solution), but still much less error-prone:
bitkit-android/app/src/main/java/to/bitkit/repositories/WalletRepo.kt
Lines 318 to 336 in 46d613a
Much recommended to use the getMaxSendAmount() here as well, that way we won't ALWAYS end up with the DEFAULT_TX_FEE.
PS. I informed @coreyphillips about this issue but it's not the highest priority thus looking into it will be delayed.
There was a problem hiding this comment.
Much better, though I still get error: Invalid request format when selecting the max amount
There was a problem hiding this comment.
True, because Invalid request format comes from bitkit-core's http call to Blocktank staging.
jvsena42
commented
Jul 30, 2025
ovitrif
left a comment
There was a problem hiding this comment.
Nice refactor, the changed code works good!
Added an remark for improvement, feel free to address outside of this PR though.
Tested
- Normal Success flow
- Max amount
- 25%
- Error value higher than max amount
| if (sats > _spendingUiState.value.maxAllowedToSend) { | ||
| setTransferEffect( | ||
| TransferEffect.ToastError( | ||
| title = context.getString(R.string.lightning__spending_amount__error_max__title), | ||
| description = context.getString( | ||
| R.string.lightning__spending_amount__error_max__description | ||
| ).replace("{amount}", _spendingUiState.value.maxAllowedToSend.toString()), | ||
| ) | ||
| ) | ||
| } |
There was a problem hiding this comment.
in the RN app, the amount will not update if it would exceed the max limit.
I think we can easily do the same here with this code right after the effect:
_spendingUiState.update { it.copy(overrideSats = it.satsAmount) }
return
Related to #229
Description
Preview
transfer_tested.mp4
QA Notes
Tested