From 503ac8d80110504fc1944046d6c689a027ecb3d1 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 15 Aug 2020 17:59:51 +0200 Subject: [PATCH] legacy: allow spending coins from Bitcoin paths if the coin ... has implemented strong replay protection via SIGHASH_FORKID --- legacy/firmware/CHANGELOG.md | 2 ++ legacy/firmware/crypto.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/legacy/firmware/CHANGELOG.md b/legacy/firmware/CHANGELOG.md index 6fdb2aaf29..8aabeb4a43 100644 --- a/legacy/firmware/CHANGELOG.md +++ b/legacy/firmware/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Print inverted question mark for non-printable characters. +- Allow spending coins from Bitcoin paths if the coin has implemented strong replay protection via `SIGHASH_FORKID`. [#1188] ### Deprecated @@ -331,3 +332,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). [#1030]: https://github.com/trezor/trezor-firmware/issues/1030 [#1098]: https://github.com/trezor/trezor-firmware/issues/1098 [#1165]: https://github.com/trezor/trezor-firmware/pull/1165 +[#1188]: https://github.com/trezor/trezor-firmware/issues/1188 diff --git a/legacy/firmware/crypto.c b/legacy/firmware/crypto.c index bb28644b60..0848a55e6c 100644 --- a/legacy/firmware/crypto.c +++ b/legacy/firmware/crypto.c @@ -509,7 +509,18 @@ int cryptoIdentityFingerprint(const IdentityType *identity, uint8_t *hash) { } static bool check_cointype(const CoinInfo *coin, uint32_t slip44, bool full) { +#if BITCOIN_ONLY (void)full; +#else + if (!full) { + // some wallets such as Electron-Cash (BCH) store coins on Bitcoin paths + // we can allow spending these coins from Bitcoin paths if the coin has + // implemented strong replay protection via SIGHASH_FORKID + if (slip44 == 0x80000000 && coin->has_fork_id) { + return true; + } + } +#endif return coin->coin_type == slip44; }