findUnusedAddress function

String findUnusedAddress({
  1. required Iterable<String> addresses,
  2. required Iterable<UTXOTransaction> txs,
})

Implementation

String findUnusedAddress({
  required Iterable<String> addresses,
  required Iterable<UTXOTransaction> txs,
}) {
  for (final address in addresses) {
    if (!txs.any(
      (tx) => tx.outputs.any((output) => output.node.address == address),
    )) {
      return address;
    }
  }

  throw Exception("No address found");
}