From 2bda9eae1841bd5711d5798792a94691c966f332 Mon Sep 17 00:00:00 2001 From: hzheng-ledger <71653044+hzheng-ledger@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:39:27 +0200 Subject: [PATCH] fix bch address convert issue (#1847) --- src/families/bitcoin/logic.ts | 5 ++--- src/families/bitcoin/specs.ts | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/families/bitcoin/logic.ts b/src/families/bitcoin/logic.ts index d7c682e2fc..9957284ca1 100644 --- a/src/families/bitcoin/logic.ts +++ b/src/families/bitcoin/logic.ts @@ -1,5 +1,4 @@ import cashaddr from "cashaddrjs"; -import bchaddr from "bchaddrjs"; import { Currency, isValidAddress } from "./wallet-btc"; import { RecipientRequired, InvalidAddress } from "@ledgerhq/errors"; import type { Account, CryptoCurrency, CryptoCurrencyIds } from "./../../types"; @@ -143,8 +142,8 @@ type CoinLogic = { injectGetAddressParams?: (arg0: Account) => any; }; -const bchToCashaddrAddressWithoutPrefix = (recipient) => - recipient ? bchaddr.toCashAddress(recipient).split(":")[1] : recipient; +export const bchToCashaddrAddressWithoutPrefix = (recipient) => + recipient ? recipient.substring(recipient.indexOf(":") + 1) : recipient; export const perCoinLogic: Record< CryptoCurrencyIds, diff --git a/src/families/bitcoin/specs.ts b/src/families/bitcoin/specs.ts index 138836a167..14bfb23fa5 100644 --- a/src/families/bitcoin/specs.ts +++ b/src/families/bitcoin/specs.ts @@ -257,7 +257,9 @@ const bitcoinLikeMutations = ({ test: ({ account }) => { expect( account.bitcoinResources?.utxos - .filter((u) => u.blockHeight && u.blockHeight < account.blockHeight) // Exclude pending UTXOs and the Utxos just written into new block + .filter( + (u) => u.blockHeight && u.blockHeight < account.blockHeight - 10 + ) // Exclude pending UTXOs and the Utxos just written into new block (10 blocks time) .reduce((p, c) => p.plus(c.value), new BigNumber(0)) .toString() ).toBe("0");