From 5c5a6e114ea35be1c7a79ddb9d06c8ff967e003a Mon Sep 17 00:00:00 2001 From: huiqi Date: Wed, 3 Nov 2021 23:14:41 +0100 Subject: [PATCH] fix tx pagination logic --- src/families/bitcoin/wallet-btc/xpub.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/families/bitcoin/wallet-btc/xpub.ts b/src/families/bitcoin/wallet-btc/xpub.ts index 19d0e35ab2..eba3224dcc 100644 --- a/src/families/bitcoin/wallet-btc/xpub.ts +++ b/src/families/bitcoin/wallet-btc/xpub.ts @@ -430,9 +430,11 @@ class Xpub extends EventEmitter { { address, account, index }, lastTx ); - pendingTxs = pendingTxs.concat(txs.filter((tx) => !tx.block)); + if (pendingTxs.length === 0) { + pendingTxs = txs.filter((tx) => !tx.block); + } inserted += await this.storage.appendTxs(txs.filter((tx) => tx.block)); // only insert not pending tx - } while (txs.length >= this.txsSyncArraySize); // check whether page is full, if not, it is the last page + } while (txs.length - pendingTxs.length >= this.txsSyncArraySize); // check whether page is full, if not, it is the last page inserted += await this.storage.appendTxs(pendingTxs); return inserted; }