diff --git a/cw_bitcoin/lib/pending_bitcoin_transaction.dart b/cw_bitcoin/lib/pending_bitcoin_transaction.dart index fa413febd..b45931133 100644 --- a/cw_bitcoin/lib/pending_bitcoin_transaction.dart +++ b/cw_bitcoin/lib/pending_bitcoin_transaction.dart @@ -31,6 +31,9 @@ class PendingBitcoinTransaction with PendingTransaction { @override String get feeFormatted => bitcoinAmountToString(amount: fee); + @override + int? get outputCount => _tx.outputs.length; + final List _listeners; @override diff --git a/cw_core/lib/pending_transaction.dart b/cw_core/lib/pending_transaction.dart index cc5686fc9..042b0ca2b 100644 --- a/cw_core/lib/pending_transaction.dart +++ b/cw_core/lib/pending_transaction.dart @@ -3,6 +3,7 @@ mixin PendingTransaction { String get amountFormatted; String get feeFormatted; String get hex; + int? get outputCount => null; Future commit(); } \ No newline at end of file diff --git a/lib/view_model/exchange/exchange_trade_view_model.dart b/lib/view_model/exchange/exchange_trade_view_model.dart index b2894b43d..9bb1db503 100644 --- a/lib/view_model/exchange/exchange_trade_view_model.dart +++ b/lib/view_model/exchange/exchange_trade_view_model.dart @@ -106,7 +106,7 @@ abstract class ExchangeTradeViewModelBase with Store { output.setCryptoAmount(trade.amount); if (_provider is ThorChainExchangeProvider) output.memo = trade.memo; sendViewModel.selectedCryptoCurrency = trade.from; - final pendingTransaction = await sendViewModel.createTransaction(); + final pendingTransaction = await sendViewModel.createTransaction(provider: _provider); if (_provider is ThorChainExchangeProvider) { trade.id = pendingTransaction?.id ?? ''; trades.add(trade); diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 779a0187b..329ee4375 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -1,6 +1,8 @@ import 'package:cake_wallet/entities/priority_for_wallet_type.dart'; import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; +import 'package:cake_wallet/exchange/provider/exchange_provider.dart'; +import 'package:cake_wallet/exchange/provider/thorchain_exchange.provider.dart'; import 'package:cake_wallet/nano/nano.dart'; import 'package:cake_wallet/core/wallet_change_listener_view_model.dart'; import 'package:cake_wallet/entities/contact_record.dart'; @@ -295,10 +297,16 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor } @action - Future createTransaction() async { + Future createTransaction({ExchangeProvider? provider}) async { try { state = IsExecutingState(); pendingTransaction = await wallet.createTransaction(_credentials()); + if (provider is ThorChainExchangeProvider) { + print('Output count: ${pendingTransaction?.outputCount}'); + print('provider is ThorChainExchangeProvider and pendingTransaction is ${provider.runtimeType}'); + final outputCount = pendingTransaction?.outputCount ?? 0; + if (outputCount > 10) throw Exception("ThorChain does not support more than 10 outputs"); + } state = ExecutedSuccessfullyState(); return pendingTransaction; } catch (e) {