silent payments fix

This commit is contained in:
Matthew Fosse 2024-09-11 21:03:47 -07:00
parent cb8929173e
commit e6b9a49a28

View file

@ -11,6 +11,7 @@ import 'package:cake_wallet/utils/feature_flag.dart';
import 'package:cake_wallet/view_model/settings/sync_mode.dart'; import 'package:cake_wallet/view_model/settings/sync_mode.dart';
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart'; import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart'; import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
import 'package:cw_bitcoin/electrum_wallet.dart';
import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/wallet_type.dart'; import 'package:cw_core/wallet_type.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
@ -151,6 +152,8 @@ Future<void> onStart(ServiceInstance service) async {
final node = getIt.get<SettingsStore>().getCurrentNode(bitcoinWallets[i].type); final node = getIt.get<SettingsStore>().getCurrentNode(bitcoinWallets[i].type);
await wallet.connectToNode(node: node); await wallet.connectToNode(node: node);
await wallet.startSync(); await wallet.startSync();
// TODO: use proxy layer:
await (wallet as ElectrumWallet).setSilentPaymentsScanning(true);
syncingWallets.add(wallet); syncingWallets.add(wallet);
} }
} else { } else {
@ -166,6 +169,7 @@ Future<void> onStart(ServiceInstance service) async {
// } // }
} }
print("STARTING SYNC TIMER");
_syncTimer?.cancel(); _syncTimer?.cancel();
_syncTimer = Timer.periodic(const Duration(milliseconds: 2000), (timer) { _syncTimer = Timer.periodic(const Duration(milliseconds: 2000), (timer) {
// final wallet = getIt.get<AppStore>().wallet; // final wallet = getIt.get<AppStore>().wallet;
@ -209,8 +213,6 @@ Future<void> onStart(ServiceInstance service) async {
), ),
); );
} }
}); });
}); });
} }
@ -263,6 +265,8 @@ Future<void> initializeService(FlutterBackgroundService bgService, bool useNotif
} }
} catch (_) {} } catch (_) {}
print("INITIALIZING SERVICE");
await bgService.configure( await bgService.configure(
androidConfiguration: AndroidConfiguration( androidConfiguration: AndroidConfiguration(
onStart: onStart, onStart: onStart,