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;