searchTransactionsForWalletType function

Future<(Set<ElectrumTransactionInfo>, Set<NodeWithAddress>)> searchTransactionsForWalletType({
  1. required BipNode masterNode,
  2. required HDWalletPurpose? purpose,
  3. required Iterable<AddressType> addressTypes,
  4. required UTXONetworkType networkType,
  5. required List<(String, int)> endpoints,
  6. required List<NodeWithAddress> cachedNodes,
  7. required IsolateManager isolateManager,
})

Implementation

Future<(Set<ElectrumTransactionInfo>, Set<NodeWithAddress>)>
    searchTransactionsForWalletType({
  required BipNode masterNode,
  required HDWalletPurpose? purpose,
  required Iterable<AddressType> addressTypes,
  required UTXONetworkType networkType,
  required List<(String, int)> endpoints,
  required List<NodeWithAddress> cachedNodes,
  required IsolateManager isolateManager,
}) async {
  final receiveTxsFuture = searchForTransactions(
    masterNode: masterNode,
    chainIndex: EXTERNAL_CHAIN_INDEX,
    addressTypes: addressTypes,
    walletPurpose: purpose,
    networkType: networkType,
    endpoints: endpoints,
    cachedNodes: cachedNodes,
    isolateManager: isolateManager,
  );

  final changeTxsFuture = searchForTransactions(
    masterNode: masterNode,
    chainIndex: INTERNAL_CHAIN_INDEX,
    addressTypes: addressTypes,
    walletPurpose: purpose,
    networkType: networkType,
    endpoints: endpoints,
    cachedNodes: cachedNodes,
    isolateManager: isolateManager,
  );

  final allTxsResult = await Future.wait([receiveTxsFuture, changeTxsFuture]);
  final allTxs = allTxsResult.expand((element) => element.$1).toSet();
  final nodes = allTxsResult.expand((element) => element.$2).toSet();

  return (allTxs, nodes);
}