-
Notifications
You must be signed in to change notification settings - Fork 109
Handle BTC fee fallback without raw transaction #6188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1446,19 +1446,40 @@ class InputFragment : BaseFragment(R.layout.fragment_input), OnReceiveSelectionC | |||||
| null | ||||||
| } | ||||||
| if (transaction == null) { | ||||||
| delay(3000) | ||||||
| refreshGas(t) | ||||||
| val handledByBtcFallback = t.chainId == Constants.ChainId.BITCOIN_CHAIN_ID && | ||||||
| isAdded && | ||||||
| applyFallbackBtcFeeWithoutRawTransaction(t) | ||||||
| if (handledByBtcFallback) { | ||||||
| binding.iconImageView.isVisible = false | ||||||
| binding.contentTextView.isVisible = true | ||||||
| binding.loadingProgressBar.isVisible = false | ||||||
| applyFeeUi() | ||||||
| return | ||||||
| } | ||||||
| delay(3000) | ||||||
| refreshGas(t) | ||||||
| return | ||||||
|
Comment on lines
+1459
to
+1461
|
||||||
| } else if (isAdded) { | ||||||
| val estimate= web3ViewModel.calcFee(t, transaction, fromAddress) | ||||||
| gas = estimate.fee | ||||||
| rate = estimate.rate | ||||||
| miniFee = estimate.minFee | ||||||
| if (gas == null) { | ||||||
| val handledByBtcFallback = t.chainId == Constants.ChainId.BITCOIN_CHAIN_ID && | ||||||
| applyFallbackBtcFeeWithoutRawTransaction(t) | ||||||
| if (handledByBtcFallback) { | ||||||
| binding.iconImageView.isVisible = false | ||||||
| binding.contentTextView.isVisible = true | ||||||
| binding.loadingProgressBar.isVisible = false | ||||||
| applyFeeUi() | ||||||
| return | ||||||
| } | ||||||
| delay(3000) | ||||||
| if (dialog.isShowing) { | ||||||
| dialog.dismiss() | ||||||
| } | ||||||
| refreshGas(t) | ||||||
| return | ||||||
| } | ||||||
| if (chainToken?.assetId == t.assetId) { | ||||||
| val balance = runCatching { | ||||||
|
|
@@ -1509,11 +1530,23 @@ class InputFragment : BaseFragment(R.layout.fragment_input), OnReceiveSelectionC | |||||
| applyFeeUi() | ||||||
| } | ||||||
|
|
||||||
| private suspend fun applyFallbackBtcFeeWithoutRawTransaction(t: Web3TokenItem): Boolean { | ||||||
| val estimate = web3ViewModel.estimateBtcFeeRate(currentRate = rate?.toPlainString()) ?: return false | ||||||
| rate = estimate.feeRate?.toBigDecimalOrNull() ?: rate | ||||||
| miniFee = estimate.minFee ?: miniFee | ||||||
| val fallbackFee: BigDecimal = estimate.minFee?.toBigDecimalOrNull()?.movePointLeft(1) ?: return false | ||||||
|
||||||
| val fallbackFee: BigDecimal = estimate.minFee?.toBigDecimalOrNull()?.movePointLeft(1) ?: return false | |
| val fallbackFee: BigDecimal = estimate.minFee?.toBigDecimalOrNull() ?: return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback handling repeats the same UI state toggles (
iconImageView/contentTextView/loadingProgressBar+applyFeeUi()) in multiple branches. This duplication makes it easy for the branches to drift (e.g., one path missing a UI update). Consider extracting a small helper to apply the common UI state for "fee resolved" and call it from all branches.