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

Commit

Permalink
Revert "fix bch address convert issue (#1847)"
Browse files Browse the repository at this point in the history
This reverts commit c171d0b.
  • Loading branch information
lambertkevin authored Apr 5, 2022
1 parent c171d0b commit 14ff789
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/families/bitcoin/logic.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/families/bitcoin/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 4 additions & 1 deletion 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 { bchToCashaddrAddressWithoutPrefix } from "./logic";
import bchaddr from "bchaddrjs";
import cashaddr from "cashaddrjs";
import type {
Transaction,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 14ff789

Please sign in to comment.