diff --git a/lib/data_sources/data_source.dart b/lib/data_sources/data_source.dart index 7f6c3765..7a3fdd6c 100644 --- a/lib/data_sources/data_source.dart +++ b/lib/data_sources/data_source.dart @@ -2,6 +2,8 @@ import 'dart:async'; import '../providers/connection_provider.dart'; +enum BackendType { electrum, marisma } + abstract class DataSource { BackendConnectionState connectionState = BackendConnectionState.waiting; Map paperWalletUtxos = {}; diff --git a/lib/models/wallet_scanner_stream_reply.dart b/lib/models/wallet_scanner_stream_reply.dart new file mode 100644 index 00000000..169f335e --- /dev/null +++ b/lib/models/wallet_scanner_stream_reply.dart @@ -0,0 +1,16 @@ +enum WalletScannerMessageType { + newWallet, + newAddress, + scanFinished, + error, +} + +class WalletScannerStreamReply { + final WalletScannerMessageType type; + final String message; + + WalletScannerStreamReply({ + required this.type, + required this.message, + }); +} diff --git a/lib/data_sources/wallet_scanner.dart b/lib/tools/wallet_scanner.dart similarity index 80% rename from lib/data_sources/wallet_scanner.dart rename to lib/tools/wallet_scanner.dart index 2e3805c3..bcb7d445 100644 --- a/lib/data_sources/wallet_scanner.dart +++ b/lib/tools/wallet_scanner.dart @@ -1,27 +1,33 @@ -import '../tools/logger_wrapper.dart'; -import 'data_source.dart'; - -enum WalletScanMode { seed, singleWallet, singleCoin } +import '../models/coin.dart'; +import '../models/wallet_scanner_stream_reply.dart'; +import 'logger_wrapper.dart'; +import '../data_sources/data_source.dart'; class WalletScanner { - int _depthPointer = 1; - int _maxChainDepth = 5; - int _maxAddressDepth = 0; //no address depth scan for now - Map _queryDepth = {'account': 0, 'chain': 0, 'address': 0}; - - String walletName; - WalletScanMode scanMode; - DataSource backend; + int _chainDepthPointer = 0; + Coin coin; + int accountNumber; + BackendType backend; WalletScanner({ - required this.walletName, - required this.scanMode, + required this.accountNumber, required this.backend, + required this.coin, }); + Stream startScanning() async* { + LoggerWrapper.logInfo( + 'WalletScanner', + 'start', + 'starting scan for ${coin.displayName} at $accountNumber with ${backend.name}', + ); + + //Return stream of scan results + } + // void hold() { // if (newStatus == null) { - // await subscribeNextDerivedAddress(); //TODO move this logic out of the connection provider, it has no real business here + // await subscribeNextDerivedAddress(); // } else { // //increase depth because we found one != null // if (_depthPointer == 1) {