Skip to content

Commit

Permalink
introduce WalletScannerStreamReply
Browse files Browse the repository at this point in the history
  • Loading branch information
willyfromtheblock committed Aug 14, 2023
1 parent d3361dc commit 8aeefdf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
2 changes: 2 additions & 0 deletions lib/data_sources/data_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'dart:async';

import '../providers/connection_provider.dart';

enum BackendType { electrum, marisma }

abstract class DataSource {
BackendConnectionState connectionState = BackendConnectionState.waiting;
Map<String, List?> paperWalletUtxos = {};
Expand Down
16 changes: 16 additions & 0 deletions lib/models/wallet_scanner_stream_reply.dart
Original file line number Diff line number Diff line change
@@ -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,
});
}
Original file line number Diff line number Diff line change
@@ -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<String, int> _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<WalletScannerStreamReply> 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) {
Expand Down

0 comments on commit 8aeefdf

Please sign in to comment.