diff --git a/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart b/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart index aa4a4d6c8..6f9f07077 100644 --- a/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart +++ b/cw_bitcoin_cash/lib/src/bitcoin_cash_wallet.dart @@ -119,13 +119,10 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store { } } - if (inputs.isEmpty) { - throw BitcoinTransactionNoInputsException(); - } + if (inputs.isEmpty) throw BitcoinTransactionNoInputsException(); - final int feeRate = transactionCredentials.feeRate != null - ? transactionCredentials.feeRate! - : BitcoinCashFeeRates.feeRate(transactionCredentials.priority!); + final int feeRate = transactionCredentials.feeRate ?? + BitcoinCashFeeRates.feeRate(transactionCredentials.priority!); final int allAmountFee = bitbox.BitcoinCash.getByteCount(inputs.length, transactionCredentials.outputs.length) * @@ -145,8 +142,6 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store { return acc + value.formattedCryptoAmount!; }); - print(credentialsAmount); - if (allAmount - credentialsAmount < minAmount) { throw BitcoinTransactionWrongBalanceException(currency); } @@ -164,9 +159,7 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store { final output = outputs.first; credentialsAmount = !output.sendAll ? output.formattedCryptoAmount! : 0; - if (credentialsAmount > allAmount) { - throw BitcoinTransactionWrongBalanceException(currency); - } + if (credentialsAmount > allAmount) throw BitcoinTransactionWrongBalanceException(currency); amount = output.sendAll || allAmount - credentialsAmount < minAmount ? allAmount @@ -181,9 +174,7 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store { } } - if (fee == 0) { - throw BitcoinTransactionWrongBalanceException(currency); - } + if (fee == 0) throw BitcoinTransactionWrongBalanceException(currency); final totalAmount = amount + fee; @@ -203,15 +194,11 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store { totalInputAmount += utx.value; inputs.add(utx); - if (leftAmount <= 0) { - break; - } + if (leftAmount <= 0) break; } } - if (inputs.isEmpty) { - throw BitcoinTransactionNoInputsException(); - } + if (inputs.isEmpty) throw BitcoinTransactionNoInputsException(); if (amount <= 0 || totalInputAmount < totalAmount) { throw BitcoinTransactionWrongBalanceException(currency); diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 1c49c1a7c..6bb512c2b 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -325,9 +325,7 @@ abstract class SendViewModelBase with Store { Object _credentials() { final priority = _settingsStore.priority[_wallet.type]; - if (priority == null) { - throw Exception('Priority is null for wallet type: ${_wallet.type}'); - } + if (priority == null) throw Exception('Priority is null for wallet type: ${_wallet.type}'); switch (_wallet.type) { case WalletType.bitcoin: diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index bb6008754..de2e0e75e 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -39,6 +39,7 @@ abstract class TransactionDetailsViewModelBase with Store { break; case WalletType.bitcoin: case WalletType.litecoin: + case WalletType.bitcoinCash: _addElectrumListItems(tx, dateFormat); break; case WalletType.haven: @@ -111,6 +112,7 @@ abstract class TransactionDetailsViewModelBase with Store { case WalletType.bitcoin: return 'https://mempool.space/tx/${txId}'; case WalletType.litecoin: + case WalletType.bitcoinCash: return 'https://blockchair.com/litecoin/transaction/${txId}'; case WalletType.haven: return 'https://explorer.havenprotocol.org/search?value=${txId}'; @@ -128,6 +130,7 @@ abstract class TransactionDetailsViewModelBase with Store { case WalletType.bitcoin: return S.current.view_transaction_on + 'mempool.space'; case WalletType.litecoin: + case WalletType.bitcoinCash: return S.current.view_transaction_on + 'Blockchair.com'; case WalletType.haven: return S.current.view_transaction_on + 'explorer.havenprotocol.org';