This commit is contained in:
julian 2023-10-25 10:45:30 -06:00
parent 381a6b7b4b
commit ea04ea9796
3 changed files with 29 additions and 1 deletions

@ -1 +1 @@
Subproject commit a7e034e4c3aca9df1b186ed1814793c5fe0012f4
Subproject commit 65643acb54f829d29bb07939e16e3002e85eede7

View file

@ -151,6 +151,7 @@ class BitcoinCashWallet extends CoinServiceAPI
mnemonic: mnemonicString,
mnemonicPassphrase: mnemonicPassphrase,
network: _network,
convertToScriptHash: _convertToScriptHash,
);
initCoinControlInterface(
walletId: walletId,

View file

@ -125,6 +125,8 @@ mixin FusionWalletInterface {
late final CachedElectrumX Function() _getWalletCachedElectrumX;
late final Future<int> Function() _getChainHeight;
late final Future<void> Function() _updateWalletUTXOS;
late final String Function(String bchAddress, btcdart.NetworkType network)
_convertToScriptHash;
// Fusion object.
fusion.Fusion? _mainFusionObject;
@ -154,6 +156,9 @@ mixin FusionWalletInterface {
required Future<String?> mnemonic,
required Future<String?> mnemonicPassphrase,
required btcdart.NetworkType network,
required final String Function(
String bchAddress, btcdart.NetworkType network)
convertToScriptHash,
}) async {
// Set passed in wallet data.
_walletId = walletId;
@ -167,6 +172,7 @@ mixin FusionWalletInterface {
_mnemonic = mnemonic;
_mnemonicPassphrase = mnemonicPassphrase;
_network = network;
_convertToScriptHash = convertToScriptHash;
}
// callback to update the ui state object
@ -409,6 +415,26 @@ mixin FusionWalletInterface {
}
}
Future<bool> _checkUtxoExists(
String address,
String prevTxid,
int prevIndex,
) async {
final scriptHash = _convertToScriptHash(address, _network);
final utxos = await _getWalletCachedElectrumX()
.electrumXClient
.getUTXOs(scripthash: scriptHash);
for (final utxo in utxos) {
if (utxo["tx_hash"] == prevTxid && utxo["tx_pos"] == prevIndex) {
return true;
}
}
return false;
}
// Initial attempt for CashFusion integration goes here.
/// Fuse the wallet's UTXOs.
@ -446,6 +472,7 @@ mixin FusionWalletInterface {
getSocksProxyAddress: _getSocksProxyAddress,
getChainHeight: _getChainHeight,
updateStatusCallback: _updateStatus,
checkUtxoExists: _checkUtxoExists,
getTransactionJson: (String txid) async =>
await _getWalletCachedElectrumX().getTransaction(
coin: _coin,