From 9f4e6f1a3a060901460a26271b3ec9d71ca29317 Mon Sep 17 00:00:00 2001 From: Blazebrain Date: Thu, 6 Jul 2023 17:11:50 +0100 Subject: [PATCH] feat: Implement sweep all --- cw_monero/lib/monero_wallet.dart | 24 ++++++++++++------------ lib/view_model/wallet_creation_vm.dart | 8 ++++++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 4375105c4..6ef0a9884 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -172,15 +172,15 @@ abstract class MoneroWalletBase extends WalletBase 1; - final unlockedBalance = monero_wallet.getUnlockedBalance( - accountIndex: walletAddresses.account!.id); + // final unlockedBalance = monero_wallet.getUnlockedBalance( + // accountIndex: walletAddresses.accountList.accounts.first.id); PendingTransactionDescription pendingTransactionDescription; - // if (!(syncStatus is SyncedSyncStatus)) { - // print('Wallet is not synced'); - // throw MoneroTransactionCreationException('The wallet is not synced.'); - // } + if (!(syncStatus is SyncedSyncStatus)) { + print('Wallet is not synced'); + throw MoneroTransactionCreationException('The wallet is not synced.'); + } if (hasMultiDestination) { if (outputs.any( @@ -192,10 +192,10 @@ abstract class MoneroWalletBase extends WalletBase acc + (value.formattedCryptoAmount ?? 0)); - if (unlockedBalance < totalAmount) { - throw MoneroTransactionCreationException( - 'You do not have enough XMR to send this amount.'); - } + // if (unlockedBalance < totalAmount) { + // throw MoneroTransactionCreationException( + // 'You do not have enough XMR to send this amount.'); + // } final moneroOutputs = outputs.map((output) { final outputAddress = @@ -217,8 +217,8 @@ abstract class MoneroWalletBase extends WalletBase, TransactionInfo> wallet, + WalletBase, + TransactionInfo> + newWallet, WalletType type, String newWalletAddress, String paymentId) async { @@ -182,8 +185,9 @@ abstract class WalletCreationVMBase with Store { //* Switch back to new wallet _appStore.changeCurrentWallet(wallet); + await _walletInfoSource.deleteAt(0); //* Add the new Wallet info to the walletInfoSource - await _walletInfoSource.add(wallet.walletInfo); + await _walletInfoSource.add(newWallet.walletInfo); //* Approve authentication as successful _appStore.authenticationStore.allowed();