From 8167ca98439406618e6af832571c64090a4a7703 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 13 Dec 2024 23:10:41 -0600 Subject: [PATCH 01/10] WIP: fix electrumx failovers, add some "default" firo nodes, and tweak firo pings --- lib/electrumx_rpc/electrumx_client.dart | 15 ++++--- lib/services/node_service.dart | 43 +++++++++++++++++++ lib/wallets/wallet/wallet.dart | 27 +++++++----- test/cached_electrumx_test.mocks.dart | 9 ---- .../bitcoin/bitcoin_wallet_test.mocks.dart | 9 ---- .../bitcoincash_wallet_test.mocks.dart | 9 ---- .../dogecoin/dogecoin_wallet_test.mocks.dart | 9 ---- .../namecoin/namecoin_wallet_test.mocks.dart | 9 ---- .../particl/particl_wallet_test.mocks.dart | 9 ---- 9 files changed, 68 insertions(+), 71 deletions(-) diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index dff2b68fd..39e27ee81 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -108,7 +108,7 @@ class ElectrumXClient { late Prefs _prefs; late TorService _torService; - List? failovers; + late final List _failovers; int currentFailoverIndex = -1; final Duration connectionTimeoutForSpecialCaseJsonRPCClients; @@ -145,6 +145,7 @@ class ElectrumXClient { _host = host; _port = port; _useSSL = useSSL; + _failovers = failovers; final bus = globalEventBusForTesting ?? GlobalEventBus.instance; @@ -284,9 +285,11 @@ class ElectrumXClient { usePort = port; useUseSSL = useSSL; } else { - useHost = failovers![currentFailoverIndex].address; - usePort = failovers![currentFailoverIndex].port; - useUseSSL = failovers![currentFailoverIndex].useSSL; + _electrumAdapterChannel = null; + await ClientManager.sharedInstance.remove(cryptoCurrency: cryptoCurrency); + useHost = _failovers[currentFailoverIndex].address; + usePort = _failovers[currentFailoverIndex].port; + useUseSSL = _failovers[currentFailoverIndex].useSSL; } _electrumAdapterChannel ??= await electrum_adapter.connect( @@ -402,7 +405,7 @@ class ElectrumXClient { rethrow; } } catch (e) { - if (failovers != null && currentFailoverIndex < failovers!.length - 1) { + if (currentFailoverIndex < _failovers.length - 1) { currentFailoverIndex++; return request( command: command, @@ -495,7 +498,7 @@ class ElectrumXClient { rethrow; } } catch (e) { - if (failovers != null && currentFailoverIndex < failovers!.length - 1) { + if (currentFailoverIndex < _failovers.length - 1) { currentFailoverIndex++; return batchRequest( command: command, diff --git a/lib/services/node_service.dart b/lib/services/node_service.dart index e55e2218b..db4a25a1b 100644 --- a/lib/services/node_service.dart +++ b/lib/services/node_service.dart @@ -32,6 +32,49 @@ class NodeService extends ChangeNotifier { }); Future updateDefaults() async { + // hack + if (AppConfig.coins.where((e) => e.identifier == "firo").isNotEmpty) { + final others = [ + "electrumx01.firo.org", + "electrumx02.firo.org", + "electrumx03.firo.org", + "electrumx.firo.org", + ]; + const port = 50002; + const idPrefix = "not_a_real_default_but_temp"; + + for (final host in others) { + final _id = "${idPrefix}_$host"; + + NodeModel? node = DB.instance.get( + boxName: DB.boxNameNodeModels, + key: _id, + ); + + if (node == null) { + node = NodeModel( + host: host, + port: port, + name: host, + id: _id, + useSSL: true, + enabled: true, + coinName: "firo", + isFailover: true, + isDown: false, + torEnabled: true, + clearnetEnabled: true, + ); + + await DB.instance.put( + boxName: DB.boxNameNodeModels, + key: _id, + value: node, + ); + } + } + } + for (final defaultNode in AppConfig.coins.map( (e) => e.defaultNode, )) { diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index 0beaf2a80..bb2d2df56 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -569,16 +569,19 @@ abstract class Wallet { final start = DateTime.now(); bool tAlive = true; - final t = Timer.periodic(const Duration(seconds: 1), (timer) async { - if (tAlive) { - final pingSuccess = await pingCheck(); - if (!pingSuccess) { - tAlive = false; + Timer? t; + if (this is! SparkInterface) { + t = Timer.periodic(const Duration(seconds: 1), (timer) async { + if (tAlive) { + final pingSuccess = await pingCheck(); + if (!pingSuccess) { + tAlive = false; + } + } else { + timer.cancel(); } - } else { - timer.cancel(); - } - }); + }); + } void _checkAlive() { if (!tAlive) throw Exception("refresh alive ping failure"); @@ -717,13 +720,15 @@ abstract class Wallet { _checkAlive(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(1.0, walletId)); - tAlive = false; // interrupt timer as its not needed anymore + if (this is! SparkInterface) { + tAlive = false; // interrupt timer as its not needed anymore + } completer.complete(); } catch (error, strace) { completer.completeError(error, strace); } finally { - t.cancel(); + t?.cancel(); refreshMutex.release(); if (!completer.isCompleted) { completer.completeError( diff --git a/test/cached_electrumx_test.mocks.dart b/test/cached_electrumx_test.mocks.dart index 993f73f69..25324b805 100644 --- a/test/cached_electrumx_test.mocks.dart +++ b/test/cached_electrumx_test.mocks.dart @@ -90,15 +90,6 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { ), ) as _i2.CryptoCurrency); - @override - set failovers(List<_i5.ElectrumXNode>? _failovers) => super.noSuchMethod( - Invocation.setter( - #failovers, - _failovers, - ), - returnValueForMissingStub: null, - ); - @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart index e38af7ce9..75fc2228a 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart @@ -87,15 +87,6 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); - @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( - Invocation.setter( - #failovers, - _failovers, - ), - returnValueForMissingStub: null, - ); - @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart index edbb3c632..c6eadd8f6 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart @@ -87,15 +87,6 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); - @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( - Invocation.setter( - #failovers, - _failovers, - ), - returnValueForMissingStub: null, - ); - @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart index c5c167366..344647a50 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart @@ -87,15 +87,6 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); - @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( - Invocation.setter( - #failovers, - _failovers, - ), - returnValueForMissingStub: null, - ); - @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), diff --git a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart index 80e8c8922..851a2855c 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart @@ -87,15 +87,6 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); - @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( - Invocation.setter( - #failovers, - _failovers, - ), - returnValueForMissingStub: null, - ); - @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), diff --git a/test/services/coins/particl/particl_wallet_test.mocks.dart b/test/services/coins/particl/particl_wallet_test.mocks.dart index 0fde0b645..ccd74b4d7 100644 --- a/test/services/coins/particl/particl_wallet_test.mocks.dart +++ b/test/services/coins/particl/particl_wallet_test.mocks.dart @@ -87,15 +87,6 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); - @override - set failovers(List<_i4.ElectrumXNode>? _failovers) => super.noSuchMethod( - Invocation.setter( - #failovers, - _failovers, - ), - returnValueForMissingStub: null, - ); - @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), From 40dfbbf710c14b1a75407114e6bdc0e868008d3c Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 14 Dec 2024 15:29:17 -0600 Subject: [PATCH 02/10] WIP: paginated spark anon set prep --- lib/db/sqlite/firo_cache.dart | 52 ++++++ lib/db/sqlite/firo_cache_coordinator.dart | 168 ++++++++++++++---- lib/db/sqlite/firo_cache_reader.dart | 15 ++ lib/db/sqlite/firo_cache_worker.dart | 27 ++- lib/db/sqlite/firo_cache_writer.dart | 25 +++ lib/electrumx_rpc/electrumx_client.dart | 145 +++++++++++---- .../electrumx_response/spark_models.dart | 47 +++++ lib/wallets/wallet/impl/firo_wallet.dart | 1 + lib/wallets/wallet/wallet.dart | 2 +- .../spark_interface.dart | 7 +- 10 files changed, 420 insertions(+), 69 deletions(-) create mode 100644 lib/models/electrumx_response/spark_models.dart diff --git a/lib/db/sqlite/firo_cache.dart b/lib/db/sqlite/firo_cache.dart index eac511aaa..6b3c70c8e 100644 --- a/lib/db/sqlite/firo_cache.dart +++ b/lib/db/sqlite/firo_cache.dart @@ -9,6 +9,7 @@ import 'package:sqlite3/sqlite3.dart'; import 'package:uuid/uuid.dart'; import '../../electrumx_rpc/electrumx_client.dart'; +import '../../models/electrumx_response/spark_models.dart'; import '../../utilities/extensions/extensions.dart'; import '../../utilities/logger.dart'; import '../../utilities/stack_file_system.dart'; @@ -42,12 +43,17 @@ abstract class _FiroCache { network == CryptoCurrencyNetwork.main ? "spark_set_v$_setCacheVersion.sqlite3" : "spark_set_v${_setCacheVersion}_${network.name}.sqlite3"; + static String sparkSetMetaCacheFileName(CryptoCurrencyNetwork network) => + network == CryptoCurrencyNetwork.main + ? "spark_set_meta_v$_setCacheVersion.sqlite3" + : "spark_set_meta_v${_setCacheVersion}_${network.name}.sqlite3"; static String sparkUsedTagsCacheFileName(CryptoCurrencyNetwork network) => network == CryptoCurrencyNetwork.main ? "spark_tags_v$_tagsCacheVersion.sqlite3" : "spark_tags_v${_tagsCacheVersion}_${network.name}.sqlite3"; static final Map _setCacheDB = {}; + static final Map _setMetaCacheDB = {}; static final Map _usedTagsCacheDB = {}; static Database setCacheDB(CryptoCurrencyNetwork network) { if (_setCacheDB[network] == null) { @@ -58,6 +64,15 @@ abstract class _FiroCache { return _setCacheDB[network]!; } + static Database setMetaCacheDB(CryptoCurrencyNetwork network) { + if (_setMetaCacheDB[network] == null) { + throw Exception( + "FiroCache.init() must be called before accessing FiroCache.db!", + ); + } + return _setMetaCacheDB[network]!; + } + static Database usedTagsCacheDB(CryptoCurrencyNetwork network) { if (_usedTagsCacheDB[network] == null) { throw Exception( @@ -78,12 +93,18 @@ abstract class _FiroCache { final sparkSetCacheFile = File("${sqliteDir.path}/${sparkSetCacheFileName(network)}"); + final sparkSetMetaCacheFile = + File("${sqliteDir.path}/${sparkSetMetaCacheFileName(network)}"); + final sparkUsedTagsCacheFile = File("${sqliteDir.path}/${sparkUsedTagsCacheFileName(network)}"); if (!(await sparkSetCacheFile.exists())) { await _createSparkSetCacheDb(sparkSetCacheFile.path); } + if (!(await sparkSetMetaCacheFile.exists())) { + await _createSparkSetMetaCacheDb(sparkSetMetaCacheFile.path); + } if (!(await sparkUsedTagsCacheFile.exists())) { await _createSparkUsedTagsCacheDb(sparkUsedTagsCacheFile.path); } @@ -92,6 +113,10 @@ abstract class _FiroCache { sparkSetCacheFile.path, mode: OpenMode.readWrite, ); + _setMetaCacheDB[network] = sqlite3.open( + sparkSetMetaCacheFile.path, + mode: OpenMode.readWrite, + ); _usedTagsCacheDB[network] = sqlite3.open( sparkUsedTagsCacheFile.path, mode: OpenMode.readWrite, @@ -109,6 +134,12 @@ abstract class _FiroCache { VACUUM; """, ); + setMetaCacheDB(network).execute( + """ + DELETE FROM PreviousMetaFetchResult; + VACUUM; + """, + ); usedTagsCacheDB(network).execute( """ DELETE FROM SparkUsedCoinTags; @@ -159,6 +190,27 @@ abstract class _FiroCache { db.dispose(); } + static Future _createSparkSetMetaCacheDb(String file) async { + final db = sqlite3.open( + file, + mode: OpenMode.readWriteCreate, + ); + + db.execute( + """ + CREATE TABLE PreviousMetaFetchResult ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, + coinGroupId INTEGER NOT NULL UNIQUE, + blockHash TEXT NOT NULL, + setHash TEXT NOT NULL, + size INTEGER NOT NULL + ); + """, + ); + + db.dispose(); + } + static Future _createSparkUsedTagsCacheDb(String file) async { final db = sqlite3.open( file, diff --git a/lib/db/sqlite/firo_cache_coordinator.dart b/lib/db/sqlite/firo_cache_coordinator.dart index fe720f804..81da6134b 100644 --- a/lib/db/sqlite/firo_cache_coordinator.dart +++ b/lib/db/sqlite/firo_cache_coordinator.dart @@ -6,6 +6,8 @@ typedef LTagPair = ({String tag, String txid}); /// background isolate and [FiroCacheCoordinator] should manage that isolate abstract class FiroCacheCoordinator { static final Map _workers = {}; + static final Map _tagLocks = {}; + static final Map _setLocks = {}; static bool _init = false; static Future init() async { @@ -15,6 +17,8 @@ abstract class FiroCacheCoordinator { _init = true; await _FiroCache.init(); for (final network in _FiroCache.networks) { + _tagLocks[network] = Mutex(); + _setLocks[network] = Mutex(); _workers[network] = await _FiroCacheWorker.spawn(network); } } @@ -28,14 +32,26 @@ abstract class FiroCacheCoordinator { final setCacheFile = File( "${dir.path}/${_FiroCache.sparkSetCacheFileName(network)}", ); + final setMetaCacheFile = File( + "${dir.path}/${_FiroCache.sparkSetMetaCacheFileName(network)}", + ); final usedTagsCacheFile = File( "${dir.path}/${_FiroCache.sparkUsedTagsCacheFileName(network)}", ); - final int bytes = - ((await setCacheFile.exists()) ? await setCacheFile.length() : 0) + - ((await usedTagsCacheFile.exists()) - ? await usedTagsCacheFile.length() - : 0); + + final setSize = + (await setCacheFile.exists()) ? await setCacheFile.length() : 0; + final tagsSize = (await usedTagsCacheFile.exists()) + ? await usedTagsCacheFile.length() + : 0; + final setMetaSize = + (await setMetaCacheFile.exists()) ? await setMetaCacheFile.length() : 0; + + print("TAG SIZE: $tagsSize"); + print("SET SIZE: $setSize"); + print("SET META SIZE: $setMetaSize"); + + final int bytes = tagsSize + setSize + setMetaSize; if (bytes < 1024) { return '$bytes B'; @@ -55,43 +71,116 @@ abstract class FiroCacheCoordinator { ElectrumXClient client, CryptoCurrencyNetwork network, ) async { - final count = await FiroCacheCoordinator.getUsedCoinTagsCount(network); - final unhashedTags = await client.getSparkUnhashedUsedCoinsTagsWithTxHashes( - startNumber: count, - ); - if (unhashedTags.isNotEmpty) { - await _workers[network]!.runTask( - FCTask( - func: FCFuncName._updateSparkUsedTagsWith, - data: unhashedTags, - ), + await _tagLocks[network]!.protect(() async { + final count = await FiroCacheCoordinator.getUsedCoinTagsCount(network); + final unhashedTags = + await client.getSparkUnhashedUsedCoinsTagsWithTxHashes( + startNumber: count, ); - } + if (unhashedTags.isNotEmpty) { + await _workers[network]!.runTask( + FCTask( + func: FCFuncName._updateSparkUsedTagsWith, + data: unhashedTags, + ), + ); + } + }); } static Future runFetchAndUpdateSparkAnonSetCacheForGroupId( int groupId, ElectrumXClient client, CryptoCurrencyNetwork network, + void Function(int countFetched, int totalCount)? progressUpdated, ) async { - final blockhashResult = - await FiroCacheCoordinator.getLatestSetInfoForGroupId( - groupId, - network, - ); - final blockHash = blockhashResult?.blockHash ?? ""; + await _setLocks[network]!.protect(() async { + Map json; + SparkAnonymitySetMeta? meta; - final json = await client.getSparkAnonymitySet( - coinGroupId: groupId.toString(), - startBlockHash: blockHash.toHexReversedFromBase64, - ); + if (progressUpdated == null) { + // Legacy + final blockhashResult = + await FiroCacheCoordinator.getLatestSetInfoForGroupId( + groupId, + network, + ); + final blockHash = blockhashResult?.blockHash ?? ""; - await _workers[network]!.runTask( - FCTask( - func: FCFuncName._updateSparkAnonSetCoinsWith, - data: (groupId, json), - ), - ); + json = await client.getSparkAnonymitySet( + coinGroupId: groupId.toString(), + startBlockHash: blockHash.toHexReversedFromBase64, + ); + } else { + const sectorSize = 100; // TODO adjust this? + final prevMetaSize = + await FiroCacheCoordinator.getSparkMetaSetSizeForGroupId( + groupId, + network, + ); + final prevSize = prevMetaSize ?? 0; + + meta = await client.getSparkAnonymitySetMeta( + coinGroupId: groupId, + ); + + progressUpdated.call(prevSize, meta.size); + + /// Returns blockHash (last block hash), + /// setHash (hash of current set) + /// and coins (the list of pairs serialized coin and tx hash) + + final fullSectorCount = (meta.size - prevSize) ~/ sectorSize; + final remainder = (meta.size - prevSize) % sectorSize; + + final List coins = []; + + for (int i = 0; i < fullSectorCount; i++) { + final start = (i * sectorSize) + prevSize; + final data = await client.getSparkAnonymitySetBySector( + coinGroupId: groupId, + latestBlock: meta.blockHash, + startIndex: start, + endIndex: start + sectorSize, + ); + + coins.addAll(data); + } + + if (remainder > 0) { + final data = await client.getSparkAnonymitySetBySector( + coinGroupId: groupId, + latestBlock: meta.blockHash, + startIndex: meta.size - remainder, + endIndex: meta.size, + ); + + coins.addAll(data); + } + + json = { + "blockHash": meta.blockHash, + "setHash": meta.setHash, + "coins": coins, + }; + } + + await _workers[network]!.runTask( + FCTask( + func: FCFuncName._updateSparkAnonSetCoinsWith, + data: (groupId, json), + ), + ); + + if (meta != null) { + await _workers[network]!.runTask( + FCTask( + func: FCFuncName._updateSparkAnonSetMetaWith, + data: meta, + ), + ); + } + }); } // =========================================================================== @@ -228,4 +317,19 @@ abstract class FiroCacheCoordinator { db: _FiroCache.setCacheDB(network), ); } + + static Future getSparkMetaSetSizeForGroupId( + int groupId, + CryptoCurrencyNetwork network, + ) async { + final result = await _Reader._getSizeForGroupId( + groupId, + db: _FiroCache.setMetaCacheDB(network), + ); + if (result.isEmpty) { + return null; + } + + return result.first["size"] as int; + } } diff --git a/lib/db/sqlite/firo_cache_reader.dart b/lib/db/sqlite/firo_cache_reader.dart index 33763ba3e..11e6382f8 100644 --- a/lib/db/sqlite/firo_cache_reader.dart +++ b/lib/db/sqlite/firo_cache_reader.dart @@ -56,6 +56,21 @@ abstract class _Reader { return db.select("$query;").first["setExists"] == 1; } + // =========================================================================== + // =============== Spark anonymity set meta queries ========================== + static Future _getSizeForGroupId( + int groupId, { + required Database db, + }) async { + final query = """ + SELECT ss.size + FROM PreviousMetaFetchResult ss + WHERE ss.groupId = $groupId; + """; + + return db.select("$query;"); + } + // =========================================================================== // =============== Spark used coin tags queries ============================== diff --git a/lib/db/sqlite/firo_cache_worker.dart b/lib/db/sqlite/firo_cache_worker.dart index 71e407992..a417cdb07 100644 --- a/lib/db/sqlite/firo_cache_worker.dart +++ b/lib/db/sqlite/firo_cache_worker.dart @@ -3,6 +3,7 @@ part of 'firo_cache.dart'; enum FCFuncName { _updateSparkAnonSetCoinsWith, _updateSparkUsedTagsWith, + _updateSparkAnonSetMetaWith, } class FCTask { @@ -29,6 +30,8 @@ class _FiroCacheWorker { final dir = await StackFileSystem.applicationFiroCacheSQLiteDirectory(); final setCacheFilePath = "${dir.path}/${_FiroCache.sparkSetCacheFileName(network)}"; + final setMetaCacheFilePath = + "${dir.path}/${_FiroCache.sparkSetMetaCacheFileName(network)}"; final usedTagsCacheFilePath = "${dir.path}/${_FiroCache.sparkUsedTagsCacheFileName(network)}"; @@ -48,7 +51,12 @@ class _FiroCacheWorker { try { await Isolate.spawn( _startWorkerIsolate, - (initPort.sendPort, setCacheFilePath, usedTagsCacheFilePath), + ( + initPort.sendPort, + setCacheFilePath, + setMetaCacheFilePath, + usedTagsCacheFilePath, + ), ); } catch (_) { initPort.close(); @@ -79,6 +87,7 @@ class _FiroCacheWorker { ReceivePort receivePort, SendPort sendPort, Database setCacheDb, + Database setMetaCacheDb, Database usedTagsCacheDb, Mutex mutex, ) { @@ -104,6 +113,13 @@ class _FiroCacheWorker { task.data as List>, ); break; + + case FCFuncName._updateSparkAnonSetMetaWith: + result = _updateSparkAnonSetMetaWith( + setMetaCacheDb, + task.data as SparkAnonymitySetMeta, + ); + break; } if (result.success) { @@ -118,7 +134,7 @@ class _FiroCacheWorker { }); } - static void _startWorkerIsolate((SendPort, String, String) args) { + static void _startWorkerIsolate((SendPort, String, String, String) args) { final receivePort = ReceivePort(); args.$1.send(receivePort.sendPort); final mutex = Mutex(); @@ -126,14 +142,19 @@ class _FiroCacheWorker { args.$2, mode: OpenMode.readWrite, ); - final usedTagsCacheDb = sqlite3.open( + final setMetaCacheDb = sqlite3.open( args.$3, mode: OpenMode.readWrite, ); + final usedTagsCacheDb = sqlite3.open( + args.$4, + mode: OpenMode.readWrite, + ); _handleCommandsToIsolate( receivePort, args.$1, setCacheDb, + setMetaCacheDb, usedTagsCacheDb, mutex, ); diff --git a/lib/db/sqlite/firo_cache_writer.dart b/lib/db/sqlite/firo_cache_writer.dart index 99d318444..36b71369b 100644 --- a/lib/db/sqlite/firo_cache_writer.dart +++ b/lib/db/sqlite/firo_cache_writer.dart @@ -48,6 +48,31 @@ FCResult _updateSparkUsedTagsWith( } } +// =========================================================================== +// ================== write to spark anon set Meta cache ========================== +FCResult _updateSparkAnonSetMetaWith( + Database db, + SparkAnonymitySetMeta meta, +) { + db.execute("BEGIN;"); + try { + db.execute( + """ + INSERT OR REPLACE INTO PreviousMetaFetchResult (coinGroupId, blockHash, setHash, size) + VALUES (?, ?, ?, ?); + """, + [meta.coinGroupId, meta.blockHash, meta.setHash, meta.size], + ); + + db.execute("COMMIT;"); + + return FCResult(success: true); + } catch (e) { + db.execute("ROLLBACK;"); + return FCResult(success: false, error: e); + } +} + // =========================================================================== // ================== write to spark anon set cache ========================== diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index 39e27ee81..f8196388a 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -21,6 +21,7 @@ import 'package:mutex/mutex.dart'; import 'package:stream_channel/stream_channel.dart'; import '../exceptions/electrumx/no_such_transaction.dart'; +import '../models/electrumx_response/spark_models.dart'; import '../services/event_bus/events/global/tor_connection_status_changed_event.dart'; import '../services/event_bus/events/global/tor_status_changed_event.dart'; import '../services/event_bus/global_event_bus.dart'; @@ -34,13 +35,6 @@ import '../wallets/crypto_currency/crypto_currency.dart'; import '../wallets/crypto_currency/interfaces/electrumx_currency_interface.dart'; import 'client_manager.dart'; -typedef SparkMempoolData = ({ - String txid, - List serialContext, - List lTags, - List coins, -}); - class WifiOnlyException implements Exception {} class TorOnlyException implements Exception {} @@ -1037,29 +1031,30 @@ class ElectrumXClient { /// "b476ed2b374bb081ea51d111f68f0136252521214e213d119b8dc67b92f5a390", /// ] /// } - Future>> getSparkMintMetaData({ - String? requestID, - required List sparkCoinHashes, - }) async { - try { - Logging.instance.log( - "attempting to fetch spark.getsparkmintmetadata...", - level: LogLevel.Info, - ); - await checkElectrumAdapter(); - final List response = - await (getElectrumAdapter() as FiroElectrumClient) - .getSparkMintMetaData(sparkCoinHashes: sparkCoinHashes); - Logging.instance.log( - "Fetching spark.getsparkmintmetadata finished", - level: LogLevel.Info, - ); - return List>.from(response); - } catch (e) { - Logging.instance.log(e, level: LogLevel.Error); - rethrow; - } - } + /// NOT USED? + // Future>> getSparkMintMetaData({ + // String? requestID, + // required List sparkCoinHashes, + // }) async { + // try { + // Logging.instance.log( + // "attempting to fetch spark.getsparkmintmetadata...", + // level: LogLevel.Info, + // ); + // await checkElectrumAdapter(); + // final List response = + // await (getElectrumAdapter() as FiroElectrumClient) + // .getSparkMintMetaData(sparkCoinHashes: sparkCoinHashes); + // Logging.instance.log( + // "Fetching spark.getsparkmintmetadata finished", + // level: LogLevel.Info, + // ); + // return List>.from(response); + // } catch (e) { + // Logging.instance.log(e, level: LogLevel.Error); + // rethrow; + // } + // } /// Returns the latest Spark set id /// @@ -1135,7 +1130,7 @@ class ElectrumXClient { final List result = []; for (final entry in map.entries) { result.add( - ( + SparkMempoolData( txid: entry.key, serialContext: List.from(entry.value["serial_context"] as List), @@ -1191,6 +1186,94 @@ class ElectrumXClient { rethrow; } } + // ======== New Paginated Endpoints ========================================== + + Future getSparkAnonymitySetMeta({ + String? requestID, + required int coinGroupId, + }) async { + try { + const command = + "spark.getsparkanonyumitysetmeta"; // TODO verify this will be correct + final start = DateTime.now(); + final response = await request( + requestID: requestID, + command: command, + args: [ + "$coinGroupId", + ], + ); + + final map = Map.from(response as Map); + + final result = SparkAnonymitySetMeta( + coinGroupId: coinGroupId, + blockHash: map["blockHash"] as String, + setHash: map["setHash"] as String, + size: map["size"] as int, + ); + + Logging.instance.log( + "Finished ElectrumXClient.getSparkAnonymitySetMeta(" + "requestID=$requestID, " + "coinGroupId=$coinGroupId" + "). Set meta=$result, " + "Duration=${DateTime.now().difference(start)}", + level: LogLevel.Debug, + ); + + return result; + } catch (e) { + Logging.instance.log(e, level: LogLevel.Error); + rethrow; + } + } + + Future> getSparkAnonymitySetBySector({ + String? requestID, + required int coinGroupId, + required String latestBlock, + required int startIndex, // inclusive + required int endIndex, // exclusive + }) async { + try { + const command = + "spark.getsparkanonyumitysetsector"; // TODO verify this will be correct + final start = DateTime.now(); + final response = await request( + requestID: requestID, + command: command, + args: [ + "$coinGroupId", + latestBlock, + "$startIndex", + "$endIndex", + ], + ); + + final map = Map.from(response as Map); + + final result = map["coins"] as List; + + Logging.instance.log( + "Finished ElectrumXClient.getSparkAnonymitySetBySector(" + "requestID=$requestID, " + "coinGroupId=$coinGroupId, " + "latestBlock=$latestBlock, " + "startIndex=$startIndex, " + "endIndex=$endIndex" + "). # of coins=${result.length}, " + "Duration=${DateTime.now().difference(start)}", + level: LogLevel.Debug, + ); + + return result; + } catch (e) { + Logging.instance.log(e, level: LogLevel.Error); + rethrow; + } + } + // =========================================================================== Future isMasterNodeCollateral({ diff --git a/lib/models/electrumx_response/spark_models.dart b/lib/models/electrumx_response/spark_models.dart new file mode 100644 index 000000000..499f20cf6 --- /dev/null +++ b/lib/models/electrumx_response/spark_models.dart @@ -0,0 +1,47 @@ +class SparkMempoolData { + final String txid; + final List serialContext; + final List lTags; + final List coins; + + SparkMempoolData({ + required this.txid, + required this.serialContext, + required this.lTags, + required this.coins, + }); + + @override + String toString() { + return "SparkMempoolData{" + "txid: $txid, " + "serialContext: $serialContext, " + "lTags: $lTags, " + "coins: $coins" + "}"; + } +} + +class SparkAnonymitySetMeta { + final int coinGroupId; + final String blockHash; + final String setHash; + final int size; + + SparkAnonymitySetMeta({ + required this.coinGroupId, + required this.blockHash, + required this.setHash, + required this.size, + }); + + @override + String toString() { + return "SparkAnonymitySetMeta{" + "coinGroupId: $coinGroupId, " + "blockHash: $blockHash, " + "setHash: $setHash, " + "size: $size" + "}"; + } +} diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index 1ff9999fe..d4faabef9 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -725,6 +725,7 @@ class FiroWallet extends Bip39HDWallet i, electrumXClient, cryptoCurrency.network, + null, ), ); } diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index bb2d2df56..6e5a9c08f 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -670,7 +670,7 @@ abstract class Wallet { GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); if (this is SparkInterface && !viewOnly) { // this should be called before updateTransactions() - await (this as SparkInterface).refreshSparkData(); + await (this as SparkInterface).refreshSparkData(null); } _checkAlive(); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index 977a95124..8460ce319 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -795,7 +795,9 @@ mixin SparkInterface } } - Future refreshSparkData() async { + Future refreshSparkData( + void Function(int countFetched, int totalCount)? progressUpdated, + ) async { final start = DateTime.now(); try { // start by checking if any previous sets are missing from db and add the @@ -823,6 +825,7 @@ mixin SparkInterface e, electrumXClient, cryptoCurrency.network, + null, ), ); @@ -1086,7 +1089,7 @@ mixin SparkInterface } try { - await refreshSparkData(); + await refreshSparkData(null); } catch (e, s) { Logging.instance.log( "$runtimeType $walletId ${info.name}: $e\n$s", From 021367445b8790fa363bbbfc4f27e4488f10b805 Mon Sep 17 00:00:00 2001 From: julian Date: Sun, 15 Dec 2024 20:15:33 -0600 Subject: [PATCH 03/10] fix: updated spark data calls and caching --- lib/db/sqlite/firo_cache_coordinator.dart | 23 +++++++++++++++++------ lib/db/sqlite/firo_cache_reader.dart | 6 +++--- lib/electrumx_rpc/electrumx_client.dart | 10 +++++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/db/sqlite/firo_cache_coordinator.dart b/lib/db/sqlite/firo_cache_coordinator.dart index 81da6134b..45fa4c62e 100644 --- a/lib/db/sqlite/firo_cache_coordinator.dart +++ b/lib/db/sqlite/firo_cache_coordinator.dart @@ -47,9 +47,18 @@ abstract class FiroCacheCoordinator { final setMetaSize = (await setMetaCacheFile.exists()) ? await setMetaCacheFile.length() : 0; - print("TAG SIZE: $tagsSize"); - print("SET SIZE: $setSize"); - print("SET META SIZE: $setMetaSize"); + Logging.instance.log( + "Spark cache used tags size: $tagsSize", + level: LogLevel.Debug, + ); + Logging.instance.log( + "Spark cache anon set size: $setSize", + level: LogLevel.Debug, + ); + Logging.instance.log( + "Spark cache set meta size: $setMetaSize", + level: LogLevel.Debug, + ); final int bytes = tagsSize + setSize + setMetaSize; @@ -112,7 +121,7 @@ abstract class FiroCacheCoordinator { startBlockHash: blockHash.toHexReversedFromBase64, ); } else { - const sectorSize = 100; // TODO adjust this? + const sectorSize = 2000; // TODO adjust this? final prevMetaSize = await FiroCacheCoordinator.getSparkMetaSetSizeForGroupId( groupId, @@ -139,10 +148,11 @@ abstract class FiroCacheCoordinator { final start = (i * sectorSize) + prevSize; final data = await client.getSparkAnonymitySetBySector( coinGroupId: groupId, - latestBlock: meta.blockHash, + latestBlock: meta.blockHash.toHexReversedFromBase64, startIndex: start, endIndex: start + sectorSize, ); + progressUpdated.call(start + sectorSize, meta.size); coins.addAll(data); } @@ -150,10 +160,11 @@ abstract class FiroCacheCoordinator { if (remainder > 0) { final data = await client.getSparkAnonymitySetBySector( coinGroupId: groupId, - latestBlock: meta.blockHash, + latestBlock: meta.blockHash.toHexReversedFromBase64, startIndex: meta.size - remainder, endIndex: meta.size, ); + progressUpdated.call(meta.size, meta.size); coins.addAll(data); } diff --git a/lib/db/sqlite/firo_cache_reader.dart b/lib/db/sqlite/firo_cache_reader.dart index 11e6382f8..b27cd77e3 100644 --- a/lib/db/sqlite/firo_cache_reader.dart +++ b/lib/db/sqlite/firo_cache_reader.dart @@ -63,9 +63,9 @@ abstract class _Reader { required Database db, }) async { final query = """ - SELECT ss.size - FROM PreviousMetaFetchResult ss - WHERE ss.groupId = $groupId; + SELECT size + FROM PreviousMetaFetchResult + WHERE coinGroupId = $groupId; """; return db.select("$query;"); diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index f8196388a..6737e7b4b 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -1193,8 +1193,12 @@ class ElectrumXClient { required int coinGroupId, }) async { try { - const command = - "spark.getsparkanonyumitysetmeta"; // TODO verify this will be correct + const command = "spark.getsparkanonymitysetmeta"; + Logging.instance.log( + "[${getElectrumAdapter()?.host}] => attempting to fetch $command...", + level: LogLevel.Info, + ); + final start = DateTime.now(); final response = await request( requestID: requestID, @@ -1238,7 +1242,7 @@ class ElectrumXClient { }) async { try { const command = - "spark.getsparkanonyumitysetsector"; // TODO verify this will be correct + "spark.getsparkanonymitysetsector"; // TODO verify this will be correct final start = DateTime.now(); final response = await request( requestID: requestID, From 7b2f8b0116b2ea460d83412cbad4a5b5804596ba Mon Sep 17 00:00:00 2001 From: julian Date: Sun, 15 Dec 2024 20:17:41 -0600 Subject: [PATCH 04/10] reduced pings --- lib/electrumx_rpc/electrumx_client.dart | 5 +-- lib/utilities/constants.dart | 2 +- lib/wallets/wallet/wallet.dart | 47 +++---------------------- 3 files changed, 9 insertions(+), 45 deletions(-) diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index 6737e7b4b..3f8241bca 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -399,6 +399,7 @@ class ElectrumXClient { rethrow; } } catch (e) { + Logging.instance.log("$host $e", level: LogLevel.Debug); if (currentFailoverIndex < _failovers.length - 1) { currentFailoverIndex++; return request( @@ -525,10 +526,10 @@ class ElectrumXClient { return await request( requestID: requestID, command: 'server.ping', - requestTimeout: const Duration(seconds: 3), + requestTimeout: const Duration(seconds: 30), retries: retryCount, ).timeout( - const Duration(seconds: 3), + const Duration(seconds: 30), onTimeout: () { Logging.instance.log( "ElectrumxClient.ping timed out with retryCount=$retryCount, host=$_host", diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index 6b64d4a73..163b7d04e 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -35,7 +35,7 @@ abstract class Constants { // // true; // true for development, static const int notificationsMax = 0xFFFFFFFF; - static const Duration networkAliveTimerDuration = Duration(seconds: 10); + static const Duration networkAliveTimerDuration = Duration(seconds: 30); // Enable Logger.print statements static const bool disableLogger = false; diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index 6e5a9c08f..5b8eba8a6 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -415,6 +415,11 @@ abstract class Wallet { } void _periodicPingCheck() async { + if (refreshMutex.isLocked) { + // should be active calls happening so no need to make extra work + return; + } + final bool hasNetwork = await pingCheck(); if (_isConnected != hasNetwork) { @@ -568,25 +573,6 @@ abstract class Wallet { } final start = DateTime.now(); - bool tAlive = true; - Timer? t; - if (this is! SparkInterface) { - t = Timer.periodic(const Duration(seconds: 1), (timer) async { - if (tAlive) { - final pingSuccess = await pingCheck(); - if (!pingSuccess) { - tAlive = false; - } - } else { - timer.cancel(); - } - }); - } - - void _checkAlive() { - if (!tAlive) throw Exception("refresh alive ping failure"); - } - final viewOnly = this is ViewOnlyOptionInterface && (this as ViewOnlyOptionInterface).isViewOnly; @@ -603,57 +589,45 @@ abstract class Wallet { ), ); - _checkAlive(); - // add some small buffer before making calls. // this can probably be removed in the future but was added as a // debugging feature await Future.delayed(const Duration(milliseconds: 300)); - _checkAlive(); // TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided. final Set codesToCheck = {}; - _checkAlive(); if (this is PaynymInterface && !viewOnly) { // isSegwit does not matter here at all final myCode = await (this as PaynymInterface).getPaymentCode(isSegwit: false); - _checkAlive(); final nym = await PaynymIsApi().nym(myCode.toString()); - _checkAlive(); if (nym.value != null) { for (final follower in nym.value!.followers) { codesToCheck.add(follower.code); } - _checkAlive(); for (final following in nym.value!.following) { codesToCheck.add(following.code); } } - _checkAlive(); } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.0, walletId)); _checkAlive(); await updateChainHeight(); - _checkAlive(); if (this is BitcoinFrostWallet) { await (this as BitcoinFrostWallet).lookAhead(); } - _checkAlive(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.1, walletId)); - _checkAlive(); // TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided. if (this is MultiAddressInterface) { if (info.otherData[WalletInfoKeys.reuseAddress] != true) { await (this as MultiAddressInterface) .checkReceivingAddressForTransactions(); } - _checkAlive(); } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); @@ -672,49 +646,39 @@ abstract class Wallet { // this should be called before updateTransactions() await (this as SparkInterface).refreshSparkData(null); } - _checkAlive(); - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.50, walletId)); - _checkAlive(); final fetchFuture = updateTransactions(); _checkAlive(); final utxosRefreshFuture = updateUTXOs(); // if (currentHeight != storedHeight) { GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.60, walletId)); - _checkAlive(); await utxosRefreshFuture; GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.70, walletId)); - _checkAlive(); await fetchFuture; // TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided. if (!viewOnly && this is PaynymInterface && codesToCheck.isNotEmpty) { - _checkAlive(); await (this as PaynymInterface) .checkForNotificationTransactionsTo(codesToCheck); // check utxos again for notification outputs - _checkAlive(); await updateUTXOs(); } _checkAlive(); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.80, walletId)); // await getAllTxsToWatch(); - _checkAlive(); // TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided. if (this is LelantusInterface && !viewOnly) { if (info.otherData[WalletInfoKeys.enableLelantusScanning] as bool? ?? false) { await (this as LelantusInterface).refreshLelantusData(); - _checkAlive(); } } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId)); - _checkAlive(); await updateBalance(); _checkAlive(); @@ -728,7 +692,6 @@ abstract class Wallet { } catch (error, strace) { completer.completeError(error, strace); } finally { - t?.cancel(); refreshMutex.release(); if (!completer.isCompleted) { completer.completeError( From e03c101e351af9bd6cb9a914dc6bcdd7f8a618cb Mon Sep 17 00:00:00 2001 From: julian Date: Sun, 15 Dec 2024 20:22:39 -0600 Subject: [PATCH 05/10] fix: tweak sync percent feature and track progress during spark anon set download --- .../wallet_network_settings_view.dart | 6 +- lib/wallets/wallet/wallet.dart | 37 ++++---- .../electrumx_interface.dart | 2 + .../spark_interface.dart | 92 +++++++++++++++---- 4 files changed, 100 insertions(+), 37 deletions(-) diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart index 1be577f1d..f8eb344a8 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart @@ -39,6 +39,7 @@ import '../../../../wallets/isar/providers/wallet_info_provider.dart'; import '../../../../wallets/wallet/impl/epiccash_wallet.dart'; import '../../../../wallets/wallet/impl/monero_wallet.dart'; import '../../../../wallets/wallet/impl/wownero_wallet.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; import '../../../../widgets/animated_text.dart'; import '../../../../widgets/background.dart'; import '../../../../widgets/conditional_parent.dart'; @@ -233,7 +234,10 @@ class _WalletNetworkSettingsViewState _percent = 1; _blocksRemaining = 0; } else { - _percent = 0; + _percent = + (ref.read(pWallets).getWallet(widget.walletId) as ElectrumXInterface?) + ?.refreshingPercent ?? + 0; _blocksRemaining = -1; } diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index 5b8eba8a6..b0516b74e 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -564,6 +564,11 @@ abstract class Wallet { return future; } + void _fireRefreshPercentChange(double percent) { + (this as ElectrumXInterface?)?.refreshingPercent = percent; + GlobalEventBus.instance.fire(RefreshPercentChangedEvent(percent, walletId)); + } + // Should fire events Future _refresh(Completer completer) async { // Awaiting this lock could be dangerous. @@ -612,15 +617,14 @@ abstract class Wallet { } } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.0, walletId)); - _checkAlive(); + _fireRefreshPercentChange(0); await updateChainHeight(); if (this is BitcoinFrostWallet) { await (this as BitcoinFrostWallet).lookAhead(); } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.1, walletId)); + _fireRefreshPercentChange(0.1); // TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided. if (this is MultiAddressInterface) { @@ -630,8 +634,7 @@ abstract class Wallet { } } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - _checkAlive(); + _fireRefreshPercentChange(0.2); // TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided. if (this is MultiAddressInterface) { @@ -640,21 +643,21 @@ abstract class Wallet { .checkChangeAddressForTransactions(); } } - _checkAlive(); - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); + _fireRefreshPercentChange(0.3); if (this is SparkInterface && !viewOnly) { // this should be called before updateTransactions() - await (this as SparkInterface).refreshSparkData(null); + await (this as SparkInterface).refreshSparkData((0.3, 0.6)); } final fetchFuture = updateTransactions(); - _checkAlive(); + + _fireRefreshPercentChange(0.6); final utxosRefreshFuture = updateUTXOs(); // if (currentHeight != storedHeight) { - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.60, walletId)); + _fireRefreshPercentChange(0.65); await utxosRefreshFuture; - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.70, walletId)); + _fireRefreshPercentChange(0.70); await fetchFuture; @@ -665,8 +668,7 @@ abstract class Wallet { // check utxos again for notification outputs await updateUTXOs(); } - _checkAlive(); - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.80, walletId)); + _fireRefreshPercentChange(0.80); // await getAllTxsToWatch(); @@ -677,16 +679,11 @@ abstract class Wallet { await (this as LelantusInterface).refreshLelantusData(); } } - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId)); + _fireRefreshPercentChange(0.90); await updateBalance(); - _checkAlive(); - GlobalEventBus.instance.fire(RefreshPercentChangedEvent(1.0, walletId)); - - if (this is! SparkInterface) { - tAlive = false; // interrupt timer as its not needed anymore - } + _fireRefreshPercentChange(1.0); completer.complete(); } catch (error, strace) { diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart index cc49149d9..b59041ef8 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart @@ -42,6 +42,8 @@ mixin ElectrumXInterface int? get maximumFeerate => null; + double? refreshingPercent; + static const _kServerBatchCutoffVersion = [1, 6]; List? _serverVersion; Future get serverCanBatch async { diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index 8460ce319..fbc294e7c 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -14,6 +14,8 @@ import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; import '../../../models/isar/models/isar_models.dart'; import '../../../models/signing_data.dart'; +import '../../../services/event_bus/events/global/refresh_percent_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; import '../../../utilities/amount/amount.dart'; import '../../../utilities/enums/derive_path_type_enum.dart'; import '../../../utilities/extensions/extensions.dart'; @@ -795,8 +797,24 @@ mixin SparkInterface } } + // returns next percent + double _triggerEventHelper(double current, double increment) { + refreshingPercent = current; + GlobalEventBus.instance.fire( + RefreshPercentChangedEvent( + current, + walletId, + ), + ); + return current + increment; + } + + // Linearly make calls so there is less chance of timing out or otherwise breaking Future refreshSparkData( - void Function(int countFetched, int totalCount)? progressUpdated, + ( + double startingPercent, + double endingPercent, + )? refreshProgressRange, ) async { final start = DateTime.now(); try { @@ -818,25 +836,55 @@ mixin SparkInterface } groupIds.add(latestGroupId); - // start fetch and update process for each set groupId as required - final possibleFutures = groupIds.map( - (e) => - FiroCacheCoordinator.runFetchAndUpdateSparkAnonSetCacheForGroupId( - e, + final steps = groupIds.length + + 1 // get used tags step + + + 1 // check updated cache step + + + 1 // identify coins step + + + 1 // cross ref coins and txns + + + 1; // update balance + + final percentIncrement = refreshProgressRange == null + ? null + : (refreshProgressRange.$2 - refreshProgressRange.$1) / steps; + double currentPercent = refreshProgressRange?.$1 ?? 0; + + // fetch and update process for each set groupId as required + for (final gId in groupIds) { + await FiroCacheCoordinator.runFetchAndUpdateSparkAnonSetCacheForGroupId( + gId, electrumXClient, cryptoCurrency.network, - null, - ), + // null, + (a, b) { + if (percentIncrement != null) { + _triggerEventHelper( + currentPercent + (percentIncrement * (a / b)), + 0, + ); + } + }, + ); + if (percentIncrement != null) { + currentPercent += percentIncrement; + } + } + + if (percentIncrement != null) { + currentPercent = _triggerEventHelper(currentPercent, percentIncrement); + } + + await FiroCacheCoordinator.runFetchAndUpdateSparkUsedCoinTags( + electrumXClient, + cryptoCurrency.network, ); - // wait for each fetch and update to complete - await Future.wait([ - ...possibleFutures, - FiroCacheCoordinator.runFetchAndUpdateSparkUsedCoinTags( - electrumXClient, - cryptoCurrency.network, - ), - ]); + if (percentIncrement != null) { + currentPercent = _triggerEventHelper(currentPercent, percentIncrement); + } // Get cached timestamps per groupId. These timestamps are used to check // and try to id coins that were added to the spark anon set cache @@ -883,6 +931,10 @@ mixin SparkInterface ); } + if (percentIncrement != null) { + currentPercent = _triggerEventHelper(currentPercent, percentIncrement); + } + // get address(es) to get the private key hex strings required for // identifying spark coins final sparkAddresses = await mainDB.isar.addresses @@ -930,6 +982,10 @@ mixin SparkInterface isar: mainDB.isar, ); + if (percentIncrement != null) { + currentPercent = _triggerEventHelper(currentPercent, percentIncrement); + } + // check for spark coins in mempool final mempoolMyCoins = await _refreshSparkCoinsMempoolCheck( privateKeyHexSet: privateKeyHexSet, @@ -991,6 +1047,10 @@ mixin SparkInterface }); } + if (percentIncrement != null) { + currentPercent = _triggerEventHelper(currentPercent, percentIncrement); + } + // used to check if balance is spendable or total final currentHeight = await chainHeight; From 9d46a8d19af945b442acd68a58584e455dd677a3 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Dec 2024 19:34:59 -0600 Subject: [PATCH 06/10] fix: spark coin confirmations issue --- lib/wallets/isar/models/spark_coin.dart | 15 +++++++++++++++ .../wallet_mixin_interfaces/spark_interface.dart | 4 +--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/wallets/isar/models/spark_coin.dart b/lib/wallets/isar/models/spark_coin.dart index d3ef6825c..9501bf06d 100644 --- a/lib/wallets/isar/models/spark_coin.dart +++ b/lib/wallets/isar/models/spark_coin.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:isar/isar.dart'; part 'spark_coin.g.dart'; @@ -59,6 +61,19 @@ class SparkCoin { @ignore BigInt get diversifier => BigInt.parse(diversifierIntString); + int getConfirmations(int currentChainHeight) { + if (height == null || height! <= 0) return 0; + return max(0, currentChainHeight - (height! - 1)); + } + + bool isConfirmed( + int currentChainHeight, + int minimumConfirms, + ) { + final confirmations = getConfirmations(currentChainHeight); + return confirmations >= minimumConfirms; + } + SparkCoin({ required this.walletId, required this.type, diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index fbc294e7c..5390b66d3 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -1071,9 +1071,7 @@ mixin SparkInterface final spendable = Amount( rawValue: unusedCoins .where( - (e) => - e.height != null && - e.height! + cryptoCurrency.minConfirms <= currentHeight, + (e) => e.isConfirmed(currentHeight, cryptoCurrency.minConfirms), ) .map((e) => e.value) .fold(BigInt.zero, (prev, e) => prev + e), From 566cdf59f676f9c3b77d1357a8a17d29b1ed27d8 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 16 Dec 2024 19:35:39 -0600 Subject: [PATCH 07/10] fix: incremental spark data cache --- lib/db/sqlite/firo_cache.dart | 58 +----- lib/db/sqlite/firo_cache_coordinator.dart | 182 +++++++----------- lib/db/sqlite/firo_cache_reader.dart | 60 +++--- lib/db/sqlite/firo_cache_worker.dart | 24 +-- lib/db/sqlite/firo_cache_writer.dart | 102 ++-------- lib/electrumx_rpc/electrumx_client.dart | 4 + .../electrumx_response/spark_models.dart | 51 +++++ lib/wallets/isar/models/wallet_info.dart | 4 +- lib/wallets/wallet/impl/firo_wallet.dart | 2 +- .../spark_interface.dart | 25 +-- 10 files changed, 191 insertions(+), 321 deletions(-) diff --git a/lib/db/sqlite/firo_cache.dart b/lib/db/sqlite/firo_cache.dart index 6b3c70c8e..d32db1bf3 100644 --- a/lib/db/sqlite/firo_cache.dart +++ b/lib/db/sqlite/firo_cache.dart @@ -31,7 +31,7 @@ void _debugLog(Object? object) { } abstract class _FiroCache { - static const int _setCacheVersion = 1; + static const int _setCacheVersion = 2; static const int _tagsCacheVersion = 2; static final networks = [ @@ -43,17 +43,12 @@ abstract class _FiroCache { network == CryptoCurrencyNetwork.main ? "spark_set_v$_setCacheVersion.sqlite3" : "spark_set_v${_setCacheVersion}_${network.name}.sqlite3"; - static String sparkSetMetaCacheFileName(CryptoCurrencyNetwork network) => - network == CryptoCurrencyNetwork.main - ? "spark_set_meta_v$_setCacheVersion.sqlite3" - : "spark_set_meta_v${_setCacheVersion}_${network.name}.sqlite3"; static String sparkUsedTagsCacheFileName(CryptoCurrencyNetwork network) => network == CryptoCurrencyNetwork.main ? "spark_tags_v$_tagsCacheVersion.sqlite3" : "spark_tags_v${_tagsCacheVersion}_${network.name}.sqlite3"; static final Map _setCacheDB = {}; - static final Map _setMetaCacheDB = {}; static final Map _usedTagsCacheDB = {}; static Database setCacheDB(CryptoCurrencyNetwork network) { if (_setCacheDB[network] == null) { @@ -64,15 +59,6 @@ abstract class _FiroCache { return _setCacheDB[network]!; } - static Database setMetaCacheDB(CryptoCurrencyNetwork network) { - if (_setMetaCacheDB[network] == null) { - throw Exception( - "FiroCache.init() must be called before accessing FiroCache.db!", - ); - } - return _setMetaCacheDB[network]!; - } - static Database usedTagsCacheDB(CryptoCurrencyNetwork network) { if (_usedTagsCacheDB[network] == null) { throw Exception( @@ -93,18 +79,12 @@ abstract class _FiroCache { final sparkSetCacheFile = File("${sqliteDir.path}/${sparkSetCacheFileName(network)}"); - final sparkSetMetaCacheFile = - File("${sqliteDir.path}/${sparkSetMetaCacheFileName(network)}"); - final sparkUsedTagsCacheFile = File("${sqliteDir.path}/${sparkUsedTagsCacheFileName(network)}"); if (!(await sparkSetCacheFile.exists())) { await _createSparkSetCacheDb(sparkSetCacheFile.path); } - if (!(await sparkSetMetaCacheFile.exists())) { - await _createSparkSetMetaCacheDb(sparkSetMetaCacheFile.path); - } if (!(await sparkUsedTagsCacheFile.exists())) { await _createSparkUsedTagsCacheDb(sparkUsedTagsCacheFile.path); } @@ -113,10 +93,6 @@ abstract class _FiroCache { sparkSetCacheFile.path, mode: OpenMode.readWrite, ); - _setMetaCacheDB[network] = sqlite3.open( - sparkSetMetaCacheFile.path, - mode: OpenMode.readWrite, - ); _usedTagsCacheDB[network] = sqlite3.open( sparkUsedTagsCacheFile.path, mode: OpenMode.readWrite, @@ -134,12 +110,6 @@ abstract class _FiroCache { VACUUM; """, ); - setMetaCacheDB(network).execute( - """ - DELETE FROM PreviousMetaFetchResult; - VACUUM; - """, - ); usedTagsCacheDB(network).execute( """ DELETE FROM SparkUsedCoinTags; @@ -165,7 +135,7 @@ abstract class _FiroCache { blockHash TEXT NOT NULL, setHash TEXT NOT NULL, groupId INTEGER NOT NULL, - timestampUTC INTEGER NOT NULL, + size INTEGER NOT NULL, UNIQUE (blockHash, setHash, groupId) ); @@ -174,7 +144,8 @@ abstract class _FiroCache { serialized TEXT NOT NULL, txHash TEXT NOT NULL, context TEXT NOT NULL, - UNIQUE(serialized, txHash, context) + groupId INTEGER NOT NULL, + UNIQUE(serialized, txHash, context, groupId) ); CREATE TABLE SparkSetCoins ( @@ -190,27 +161,6 @@ abstract class _FiroCache { db.dispose(); } - static Future _createSparkSetMetaCacheDb(String file) async { - final db = sqlite3.open( - file, - mode: OpenMode.readWriteCreate, - ); - - db.execute( - """ - CREATE TABLE PreviousMetaFetchResult ( - id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, - coinGroupId INTEGER NOT NULL UNIQUE, - blockHash TEXT NOT NULL, - setHash TEXT NOT NULL, - size INTEGER NOT NULL - ); - """, - ); - - db.dispose(); - } - static Future _createSparkUsedTagsCacheDb(String file) async { final db = sqlite3.open( file, diff --git a/lib/db/sqlite/firo_cache_coordinator.dart b/lib/db/sqlite/firo_cache_coordinator.dart index 45fa4c62e..038668248 100644 --- a/lib/db/sqlite/firo_cache_coordinator.dart +++ b/lib/db/sqlite/firo_cache_coordinator.dart @@ -32,9 +32,6 @@ abstract class FiroCacheCoordinator { final setCacheFile = File( "${dir.path}/${_FiroCache.sparkSetCacheFileName(network)}", ); - final setMetaCacheFile = File( - "${dir.path}/${_FiroCache.sparkSetMetaCacheFileName(network)}", - ); final usedTagsCacheFile = File( "${dir.path}/${_FiroCache.sparkUsedTagsCacheFileName(network)}", ); @@ -44,8 +41,6 @@ abstract class FiroCacheCoordinator { final tagsSize = (await usedTagsCacheFile.exists()) ? await usedTagsCacheFile.length() : 0; - final setMetaSize = - (await setMetaCacheFile.exists()) ? await setMetaCacheFile.length() : 0; Logging.instance.log( "Spark cache used tags size: $tagsSize", @@ -55,12 +50,8 @@ abstract class FiroCacheCoordinator { "Spark cache anon set size: $setSize", level: LogLevel.Debug, ); - Logging.instance.log( - "Spark cache set meta size: $setMetaSize", - level: LogLevel.Debug, - ); - final int bytes = tagsSize + setSize + setMetaSize; + final int bytes = tagsSize + setSize; if (bytes < 1024) { return '$bytes B'; @@ -104,93 +95,70 @@ abstract class FiroCacheCoordinator { void Function(int countFetched, int totalCount)? progressUpdated, ) async { await _setLocks[network]!.protect(() async { - Map json; - SparkAnonymitySetMeta? meta; - - if (progressUpdated == null) { - // Legacy - final blockhashResult = - await FiroCacheCoordinator.getLatestSetInfoForGroupId( - groupId, - network, - ); - final blockHash = blockhashResult?.blockHash ?? ""; + const sectorSize = 12000; // TODO adjust this? + final prevMeta = await FiroCacheCoordinator.getLatestSetInfoForGroupId( + groupId, + network, + ); - json = await client.getSparkAnonymitySet( - coinGroupId: groupId.toString(), - startBlockHash: blockHash.toHexReversedFromBase64, - ); - } else { - const sectorSize = 2000; // TODO adjust this? - final prevMetaSize = - await FiroCacheCoordinator.getSparkMetaSetSizeForGroupId( - groupId, - network, - ); - final prevSize = prevMetaSize ?? 0; + final prevSize = prevMeta?.size ?? 0; - meta = await client.getSparkAnonymitySetMeta( - coinGroupId: groupId, - ); + final meta = await client.getSparkAnonymitySetMeta( + coinGroupId: groupId, + ); - progressUpdated.call(prevSize, meta.size); + progressUpdated?.call(prevSize, meta.size); - /// Returns blockHash (last block hash), - /// setHash (hash of current set) - /// and coins (the list of pairs serialized coin and tx hash) + if (prevMeta?.blockHash == meta.blockHash) { + Logging.instance.log( + "prevMeta?.blockHash == meta.blockHash", + level: LogLevel.Debug, + ); + return; + } - final fullSectorCount = (meta.size - prevSize) ~/ sectorSize; - final remainder = (meta.size - prevSize) % sectorSize; + final numberOfCoinsToFetch = meta.size - prevSize; - final List coins = []; + final fullSectorCount = numberOfCoinsToFetch ~/ sectorSize; + final remainder = numberOfCoinsToFetch % sectorSize; - for (int i = 0; i < fullSectorCount; i++) { - final start = (i * sectorSize) + prevSize; - final data = await client.getSparkAnonymitySetBySector( - coinGroupId: groupId, - latestBlock: meta.blockHash.toHexReversedFromBase64, - startIndex: start, - endIndex: start + sectorSize, - ); - progressUpdated.call(start + sectorSize, meta.size); + final List coins = []; - coins.addAll(data); - } + for (int i = 0; i < fullSectorCount; i++) { + final start = (i * sectorSize); + final data = await client.getSparkAnonymitySetBySector( + coinGroupId: groupId, + latestBlock: meta.blockHash.toHexReversedFromBase64, + startIndex: start, + endIndex: start + sectorSize, + ); + progressUpdated?.call(start + sectorSize, numberOfCoinsToFetch); - if (remainder > 0) { - final data = await client.getSparkAnonymitySetBySector( - coinGroupId: groupId, - latestBlock: meta.blockHash.toHexReversedFromBase64, - startIndex: meta.size - remainder, - endIndex: meta.size, - ); - progressUpdated.call(meta.size, meta.size); + coins.addAll(data); + } - coins.addAll(data); - } + if (remainder > 0) { + final data = await client.getSparkAnonymitySetBySector( + coinGroupId: groupId, + latestBlock: meta.blockHash.toHexReversedFromBase64, + startIndex: numberOfCoinsToFetch - remainder, + endIndex: numberOfCoinsToFetch, + ); + progressUpdated?.call(numberOfCoinsToFetch, numberOfCoinsToFetch); - json = { - "blockHash": meta.blockHash, - "setHash": meta.setHash, - "coins": coins, - }; + coins.addAll(data); } + final result = coins + .map((e) => RawSparkCoin.fromRPCResponse(e as List, groupId)) + .toList(); + await _workers[network]!.runTask( FCTask( func: FCFuncName._updateSparkAnonSetCoinsWith, - data: (groupId, json), + data: (meta, result), ), ); - - if (meta != null) { - await _workers[network]!.runTask( - FCTask( - func: FCFuncName._updateSparkAnonSetMetaWith, - data: meta, - ), - ); - } }); } @@ -265,28 +233,29 @@ abstract class FiroCacheCoordinator { ); } - static Future< - List< - ({ - String serialized, - String txHash, - String context, - })>> getSetCoinsForGroupId( + static Future> getSetCoinsForGroupId( int groupId, { - int? newerThanTimeStamp, + String? afterBlockHash, required CryptoCurrencyNetwork network, }) async { - final resultSet = await _Reader._getSetCoinsForGroupId( - groupId, - db: _FiroCache.setCacheDB(network), - newerThanTimeStamp: newerThanTimeStamp, - ); + final resultSet = afterBlockHash == null + ? await _Reader._getSetCoinsForGroupId( + groupId, + db: _FiroCache.setCacheDB(network), + ) + : await _Reader._getSetCoinsForGroupIdAndBlockHash( + groupId, + afterBlockHash, + db: _FiroCache.setCacheDB(network), + ); + return resultSet .map( - (row) => ( + (row) => RawSparkCoin( serialized: row["serialized"] as String, txHash: row["txHash"] as String, context: row["context"] as String, + groupId: groupId, ), ) .toList() @@ -294,12 +263,7 @@ abstract class FiroCacheCoordinator { .toList(); } - static Future< - ({ - String blockHash, - String setHash, - int timestampUTC, - })?> getLatestSetInfoForGroupId( + static Future getLatestSetInfoForGroupId( int groupId, CryptoCurrencyNetwork network, ) async { @@ -312,10 +276,11 @@ abstract class FiroCacheCoordinator { return null; } - return ( + return SparkAnonymitySetMeta( + coinGroupId: groupId, blockHash: result.first["blockHash"] as String, setHash: result.first["setHash"] as String, - timestampUTC: result.first["timestampUTC"] as int, + size: result.first["size"] as int, ); } @@ -328,19 +293,4 @@ abstract class FiroCacheCoordinator { db: _FiroCache.setCacheDB(network), ); } - - static Future getSparkMetaSetSizeForGroupId( - int groupId, - CryptoCurrencyNetwork network, - ) async { - final result = await _Reader._getSizeForGroupId( - groupId, - db: _FiroCache.setMetaCacheDB(network), - ); - if (result.isEmpty) { - return null; - } - - return result.first["size"] as int; - } } diff --git a/lib/db/sqlite/firo_cache_reader.dart b/lib/db/sqlite/firo_cache_reader.dart index b27cd77e3..67fea7764 100644 --- a/lib/db/sqlite/firo_cache_reader.dart +++ b/lib/db/sqlite/firo_cache_reader.dart @@ -8,21 +8,15 @@ abstract class _Reader { static Future _getSetCoinsForGroupId( int groupId, { required Database db, - int? newerThanTimeStamp, }) async { - String query = """ - SELECT sc.serialized, sc.txHash, sc.context + final query = """ + SELECT sc.serialized, sc.txHash, sc.context, sc.groupId FROM SparkSet AS ss JOIN SparkSetCoins AS ssc ON ss.id = ssc.setId JOIN SparkCoin AS sc ON ssc.coinId = sc.id - WHERE ss.groupId = $groupId + WHERE ss.groupId = $groupId; """; - if (newerThanTimeStamp != null) { - query += " AND ss.timestampUTC" - " > $newerThanTimeStamp"; - } - return db.select("$query;"); } @@ -31,16 +25,45 @@ abstract class _Reader { required Database db, }) async { final query = """ - SELECT ss.blockHash, ss.setHash, ss.timestampUTC + SELECT ss.blockHash, ss.setHash, ss.size FROM SparkSet ss WHERE ss.groupId = $groupId - ORDER BY ss.timestampUTC DESC + ORDER BY ss.size DESC LIMIT 1; """; return db.select("$query;"); } + static Future _getSetCoinsForGroupIdAndBlockHash( + int groupId, + String blockHash, { + required Database db, + }) async { + const query = """ + WITH TargetBlock AS ( + SELECT id + FROM SparkSet + WHERE blockHash = ? + ), + TargetSets AS ( + SELECT id AS setId + FROM SparkSet + WHERE groupId = ? AND id > (SELECT id FROM TargetBlock) + ) + SELECT + SparkCoin.serialized, + SparkCoin.txHash, + SparkCoin.context, + SparkCoin.groupId + FROM SparkSetCoins + JOIN SparkCoin ON SparkSetCoins.coinId = SparkCoin.id + WHERE SparkSetCoins.setId IN (SELECT setId FROM TargetSets); + """; + + return db.select("$query;", [blockHash, groupId]); + } + static Future _checkSetInfoForGroupIdExists( int groupId, { required Database db, @@ -56,21 +79,6 @@ abstract class _Reader { return db.select("$query;").first["setExists"] == 1; } - // =========================================================================== - // =============== Spark anonymity set meta queries ========================== - static Future _getSizeForGroupId( - int groupId, { - required Database db, - }) async { - final query = """ - SELECT size - FROM PreviousMetaFetchResult - WHERE coinGroupId = $groupId; - """; - - return db.select("$query;"); - } - // =========================================================================== // =============== Spark used coin tags queries ============================== diff --git a/lib/db/sqlite/firo_cache_worker.dart b/lib/db/sqlite/firo_cache_worker.dart index a417cdb07..abaceb288 100644 --- a/lib/db/sqlite/firo_cache_worker.dart +++ b/lib/db/sqlite/firo_cache_worker.dart @@ -3,7 +3,6 @@ part of 'firo_cache.dart'; enum FCFuncName { _updateSparkAnonSetCoinsWith, _updateSparkUsedTagsWith, - _updateSparkAnonSetMetaWith, } class FCTask { @@ -30,8 +29,6 @@ class _FiroCacheWorker { final dir = await StackFileSystem.applicationFiroCacheSQLiteDirectory(); final setCacheFilePath = "${dir.path}/${_FiroCache.sparkSetCacheFileName(network)}"; - final setMetaCacheFilePath = - "${dir.path}/${_FiroCache.sparkSetMetaCacheFileName(network)}"; final usedTagsCacheFilePath = "${dir.path}/${_FiroCache.sparkUsedTagsCacheFileName(network)}"; @@ -54,7 +51,6 @@ class _FiroCacheWorker { ( initPort.sendPort, setCacheFilePath, - setMetaCacheFilePath, usedTagsCacheFilePath, ), ); @@ -87,7 +83,6 @@ class _FiroCacheWorker { ReceivePort receivePort, SendPort sendPort, Database setCacheDb, - Database setMetaCacheDb, Database usedTagsCacheDb, Mutex mutex, ) { @@ -99,7 +94,8 @@ class _FiroCacheWorker { final FCResult result; switch (task.func) { case FCFuncName._updateSparkAnonSetCoinsWith: - final data = task.data as (int, Map); + final data = + task.data as (SparkAnonymitySetMeta, List); result = _updateSparkAnonSetCoinsWith( setCacheDb, data.$2, @@ -113,13 +109,6 @@ class _FiroCacheWorker { task.data as List>, ); break; - - case FCFuncName._updateSparkAnonSetMetaWith: - result = _updateSparkAnonSetMetaWith( - setMetaCacheDb, - task.data as SparkAnonymitySetMeta, - ); - break; } if (result.success) { @@ -134,7 +123,7 @@ class _FiroCacheWorker { }); } - static void _startWorkerIsolate((SendPort, String, String, String) args) { + static void _startWorkerIsolate((SendPort, String, String) args) { final receivePort = ReceivePort(); args.$1.send(receivePort.sendPort); final mutex = Mutex(); @@ -142,19 +131,14 @@ class _FiroCacheWorker { args.$2, mode: OpenMode.readWrite, ); - final setMetaCacheDb = sqlite3.open( - args.$3, - mode: OpenMode.readWrite, - ); final usedTagsCacheDb = sqlite3.open( - args.$4, + args.$3, mode: OpenMode.readWrite, ); _handleCommandsToIsolate( receivePort, args.$1, setCacheDb, - setMetaCacheDb, usedTagsCacheDb, mutex, ); diff --git a/lib/db/sqlite/firo_cache_writer.dart b/lib/db/sqlite/firo_cache_writer.dart index 36b71369b..63192d964 100644 --- a/lib/db/sqlite/firo_cache_writer.dart +++ b/lib/db/sqlite/firo_cache_writer.dart @@ -48,58 +48,17 @@ FCResult _updateSparkUsedTagsWith( } } -// =========================================================================== -// ================== write to spark anon set Meta cache ========================== -FCResult _updateSparkAnonSetMetaWith( - Database db, - SparkAnonymitySetMeta meta, -) { - db.execute("BEGIN;"); - try { - db.execute( - """ - INSERT OR REPLACE INTO PreviousMetaFetchResult (coinGroupId, blockHash, setHash, size) - VALUES (?, ?, ?, ?); - """, - [meta.coinGroupId, meta.blockHash, meta.setHash, meta.size], - ); - - db.execute("COMMIT;"); - - return FCResult(success: true); - } catch (e) { - db.execute("ROLLBACK;"); - return FCResult(success: false, error: e); - } -} - // =========================================================================== // ================== write to spark anon set cache ========================== /// update the sqlite cache -/// Expected json format: -/// { -/// "blockHash": "someBlockHash", -/// "setHash": "someSetHash", -/// "coins": [ -/// ["serliazed1", "hash1", "context1"], -/// ["serliazed2", "hash2", "context2"], -/// ... -/// ["serliazed3", "hash3", "context3"], -/// ["serliazed4", "hash4", "context4"], -/// ], -/// } /// /// returns true if successful, otherwise false FCResult _updateSparkAnonSetCoinsWith( Database db, - Map json, - int groupId, + final List coinsRaw, + SparkAnonymitySetMeta meta, ) { - final blockHash = json["blockHash"] as String; - final setHash = json["setHash"] as String; - final coinsRaw = json["coins"] as List; - if (coinsRaw.isEmpty) { // no coins to actually insert return FCResult(success: true); @@ -112,9 +71,9 @@ FCResult _updateSparkAnonSetCoinsWith( WHERE blockHash = ? AND setHash = ? AND groupId = ?; """, [ - blockHash, - setHash, - groupId, + meta.blockHash, + meta.setHash, + meta.coinGroupId, ], ); @@ -123,59 +82,28 @@ FCResult _updateSparkAnonSetCoinsWith( return FCResult(success: true); } - final coins = coinsRaw - .map( - (e) => [ - e[0] as String, - e[1] as String, - e[2] as String, - ], - ) - .toList() - .reversed; - - final timestamp = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000; + final coins = coinsRaw.reversed; db.execute("BEGIN;"); try { db.execute( """ - INSERT INTO SparkSet (blockHash, setHash, groupId, timestampUTC) + INSERT INTO SparkSet (blockHash, setHash, groupId, size) VALUES (?, ?, ?, ?); """, - [blockHash, setHash, groupId, timestamp], + [meta.blockHash, meta.setHash, meta.coinGroupId, meta.size], ); final setId = db.lastInsertRowId; for (final coin in coins) { - int coinId; - try { - // try to insert and get row id - db.execute( - """ - INSERT INTO SparkCoin (serialized, txHash, context) - VALUES (?, ?, ?); + db.execute( + """ + INSERT INTO SparkCoin (serialized, txHash, context, groupId) + VALUES (?, ?, ?, ?); """, - coin, - ); - coinId = db.lastInsertRowId; - } on SqliteException catch (e) { - // if there already is a matching coin in the db - // just grab its row id - if (e.extendedResultCode == 2067) { - final result = db.select( - """ - SELECT id - FROM SparkCoin - WHERE serialized = ? AND txHash = ? AND context = ?; - """, - coin, - ); - coinId = result.first["id"] as int; - } else { - rethrow; - } - } + [coin.serialized, coin.txHash, coin.context, coin.groupId], + ); + final coinId = db.lastInsertRowId; // finally add the row id to the newly added set db.execute( diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index 3f8241bca..8ff04712a 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -399,7 +399,11 @@ class ElectrumXClient { rethrow; } } catch (e) { + final errorMessage = e.toString(); Logging.instance.log("$host $e", level: LogLevel.Debug); + if (errorMessage.contains("JSON-RPC error")) { + currentFailoverIndex = _failovers.length; + } if (currentFailoverIndex < _failovers.length - 1) { currentFailoverIndex++; return request( diff --git a/lib/models/electrumx_response/spark_models.dart b/lib/models/electrumx_response/spark_models.dart index 499f20cf6..43bf9f61f 100644 --- a/lib/models/electrumx_response/spark_models.dart +++ b/lib/models/electrumx_response/spark_models.dart @@ -45,3 +45,54 @@ class SparkAnonymitySetMeta { "}"; } } + +class RawSparkCoin { + final String serialized; + final String txHash; + final String context; + final int groupId; + + RawSparkCoin({ + required this.serialized, + required this.txHash, + required this.context, + required this.groupId, + }); + + static RawSparkCoin fromRPCResponse(List data, int groupId) { + try { + if (data.length != 3) throw Exception(); + return RawSparkCoin( + serialized: data[0] as String, + txHash: data[1] as String, + context: data[2] as String, + groupId: groupId, + ); + } catch (_) { + throw Exception("Invalid coin data: $data"); + } + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! RawSparkCoin) return false; + return serialized == other.serialized && + txHash == other.txHash && + groupId == other.groupId && + context == other.context; + } + + @override + int get hashCode => Object.hash(serialized, txHash, context); + + @override + String toString() { + return "SparkAnonymitySetMeta{" + "serialized: $serialized, " + "txHash: $txHash, " + "context: $context, " + "groupId: $groupId" + "}"; + } +} diff --git a/lib/wallets/isar/models/wallet_info.dart b/lib/wallets/isar/models/wallet_info.dart index eb6a4e9ea..51aa69a45 100644 --- a/lib/wallets/isar/models/wallet_info.dart +++ b/lib/wallets/isar/models/wallet_info.dart @@ -520,8 +520,8 @@ abstract class WalletInfoKeys { static const String lelantusCoinIsarRescanRequired = "lelantusCoinIsarRescanRequired"; static const String enableLelantusScanning = "enableLelantusScanningKey"; - static const String firoSparkCacheSetTimestampCache = - "firoSparkCacheSetTimestampCacheKey"; + static const String firoSparkCacheSetBlockHashCache = + "firoSparkCacheSetBlockHashCacheKey"; static const String enableOptInRbf = "enableOptInRbfKey"; static const String reuseAddress = "reuseAddressKey"; static const String isViewOnlyKey = "isViewOnlyKey"; diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index d4faabef9..d412f1d5b 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -671,7 +671,7 @@ class FiroWallet extends Bip39HDWallet // reset last checked values await info.updateOtherData( newEntries: { - WalletInfoKeys.firoSparkCacheSetTimestampCache: {}, + WalletInfoKeys.firoSparkCacheSetBlockHashCache: {}, }, isar: mainDB.isar, ); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index 5390b66d3..2b1f0f903 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -886,11 +886,11 @@ mixin SparkInterface currentPercent = _triggerEventHelper(currentPercent, percentIncrement); } - // Get cached timestamps per groupId. These timestamps are used to check + // Get cached block hashes per groupId. These hashes are used to check // and try to id coins that were added to the spark anon set cache - // after that timestamp. - final groupIdTimestampUTCMap = - info.otherData[WalletInfoKeys.firoSparkCacheSetTimestampCache] + // after that block. + final groupIdBlockHashMap = + info.otherData[WalletInfoKeys.firoSparkCacheSetBlockHashCache] as Map? ?? {}; @@ -898,8 +898,7 @@ mixin SparkInterface // processed by this wallet yet final Map>> rawCoinsBySetId = {}; for (int i = 1; i <= latestGroupId; i++) { - final lastCheckedTimeStampUTC = - groupIdTimestampUTCMap[i.toString()] as int? ?? 0; + final lastCheckedHash = groupIdBlockHashMap[i.toString()] as String?; final info = await FiroCacheCoordinator.getLatestSetInfoForGroupId( i, cryptoCurrency.network, @@ -907,7 +906,7 @@ mixin SparkInterface final anonymitySetResult = await FiroCacheCoordinator.getSetCoinsForGroupId( i, - newerThanTimeStamp: lastCheckedTimeStampUTC, + afterBlockHash: lastCheckedHash, network: cryptoCurrency.network, ); final coinsRaw = anonymitySetResult @@ -924,11 +923,8 @@ mixin SparkInterface rawCoinsBySetId[i] = coinsRaw; } - // update last checked timestamp data - groupIdTimestampUTCMap[i.toString()] = max( - lastCheckedTimeStampUTC, - info?.timestampUTC ?? lastCheckedTimeStampUTC, - ); + // update last checked + groupIdBlockHashMap[i.toString()] = info?.blockHash; } if (percentIncrement != null) { @@ -973,11 +969,10 @@ mixin SparkInterface }); } - // finally update the cached timestamps in the database + // finally update the cached block hashes in the database await info.updateOtherData( newEntries: { - WalletInfoKeys.firoSparkCacheSetTimestampCache: - groupIdTimestampUTCMap, + WalletInfoKeys.firoSparkCacheSetBlockHashCache: groupIdBlockHashMap, }, isar: mainDB.isar, ); From cc80771b90402ccd168a9b8ff51d3e6802ef156d Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Dec 2024 14:03:31 -0600 Subject: [PATCH 08/10] fix: update hash format and use better sector/page size --- lib/db/sqlite/firo_cache_coordinator.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/db/sqlite/firo_cache_coordinator.dart b/lib/db/sqlite/firo_cache_coordinator.dart index 038668248..a002dc222 100644 --- a/lib/db/sqlite/firo_cache_coordinator.dart +++ b/lib/db/sqlite/firo_cache_coordinator.dart @@ -95,7 +95,8 @@ abstract class FiroCacheCoordinator { void Function(int countFetched, int totalCount)? progressUpdated, ) async { await _setLocks[network]!.protect(() async { - const sectorSize = 12000; // TODO adjust this? + const sectorSize = + 1500; // chosen as a somewhat decent value. Could be changed in the future if wanted/needed final prevMeta = await FiroCacheCoordinator.getLatestSetInfoForGroupId( groupId, network, @@ -128,7 +129,7 @@ abstract class FiroCacheCoordinator { final start = (i * sectorSize); final data = await client.getSparkAnonymitySetBySector( coinGroupId: groupId, - latestBlock: meta.blockHash.toHexReversedFromBase64, + latestBlock: meta.blockHash, startIndex: start, endIndex: start + sectorSize, ); @@ -140,7 +141,7 @@ abstract class FiroCacheCoordinator { if (remainder > 0) { final data = await client.getSparkAnonymitySetBySector( coinGroupId: groupId, - latestBlock: meta.blockHash.toHexReversedFromBase64, + latestBlock: meta.blockHash, startIndex: numberOfCoinsToFetch - remainder, endIndex: numberOfCoinsToFetch, ); From b9d85da1fce6cb1aafd085815bb61e6d131dd0a0 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Dec 2024 15:40:13 -0600 Subject: [PATCH 09/10] fix: Issue where spark spend may not have appeared as confirmed --- lib/wallets/wallet/impl/firo_wallet.dart | 79 +++++++++++-------- .../spark_interface.dart | 12 +-- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index d412f1d5b..d149a7a9e 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -93,33 +93,13 @@ class FiroWallet extends Bip39HDWallet .walletIdEqualToAnyLTagHash(walletId) .findAll(); - final Set sparkTxids = {}; - - for (final coin in sparkCoins) { - sparkTxids.add(coin.txHash); - // check for duplicates before adding to list - if (allTxHashes.indexWhere((e) => e["tx_hash"] == coin.txHash) == -1) { - final info = { - "tx_hash": coin.txHash, - "height": coin.height, - }; - allTxHashes.add(info); - } - } - - final missing = await getMissingSparkSpendTransactionIds(); - for (final txid in missing.map((e) => e.txid).toSet()) { - allTxHashes.add({ - "tx_hash": txid, - }); - } - final List> allTransactions = []; // some lelantus transactions aren't fetched via wallet addresses so they // will never show as confirmed in the gui. - final unconfirmedTransactions = await mainDB - .getTransactions(walletId) + final unconfirmedTransactions = await mainDB.isar.transactionV2s + .where() + .walletIdEqualTo(walletId) .filter() .heightIsNull() .findAll(); @@ -137,21 +117,54 @@ class FiroWallet extends Bip39HDWallet final info = { "tx_hash": tx.txid, "height": height, - "address": tx.address.value?.value, }; allTxHashes.add(info); } } - for (final txHash in allTxHashes) { - // final storedTx = await db - // .getTransactions(walletId) - // .filter() - // .txidEqualTo(txHash["tx_hash"] as String) - // .findFirst(); + final Set sparkTxids = {}; + for (final coin in sparkCoins) { + sparkTxids.add(coin.txHash); + // check for duplicates before adding to list + if (allTxHashes.indexWhere((e) => e["tx_hash"] == coin.txHash) == -1) { + final info = { + "tx_hash": coin.txHash, + "height": coin.height, + }; + allTxHashes.add(info); + } + } + + final missing = await getSparkSpendTransactionIds(); + for (final txid in missing.map((e) => e.txid).toSet()) { + // check for duplicates before adding to list + if (allTxHashes.indexWhere((e) => e["tx_hash"] == txid) == -1) { + final info = { + "tx_hash": txid, + }; + allTxHashes.add(info); + } + } + + final currentHeight = await chainHeight; - // if (storedTx == null || - // !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + for (final txHash in allTxHashes) { + final storedTx = await mainDB.isar.transactionV2s + .where() + .walletIdEqualTo(walletId) + .filter() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); + + if (storedTx?.isConfirmed( + currentHeight, + cryptoCurrency.minConfirms, + cryptoCurrency.minCoinbaseConfirms, + ) == + true) { + // tx already confirmed, no need to process it again + continue; + } // firod/electrumx seem to take forever to process spark txns so we'll // just ignore null errors and check again on next refresh. @@ -174,7 +187,6 @@ class FiroWallet extends Bip39HDWallet tx["height"] ??= txHash["height"]; allTransactions.add(tx); } - // } } final List txns = []; @@ -193,7 +205,6 @@ class FiroWallet extends Bip39HDWallet bool isMint = false; bool isJMint = false; bool isSparkMint = false; - final bool isMasterNodePayment = false; final bool isSparkSpend = txData["type"] == 9 && txData["version"] == 3; final bool isMySpark = sparkTxids.contains(txData["txid"] as String); final bool isMySpentSpark = diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index 2b1f0f903..186eb5663 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -1103,7 +1103,7 @@ mixin SparkInterface } } - Future> getMissingSparkSpendTransactionIds() async { + Future> getSparkSpendTransactionIds() async { final tags = await mainDB.isar.sparkCoins .where() .walletIdEqualToAnyLTagHash(walletId) @@ -1112,21 +1112,11 @@ mixin SparkInterface .lTagHashProperty() .findAll(); - final usedCoinTxidsFoundLocally = await mainDB.isar.transactionV2s - .where() - .walletIdEqualTo(walletId) - .filter() - .subTypeEqualTo(TransactionSubType.sparkSpend) - .txidProperty() - .findAll(); - final pairs = await FiroCacheCoordinator.getUsedCoinTxidsFor( tags: tags, network: cryptoCurrency.network, ); - pairs.removeWhere((e) => usedCoinTxidsFoundLocally.contains(e.txid)); - return pairs.toSet(); } From 89d54f328a81d888b29a52b8d39cef52b46470bb Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 17 Dec 2024 16:04:26 -0600 Subject: [PATCH 10/10] chore: build runner --- .../models/blockchain_data/address.g.dart | 2 + lib/wallets/isar/models/wallet_info.g.dart | 2 + test/cached_electrumx_test.mocks.dart | 403 ++++++++++-------- .../bitcoin/bitcoin_wallet_test.mocks.dart | 377 ++++++++-------- .../bitcoincash_wallet_test.mocks.dart | 377 ++++++++-------- .../dogecoin/dogecoin_wallet_test.mocks.dart | 377 ++++++++-------- .../namecoin/namecoin_wallet_test.mocks.dart | 377 ++++++++-------- .../particl/particl_wallet_test.mocks.dart | 377 ++++++++-------- 8 files changed, 1229 insertions(+), 1063 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/address.g.dart b/lib/models/isar/models/blockchain_data/address.g.dart index 092198990..340ab9f1b 100644 --- a/lib/models/isar/models/blockchain_data/address.g.dart +++ b/lib/models/isar/models/blockchain_data/address.g.dart @@ -278,6 +278,7 @@ const _AddresstypeEnumValueMap = { 'frostMS': 13, 'p2tr': 14, 'solana': 15, + 'cardanoShelley': 16, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, @@ -296,6 +297,7 @@ const _AddresstypeValueEnumMap = { 13: AddressType.frostMS, 14: AddressType.p2tr, 15: AddressType.solana, + 16: AddressType.cardanoShelley, }; Id _addressGetId(Address object) { diff --git a/lib/wallets/isar/models/wallet_info.g.dart b/lib/wallets/isar/models/wallet_info.g.dart index 89c5511fa..6e02fd6d5 100644 --- a/lib/wallets/isar/models/wallet_info.g.dart +++ b/lib/wallets/isar/models/wallet_info.g.dart @@ -268,6 +268,7 @@ const _WalletInfomainAddressTypeEnumValueMap = { 'frostMS': 13, 'p2tr': 14, 'solana': 15, + 'cardanoShelley': 16, }; const _WalletInfomainAddressTypeValueEnumMap = { 0: AddressType.p2pkh, @@ -286,6 +287,7 @@ const _WalletInfomainAddressTypeValueEnumMap = { 13: AddressType.frostMS, 14: AddressType.p2tr, 15: AddressType.solana, + 16: AddressType.cardanoShelley, }; Id _walletInfoGetId(WalletInfo object) { diff --git a/test/cached_electrumx_test.mocks.dart b/test/cached_electrumx_test.mocks.dart index 25324b805..a5c7c4c54 100644 --- a/test/cached_electrumx_test.mocks.dart +++ b/test/cached_electrumx_test.mocks.dart @@ -3,21 +3,23 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i7; -import 'dart:ui' as _i12; +import 'dart:async' as _i9; +import 'dart:ui' as _i14; -import 'package:decimal/decimal.dart' as _i3; +import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i6; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i5; -import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i11; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i10; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i9; -import 'package:stackwallet/utilities/prefs.dart' as _i8; +import 'package:mockito/src/dummies.dart' as _i8; +import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i6; +import 'package:stackwallet/models/electrumx_response/spark_models.dart' as _i3; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i13; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i12; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i11; +import 'package:stackwallet/utilities/prefs.dart' as _i10; +import 'package:stackwallet/utilities/tor_plain_net_option_enum.dart' as _i7; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart' - as _i4; + as _i5; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -53,8 +55,9 @@ class _FakeDuration_1 extends _i1.SmartFake implements Duration { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { - _FakeDecimal_2( +class _FakeSparkAnonymitySetMeta_2 extends _i1.SmartFake + implements _i3.SparkAnonymitySetMeta { + _FakeSparkAnonymitySetMeta_2( Object parent, Invocation parentInvocation, ) : super( @@ -63,8 +66,18 @@ class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { ); } -class _FakeFusionInfo_3 extends _i1.SmartFake implements _i4.FusionInfo { - _FakeFusionInfo_3( +class _FakeDecimal_3 extends _i1.SmartFake implements _i4.Decimal { + _FakeDecimal_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeFusionInfo_4 extends _i1.SmartFake implements _i5.FusionInfo { + _FakeFusionInfo_4( Object parent, Invocation parentInvocation, ) : super( @@ -76,7 +89,7 @@ class _FakeFusionInfo_3 extends _i1.SmartFake implements _i4.FusionInfo { /// A class which mocks [ElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { +class MockElectrumXClient extends _i1.Mock implements _i6.ElectrumXClient { MockElectrumXClient() { _i1.throwOnMissingStub(this); } @@ -90,6 +103,12 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { ), ) as _i2.CryptoCurrency); + @override + _i7.TorPlainNetworkOption get netType => (super.noSuchMethod( + Invocation.getter(#netType), + returnValue: _i7.TorPlainNetworkOption.tor, + ) as _i7.TorPlainNetworkOption); + @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), @@ -118,7 +137,7 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { @override String get host => (super.noSuchMethod( Invocation.getter(#host), - returnValue: _i6.dummyValue( + returnValue: _i8.dummyValue( this, Invocation.getter(#host), ), @@ -137,27 +156,27 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { ) as bool); @override - _i7.Future closeAdapter() => (super.noSuchMethod( + _i9.Future closeAdapter() => (super.noSuchMethod( Invocation.method( #closeAdapter, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i7.Future checkElectrumAdapter() => (super.noSuchMethod( + _i9.Future checkElectrumAdapter() => (super.noSuchMethod( Invocation.method( #checkElectrumAdapter, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i7.Future request({ + _i9.Future request({ required String? command, List? args = const [], String? requestID, @@ -176,11 +195,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #requestTimeout: requestTimeout, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + ) as _i9.Future); @override - _i7.Future> batchRequest({ + _i9.Future> batchRequest({ required String? command, required List? args, Duration? requestTimeout = const Duration(seconds: 60), @@ -197,11 +216,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #retries: retries, }, ), - returnValue: _i7.Future>.value([]), - ) as _i7.Future>); + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override - _i7.Future ping({ + _i9.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -214,11 +233,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #retryCount: retryCount, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i7.Future> getBlockHeadTip({String? requestID}) => + _i9.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -226,11 +245,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future> getServerFeatures({String? requestID}) => + _i9.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -238,11 +257,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future broadcastTransaction({ + _i9.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -255,7 +274,7 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i7.Future.value(_i6.dummyValue( + returnValue: _i9.Future.value(_i8.dummyValue( this, Invocation.method( #broadcastTransaction, @@ -266,10 +285,10 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { }, ), )), - ) as _i7.Future); + ) as _i9.Future); @override - _i7.Future> getBalance({ + _i9.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -283,11 +302,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future>> getHistory({ + _i9.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -300,12 +319,12 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i7.Future>>.value( + returnValue: _i9.Future>>.value( >[]), - ) as _i7.Future>>); + ) as _i9.Future>>); @override - _i7.Future>>> getBatchHistory( + _i9.Future>>> getBatchHistory( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -313,12 +332,12 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { [], {#args: args}, ), - returnValue: _i7.Future>>>.value( + returnValue: _i9.Future>>>.value( >>[]), - ) as _i7.Future>>>); + ) as _i9.Future>>>); @override - _i7.Future>> getUTXOs({ + _i9.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -331,12 +350,12 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i7.Future>>.value( + returnValue: _i9.Future>>.value( >[]), - ) as _i7.Future>>); + ) as _i9.Future>>); @override - _i7.Future>>> getBatchUTXOs( + _i9.Future>>> getBatchUTXOs( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -344,12 +363,12 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { [], {#args: args}, ), - returnValue: _i7.Future>>>.value( + returnValue: _i9.Future>>>.value( >>[]), - ) as _i7.Future>>>); + ) as _i9.Future>>>); @override - _i7.Future> getTransaction({ + _i9.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -365,11 +384,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future> getLelantusAnonymitySet({ + _i9.Future> getLelantusAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -385,11 +404,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future getLelantusMintData({ + _i9.Future getLelantusMintData({ dynamic mints, String? requestID, }) => @@ -402,11 +421,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + ) as _i9.Future); @override - _i7.Future> getLelantusUsedCoinSerials({ + _i9.Future> getLelantusUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -420,22 +439,22 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future getLelantusLatestCoinId({String? requestID}) => + _i9.Future getLelantusLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLelantusLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i7.Future> getSparkAnonymitySet({ + _i9.Future> getSparkAnonymitySet({ String? coinGroupId = r'1', String? startBlockHash = r'', String? requestID, @@ -451,58 +470,33 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { }, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); - - @override - _i7.Future>> getSparkMintMetaData({ - String? requestID, - required List? sparkCoinHashes, - }) => - (super.noSuchMethod( - Invocation.method( - #getSparkMintMetaData, - [], - { - #requestID: requestID, - #sparkCoinHashes: sparkCoinHashes, - }, - ), - returnValue: _i7.Future>>.value( - >[]), - ) as _i7.Future>>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future getSparkLatestCoinId({String? requestID}) => + _i9.Future getSparkLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getSparkLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i7.Future.value(0), - ) as _i7.Future); + returnValue: _i9.Future.value(0), + ) as _i9.Future); @override - _i7.Future> getMempoolTxids({String? requestID}) => + _i9.Future> getMempoolTxids({String? requestID}) => (super.noSuchMethod( Invocation.method( #getMempoolTxids, [], {#requestID: requestID}, ), - returnValue: _i7.Future>.value({}), - ) as _i7.Future>); + returnValue: _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>> getMempoolSparkData({ + _i9.Future> getMempoolSparkData({ String? requestID, required List? txids, }) => @@ -515,30 +509,12 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #txids: txids, }, ), - returnValue: _i7.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>.value(<({ - List coins, - List lTags, - List serialContext, - String txid - })>[]), - ) as _i7.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>); - - @override - _i7.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ + returnValue: _i9.Future>.value( + <_i3.SparkMempoolData>[]), + ) as _i9.Future>); + + @override + _i9.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ String? requestID, required int? startNumber, }) => @@ -551,11 +527,62 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #startNumber: startNumber, }, ), - returnValue: _i7.Future>>.value(>[]), - ) as _i7.Future>>); + returnValue: _i9.Future>>.value(>[]), + ) as _i9.Future>>); + + @override + _i9.Future<_i3.SparkAnonymitySetMeta> getSparkAnonymitySetMeta({ + String? requestID, + required int? coinGroupId, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + returnValue: _i9.Future<_i3.SparkAnonymitySetMeta>.value( + _FakeSparkAnonymitySetMeta_2( + this, + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + )), + ) as _i9.Future<_i3.SparkAnonymitySetMeta>); + + @override + _i9.Future> getSparkAnonymitySetBySector({ + String? requestID, + required int? coinGroupId, + required String? latestBlock, + required int? startIndex, + required int? endIndex, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetBySector, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + #latestBlock: latestBlock, + #startIndex: startIndex, + #endIndex: endIndex, + }, + ), + returnValue: _i9.Future>.value([]), + ) as _i9.Future>); @override - _i7.Future isMasterNodeCollateral({ + _i9.Future isMasterNodeCollateral({ String? requestID, required String? txid, required int? index, @@ -570,11 +597,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #index: index, }, ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i7.Future> getFeeRate({String? requestID}) => + _i9.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -582,11 +609,11 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i7.Future>.value({}), - ) as _i7.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i7.Future<_i3.Decimal> estimateFee({ + _i9.Future<_i4.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -599,7 +626,7 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { #blocks: blocks, }, ), - returnValue: _i7.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i9.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #estimateFee, @@ -610,16 +637,16 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { }, ), )), - ) as _i7.Future<_i3.Decimal>); + ) as _i9.Future<_i4.Decimal>); @override - _i7.Future<_i3.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i9.Future<_i4.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i7.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i9.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #relayFee, @@ -627,13 +654,13 @@ class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { {#requestID: requestID}, ), )), - ) as _i7.Future<_i3.Decimal>); + ) as _i9.Future<_i4.Decimal>); } /// A class which mocks [Prefs]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrefs extends _i1.Mock implements _i8.Prefs { +class MockPrefs extends _i1.Mock implements _i10.Prefs { MockPrefs() { _i1.throwOnMissingStub(this); } @@ -697,13 +724,13 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { ); @override - _i9.SyncingType get syncType => (super.noSuchMethod( + _i11.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i9.SyncingType.currentWalletOnly, - ) as _i9.SyncingType); + returnValue: _i11.SyncingType.currentWalletOnly, + ) as _i11.SyncingType); @override - set syncType(_i9.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i11.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -744,7 +771,7 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { @override String get language => (super.noSuchMethod( Invocation.getter(#language), - returnValue: _i6.dummyValue( + returnValue: _i8.dummyValue( this, Invocation.getter(#language), ), @@ -762,7 +789,7 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { @override String get currency => (super.noSuchMethod( Invocation.getter(#currency), - returnValue: _i6.dummyValue( + returnValue: _i8.dummyValue( this, Invocation.getter(#currency), ), @@ -892,13 +919,13 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { ); @override - _i10.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i12.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i10.BackupFrequencyType.everyTenMinutes, - ) as _i10.BackupFrequencyType); + returnValue: _i12.BackupFrequencyType.everyTenMinutes, + ) as _i12.BackupFrequencyType); @override - set backupFrequencyType(_i10.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i12.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -1005,7 +1032,7 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { @override String get themeId => (super.noSuchMethod( Invocation.getter(#themeId), - returnValue: _i6.dummyValue( + returnValue: _i8.dummyValue( this, Invocation.getter(#themeId), ), @@ -1023,7 +1050,7 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { @override String get systemBrightnessLightThemeId => (super.noSuchMethod( Invocation.getter(#systemBrightnessLightThemeId), - returnValue: _i6.dummyValue( + returnValue: _i8.dummyValue( this, Invocation.getter(#systemBrightnessLightThemeId), ), @@ -1042,7 +1069,7 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { @override String get systemBrightnessDarkThemeId => (super.noSuchMethod( Invocation.getter(#systemBrightnessDarkThemeId), - returnValue: _i6.dummyValue( + returnValue: _i8.dummyValue( this, Invocation.getter(#systemBrightnessDarkThemeId), ), @@ -1110,67 +1137,67 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { ) as bool); @override - _i7.Future init() => (super.noSuchMethod( + _i9.Future init() => (super.noSuchMethod( Invocation.method( #init, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i7.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( + _i9.Future incrementCurrentNotificationIndex() => (super.noSuchMethod( Invocation.method( #incrementCurrentNotificationIndex, [], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i7.Future isExternalCallsSet() => (super.noSuchMethod( + _i9.Future isExternalCallsSet() => (super.noSuchMethod( Invocation.method( #isExternalCallsSet, [], ), - returnValue: _i7.Future.value(false), - ) as _i7.Future); + returnValue: _i9.Future.value(false), + ) as _i9.Future); @override - _i7.Future saveUserID(String? userId) => (super.noSuchMethod( + _i9.Future saveUserID(String? userId) => (super.noSuchMethod( Invocation.method( #saveUserID, [userId], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i7.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( + _i9.Future saveSignupEpoch(int? signupEpoch) => (super.noSuchMethod( Invocation.method( #saveSignupEpoch, [signupEpoch], ), - returnValue: _i7.Future.value(), - returnValueForMissingStub: _i7.Future.value(), - ) as _i7.Future); + returnValue: _i9.Future.value(), + returnValueForMissingStub: _i9.Future.value(), + ) as _i9.Future); @override - _i11.AmountUnit amountUnit(_i2.CryptoCurrency? coin) => (super.noSuchMethod( + _i13.AmountUnit amountUnit(_i2.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i11.AmountUnit.normal, - ) as _i11.AmountUnit); + returnValue: _i13.AmountUnit.normal, + ) as _i13.AmountUnit); @override void updateAmountUnit({ required _i2.CryptoCurrency? coin, - required _i11.AmountUnit? amountUnit, + required _i13.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -1211,25 +1238,25 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { ); @override - _i4.FusionInfo getFusionServerInfo(_i2.CryptoCurrency? coin) => + _i5.FusionInfo getFusionServerInfo(_i2.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #getFusionServerInfo, [coin], ), - returnValue: _FakeFusionInfo_3( + returnValue: _FakeFusionInfo_4( this, Invocation.method( #getFusionServerInfo, [coin], ), ), - ) as _i4.FusionInfo); + ) as _i5.FusionInfo); @override void setFusionServerInfo( _i2.CryptoCurrency? coin, - _i4.FusionInfo? fusionServerInfo, + _i5.FusionInfo? fusionServerInfo, ) => super.noSuchMethod( Invocation.method( @@ -1243,7 +1270,7 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { ); @override - void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1252,7 +1279,7 @@ class MockPrefs extends _i1.Mock implements _i8.Prefs { ); @override - void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart index 75fc2228a..a36aefef0 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart @@ -3,15 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i8; -import 'package:decimal/decimal.dart' as _i3; +import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i5; -import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; +import 'package:mockito/src/dummies.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i5; +import 'package:stackwallet/models/electrumx_response/spark_models.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; + as _i10; +import 'package:stackwallet/utilities/tor_plain_net_option_enum.dart' as _i6; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -49,8 +51,9 @@ class _FakeDuration_1 extends _i1.SmartFake implements Duration { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { - _FakeDecimal_2( +class _FakeSparkAnonymitySetMeta_2 extends _i1.SmartFake + implements _i3.SparkAnonymitySetMeta { + _FakeSparkAnonymitySetMeta_2( Object parent, Invocation parentInvocation, ) : super( @@ -59,9 +62,19 @@ class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { ); } -class _FakeElectrumXClient_3 extends _i1.SmartFake - implements _i4.ElectrumXClient { - _FakeElectrumXClient_3( +class _FakeDecimal_3 extends _i1.SmartFake implements _i4.Decimal { + _FakeDecimal_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXClient_4 extends _i1.SmartFake + implements _i5.ElectrumXClient { + _FakeElectrumXClient_4( Object parent, Invocation parentInvocation, ) : super( @@ -73,7 +86,7 @@ class _FakeElectrumXClient_3 extends _i1.SmartFake /// A class which mocks [ElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { +class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { MockElectrumXClient() { _i1.throwOnMissingStub(this); } @@ -87,6 +100,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); + @override + _i6.TorPlainNetworkOption get netType => (super.noSuchMethod( + Invocation.getter(#netType), + returnValue: _i6.TorPlainNetworkOption.tor, + ) as _i6.TorPlainNetworkOption); + @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), @@ -115,7 +134,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { @override String get host => (super.noSuchMethod( Invocation.getter(#host), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#host), ), @@ -134,27 +153,27 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ) as bool); @override - _i6.Future closeAdapter() => (super.noSuchMethod( + _i8.Future closeAdapter() => (super.noSuchMethod( Invocation.method( #closeAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future checkElectrumAdapter() => (super.noSuchMethod( + _i8.Future checkElectrumAdapter() => (super.noSuchMethod( Invocation.method( #checkElectrumAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future request({ + _i8.Future request({ required String? command, List? args = const [], String? requestID, @@ -173,11 +192,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestTimeout: requestTimeout, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> batchRequest({ + _i8.Future> batchRequest({ required String? command, required List? args, Duration? requestTimeout = const Duration(seconds: 60), @@ -194,11 +213,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retries: retries, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future ping({ + _i8.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -211,11 +230,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i8.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -223,11 +242,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i8.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -235,11 +254,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future broadcastTransaction({ + _i8.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -252,7 +271,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(_i5.dummyValue( + returnValue: _i8.Future.value(_i7.dummyValue( this, Invocation.method( #broadcastTransaction, @@ -263,10 +282,10 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future); + ) as _i8.Future); @override - _i6.Future> getBalance({ + _i8.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -280,11 +299,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future>> getHistory({ + _i8.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -297,12 +316,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchHistory( + _i8.Future>>> getBatchHistory( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -310,12 +329,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future>> getUTXOs({ + _i8.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -328,12 +347,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i8.Future>>> getBatchUTXOs( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -341,12 +360,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -362,11 +381,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getLelantusAnonymitySet({ + _i8.Future> getLelantusAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -382,11 +401,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusMintData({ + _i8.Future getLelantusMintData({ dynamic mints, String? requestID, }) => @@ -399,11 +418,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> getLelantusUsedCoinSerials({ + _i8.Future> getLelantusUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -417,22 +436,22 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusLatestCoinId({String? requestID}) => + _i8.Future getLelantusLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLelantusLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getSparkAnonymitySet({ + _i8.Future> getSparkAnonymitySet({ String? coinGroupId = r'1', String? startBlockHash = r'', String? requestID, @@ -448,58 +467,33 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); - - @override - _i6.Future>> getSparkMintMetaData({ - String? requestID, - required List? sparkCoinHashes, - }) => - (super.noSuchMethod( - Invocation.method( - #getSparkMintMetaData, - [], - { - #requestID: requestID, - #sparkCoinHashes: sparkCoinHashes, - }, - ), - returnValue: _i6.Future>>.value( - >[]), - ) as _i6.Future>>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getSparkLatestCoinId({String? requestID}) => + _i8.Future getSparkLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getSparkLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getMempoolTxids({String? requestID}) => + _i8.Future> getMempoolTxids({String? requestID}) => (super.noSuchMethod( Invocation.method( #getMempoolTxids, [], {#requestID: requestID}, ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>> getMempoolSparkData({ + _i8.Future> getMempoolSparkData({ String? requestID, required List? txids, }) => @@ -512,30 +506,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #txids: txids, }, ), - returnValue: _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>.value(<({ - List coins, - List lTags, - List serialContext, - String txid - })>[]), - ) as _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>); - - @override - _i6.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ + returnValue: _i8.Future>.value( + <_i3.SparkMempoolData>[]), + ) as _i8.Future>); + + @override + _i8.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ String? requestID, required int? startNumber, }) => @@ -548,11 +524,62 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #startNumber: startNumber, }, ), - returnValue: _i6.Future>>.value(>[]), - ) as _i6.Future>>); + returnValue: _i8.Future>>.value(>[]), + ) as _i8.Future>>); + + @override + _i8.Future<_i3.SparkAnonymitySetMeta> getSparkAnonymitySetMeta({ + String? requestID, + required int? coinGroupId, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + returnValue: _i8.Future<_i3.SparkAnonymitySetMeta>.value( + _FakeSparkAnonymitySetMeta_2( + this, + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + )), + ) as _i8.Future<_i3.SparkAnonymitySetMeta>); + + @override + _i8.Future> getSparkAnonymitySetBySector({ + String? requestID, + required int? coinGroupId, + required String? latestBlock, + required int? startIndex, + required int? endIndex, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetBySector, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + #latestBlock: latestBlock, + #startIndex: startIndex, + #endIndex: endIndex, + }, + ), + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future isMasterNodeCollateral({ + _i8.Future isMasterNodeCollateral({ String? requestID, required String? txid, required int? index, @@ -567,11 +594,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #index: index, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i8.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -579,11 +606,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future<_i3.Decimal> estimateFee({ + _i8.Future<_i4.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -596,7 +623,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #blocks: blocks, }, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #estimateFee, @@ -607,16 +634,16 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); @override - _i6.Future<_i3.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i8.Future<_i4.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #relayFee, @@ -624,29 +651,29 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); } /// A class which mocks [CachedElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. class MockCachedElectrumXClient extends _i1.Mock - implements _i7.CachedElectrumXClient { + implements _i9.CachedElectrumXClient { MockCachedElectrumXClient() { _i1.throwOnMissingStub(this); } @override - _i4.ElectrumXClient get electrumXClient => (super.noSuchMethod( + _i5.ElectrumXClient get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumXClient_3( + returnValue: _FakeElectrumXClient_4( this, Invocation.getter(#electrumXClient), ), - ) as _i4.ElectrumXClient); + ) as _i5.ElectrumXClient); @override - _i6.Future> getAnonymitySet({ + _i8.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', required _i2.CryptoCurrency? cryptoCurrency, @@ -662,8 +689,8 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( @@ -671,7 +698,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToHex, @@ -686,7 +713,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToReverseHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToReverseHex, @@ -696,7 +723,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as String); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, @@ -712,11 +739,11 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getUsedCoinSerials({ + _i8.Future> getUsedCoinSerials({ required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => @@ -729,11 +756,11 @@ class MockCachedElectrumXClient extends _i1.Mock #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future clearSharedTransactionCache( + _i8.Future clearSharedTransactionCache( {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( @@ -741,16 +768,16 @@ class MockCachedElectrumXClient extends _i1.Mock [], {#cryptoCurrency: cryptoCurrency}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i10.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -758,7 +785,7 @@ class MockTransactionNotificationTracker extends _i1.Mock @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#walletId), ), @@ -786,14 +813,14 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( @@ -805,22 +832,22 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future deleteTransaction(String? txid) => (super.noSuchMethod( + _i8.Future deleteTransaction(String? txid) => (super.noSuchMethod( Invocation.method( #deleteTransaction, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart index c6eadd8f6..c853a3f37 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart @@ -3,15 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i8; -import 'package:decimal/decimal.dart' as _i3; +import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i5; -import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; +import 'package:mockito/src/dummies.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i5; +import 'package:stackwallet/models/electrumx_response/spark_models.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; + as _i10; +import 'package:stackwallet/utilities/tor_plain_net_option_enum.dart' as _i6; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -49,8 +51,9 @@ class _FakeDuration_1 extends _i1.SmartFake implements Duration { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { - _FakeDecimal_2( +class _FakeSparkAnonymitySetMeta_2 extends _i1.SmartFake + implements _i3.SparkAnonymitySetMeta { + _FakeSparkAnonymitySetMeta_2( Object parent, Invocation parentInvocation, ) : super( @@ -59,9 +62,19 @@ class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { ); } -class _FakeElectrumXClient_3 extends _i1.SmartFake - implements _i4.ElectrumXClient { - _FakeElectrumXClient_3( +class _FakeDecimal_3 extends _i1.SmartFake implements _i4.Decimal { + _FakeDecimal_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXClient_4 extends _i1.SmartFake + implements _i5.ElectrumXClient { + _FakeElectrumXClient_4( Object parent, Invocation parentInvocation, ) : super( @@ -73,7 +86,7 @@ class _FakeElectrumXClient_3 extends _i1.SmartFake /// A class which mocks [ElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { +class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { MockElectrumXClient() { _i1.throwOnMissingStub(this); } @@ -87,6 +100,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); + @override + _i6.TorPlainNetworkOption get netType => (super.noSuchMethod( + Invocation.getter(#netType), + returnValue: _i6.TorPlainNetworkOption.tor, + ) as _i6.TorPlainNetworkOption); + @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), @@ -115,7 +134,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { @override String get host => (super.noSuchMethod( Invocation.getter(#host), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#host), ), @@ -134,27 +153,27 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ) as bool); @override - _i6.Future closeAdapter() => (super.noSuchMethod( + _i8.Future closeAdapter() => (super.noSuchMethod( Invocation.method( #closeAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future checkElectrumAdapter() => (super.noSuchMethod( + _i8.Future checkElectrumAdapter() => (super.noSuchMethod( Invocation.method( #checkElectrumAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future request({ + _i8.Future request({ required String? command, List? args = const [], String? requestID, @@ -173,11 +192,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestTimeout: requestTimeout, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> batchRequest({ + _i8.Future> batchRequest({ required String? command, required List? args, Duration? requestTimeout = const Duration(seconds: 60), @@ -194,11 +213,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retries: retries, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future ping({ + _i8.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -211,11 +230,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i8.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -223,11 +242,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i8.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -235,11 +254,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future broadcastTransaction({ + _i8.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -252,7 +271,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(_i5.dummyValue( + returnValue: _i8.Future.value(_i7.dummyValue( this, Invocation.method( #broadcastTransaction, @@ -263,10 +282,10 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future); + ) as _i8.Future); @override - _i6.Future> getBalance({ + _i8.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -280,11 +299,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future>> getHistory({ + _i8.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -297,12 +316,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchHistory( + _i8.Future>>> getBatchHistory( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -310,12 +329,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future>> getUTXOs({ + _i8.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -328,12 +347,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i8.Future>>> getBatchUTXOs( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -341,12 +360,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -362,11 +381,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getLelantusAnonymitySet({ + _i8.Future> getLelantusAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -382,11 +401,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusMintData({ + _i8.Future getLelantusMintData({ dynamic mints, String? requestID, }) => @@ -399,11 +418,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> getLelantusUsedCoinSerials({ + _i8.Future> getLelantusUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -417,22 +436,22 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusLatestCoinId({String? requestID}) => + _i8.Future getLelantusLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLelantusLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getSparkAnonymitySet({ + _i8.Future> getSparkAnonymitySet({ String? coinGroupId = r'1', String? startBlockHash = r'', String? requestID, @@ -448,58 +467,33 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); - - @override - _i6.Future>> getSparkMintMetaData({ - String? requestID, - required List? sparkCoinHashes, - }) => - (super.noSuchMethod( - Invocation.method( - #getSparkMintMetaData, - [], - { - #requestID: requestID, - #sparkCoinHashes: sparkCoinHashes, - }, - ), - returnValue: _i6.Future>>.value( - >[]), - ) as _i6.Future>>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getSparkLatestCoinId({String? requestID}) => + _i8.Future getSparkLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getSparkLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getMempoolTxids({String? requestID}) => + _i8.Future> getMempoolTxids({String? requestID}) => (super.noSuchMethod( Invocation.method( #getMempoolTxids, [], {#requestID: requestID}, ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>> getMempoolSparkData({ + _i8.Future> getMempoolSparkData({ String? requestID, required List? txids, }) => @@ -512,30 +506,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #txids: txids, }, ), - returnValue: _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>.value(<({ - List coins, - List lTags, - List serialContext, - String txid - })>[]), - ) as _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>); - - @override - _i6.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ + returnValue: _i8.Future>.value( + <_i3.SparkMempoolData>[]), + ) as _i8.Future>); + + @override + _i8.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ String? requestID, required int? startNumber, }) => @@ -548,11 +524,62 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #startNumber: startNumber, }, ), - returnValue: _i6.Future>>.value(>[]), - ) as _i6.Future>>); + returnValue: _i8.Future>>.value(>[]), + ) as _i8.Future>>); + + @override + _i8.Future<_i3.SparkAnonymitySetMeta> getSparkAnonymitySetMeta({ + String? requestID, + required int? coinGroupId, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + returnValue: _i8.Future<_i3.SparkAnonymitySetMeta>.value( + _FakeSparkAnonymitySetMeta_2( + this, + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + )), + ) as _i8.Future<_i3.SparkAnonymitySetMeta>); + + @override + _i8.Future> getSparkAnonymitySetBySector({ + String? requestID, + required int? coinGroupId, + required String? latestBlock, + required int? startIndex, + required int? endIndex, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetBySector, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + #latestBlock: latestBlock, + #startIndex: startIndex, + #endIndex: endIndex, + }, + ), + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future isMasterNodeCollateral({ + _i8.Future isMasterNodeCollateral({ String? requestID, required String? txid, required int? index, @@ -567,11 +594,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #index: index, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i8.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -579,11 +606,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future<_i3.Decimal> estimateFee({ + _i8.Future<_i4.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -596,7 +623,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #blocks: blocks, }, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #estimateFee, @@ -607,16 +634,16 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); @override - _i6.Future<_i3.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i8.Future<_i4.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #relayFee, @@ -624,29 +651,29 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); } /// A class which mocks [CachedElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. class MockCachedElectrumXClient extends _i1.Mock - implements _i7.CachedElectrumXClient { + implements _i9.CachedElectrumXClient { MockCachedElectrumXClient() { _i1.throwOnMissingStub(this); } @override - _i4.ElectrumXClient get electrumXClient => (super.noSuchMethod( + _i5.ElectrumXClient get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumXClient_3( + returnValue: _FakeElectrumXClient_4( this, Invocation.getter(#electrumXClient), ), - ) as _i4.ElectrumXClient); + ) as _i5.ElectrumXClient); @override - _i6.Future> getAnonymitySet({ + _i8.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', required _i2.CryptoCurrency? cryptoCurrency, @@ -662,8 +689,8 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( @@ -671,7 +698,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToHex, @@ -686,7 +713,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToReverseHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToReverseHex, @@ -696,7 +723,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as String); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, @@ -712,11 +739,11 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getUsedCoinSerials({ + _i8.Future> getUsedCoinSerials({ required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => @@ -729,11 +756,11 @@ class MockCachedElectrumXClient extends _i1.Mock #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future clearSharedTransactionCache( + _i8.Future clearSharedTransactionCache( {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( @@ -741,16 +768,16 @@ class MockCachedElectrumXClient extends _i1.Mock [], {#cryptoCurrency: cryptoCurrency}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i10.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -758,7 +785,7 @@ class MockTransactionNotificationTracker extends _i1.Mock @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#walletId), ), @@ -786,14 +813,14 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( @@ -805,22 +832,22 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future deleteTransaction(String? txid) => (super.noSuchMethod( + _i8.Future deleteTransaction(String? txid) => (super.noSuchMethod( Invocation.method( #deleteTransaction, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart index 344647a50..08f884b57 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart @@ -3,15 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i8; -import 'package:decimal/decimal.dart' as _i3; +import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i5; -import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; +import 'package:mockito/src/dummies.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i5; +import 'package:stackwallet/models/electrumx_response/spark_models.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; + as _i10; +import 'package:stackwallet/utilities/tor_plain_net_option_enum.dart' as _i6; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -49,8 +51,9 @@ class _FakeDuration_1 extends _i1.SmartFake implements Duration { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { - _FakeDecimal_2( +class _FakeSparkAnonymitySetMeta_2 extends _i1.SmartFake + implements _i3.SparkAnonymitySetMeta { + _FakeSparkAnonymitySetMeta_2( Object parent, Invocation parentInvocation, ) : super( @@ -59,9 +62,19 @@ class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { ); } -class _FakeElectrumXClient_3 extends _i1.SmartFake - implements _i4.ElectrumXClient { - _FakeElectrumXClient_3( +class _FakeDecimal_3 extends _i1.SmartFake implements _i4.Decimal { + _FakeDecimal_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXClient_4 extends _i1.SmartFake + implements _i5.ElectrumXClient { + _FakeElectrumXClient_4( Object parent, Invocation parentInvocation, ) : super( @@ -73,7 +86,7 @@ class _FakeElectrumXClient_3 extends _i1.SmartFake /// A class which mocks [ElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { +class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { MockElectrumXClient() { _i1.throwOnMissingStub(this); } @@ -87,6 +100,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); + @override + _i6.TorPlainNetworkOption get netType => (super.noSuchMethod( + Invocation.getter(#netType), + returnValue: _i6.TorPlainNetworkOption.tor, + ) as _i6.TorPlainNetworkOption); + @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), @@ -115,7 +134,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { @override String get host => (super.noSuchMethod( Invocation.getter(#host), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#host), ), @@ -134,27 +153,27 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ) as bool); @override - _i6.Future closeAdapter() => (super.noSuchMethod( + _i8.Future closeAdapter() => (super.noSuchMethod( Invocation.method( #closeAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future checkElectrumAdapter() => (super.noSuchMethod( + _i8.Future checkElectrumAdapter() => (super.noSuchMethod( Invocation.method( #checkElectrumAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future request({ + _i8.Future request({ required String? command, List? args = const [], String? requestID, @@ -173,11 +192,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestTimeout: requestTimeout, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> batchRequest({ + _i8.Future> batchRequest({ required String? command, required List? args, Duration? requestTimeout = const Duration(seconds: 60), @@ -194,11 +213,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retries: retries, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future ping({ + _i8.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -211,11 +230,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i8.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -223,11 +242,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i8.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -235,11 +254,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future broadcastTransaction({ + _i8.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -252,7 +271,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(_i5.dummyValue( + returnValue: _i8.Future.value(_i7.dummyValue( this, Invocation.method( #broadcastTransaction, @@ -263,10 +282,10 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future); + ) as _i8.Future); @override - _i6.Future> getBalance({ + _i8.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -280,11 +299,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future>> getHistory({ + _i8.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -297,12 +316,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchHistory( + _i8.Future>>> getBatchHistory( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -310,12 +329,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future>> getUTXOs({ + _i8.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -328,12 +347,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i8.Future>>> getBatchUTXOs( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -341,12 +360,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -362,11 +381,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getLelantusAnonymitySet({ + _i8.Future> getLelantusAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -382,11 +401,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusMintData({ + _i8.Future getLelantusMintData({ dynamic mints, String? requestID, }) => @@ -399,11 +418,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> getLelantusUsedCoinSerials({ + _i8.Future> getLelantusUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -417,22 +436,22 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusLatestCoinId({String? requestID}) => + _i8.Future getLelantusLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLelantusLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getSparkAnonymitySet({ + _i8.Future> getSparkAnonymitySet({ String? coinGroupId = r'1', String? startBlockHash = r'', String? requestID, @@ -448,58 +467,33 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); - - @override - _i6.Future>> getSparkMintMetaData({ - String? requestID, - required List? sparkCoinHashes, - }) => - (super.noSuchMethod( - Invocation.method( - #getSparkMintMetaData, - [], - { - #requestID: requestID, - #sparkCoinHashes: sparkCoinHashes, - }, - ), - returnValue: _i6.Future>>.value( - >[]), - ) as _i6.Future>>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getSparkLatestCoinId({String? requestID}) => + _i8.Future getSparkLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getSparkLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getMempoolTxids({String? requestID}) => + _i8.Future> getMempoolTxids({String? requestID}) => (super.noSuchMethod( Invocation.method( #getMempoolTxids, [], {#requestID: requestID}, ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>> getMempoolSparkData({ + _i8.Future> getMempoolSparkData({ String? requestID, required List? txids, }) => @@ -512,30 +506,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #txids: txids, }, ), - returnValue: _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>.value(<({ - List coins, - List lTags, - List serialContext, - String txid - })>[]), - ) as _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>); - - @override - _i6.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ + returnValue: _i8.Future>.value( + <_i3.SparkMempoolData>[]), + ) as _i8.Future>); + + @override + _i8.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ String? requestID, required int? startNumber, }) => @@ -548,11 +524,62 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #startNumber: startNumber, }, ), - returnValue: _i6.Future>>.value(>[]), - ) as _i6.Future>>); + returnValue: _i8.Future>>.value(>[]), + ) as _i8.Future>>); + + @override + _i8.Future<_i3.SparkAnonymitySetMeta> getSparkAnonymitySetMeta({ + String? requestID, + required int? coinGroupId, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + returnValue: _i8.Future<_i3.SparkAnonymitySetMeta>.value( + _FakeSparkAnonymitySetMeta_2( + this, + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + )), + ) as _i8.Future<_i3.SparkAnonymitySetMeta>); + + @override + _i8.Future> getSparkAnonymitySetBySector({ + String? requestID, + required int? coinGroupId, + required String? latestBlock, + required int? startIndex, + required int? endIndex, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetBySector, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + #latestBlock: latestBlock, + #startIndex: startIndex, + #endIndex: endIndex, + }, + ), + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future isMasterNodeCollateral({ + _i8.Future isMasterNodeCollateral({ String? requestID, required String? txid, required int? index, @@ -567,11 +594,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #index: index, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i8.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -579,11 +606,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future<_i3.Decimal> estimateFee({ + _i8.Future<_i4.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -596,7 +623,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #blocks: blocks, }, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #estimateFee, @@ -607,16 +634,16 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); @override - _i6.Future<_i3.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i8.Future<_i4.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #relayFee, @@ -624,29 +651,29 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); } /// A class which mocks [CachedElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. class MockCachedElectrumXClient extends _i1.Mock - implements _i7.CachedElectrumXClient { + implements _i9.CachedElectrumXClient { MockCachedElectrumXClient() { _i1.throwOnMissingStub(this); } @override - _i4.ElectrumXClient get electrumXClient => (super.noSuchMethod( + _i5.ElectrumXClient get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumXClient_3( + returnValue: _FakeElectrumXClient_4( this, Invocation.getter(#electrumXClient), ), - ) as _i4.ElectrumXClient); + ) as _i5.ElectrumXClient); @override - _i6.Future> getAnonymitySet({ + _i8.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', required _i2.CryptoCurrency? cryptoCurrency, @@ -662,8 +689,8 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( @@ -671,7 +698,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToHex, @@ -686,7 +713,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToReverseHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToReverseHex, @@ -696,7 +723,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as String); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, @@ -712,11 +739,11 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getUsedCoinSerials({ + _i8.Future> getUsedCoinSerials({ required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => @@ -729,11 +756,11 @@ class MockCachedElectrumXClient extends _i1.Mock #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future clearSharedTransactionCache( + _i8.Future clearSharedTransactionCache( {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( @@ -741,16 +768,16 @@ class MockCachedElectrumXClient extends _i1.Mock [], {#cryptoCurrency: cryptoCurrency}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i10.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -758,7 +785,7 @@ class MockTransactionNotificationTracker extends _i1.Mock @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#walletId), ), @@ -786,14 +813,14 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( @@ -805,22 +832,22 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future deleteTransaction(String? txid) => (super.noSuchMethod( + _i8.Future deleteTransaction(String? txid) => (super.noSuchMethod( Invocation.method( #deleteTransaction, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } diff --git a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart index 851a2855c..cd27b6654 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart @@ -3,15 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i8; -import 'package:decimal/decimal.dart' as _i3; +import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i5; -import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; +import 'package:mockito/src/dummies.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i5; +import 'package:stackwallet/models/electrumx_response/spark_models.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; + as _i10; +import 'package:stackwallet/utilities/tor_plain_net_option_enum.dart' as _i6; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -49,8 +51,9 @@ class _FakeDuration_1 extends _i1.SmartFake implements Duration { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { - _FakeDecimal_2( +class _FakeSparkAnonymitySetMeta_2 extends _i1.SmartFake + implements _i3.SparkAnonymitySetMeta { + _FakeSparkAnonymitySetMeta_2( Object parent, Invocation parentInvocation, ) : super( @@ -59,9 +62,19 @@ class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { ); } -class _FakeElectrumXClient_3 extends _i1.SmartFake - implements _i4.ElectrumXClient { - _FakeElectrumXClient_3( +class _FakeDecimal_3 extends _i1.SmartFake implements _i4.Decimal { + _FakeDecimal_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXClient_4 extends _i1.SmartFake + implements _i5.ElectrumXClient { + _FakeElectrumXClient_4( Object parent, Invocation parentInvocation, ) : super( @@ -73,7 +86,7 @@ class _FakeElectrumXClient_3 extends _i1.SmartFake /// A class which mocks [ElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { +class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { MockElectrumXClient() { _i1.throwOnMissingStub(this); } @@ -87,6 +100,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); + @override + _i6.TorPlainNetworkOption get netType => (super.noSuchMethod( + Invocation.getter(#netType), + returnValue: _i6.TorPlainNetworkOption.tor, + ) as _i6.TorPlainNetworkOption); + @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), @@ -115,7 +134,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { @override String get host => (super.noSuchMethod( Invocation.getter(#host), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#host), ), @@ -134,27 +153,27 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ) as bool); @override - _i6.Future closeAdapter() => (super.noSuchMethod( + _i8.Future closeAdapter() => (super.noSuchMethod( Invocation.method( #closeAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future checkElectrumAdapter() => (super.noSuchMethod( + _i8.Future checkElectrumAdapter() => (super.noSuchMethod( Invocation.method( #checkElectrumAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future request({ + _i8.Future request({ required String? command, List? args = const [], String? requestID, @@ -173,11 +192,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestTimeout: requestTimeout, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> batchRequest({ + _i8.Future> batchRequest({ required String? command, required List? args, Duration? requestTimeout = const Duration(seconds: 60), @@ -194,11 +213,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retries: retries, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future ping({ + _i8.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -211,11 +230,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i8.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -223,11 +242,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i8.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -235,11 +254,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future broadcastTransaction({ + _i8.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -252,7 +271,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(_i5.dummyValue( + returnValue: _i8.Future.value(_i7.dummyValue( this, Invocation.method( #broadcastTransaction, @@ -263,10 +282,10 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future); + ) as _i8.Future); @override - _i6.Future> getBalance({ + _i8.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -280,11 +299,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future>> getHistory({ + _i8.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -297,12 +316,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchHistory( + _i8.Future>>> getBatchHistory( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -310,12 +329,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future>> getUTXOs({ + _i8.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -328,12 +347,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i8.Future>>> getBatchUTXOs( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -341,12 +360,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -362,11 +381,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getLelantusAnonymitySet({ + _i8.Future> getLelantusAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -382,11 +401,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusMintData({ + _i8.Future getLelantusMintData({ dynamic mints, String? requestID, }) => @@ -399,11 +418,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> getLelantusUsedCoinSerials({ + _i8.Future> getLelantusUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -417,22 +436,22 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusLatestCoinId({String? requestID}) => + _i8.Future getLelantusLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLelantusLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getSparkAnonymitySet({ + _i8.Future> getSparkAnonymitySet({ String? coinGroupId = r'1', String? startBlockHash = r'', String? requestID, @@ -448,58 +467,33 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); - - @override - _i6.Future>> getSparkMintMetaData({ - String? requestID, - required List? sparkCoinHashes, - }) => - (super.noSuchMethod( - Invocation.method( - #getSparkMintMetaData, - [], - { - #requestID: requestID, - #sparkCoinHashes: sparkCoinHashes, - }, - ), - returnValue: _i6.Future>>.value( - >[]), - ) as _i6.Future>>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getSparkLatestCoinId({String? requestID}) => + _i8.Future getSparkLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getSparkLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getMempoolTxids({String? requestID}) => + _i8.Future> getMempoolTxids({String? requestID}) => (super.noSuchMethod( Invocation.method( #getMempoolTxids, [], {#requestID: requestID}, ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>> getMempoolSparkData({ + _i8.Future> getMempoolSparkData({ String? requestID, required List? txids, }) => @@ -512,30 +506,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #txids: txids, }, ), - returnValue: _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>.value(<({ - List coins, - List lTags, - List serialContext, - String txid - })>[]), - ) as _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>); - - @override - _i6.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ + returnValue: _i8.Future>.value( + <_i3.SparkMempoolData>[]), + ) as _i8.Future>); + + @override + _i8.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ String? requestID, required int? startNumber, }) => @@ -548,11 +524,62 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #startNumber: startNumber, }, ), - returnValue: _i6.Future>>.value(>[]), - ) as _i6.Future>>); + returnValue: _i8.Future>>.value(>[]), + ) as _i8.Future>>); + + @override + _i8.Future<_i3.SparkAnonymitySetMeta> getSparkAnonymitySetMeta({ + String? requestID, + required int? coinGroupId, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + returnValue: _i8.Future<_i3.SparkAnonymitySetMeta>.value( + _FakeSparkAnonymitySetMeta_2( + this, + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + )), + ) as _i8.Future<_i3.SparkAnonymitySetMeta>); + + @override + _i8.Future> getSparkAnonymitySetBySector({ + String? requestID, + required int? coinGroupId, + required String? latestBlock, + required int? startIndex, + required int? endIndex, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetBySector, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + #latestBlock: latestBlock, + #startIndex: startIndex, + #endIndex: endIndex, + }, + ), + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future isMasterNodeCollateral({ + _i8.Future isMasterNodeCollateral({ String? requestID, required String? txid, required int? index, @@ -567,11 +594,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #index: index, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i8.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -579,11 +606,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future<_i3.Decimal> estimateFee({ + _i8.Future<_i4.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -596,7 +623,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #blocks: blocks, }, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #estimateFee, @@ -607,16 +634,16 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); @override - _i6.Future<_i3.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i8.Future<_i4.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #relayFee, @@ -624,29 +651,29 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); } /// A class which mocks [CachedElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. class MockCachedElectrumXClient extends _i1.Mock - implements _i7.CachedElectrumXClient { + implements _i9.CachedElectrumXClient { MockCachedElectrumXClient() { _i1.throwOnMissingStub(this); } @override - _i4.ElectrumXClient get electrumXClient => (super.noSuchMethod( + _i5.ElectrumXClient get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumXClient_3( + returnValue: _FakeElectrumXClient_4( this, Invocation.getter(#electrumXClient), ), - ) as _i4.ElectrumXClient); + ) as _i5.ElectrumXClient); @override - _i6.Future> getAnonymitySet({ + _i8.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', required _i2.CryptoCurrency? cryptoCurrency, @@ -662,8 +689,8 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( @@ -671,7 +698,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToHex, @@ -686,7 +713,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToReverseHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToReverseHex, @@ -696,7 +723,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as String); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, @@ -712,11 +739,11 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getUsedCoinSerials({ + _i8.Future> getUsedCoinSerials({ required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => @@ -729,11 +756,11 @@ class MockCachedElectrumXClient extends _i1.Mock #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future clearSharedTransactionCache( + _i8.Future clearSharedTransactionCache( {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( @@ -741,16 +768,16 @@ class MockCachedElectrumXClient extends _i1.Mock [], {#cryptoCurrency: cryptoCurrency}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i10.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -758,7 +785,7 @@ class MockTransactionNotificationTracker extends _i1.Mock @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#walletId), ), @@ -786,14 +813,14 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( @@ -805,22 +832,22 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future deleteTransaction(String? txid) => (super.noSuchMethod( + _i8.Future deleteTransaction(String? txid) => (super.noSuchMethod( Invocation.method( #deleteTransaction, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } diff --git a/test/services/coins/particl/particl_wallet_test.mocks.dart b/test/services/coins/particl/particl_wallet_test.mocks.dart index ccd74b4d7..1360bd6db 100644 --- a/test/services/coins/particl/particl_wallet_test.mocks.dart +++ b/test/services/coins/particl/particl_wallet_test.mocks.dart @@ -3,15 +3,17 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i6; +import 'dart:async' as _i8; -import 'package:decimal/decimal.dart' as _i3; +import 'package:decimal/decimal.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i5; -import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i7; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; +import 'package:mockito/src/dummies.dart' as _i7; +import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i9; +import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i5; +import 'package:stackwallet/models/electrumx_response/spark_models.dart' as _i3; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; + as _i10; +import 'package:stackwallet/utilities/tor_plain_net_option_enum.dart' as _i6; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -49,8 +51,9 @@ class _FakeDuration_1 extends _i1.SmartFake implements Duration { ); } -class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { - _FakeDecimal_2( +class _FakeSparkAnonymitySetMeta_2 extends _i1.SmartFake + implements _i3.SparkAnonymitySetMeta { + _FakeSparkAnonymitySetMeta_2( Object parent, Invocation parentInvocation, ) : super( @@ -59,9 +62,19 @@ class _FakeDecimal_2 extends _i1.SmartFake implements _i3.Decimal { ); } -class _FakeElectrumXClient_3 extends _i1.SmartFake - implements _i4.ElectrumXClient { - _FakeElectrumXClient_3( +class _FakeDecimal_3 extends _i1.SmartFake implements _i4.Decimal { + _FakeDecimal_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +class _FakeElectrumXClient_4 extends _i1.SmartFake + implements _i5.ElectrumXClient { + _FakeElectrumXClient_4( Object parent, Invocation parentInvocation, ) : super( @@ -73,7 +86,7 @@ class _FakeElectrumXClient_3 extends _i1.SmartFake /// A class which mocks [ElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { +class MockElectrumXClient extends _i1.Mock implements _i5.ElectrumXClient { MockElectrumXClient() { _i1.throwOnMissingStub(this); } @@ -87,6 +100,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ), ) as _i2.CryptoCurrency); + @override + _i6.TorPlainNetworkOption get netType => (super.noSuchMethod( + Invocation.getter(#netType), + returnValue: _i6.TorPlainNetworkOption.tor, + ) as _i6.TorPlainNetworkOption); + @override int get currentFailoverIndex => (super.noSuchMethod( Invocation.getter(#currentFailoverIndex), @@ -115,7 +134,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { @override String get host => (super.noSuchMethod( Invocation.getter(#host), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#host), ), @@ -134,27 +153,27 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { ) as bool); @override - _i6.Future closeAdapter() => (super.noSuchMethod( + _i8.Future closeAdapter() => (super.noSuchMethod( Invocation.method( #closeAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future checkElectrumAdapter() => (super.noSuchMethod( + _i8.Future checkElectrumAdapter() => (super.noSuchMethod( Invocation.method( #checkElectrumAdapter, [], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future request({ + _i8.Future request({ required String? command, List? args = const [], String? requestID, @@ -173,11 +192,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestTimeout: requestTimeout, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> batchRequest({ + _i8.Future> batchRequest({ required String? command, required List? args, Duration? requestTimeout = const Duration(seconds: 60), @@ -194,11 +213,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retries: retries, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future ping({ + _i8.Future ping({ String? requestID, int? retryCount = 1, }) => @@ -211,11 +230,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #retryCount: retryCount, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getBlockHeadTip({String? requestID}) => + _i8.Future> getBlockHeadTip({String? requestID}) => (super.noSuchMethod( Invocation.method( #getBlockHeadTip, @@ -223,11 +242,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getServerFeatures({String? requestID}) => + _i8.Future> getServerFeatures({String? requestID}) => (super.noSuchMethod( Invocation.method( #getServerFeatures, @@ -235,11 +254,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future broadcastTransaction({ + _i8.Future broadcastTransaction({ required String? rawTx, String? requestID, }) => @@ -252,7 +271,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(_i5.dummyValue( + returnValue: _i8.Future.value(_i7.dummyValue( this, Invocation.method( #broadcastTransaction, @@ -263,10 +282,10 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future); + ) as _i8.Future); @override - _i6.Future> getBalance({ + _i8.Future> getBalance({ required String? scripthash, String? requestID, }) => @@ -280,11 +299,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future>> getHistory({ + _i8.Future>> getHistory({ required String? scripthash, String? requestID, }) => @@ -297,12 +316,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchHistory( + _i8.Future>>> getBatchHistory( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -310,12 +329,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future>> getUTXOs({ + _i8.Future>> getUTXOs({ required String? scripthash, String? requestID, }) => @@ -328,12 +347,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future>>.value( + returnValue: _i8.Future>>.value( >[]), - ) as _i6.Future>>); + ) as _i8.Future>>); @override - _i6.Future>>> getBatchUTXOs( + _i8.Future>>> getBatchUTXOs( {required List? args}) => (super.noSuchMethod( Invocation.method( @@ -341,12 +360,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { [], {#args: args}, ), - returnValue: _i6.Future>>>.value( + returnValue: _i8.Future>>>.value( >>[]), - ) as _i6.Future>>>); + ) as _i8.Future>>>); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, bool? verbose = true, String? requestID, @@ -362,11 +381,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getLelantusAnonymitySet({ + _i8.Future> getLelantusAnonymitySet({ String? groupId = r'1', String? blockhash = r'', String? requestID, @@ -382,11 +401,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusMintData({ + _i8.Future getLelantusMintData({ dynamic mints, String? requestID, }) => @@ -399,11 +418,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #requestID: requestID, }, ), - returnValue: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future> getLelantusUsedCoinSerials({ + _i8.Future> getLelantusUsedCoinSerials({ String? requestID, required int? startNumber, }) => @@ -417,22 +436,22 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getLelantusLatestCoinId({String? requestID}) => + _i8.Future getLelantusLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getLelantusLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getSparkAnonymitySet({ + _i8.Future> getSparkAnonymitySet({ String? coinGroupId = r'1', String? startBlockHash = r'', String? requestID, @@ -448,58 +467,33 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); - - @override - _i6.Future>> getSparkMintMetaData({ - String? requestID, - required List? sparkCoinHashes, - }) => - (super.noSuchMethod( - Invocation.method( - #getSparkMintMetaData, - [], - { - #requestID: requestID, - #sparkCoinHashes: sparkCoinHashes, - }, - ), - returnValue: _i6.Future>>.value( - >[]), - ) as _i6.Future>>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future getSparkLatestCoinId({String? requestID}) => + _i8.Future getSparkLatestCoinId({String? requestID}) => (super.noSuchMethod( Invocation.method( #getSparkLatestCoinId, [], {#requestID: requestID}, ), - returnValue: _i6.Future.value(0), - ) as _i6.Future); + returnValue: _i8.Future.value(0), + ) as _i8.Future); @override - _i6.Future> getMempoolTxids({String? requestID}) => + _i8.Future> getMempoolTxids({String? requestID}) => (super.noSuchMethod( Invocation.method( #getMempoolTxids, [], {#requestID: requestID}, ), - returnValue: _i6.Future>.value({}), - ) as _i6.Future>); + returnValue: _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>> getMempoolSparkData({ + _i8.Future> getMempoolSparkData({ String? requestID, required List? txids, }) => @@ -512,30 +506,12 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #txids: txids, }, ), - returnValue: _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>.value(<({ - List coins, - List lTags, - List serialContext, - String txid - })>[]), - ) as _i6.Future< - List< - ({ - List coins, - List lTags, - List serialContext, - String txid - })>>); - - @override - _i6.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ + returnValue: _i8.Future>.value( + <_i3.SparkMempoolData>[]), + ) as _i8.Future>); + + @override + _i8.Future>> getSparkUnhashedUsedCoinsTagsWithTxHashes({ String? requestID, required int? startNumber, }) => @@ -548,11 +524,62 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #startNumber: startNumber, }, ), - returnValue: _i6.Future>>.value(>[]), - ) as _i6.Future>>); + returnValue: _i8.Future>>.value(>[]), + ) as _i8.Future>>); + + @override + _i8.Future<_i3.SparkAnonymitySetMeta> getSparkAnonymitySetMeta({ + String? requestID, + required int? coinGroupId, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + returnValue: _i8.Future<_i3.SparkAnonymitySetMeta>.value( + _FakeSparkAnonymitySetMeta_2( + this, + Invocation.method( + #getSparkAnonymitySetMeta, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + }, + ), + )), + ) as _i8.Future<_i3.SparkAnonymitySetMeta>); + + @override + _i8.Future> getSparkAnonymitySetBySector({ + String? requestID, + required int? coinGroupId, + required String? latestBlock, + required int? startIndex, + required int? endIndex, + }) => + (super.noSuchMethod( + Invocation.method( + #getSparkAnonymitySetBySector, + [], + { + #requestID: requestID, + #coinGroupId: coinGroupId, + #latestBlock: latestBlock, + #startIndex: startIndex, + #endIndex: endIndex, + }, + ), + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future isMasterNodeCollateral({ + _i8.Future isMasterNodeCollateral({ String? requestID, required String? txid, required int? index, @@ -567,11 +594,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #index: index, }, ), - returnValue: _i6.Future.value(false), - ) as _i6.Future); + returnValue: _i8.Future.value(false), + ) as _i8.Future); @override - _i6.Future> getFeeRate({String? requestID}) => + _i8.Future> getFeeRate({String? requestID}) => (super.noSuchMethod( Invocation.method( #getFeeRate, @@ -579,11 +606,11 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future<_i3.Decimal> estimateFee({ + _i8.Future<_i4.Decimal> estimateFee({ String? requestID, required int? blocks, }) => @@ -596,7 +623,7 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { #blocks: blocks, }, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #estimateFee, @@ -607,16 +634,16 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { }, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); @override - _i6.Future<_i3.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( + _i8.Future<_i4.Decimal> relayFee({String? requestID}) => (super.noSuchMethod( Invocation.method( #relayFee, [], {#requestID: requestID}, ), - returnValue: _i6.Future<_i3.Decimal>.value(_FakeDecimal_2( + returnValue: _i8.Future<_i4.Decimal>.value(_FakeDecimal_3( this, Invocation.method( #relayFee, @@ -624,29 +651,29 @@ class MockElectrumXClient extends _i1.Mock implements _i4.ElectrumXClient { {#requestID: requestID}, ), )), - ) as _i6.Future<_i3.Decimal>); + ) as _i8.Future<_i4.Decimal>); } /// A class which mocks [CachedElectrumXClient]. /// /// See the documentation for Mockito's code generation for more information. class MockCachedElectrumXClient extends _i1.Mock - implements _i7.CachedElectrumXClient { + implements _i9.CachedElectrumXClient { MockCachedElectrumXClient() { _i1.throwOnMissingStub(this); } @override - _i4.ElectrumXClient get electrumXClient => (super.noSuchMethod( + _i5.ElectrumXClient get electrumXClient => (super.noSuchMethod( Invocation.getter(#electrumXClient), - returnValue: _FakeElectrumXClient_3( + returnValue: _FakeElectrumXClient_4( this, Invocation.getter(#electrumXClient), ), - ) as _i4.ElectrumXClient); + ) as _i5.ElectrumXClient); @override - _i6.Future> getAnonymitySet({ + _i8.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', required _i2.CryptoCurrency? cryptoCurrency, @@ -662,8 +689,8 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override String base64ToHex(String? source) => (super.noSuchMethod( @@ -671,7 +698,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToHex, @@ -686,7 +713,7 @@ class MockCachedElectrumXClient extends _i1.Mock #base64ToReverseHex, [source], ), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.method( #base64ToReverseHex, @@ -696,7 +723,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as String); @override - _i6.Future> getTransaction({ + _i8.Future> getTransaction({ required String? txHash, required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, @@ -712,11 +739,11 @@ class MockCachedElectrumXClient extends _i1.Mock }, ), returnValue: - _i6.Future>.value({}), - ) as _i6.Future>); + _i8.Future>.value({}), + ) as _i8.Future>); @override - _i6.Future> getUsedCoinSerials({ + _i8.Future> getUsedCoinSerials({ required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => @@ -729,11 +756,11 @@ class MockCachedElectrumXClient extends _i1.Mock #startNumber: startNumber, }, ), - returnValue: _i6.Future>.value([]), - ) as _i6.Future>); + returnValue: _i8.Future>.value([]), + ) as _i8.Future>); @override - _i6.Future clearSharedTransactionCache( + _i8.Future clearSharedTransactionCache( {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( @@ -741,16 +768,16 @@ class MockCachedElectrumXClient extends _i1.Mock [], {#cryptoCurrency: cryptoCurrency}, ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); } /// A class which mocks [TransactionNotificationTracker]. /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i10.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } @@ -758,7 +785,7 @@ class MockTransactionNotificationTracker extends _i1.Mock @override String get walletId => (super.noSuchMethod( Invocation.getter(#walletId), - returnValue: _i5.dummyValue( + returnValue: _i7.dummyValue( this, Invocation.getter(#walletId), ), @@ -786,14 +813,14 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedPending(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedPending(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedPending, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override bool wasNotifiedConfirmed(String? txid) => (super.noSuchMethod( @@ -805,22 +832,22 @@ class MockTransactionNotificationTracker extends _i1.Mock ) as bool); @override - _i6.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( + _i8.Future addNotifiedConfirmed(String? txid) => (super.noSuchMethod( Invocation.method( #addNotifiedConfirmed, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i6.Future deleteTransaction(String? txid) => (super.noSuchMethod( + _i8.Future deleteTransaction(String? txid) => (super.noSuchMethod( Invocation.method( #deleteTransaction, [txid], ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); }