diff --git a/lib/electrumx_rpc/cached_electrumx.dart b/lib/electrumx_rpc/cached_electrumx.dart index 2aab533f8..66e32238c 100644 --- a/lib/electrumx_rpc/cached_electrumx.dart +++ b/lib/electrumx_rpc/cached_electrumx.dart @@ -4,43 +4,23 @@ import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; import 'package:string_validator/string_validator.dart'; class CachedElectrumX { - final ElectrumX? electrumXClient; - - final String server; - final int port; - final bool useSSL; - - final Prefs prefs; - final List failovers; + final ElectrumX electrumXClient; static const minCacheConfirms = 30; const CachedElectrumX({ - required this.server, - required this.port, - required this.useSSL, - required this.prefs, - required this.failovers, - this.electrumXClient, + required this.electrumXClient, }); factory CachedElectrumX.from({ - required ElectrumXNode node, - required Prefs prefs, - required List failovers, - ElectrumX? electrumXClient, + required ElectrumX electrumXClient, }) => CachedElectrumX( - server: node.address, - port: node.port, - useSSL: node.useSSL, - prefs: prefs, - failovers: failovers, - electrumXClient: electrumXClient); + electrumXClient: electrumXClient, + ); Future> getAnonymitySet({ required String groupId, @@ -66,16 +46,7 @@ class CachedElectrumX { set = Map.from(cachedSet); } - final client = electrumXClient ?? - ElectrumX( - host: server, - port: port, - useSSL: useSSL, - prefs: prefs, - failovers: failovers, - ); - - final newSet = await client.getAnonymitySet( + final newSet = await electrumXClient.getAnonymitySet( groupId: groupId, blockhash: set["blockHash"] as String, ); @@ -152,16 +123,8 @@ class CachedElectrumX { final cachedTx = DB.instance.get( boxName: DB.instance.boxNameTxCache(coin: coin), key: txHash) as Map?; if (cachedTx == null) { - final client = electrumXClient ?? - ElectrumX( - host: server, - port: port, - useSSL: useSSL, - prefs: prefs, - failovers: failovers, - ); - final Map result = - await client.getTransaction(txHash: txHash, verbose: verbose); + final Map result = await electrumXClient + .getTransaction(txHash: txHash, verbose: verbose); result.remove("hex"); result.remove("lelantusData"); @@ -202,16 +165,8 @@ class CachedElectrumX { final startNumber = cachedSerials.length; - final client = electrumXClient ?? - ElectrumX( - host: server, - port: port, - useSSL: useSSL, - prefs: prefs, - failovers: failovers, - ); - - final serials = await client.getUsedCoinSerials(startNumber: startNumber); + final serials = + await electrumXClient.getUsedCoinSerials(startNumber: startNumber); List newSerials = []; for (final element in (serials["serials"] as List)) {