From 2182905fff3dc62286dea002700ca5b5fab8f0d1 Mon Sep 17 00:00:00 2001 From: huiqi Date: Wed, 23 Mar 2022 10:10:33 +0100 Subject: [PATCH 1/6] fix rbf logic --- .../wallet.estimateMaxSpendable.test.ts | 12 ++---- src/families/bitcoin/bridge/libcore.ts | 7 ++-- src/families/bitcoin/bridge/mock.ts | 1 - src/families/bitcoin/cache.ts | 6 +-- src/families/bitcoin/cli-transaction.ts | 6 --- src/families/bitcoin/datasets/bitcoin.ts | 3 -- src/families/bitcoin/datasets/digibyte.ts | 3 -- src/families/bitcoin/datasets/litecoin.ts | 3 -- src/families/bitcoin/js-buildTransaction.ts | 1 - src/families/bitcoin/js-createTransaction.ts | 1 - .../bitcoin/js-estimateMaxSpendable.ts | 1 - .../bitcoin/libcore-buildTransaction.ts | 2 +- src/families/bitcoin/logic.ts | 13 ++----- src/families/bitcoin/specs.ts | 4 +- src/families/bitcoin/transaction.ts | 39 +------------------ src/families/bitcoin/types.ts | 1 - src/families/bitcoin/wallet-btc/wallet.ts | 10 ++++- 17 files changed, 27 insertions(+), 86 deletions(-) diff --git a/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts b/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts index 3f4eb2ac3d..9e69749c63 100644 --- a/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts +++ b/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts @@ -30,8 +30,7 @@ describe("testing estimateMaxSpendable", () => { let maxSpendable = await wallet.estimateAccountMaxSpendable( account, 0, - [], - true + [] ); const balance = 109088; expect(maxSpendable.toNumber()).toEqual(balance); @@ -43,16 +42,14 @@ describe("testing estimateMaxSpendable", () => { hash: "f80246be50064bb254d2cad82fb0d4ce7768582b99c113694e72411f8032fd7a", outputIndex: 0, }, - ], - true + ] ); expect(maxSpendableExcludeUtxo.toNumber()).toEqual(balance - 1000); let feesPerByte = 100; maxSpendable = await wallet.estimateAccountMaxSpendable( account, feesPerByte, - [], - true + [] ); expect(maxSpendable.toNumber()).toEqual( balance - @@ -69,8 +66,7 @@ describe("testing estimateMaxSpendable", () => { maxSpendable = await wallet.estimateAccountMaxSpendable( account, feesPerByte, - [], - true + [] ); expect(maxSpendable.toNumber()).toEqual(0); }, 60000); diff --git a/src/families/bitcoin/bridge/libcore.ts b/src/families/bitcoin/bridge/libcore.ts index 3634337365..83f1ee888d 100644 --- a/src/families/bitcoin/bridge/libcore.ts +++ b/src/families/bitcoin/bridge/libcore.ts @@ -43,9 +43,9 @@ const receive = makeAccountBridgeReceive({ const getCacheKey = (a, t) => `${a.id}_${a.blockHeight || 0}_${t.amount.toString()}_${String( t.useAllAmount - )}_${t.recipient}_${t.feePerByte ? t.feePerByte.toString() : ""}_${ - t.utxoStrategy.pickUnconfirmedRBF ? 1 : 0 - }_${t.utxoStrategy.strategy}_${String(t.rbf)}_${t.utxoStrategy.excludeUTXOs + )}_${t.recipient}_${t.feePerByte ? t.feePerByte.toString() : ""}_${0}_${ + t.utxoStrategy.strategy + }_${String(t.rbf)}_${t.utxoStrategy.excludeUTXOs .map(({ hash, outputIndex }) => `${hash}@${outputIndex}`) .join("+")}`; @@ -61,7 +61,6 @@ const createTransaction = (): Transaction => ({ amount: new BigNumber(0), utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, recipient: "", diff --git a/src/families/bitcoin/bridge/mock.ts b/src/families/bitcoin/bridge/mock.ts index ca5a7e78de..76179770a0 100644 --- a/src/families/bitcoin/bridge/mock.ts +++ b/src/families/bitcoin/bridge/mock.ts @@ -32,7 +32,6 @@ const createTransaction = (): Transaction => ({ rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }); diff --git a/src/families/bitcoin/cache.ts b/src/families/bitcoin/cache.ts index 64ec71a4bb..c1a5012fe4 100644 --- a/src/families/bitcoin/cache.ts +++ b/src/families/bitcoin/cache.ts @@ -15,9 +15,9 @@ const getCacheKeyForCalculateFees = ({ }) => `${a.id}_${a.blockHeight || 0}_${t.amount.toString()}_${String( t.useAllAmount - )}_${t.recipient}_${t.feePerByte ? t.feePerByte.toString() : ""}_${ - t.utxoStrategy.pickUnconfirmedRBF ? 1 : 0 - }_${t.utxoStrategy.strategy}_${String(t.rbf)}_${t.utxoStrategy.excludeUTXOs + )}_${t.recipient}_${t.feePerByte ? t.feePerByte.toString() : ""}_${0}_${ + t.utxoStrategy.strategy + }_${String(t.rbf)}_${t.utxoStrategy.excludeUTXOs .map(({ hash, outputIndex }) => `${hash}@${outputIndex}`) .join("+")}`; diff --git a/src/families/bitcoin/cli-transaction.ts b/src/families/bitcoin/cli-transaction.ts index ba3e299da6..c51c08165b 100644 --- a/src/families/bitcoin/cli-transaction.ts +++ b/src/families/bitcoin/cli-transaction.ts @@ -8,11 +8,6 @@ const options = [ type: String, desc: "how much fee per byte", }, - { - name: "pickUnconfirmedRBF", - type: Boolean, - desc: "also pick unconfirmed replaceable txs", - }, { name: "excludeUTXO", alias: "E", @@ -52,7 +47,6 @@ function inferTransactions( rbf: opts.rbf || false, utxoStrategy: { strategy: bitcoinPickingStrategy[opts["bitcoin-pick-strategy"]] || 0, - pickUnconfirmedRBF: opts.pickUnconfirmedRBF || false, excludeUTXOs: (opts.excludeUTXO || []).map((str) => { const [hash, index] = str.split("@"); invariant( diff --git a/src/families/bitcoin/datasets/bitcoin.ts b/src/families/bitcoin/datasets/bitcoin.ts index ef74ce0aef..c0c2669547 100644 --- a/src/families/bitcoin/datasets/bitcoin.ts +++ b/src/families/bitcoin/datasets/bitcoin.ts @@ -47,7 +47,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), @@ -73,7 +72,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), @@ -99,7 +97,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), diff --git a/src/families/bitcoin/datasets/digibyte.ts b/src/families/bitcoin/datasets/digibyte.ts index 3b1235f9d0..8f95648bfe 100644 --- a/src/families/bitcoin/datasets/digibyte.ts +++ b/src/families/bitcoin/datasets/digibyte.ts @@ -46,7 +46,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), @@ -69,7 +68,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), @@ -92,7 +90,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), diff --git a/src/families/bitcoin/datasets/litecoin.ts b/src/families/bitcoin/datasets/litecoin.ts index 4457209d5f..dc0cc9c432 100644 --- a/src/families/bitcoin/datasets/litecoin.ts +++ b/src/families/bitcoin/datasets/litecoin.ts @@ -47,7 +47,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), @@ -70,7 +69,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), @@ -93,7 +91,6 @@ const dataset: CurrenciesData = { rbf: false, utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, }), diff --git a/src/families/bitcoin/js-buildTransaction.ts b/src/families/bitcoin/js-buildTransaction.ts index daa3aa240e..99dd5be327 100644 --- a/src/families/bitcoin/js-buildTransaction.ts +++ b/src/families/bitcoin/js-buildTransaction.ts @@ -44,7 +44,6 @@ export const buildTransaction = async ( walletAccount, transaction.feePerByte.toNumber(), //!\ wallet-btc handles fees as JS number transaction.utxoStrategy.excludeUTXOs, - transaction.utxoStrategy.pickUnconfirmedRBF, [transaction.recipient] ); log("btcwallet", "building transaction", transaction); diff --git a/src/families/bitcoin/js-createTransaction.ts b/src/families/bitcoin/js-createTransaction.ts index 13826499bc..a2447cb727 100644 --- a/src/families/bitcoin/js-createTransaction.ts +++ b/src/families/bitcoin/js-createTransaction.ts @@ -12,7 +12,6 @@ const createTransaction = (): Transaction => { amount: new BigNumber(0), utxoStrategy: { strategy: 0, - pickUnconfirmedRBF: false, excludeUTXOs: [], }, recipient: "", diff --git a/src/families/bitcoin/js-estimateMaxSpendable.ts b/src/families/bitcoin/js-estimateMaxSpendable.ts index 8cc20745ef..c703988fcb 100644 --- a/src/families/bitcoin/js-estimateMaxSpendable.ts +++ b/src/families/bitcoin/js-estimateMaxSpendable.ts @@ -30,7 +30,6 @@ const estimateMaxSpendable = async ({ walletAccount, feePerByte.toNumber(), //!\ wallet-btc handles fees as JS number transaction?.utxoStrategy?.excludeUTXOs || [], - transaction?.utxoStrategy?.pickUnconfirmedRBF || false, transaction ? [transaction.recipient] : [] ); return maxSpendable.lt(0) ? new BigNumber(0) : maxSpendable; diff --git a/src/families/bitcoin/libcore-buildTransaction.ts b/src/families/bitcoin/libcore-buildTransaction.ts index 07e7f57eea..d925e0f4f8 100644 --- a/src/families/bitcoin/libcore-buildTransaction.ts +++ b/src/families/bitcoin/libcore-buildTransaction.ts @@ -6,7 +6,7 @@ import { isValidRecipient } from "../../libcore/isValidRecipient"; import { bigNumberToLibcoreAmount } from "../../libcore/buildBigNumber"; import type { Core, CoreCurrency, CoreAccount } from "../../libcore/types"; import type { CoreBitcoinLikeTransaction, Transaction } from "./types"; -import { getUTXOStatus } from "./transaction"; +import { getUTXOStatus } from "./logic"; import { promiseAllBatched } from "../../promise"; import { parseBitcoinUTXO, perCoinLogic } from "./transaction"; diff --git a/src/families/bitcoin/logic.ts b/src/families/bitcoin/logic.ts index d7c682e2fc..7c31acb5bd 100644 --- a/src/families/bitcoin/logic.ts +++ b/src/families/bitcoin/logic.ts @@ -79,7 +79,7 @@ export function isChangeOutput(output: BitcoinOutput): boolean { type UTXOStatus = | { excluded: true; - reason: "pickUnconfirmedRBF" | "pickPendingNonRBF" | "userExclusion"; + reason: "pickPendingUtxo" | "userExclusion"; } | { excluded: false; @@ -88,16 +88,11 @@ export const getUTXOStatus = ( utxo: BitcoinOutput, utxoStrategy: UtxoStrategy ): UTXOStatus => { - if (!utxoStrategy.pickUnconfirmedRBF && utxo.rbf && !utxo.blockHeight) { + if (!utxo.blockHeight && !utxo.isChange) { + // exclude pending and not change utxo return { excluded: true, - reason: "pickUnconfirmedRBF", - }; - } - if (!utxo.rbf && !utxo.blockHeight) { - return { - excluded: true, - reason: "pickPendingNonRBF", + reason: "pickPendingUtxo", }; } if ( diff --git a/src/families/bitcoin/specs.ts b/src/families/bitcoin/specs.ts index 09b16c2ed5..9aa98d8879 100644 --- a/src/families/bitcoin/specs.ts +++ b/src/families/bitcoin/specs.ts @@ -96,7 +96,8 @@ const genericTest = ({ // verify that no utxo that was supposed to be exploded were used expect( utxosPicked.filter( - (u) => getUTXOStatus(u, transaction.utxoStrategy).excluded + (u: BitcoinOutput) => + u.blockHeight && getUTXOStatus(u, transaction.utxoStrategy).excluded ) ).toEqual([]); }; @@ -243,7 +244,6 @@ const bitcoinLikeMutations = ({ { utxoStrategy: { ...transaction.utxoStrategy, - pickUnconfirmedRBF: true, }, }, { diff --git a/src/families/bitcoin/transaction.ts b/src/families/bitcoin/transaction.ts index 37e1d0134e..e5e82610dd 100644 --- a/src/families/bitcoin/transaction.ts +++ b/src/families/bitcoin/transaction.ts @@ -7,7 +7,6 @@ import type { FeeItems, FeeItemsRaw, BitcoinOutput, - UtxoStrategy, CoreBitcoinLikeOutput, CoreBitcoinLikeInput, BitcoinInput, @@ -90,7 +89,7 @@ const formatNetworkInfo = ( export const formatTransaction = (t: Transaction, account: Account): string => { const n = getEnv("DEBUG_UTXO_DISPLAY"); - const { excludeUTXOs, strategy, pickUnconfirmedRBF } = t.utxoStrategy; + const { excludeUTXOs, strategy } = t.utxoStrategy; const displayAll = excludeUTXOs.length <= n; return ` SEND ${ @@ -109,7 +108,7 @@ ${[ Object.keys(bitcoinPickingStrategy).find( (k) => bitcoinPickingStrategy[k] === strategy ), - pickUnconfirmedRBF && "pick-unconfirmed", + "pick-unconfirmed", t.rbf && "RBF-enabled", ] .filter(Boolean) @@ -200,14 +199,6 @@ export const perCoinLogic: Record< }), }, }; -export type UTXOStatus = - | { - excluded: true; - reason: "pickUnconfirmedRBF" | "userExclusion"; - } - | { - excluded: false; - }; export async function parseBitcoinInput( input: CoreBitcoinLikeInput ): Promise { @@ -267,32 +258,6 @@ export async function parseBitcoinUTXO( utxo.rbf = await output.isReplaceable(); return utxo; } -export function getUTXOStatus( - utxo: BitcoinOutput, - utxoStrategy: UtxoStrategy -): UTXOStatus { - if (!utxoStrategy.pickUnconfirmedRBF && utxo.rbf && !utxo.blockHeight) { - return { - excluded: true, - reason: "pickUnconfirmedRBF", - }; - } - - if ( - utxoStrategy.excludeUTXOs.some( - (u) => u.hash === utxo.hash && u.outputIndex === utxo.outputIndex - ) - ) { - return { - excluded: true, - reason: "userExclusion", - }; - } - - return { - excluded: false, - }; -} export function isChangeOutput(output: BitcoinOutput): boolean { if (!output.path) return false; const p = output.path.split("/"); diff --git a/src/families/bitcoin/types.ts b/src/families/bitcoin/types.ts index c2f66ba991..30e394b529 100644 --- a/src/families/bitcoin/types.ts +++ b/src/families/bitcoin/types.ts @@ -134,7 +134,6 @@ export type BitcoinPickingStrategy = typeof bitcoinPickingStrategy[keyof typeof bitcoinPickingStrategy]; export type UtxoStrategy = { strategy: BitcoinPickingStrategy; - pickUnconfirmedRBF: boolean; excludeUTXOs: Array<{ hash: string; outputIndex: number; diff --git a/src/families/bitcoin/wallet-btc/wallet.ts b/src/families/bitcoin/wallet-btc/wallet.ts index bbd3cbca27..fec571066a 100644 --- a/src/families/bitcoin/wallet-btc/wallet.ts +++ b/src/families/bitcoin/wallet-btc/wallet.ts @@ -122,10 +122,12 @@ class BitcoinLikeWallet { account: Account, feePerByte: number, excludeUTXOs: Array<{ hash: string; outputIndex: number }>, - pickUnconfirmedRBF: boolean, outputAddresses: string[] = [] ) { const addresses = await account.xpub.getXpubAddresses(); + const changeAddresses = (await account.xpub.getAccountAddresses(1)).map( + (item) => item.address + ); const utxos = flatten( await Promise.all( addresses.map((address) => @@ -144,7 +146,11 @@ class BitcoinLikeWallet { excludeUtxo.outputIndex === utxo.output_index ) ) { - if ((pickUnconfirmedRBF && utxo.rbf) || utxo.block_height !== null) { + // we can use either non pending utxo or change utxo + if ( + changeAddresses.includes(utxo.address) || + utxo.block_height !== null + ) { usableUtxoCount++; balance = balance.plus(utxo.value); } From 52f0b40a8e28d9639729ba0931e08333df462dc9 Mon Sep 17 00:00:00 2001 From: huiqi Date: Wed, 23 Mar 2022 15:55:04 +0100 Subject: [PATCH 2/6] fix change address for utxo --- .../wallet-btc/wallet.estimateMaxSpendable.test.ts | 6 +----- src/families/bitcoin/js-synchronisation.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts b/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts index 9e69749c63..dad226e4d2 100644 --- a/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts +++ b/src/__tests__/families/bitcoin/wallet-btc/wallet.estimateMaxSpendable.test.ts @@ -27,11 +27,7 @@ describe("testing estimateMaxSpendable", () => { it("should estimate max spendable correctly", async () => { await wallet.syncAccount(account); - let maxSpendable = await wallet.estimateAccountMaxSpendable( - account, - 0, - [] - ); + let maxSpendable = await wallet.estimateAccountMaxSpendable(account, 0, []); const balance = 109088; expect(maxSpendable.toNumber()).toEqual(balance); const maxSpendableExcludeUtxo = await wallet.estimateAccountMaxSpendable( diff --git a/src/families/bitcoin/js-synchronisation.ts b/src/families/bitcoin/js-synchronisation.ts index 54c8fd3ead..9df7129e2a 100644 --- a/src/families/bitcoin/js-synchronisation.ts +++ b/src/families/bitcoin/js-synchronisation.ts @@ -53,7 +53,10 @@ const toWalletNetwork = (currencyId: string): "testnet" | "mainnet" => { }; // Map wallet-btc's Output to LL's BitcoinOutput -const fromWalletUtxo = (utxo: WalletOutput): BitcoinOutput => { +const fromWalletUtxo = ( + utxo: WalletOutput, + changeAddresses: Set +): BitcoinOutput => { return { hash: utxo.output_hash, outputIndex: utxo.output_index, @@ -61,7 +64,7 @@ const fromWalletUtxo = (utxo: WalletOutput): BitcoinOutput => { address: utxo.address, value: new BigNumber(utxo.value), rbf: utxo.rbf, - isChange: false, // wallet-btc limitation: doesn't provide it + isChange: changeAddresses.has(utxo.address), path: "", }; }; @@ -350,7 +353,7 @@ const getAccountShape: GetAccountShape = async (info) => { const newUniqueOperations = deduplicateOperations(newOperations); const operations = mergeOps(oldOperations, newUniqueOperations); const rawUtxos = await wallet.getAccountUnspentUtxos(walletAccount); - const utxos = rawUtxos.map(fromWalletUtxo); + const utxos = rawUtxos.map((utxo) => fromWalletUtxo(utxo, changeAddresses)); return { id: accountId, xpub, From 23913a5266f129b907f5310da1001e103e876d73 Mon Sep 17 00:00:00 2001 From: huiqi Date: Wed, 23 Mar 2022 18:18:14 +0100 Subject: [PATCH 3/6] Trigger Build From 80d4aeb09faccd4e7e036b61afc2037d87433408 Mon Sep 17 00:00:00 2001 From: huiqi Date: Thu, 24 Mar 2022 01:57:43 +0100 Subject: [PATCH 4/6] fix bot --- src/families/bitcoin/specs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/families/bitcoin/specs.ts b/src/families/bitcoin/specs.ts index 9aa98d8879..f6a26518a2 100644 --- a/src/families/bitcoin/specs.ts +++ b/src/families/bitcoin/specs.ts @@ -256,7 +256,7 @@ const bitcoinLikeMutations = ({ test: ({ account }) => { expect( account.bitcoinResources?.utxos - .filter((u) => u.blockHeight) // Exclude pending UTXOs + .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"); From c0e969520a152bed466b7cb9b076a57661813bac Mon Sep 17 00:00:00 2001 From: hzheng-ledger <71653044+hzheng-ledger@users.noreply.github.com> Date: Tue, 29 Mar 2022 16:14:10 +0200 Subject: [PATCH 5/6] LL-1589 more robust bitcoin retry (#1835) * fix bot * fix sync error exception process --- .../bitcoin/wallet-btc/explorer/index.ts | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/families/bitcoin/wallet-btc/explorer/index.ts b/src/families/bitcoin/wallet-btc/explorer/index.ts index fa665bfd26..6da83f9286 100644 --- a/src/families/bitcoin/wallet-btc/explorer/index.ts +++ b/src/families/bitcoin/wallet-btc/explorer/index.ts @@ -207,28 +207,29 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer { // TODO add a test for failure (at the sync level) const client = await this.client.acquire(); - const res = ( - await client.client.get(url, { - params, - // some altcoin may have outputs with values > MAX_SAFE_INTEGER - transformResponse: (string) => - // eslint-disable-next-line @typescript-eslint/no-explicit-any - JSONBigNumber.parse(string, (key: string, value: any) => { - if (BigNumber.isBigNumber(value)) { - if (key === "value") { - return value.toString(); + let res: { txs: TX[] } = { txs: [] }; + try { + res = ( + await client.client.get(url, { + params, + // some altcoin may have outputs with values > MAX_SAFE_INTEGER + transformResponse: (string) => + // eslint-disable-next-line @typescript-eslint/no-explicit-any + JSONBigNumber.parse(string, (key: string, value: any) => { + if (BigNumber.isBigNumber(value)) { + if (key === "value") { + return value.toString(); + } + return value.toNumber(); } - - return value.toNumber(); - } - return value; - }), - }) - ).data as { txs: TX[] }; - await this.client.release(client); - + return value; + }), + }) + ).data; + } finally { + await this.client.release(client); + } this.emit("fetched-address-transaction", { url, params, res }); - return res; } @@ -305,7 +306,6 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer { params.block_hash = lastTx.block.hash; } } - const res = await this.fetchTxs(address, params); const hydratedTxs: TX[] = []; From 7d7bc184dd7c5f04aaac4c9a4749bf4ae712fff0 Mon Sep 17 00:00:00 2001 From: Huiqi ZHENG Date: Thu, 31 Mar 2022 16:51:07 +0200 Subject: [PATCH 6/6] fix bot --- src/families/bitcoin/specs.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/families/bitcoin/specs.ts b/src/families/bitcoin/specs.ts index f6a26518a2..8dbeeeccae 100644 --- a/src/families/bitcoin/specs.ts +++ b/src/families/bitcoin/specs.ts @@ -256,7 +256,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");