hwReadinessFor function

HwReadiness hwReadinessFor({
  1. required CryptoCoins<BaseCoinConfig> coin,
  2. required int device,
  3. String? variant,
})

Readiness of (coin, device) — optionally pinned to one address variant ('p2pkh' | 'p2wpkh' | 'p2sh' | 'p2tr', curve name otherwise).

Without variant, collapses to the best readiness across all of the coin's variants for that device. Unknown device id or unlisted coin yields HwReadiness.unknown (never shipped as supported).

This answers "can it sign", not "is it connected": combine with the runtime address/key-match probes before any signing UI.

Implementation

HwReadiness hwReadinessFor({
  required CryptoCoins coin,
  required int device,
  String? variant,
}) {
  final kind = BuHwKind.fromId(device);
  if (kind == null) return HwReadiness.unknown;
  final rows = HwCatalog.rowsFor(coin).where((r) => r.device == kind);
  if (variant != null) {
    return hwBest([
      for (final r in rows)
        if (r.variant == variant) r,
    ]);
  }
  return hwBest(rows.toList());
}