From eb42493e4d45c569bde02a218997b62f09f7b71a Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 3 Feb 2023 18:05:19 -0600 Subject: [PATCH] bch derivePath bug fix --- .../coins/bitcoincash/bitcoincash_wallet.dart | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index 3a7e25545..ea6cdccf6 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -59,14 +59,24 @@ String constructDerivePath({ required int chain, required int index, }) { - String coinType; + int coinType; switch (networkWIF) { case 0x80: // bch mainnet wif - coinType = - derivePathType == DerivePathType.bch44 ? "145" : "0"; // bch mainnet + switch (derivePathType) { + case DerivePathType.bip44: + case DerivePathType.bip49: + coinType = 145; // bch mainnet + break; + case DerivePathType.bch44: // bitcoin.com wallet specific + coinType = 0; // bch mainnet + break; + default: + throw Exception( + "DerivePathType $derivePathType not supported for coinType"); + } break; case 0xef: // bch testnet wif - coinType = "1"; // bch testnet + coinType = 1; // bch testnet break; default: throw Exception("Invalid Bitcoincash network wif used!");