Skip to content

Commit 4fd6c67

Browse files
committed
web3: add inline comments for btc speed-up/cancel conditions
1 parent 3a29f6b commit 4fd6c67

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

app/src/main/java/one/mixin/android/web3/details/Web3TransactionFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ class Web3TransactionFragment : BaseFragment(R.layout.fragment_web3_transaction)
525525
}
526526
val currentRate: BigDecimal? = estimateFeeResponse.feeRate?.toBigDecimalOrNull()
527527
val localRate: BigDecimal? = localRateString.toBigDecimalOrNull()
528+
// Only allow speed-up when the recommended fee rate is strictly higher than the current tx fee rate.
529+
// BigDecimal.compareTo returns 1 when currentRate > localRate.
528530
if (currentRate != null && localRate != null && currentRate.compareTo(localRate) != 1) {
529531
toast(getString(R.string.web3_btc_speed_up_not_needed))
530532
return@launch
@@ -566,6 +568,7 @@ class Web3TransactionFragment : BaseFragment(R.layout.fragment_web3_transaction)
566568
lifecycleScope.launch {
567569
if (token.chainId == Constants.ChainId.BITCOIN_CHAIN_ID) {
568570
val fromAddress: String = transaction.getFromAddress()
571+
// Whether this BTC transaction can be cancelled via a replacement tx (RBF).
569572
val canCancelBtcTransaction: Boolean = canCancelBtcTransaction(rawTransaction.raw, fromAddress)
570573
if (!canCancelBtcTransaction) {
571574
toast(R.string.web3_btc_cancel_not_possible)

0 commit comments

Comments
 (0)