fix transaction details screen

This commit is contained in:
Serhii 2023-08-20 23:53:36 +03:00
parent b4316581c8
commit 7f2b837c2e
3 changed files with 11 additions and 23 deletions

View file

@ -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);

View file

@ -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:

View file

@ -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';