getUtxos method

  1. @override
Future<List<UtxoRef>> getUtxos(
  1. String address
)
override

Implementation

@override
Future<List<UtxoRef>> getUtxos(String address) async {
  final scriptHash = _addressToScriptHash(address);
  final result = await _rpc(
    'blockchain.scripthash.listunspent',
    [scriptHash],
  );
  return (result as List).map((e) {
    final m = Map<String, dynamic>.from(e as Map);
    return UtxoRef(
      txid: m['tx_hash'] as String,
      vout: m['tx_pos'] as int,
      value: BigInt.from(m['value'] as int),
      scriptPubKeyHex: address,
      blockHeight: (m['height'] as int?) == 0 ? null : m['height'] as int?,
    );
  }).toList();
}