diff --git a/legacy/firmware/coins.c b/legacy/firmware/coins.c index dcd4c0de3..7def8d9ff 100644 --- a/legacy/firmware/coins.c +++ b/legacy/firmware/coins.c @@ -43,6 +43,12 @@ const CoinInfo *coinByAddressType(uint32_t address_type) { } const CoinInfo *coinBySlip44(uint32_t coin_type) { + if (coin_type == SLIP44_TESTNET) { + // The slip44 coin type is the same for all testnets, so we return the + // Bitcoin Testnet. + return coinByName("Testnet"); + } + for (int i = 0; i < COINS_COUNT; i++) { if (coin_type == coins[i].coin_type) { return &(coins[i]); diff --git a/legacy/firmware/coins.h b/legacy/firmware/coins.h index ba9219d22..b582bc35e 100644 --- a/legacy/firmware/coins.h +++ b/legacy/firmware/coins.h @@ -59,6 +59,12 @@ typedef struct _CoinInfo { #include "coin_info.h" +// SLIP-44 hardened coin type for Bitcoin +#define SLIP44_BITCOIN 0x80000000 + +// SLIP-44 hardened coin type for all Testnet coins +#define SLIP44_TESTNET 0x80000001 + const CoinInfo *coinByName(const char *name); const CoinInfo *coinByAddressType(uint32_t address_type); const CoinInfo *coinBySlip44(uint32_t coin_type); diff --git a/legacy/firmware/crypto.c b/legacy/firmware/crypto.c index 9b93041c6..043f5d963 100644 --- a/legacy/firmware/crypto.c +++ b/legacy/firmware/crypto.c @@ -37,12 +37,6 @@ #define PATH_MAX_CHANGE 1 #define PATH_MAX_ADDRESS_INDEX 1000000 -// SLIP-44 hardened coin type for Bitcoin -#define SLIP44_BITCOIN 0x80000000 - -// SLIP-44 hardened coin type for all Testnet coins -#define SLIP44_TESTNET 0x80000001 - uint32_t ser_length(uint32_t len, uint8_t *out) { if (len < 253) { out[0] = len & 0xFF;