From 14ff789b45c18383650562230a1057526e4b4b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Lambert?= <44363395+lambertkevin@users.noreply.github.com> Date: Tue, 5 Apr 2022 15:40:06 +0200 Subject: [PATCH] Revert "fix bch address convert issue (#1847)" This reverts commit c171d0b9029273ee641d9a2b62e27099d1f86e29. --- src/families/bitcoin/logic.ts | 5 +++-- src/families/bitcoin/specs.ts | 4 +--- src/families/bitcoin/transaction.ts | 5 ++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/families/bitcoin/logic.ts b/src/families/bitcoin/logic.ts index 9957284ca1..d7c682e2fc 100644 --- a/src/families/bitcoin/logic.ts +++ b/src/families/bitcoin/logic.ts @@ -1,4 +1,5 @@ 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"; @@ -142,8 +143,8 @@ type CoinLogic = { injectGetAddressParams?: (arg0: Account) => any; }; -export const bchToCashaddrAddressWithoutPrefix = (recipient) => - recipient ? recipient.substring(recipient.indexOf(":") + 1) : recipient; +const bchToCashaddrAddressWithoutPrefix = (recipient) => + recipient ? bchaddr.toCashAddress(recipient).split(":")[1] : recipient; export const perCoinLogic: Record< CryptoCurrencyIds, diff --git a/src/families/bitcoin/specs.ts b/src/families/bitcoin/specs.ts index 14bfb23fa5..138836a167 100644 --- a/src/families/bitcoin/specs.ts +++ b/src/families/bitcoin/specs.ts @@ -257,9 +257,7 @@ const bitcoinLikeMutations = ({ test: ({ account }) => { expect( account.bitcoinResources?.utxos - .filter( - (u) => u.blockHeight && u.blockHeight < account.blockHeight - 10 - ) // Exclude pending UTXOs and the Utxos just written into new block (10 blocks time) + .filter((u) => u.blockHeight && u.blockHeight < account.blockHeight) // Exclude pending UTXOs and the Utxos just written into new block .reduce((p, c) => p.plus(c.value), new BigNumber(0)) .toString() ).toBe("0"); diff --git a/src/families/bitcoin/transaction.ts b/src/families/bitcoin/transaction.ts index e95d0ec3d0..37e1d0134e 100644 --- a/src/families/bitcoin/transaction.ts +++ b/src/families/bitcoin/transaction.ts @@ -1,5 +1,5 @@ import { BigNumber } from "bignumber.js"; -import { bchToCashaddrAddressWithoutPrefix } from "./logic"; +import bchaddr from "bchaddrjs"; import cashaddr from "cashaddrjs"; import type { Transaction, @@ -134,6 +134,9 @@ function bchExplicit(str: string): string { return str; } +const bchToCashaddrAddressWithoutPrefix = (recipient) => + recipient ? bchaddr.toCashAddress(recipient).split(":")[1] : recipient; + export type CoinLogic = { hasExtraData?: boolean; hasExpiryHeight?: boolean;