fix: status toggle

This commit is contained in:
Rafael Saes 2024-05-28 12:31:42 -03:00
parent aee365ca7f
commit 802935d974
2 changed files with 8 additions and 10 deletions

View file

@ -198,10 +198,11 @@ abstract class ElectrumWalletBase
@action @action
Future<void> setSilentPaymentsScanning(bool active) async { Future<void> setSilentPaymentsScanning(bool active) async {
syncStatus = AttemptingSyncStatus();
silentPaymentsScanningActive = active; silentPaymentsScanningActive = active;
if (active) { if (active) {
syncStatus = AttemptingSyncStatus();
final tip = await getUpdatedChainTip(); final tip = await getUpdatedChainTip();
if (tip == walletInfo.restoreHeight) { if (tip == walletInfo.restoreHeight) {
@ -214,7 +215,7 @@ abstract class ElectrumWalletBase
} else { } else {
alwaysScan = false; alwaysScan = false;
_isolate?.then((runningIsolate) => runningIsolate.kill(priority: Isolate.immediate)); (await _isolate)?.kill(priority: Isolate.immediate);
if (electrumClient.isConnected) { if (electrumClient.isConnected) {
syncStatus = SyncedSyncStatus(); syncStatus = SyncedSyncStatus();
@ -387,15 +388,14 @@ abstract class ElectrumWalletBase
B_scan: silentAddress.B_scan, B_scan: silentAddress.B_scan,
B_spend: unspent.silentPaymentLabel != null B_spend: unspent.silentPaymentLabel != null
? silentAddress.B_spend.tweakAdd( ? silentAddress.B_spend.tweakAdd(
BigintUtils.fromBytes( BigintUtils.fromBytes(BytesUtils.fromHexString(unspent.silentPaymentLabel!)),
BytesUtils.fromHexString(unspent.silentPaymentLabel!)), )
)
: silentAddress.B_spend, : silentAddress.B_spend,
hrp: silentAddress.hrp, hrp: silentAddress.hrp,
); );
final addressRecord = walletAddresses.silentAddresses.firstWhereOrNull( final addressRecord = walletAddresses.silentAddresses
(address) => address.address == silentPaymentAddress.toString()); .firstWhereOrNull((address) => address.address == silentPaymentAddress.toString());
addressRecord?.txCount += 1; addressRecord?.txCount += 1;
addressRecord?.balance += unspent.value; addressRecord?.balance += unspent.value;

View file

@ -501,7 +501,7 @@ class CWBitcoin extends Bitcoin {
Future<void> setScanningActive(Object wallet, bool active) async { Future<void> setScanningActive(Object wallet, bool active) async {
final bitcoinWallet = wallet as ElectrumWallet; final bitcoinWallet = wallet as ElectrumWallet;
if (!(await getNodeIsElectrsSPEnabled(wallet))) { if (active && !(await getNodeIsElectrsSPEnabled(wallet))) {
final node = Node( final node = Node(
useSSL: false, useSSL: false,
uri: 'electrs.cakewallet.com:${(wallet.network == BitcoinNetwork.testnet ? 50002 : 50001)}', uri: 'electrs.cakewallet.com:${(wallet.network == BitcoinNetwork.testnet ? 50002 : 50001)}',
@ -564,8 +564,6 @@ class CWBitcoin extends Bitcoin {
final bitcoinWallet = wallet as ElectrumWallet; final bitcoinWallet = wallet as ElectrumWallet;
final tweaksResponse = await bitcoinWallet.electrumClient.getTweaks(height: 0); final tweaksResponse = await bitcoinWallet.electrumClient.getTweaks(height: 0);
print('tweaksResponse: $tweaksResponse');
if (tweaksResponse != null) { if (tweaksResponse != null) {
return true; return true;
} }