diff --git a/cw_monero/lib/transaction_history.dart b/cw_monero/lib/transaction_history.dart index 58db9c8e..0ca58477 100644 --- a/cw_monero/lib/transaction_history.dart +++ b/cw_monero/lib/transaction_history.dart @@ -205,7 +205,7 @@ PendingTransactionDescription _createTransactionMultDestSync(Map args) { Future createTransaction( {String address, - String paymentId, + String paymentId = '', String amount, int priorityRaw, int accountIndex = 0}) => @@ -219,7 +219,7 @@ Future createTransaction( Future createTransactionMultDest( {List outputs, - String paymentId, + String paymentId = '', int priorityRaw, int accountIndex = 0}) => compute(_createTransactionMultDestSync, { diff --git a/lib/bitcoin/electrum_wallet.dart b/lib/bitcoin/electrum_wallet.dart index 2df77951..5b7970c3 100644 --- a/lib/bitcoin/electrum_wallet.dart +++ b/lib/bitcoin/electrum_wallet.dart @@ -186,16 +186,8 @@ abstract class ElectrumWalletBase extends WalletBase item.sendAll).toList(); - - if (sendAllItems?.isNotEmpty ?? false) { - throw BitcoinTransactionWrongBalanceException(currency); - } - - final nullAmountItems = outputs.where((item) => - item.formattedCryptoAmount <= 0).toList(); - - if (nullAmountItems?.isNotEmpty ?? false) { + if (outputs.any((item) => item.sendAll) || + outputs.any((item) => item.formattedCryptoAmount <= 0)) { throw BitcoinTransactionWrongBalanceException(currency); } diff --git a/lib/monero/monero_wallet.dart b/lib/monero/monero_wallet.dart index 3acb6792..08c6d1ef 100644 --- a/lib/monero/monero_wallet.dart +++ b/lib/monero/monero_wallet.dart @@ -163,25 +163,15 @@ abstract class MoneroWalletBase extends WalletBase item.sendAll).toList(); - - if (sendAllItems?.isNotEmpty ?? false) { - throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); - } - - final nullAmountItems = outputs.where((item) => - item.formattedCryptoAmount <= 0).toList(); - - if (nullAmountItems?.isNotEmpty ?? false) { + if (outputs.any((item) => item.sendAll) || + outputs.any((item) => item.formattedCryptoAmount <= 0)) { throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); } - var credentialsAmount = 0; - - credentialsAmount = outputs.fold(0, (acc, value) => + final int totalAmount = outputs.fold(0, (acc, value) => acc + value.formattedCryptoAmount); - if (unlockedBalance < credentialsAmount) { + if (unlockedBalance < totalAmount) { throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); } @@ -194,7 +184,6 @@ abstract class MoneroWalletBase extends WalletBase