hwCoinIdForSlip44 function
Map a (SLIP44, key type, purpose) triple to a connector BuHwCoin id.
Returns null when the coin has no HW flow in the Rust hw core
(unknown SLIP44, or a curve variant no device speaks, e.g. SUI secp256r1).
A non-null id does NOT mean your device supports it — that is the
offline curve-table check HwApi.supportsCoin (no transport, no device).
Implementation
int? hwCoinIdForSlip44({
required int slip44,
required CryptoKeyType type,
int purpose = 44,
}) {
switch (slip44) {
case Slip44.bitcoin:
if (type != CryptoKeyType.secp256k1) return null;
return switch (purpose) {
84 => BuHwCoin.btcSegwit,
86 => BuHwCoin.btcTaproot,
_ => BuHwCoin.btc,
};
case Slip44.ethereum:
// Covers every EVM chain reusing 60 (BSC, Polygon, Avax-C, …).
return type == CryptoKeyType.secp256k1 ? BuHwCoin.eth : null;
case Slip44.tron:
return type == CryptoKeyType.secp256k1 ? BuHwCoin.trx : null;
case Slip44.ripple:
return type == CryptoKeyType.secp256k1 ? BuHwCoin.xrp : null;
case Slip44.atom:
return type == CryptoKeyType.secp256k1 ? BuHwCoin.atom : null;
case Slip44.filecoin:
return type == CryptoKeyType.secp256k1 ? BuHwCoin.filSecp : null;
case Slip44.tezos:
return switch (type) {
CryptoKeyType.ed25519 => BuHwCoin.xtzTz1,
CryptoKeyType.secp256k1 => BuHwCoin.xtzTz2,
CryptoKeyType.nist256p1 => BuHwCoin.xtzTz3,
_ => null,
};
case Slip44.solana:
return type == CryptoKeyType.ed25519 ? BuHwCoin.sol : null;
case Slip44.aptos:
return type == CryptoKeyType.ed25519 ? BuHwCoin.apt : null;
case Slip44.sui:
return type == CryptoKeyType.ed25519 ? BuHwCoin.suiEd : null;
case Slip44.nearProtocol:
return type == CryptoKeyType.ed25519 ? BuHwCoin.near : null;
case Slip44.stellar:
return type == CryptoKeyType.ed25519 ? BuHwCoin.xlm : null;
case Slip44.polkadot:
return type == CryptoKeyType.ed25519 ? BuHwCoin.dotSlip : null;
case Slip44.cardano:
// Known id, but Ledger/Trezor generic apps report unsupported curve.
return type == CryptoKeyType.ed25519Kholaw ? BuHwCoin.adaIcarus : null;
case Slip44.monero:
// No generic HW flow: XMR needs view+spend keys and a dedicated
// multi-round protocol (Ledger/Trezor Monero apps), not getAddress.
return null;
case Slip44.zcash:
// Transparent only; shielded (Sapling/Orchard) is on no HW wallet.
return type == CryptoKeyType.secp256k1 ? BuHwCoin.zecTransparent : null;
default:
return null;
}
}