diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index f96c1b54a..b52614ed8 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -140,7 +140,7 @@ class BitcoinCashWallet extends CoinServiceAPI coin: coin, db: db, generateAddressForChain: _generateAddressForChain, - cachedElectrumX: cachedElectrumXClient, + getWalletCachedElectrumX: () => cachedElectrumXClient, ); initCoinControlInterface( walletId: walletId, diff --git a/lib/services/mixins/fusion_wallet_interface.dart b/lib/services/mixins/fusion_wallet_interface.dart index 73d771845..40aa8529d 100644 --- a/lib/services/mixins/fusion_wallet_interface.dart +++ b/lib/services/mixins/fusion_wallet_interface.dart @@ -27,7 +27,6 @@ mixin FusionWalletInterface { late final String _walletId; late final Coin _coin; late final MainDB _db; - late final CachedElectrumX _cachedElectrumX; late final FusionTorService _torService; // Passed in wallet functions. @@ -37,6 +36,8 @@ mixin FusionWalletInterface { DerivePathType derivePathType, ) _generateAddressForChain; + late final CachedElectrumX Function() _getWalletCachedElectrumX; + /// Initializes the FusionWalletInterface mixin. /// /// This function must be called before any other functions in this mixin. @@ -51,7 +52,7 @@ mixin FusionWalletInterface { int, DerivePathType, ) generateAddressForChain, - required CachedElectrumX cachedElectrumX, + required CachedElectrumX Function() getWalletCachedElectrumX, }) async { // Set passed in wallet data. _walletId = walletId; @@ -59,7 +60,7 @@ mixin FusionWalletInterface { _db = db; _generateAddressForChain = generateAddressForChain; _torService = FusionTorService.sharedInstance; - _cachedElectrumX = cachedElectrumX; + _getWalletCachedElectrumX = getWalletCachedElectrumX; } /// Returns a list of all addresses in the wallet. @@ -78,7 +79,7 @@ mixin FusionWalletInterface { _txs.map( (tx) => tx.toFusionTransaction( dbInstance: _db, - cachedElectrumX: _cachedElectrumX, + cachedElectrumX: _getWalletCachedElectrumX(), ), ), ); @@ -258,7 +259,8 @@ mixin FusionWalletInterface { } // Find public key. - Map tx = await _cachedElectrumX.getTransaction( + Map tx = + await _getWalletCachedElectrumX().getTransaction( coin: _coin, txHash: e.txid, verbose: true,