parent
2c45ab642b
commit
e398af5690
|
@ -18,21 +18,26 @@ data class WalletSnapshot(
|
|||
val progress: PercentDecimal,
|
||||
val synchronizerError: SynchronizerError?
|
||||
) {
|
||||
// Note that both [hasSaplingFunds] and [hasTransparentFunds] checks are not entirely correct - they do not
|
||||
// calculate the resulting fee using the new Proposal API. It's fine for now, but it's subject to improvement
|
||||
// later once we figure out how to handle it in such cases.
|
||||
// Note: the wallet's transparent balance is effectively empty if it cannot cover the miner's fee
|
||||
val hasTransparentFunds = transparentBalance.value > 0L
|
||||
|
||||
// Note: the wallet is effectively empty if it cannot cover the miner's fee
|
||||
val hasSaplingFunds = saplingBalance.available.value > 0L
|
||||
|
||||
val hasSaplingBalance = saplingBalance.total.value > 0L
|
||||
|
||||
// Note: the wallet's transparent balance is effectively empty if it cannot cover the miner's fee
|
||||
val hasTransparentFunds = transparentBalance.value > 0L
|
||||
// Note: the wallet is effectively empty if it cannot cover the miner's fee
|
||||
val hasOrchardFunds = orchardBalance.available.value > 0L
|
||||
|
||||
val isSendEnabled: Boolean get() = status == Synchronizer.Status.SYNCED && hasSaplingFunds
|
||||
val hasOrchardBalance = orchardBalance.total.value > 0L
|
||||
|
||||
val isSendEnabled: Boolean get() = hasSaplingFunds && hasOrchardFunds
|
||||
}
|
||||
|
||||
// Note this check is not entirely correct - it does not calculate the resulting fee using the new Proposal API. It's
|
||||
// fine for now, but it's subject to improvement later once we figure out how to handle it in such cases.
|
||||
fun WalletSnapshot.canSpend(amount: Zatoshi): Boolean = spendableBalance() >= amount
|
||||
|
||||
fun WalletSnapshot.totalBalance() = orchardBalance.total + saplingBalance.total + transparentBalance
|
||||
|
||||
// Note that considering both to be spendable is subject to change.
|
||||
|
|
|
@ -53,6 +53,7 @@ import co.electriccoin.zcash.spackle.Twig
|
|||
import co.electriccoin.zcash.ui.R
|
||||
import co.electriccoin.zcash.ui.common.compose.BalanceWidget
|
||||
import co.electriccoin.zcash.ui.common.model.WalletSnapshot
|
||||
import co.electriccoin.zcash.ui.common.model.canSpend
|
||||
import co.electriccoin.zcash.ui.common.model.spendableBalance
|
||||
import co.electriccoin.zcash.ui.common.test.CommonTag
|
||||
import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT
|
||||
|
@ -324,7 +325,7 @@ private fun SendForm(
|
|||
recipientAddressState.address.isNotEmpty() &&
|
||||
amountState is AmountState.Valid &&
|
||||
amountState.value.isNotBlank() &&
|
||||
walletSnapshot.spendableBalance() >= amountState.zatoshi &&
|
||||
walletSnapshot.canSpend(amountState.zatoshi) &&
|
||||
// A valid memo is necessary only for non-transparent recipient
|
||||
(recipientAddressState.type == AddressType.Transparent || memoState is MemoState.Correct)
|
||||
|
||||
|
|
Loading…
Reference in New Issue