Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Bugfix/bitcoin js ll tecsupport 1152 bitcoincashadd fix #1847

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/families/bitcoin/logic.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/families/bitcoin/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 1 addition & 4 deletions src/families/bitcoin/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber } from "bignumber.js";
import bchaddr from "bchaddrjs";
import { bchToCashaddrAddressWithoutPrefix } from "./logic";
import cashaddr from "cashaddrjs";
import type {
Transaction,
Expand Down Expand Up @@ -134,9 +134,6 @@ function bchExplicit(str: string): string {
return str;
}

const bchToCashaddrAddressWithoutPrefix = (recipient) =>
recipient ? bchaddr.toCashAddress(recipient).split(":")[1] : recipient;

export type CoinLogic = {
hasExtraData?: boolean;
hasExpiryHeight?: boolean;
Expand Down