From 802935d9749a603f73aca3aad5d87dc6e5206dc6 Mon Sep 17 00:00:00 2001 From: Rafael Saes Date: Tue, 28 May 2024 12:31:42 -0300 Subject: [PATCH] fix: status toggle --- cw_bitcoin/lib/electrum_wallet.dart | 14 +++++++------- lib/bitcoin/cw_bitcoin.dart | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index f7aa0bc5d..96f871a4b 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -198,10 +198,11 @@ abstract class ElectrumWalletBase @action Future setSilentPaymentsScanning(bool active) async { - syncStatus = AttemptingSyncStatus(); silentPaymentsScanningActive = active; if (active) { + syncStatus = AttemptingSyncStatus(); + final tip = await getUpdatedChainTip(); if (tip == walletInfo.restoreHeight) { @@ -214,7 +215,7 @@ abstract class ElectrumWalletBase } else { alwaysScan = false; - _isolate?.then((runningIsolate) => runningIsolate.kill(priority: Isolate.immediate)); + (await _isolate)?.kill(priority: Isolate.immediate); if (electrumClient.isConnected) { syncStatus = SyncedSyncStatus(); @@ -387,15 +388,14 @@ abstract class ElectrumWalletBase B_scan: silentAddress.B_scan, B_spend: unspent.silentPaymentLabel != null ? silentAddress.B_spend.tweakAdd( - BigintUtils.fromBytes( - BytesUtils.fromHexString(unspent.silentPaymentLabel!)), - ) + BigintUtils.fromBytes(BytesUtils.fromHexString(unspent.silentPaymentLabel!)), + ) : silentAddress.B_spend, hrp: silentAddress.hrp, ); - final addressRecord = walletAddresses.silentAddresses.firstWhereOrNull( - (address) => address.address == silentPaymentAddress.toString()); + final addressRecord = walletAddresses.silentAddresses + .firstWhereOrNull((address) => address.address == silentPaymentAddress.toString()); addressRecord?.txCount += 1; addressRecord?.balance += unspent.value; diff --git a/lib/bitcoin/cw_bitcoin.dart b/lib/bitcoin/cw_bitcoin.dart index 27488c87b..3708f69fe 100644 --- a/lib/bitcoin/cw_bitcoin.dart +++ b/lib/bitcoin/cw_bitcoin.dart @@ -501,7 +501,7 @@ class CWBitcoin extends Bitcoin { Future setScanningActive(Object wallet, bool active) async { final bitcoinWallet = wallet as ElectrumWallet; - if (!(await getNodeIsElectrsSPEnabled(wallet))) { + if (active && !(await getNodeIsElectrsSPEnabled(wallet))) { final node = Node( useSSL: false, uri: 'electrs.cakewallet.com:${(wallet.network == BitcoinNetwork.testnet ? 50002 : 50001)}', @@ -564,8 +564,6 @@ class CWBitcoin extends Bitcoin { final bitcoinWallet = wallet as ElectrumWallet; final tweaksResponse = await bitcoinWallet.electrumClient.getTweaks(height: 0); - print('tweaksResponse: $tweaksResponse'); - if (tweaksResponse != null) { return true; }