findOurOwnCoins function

List<ElectrumOutput> findOurOwnCoins(
  1. List<ElectrumOutput> outputs,
  2. Iterable<NodeWithAddress> nodes,
  3. Iterable<AddressType> addressTypes,
  4. UTXONetworkType type,
)

Implementation

List<ElectrumOutput> findOurOwnCoins(
  List<ElectrumOutput> outputs,
  Iterable<NodeWithAddress> nodes,
  Iterable<AddressType> addressTypes,
  UTXONetworkType type,
) {
  final outputs0 = <ElectrumOutput>[];
  for (final vout in outputs) {
    final outputAddresses = vout.getAddresses(
      networkType: type,
      addressTypes: addressTypes,
    );

    final node = nodes.singleWhereOrNull(
      (node) => node.addressesList.any(
        (nodeAddress) => outputAddresses.contains(nodeAddress),
      ),
    );
    final belongsToUs = node != null;
    outputs0.add(
      vout.copyWith(
        belongsToUs: belongsToUs,
        node: node,
      ),
    );
  }
  return outputs0;
}