Fixed addressTransactions with pagination in electrum API.
This commit is contained in:
parent
5390629e41
commit
89b4de2484
@ -110,14 +110,25 @@ class BitcoindElectrsApi extends BitcoinApi implements AbstractBitcoinApi {
|
|||||||
if (!addressInfo || !addressInfo.isvalid) {
|
if (!addressInfo || !addressInfo.isvalid) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const history = await this.$getScriptHashHistory(addressInfo.scriptPubKey);
|
|
||||||
const transactions: IEsploraApi.Transaction[] = [];
|
const transactions: IEsploraApi.Transaction[] = [];
|
||||||
for (const h of history) {
|
const history = await this.$getScriptHashHistory(addressInfo.scriptPubKey);
|
||||||
const tx = await this.$getRawTransaction(h.tx_hash, false, true);
|
history.reverse();
|
||||||
|
|
||||||
|
let startingIndex = 0;
|
||||||
|
if (lastSeenTxId) {
|
||||||
|
const pos = history.findIndex((historicalTx) => historicalTx.tx_hash === lastSeenTxId);
|
||||||
|
if (pos) {
|
||||||
|
startingIndex = pos + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = startingIndex; i < Math.min(startingIndex + 10, history.length); i++) {
|
||||||
|
const tx = await this.$getRawTransaction(history[i].tx_hash, false, true);
|
||||||
if (tx) {
|
if (tx) {
|
||||||
transactions.push(tx);
|
transactions.push(tx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return transactions;
|
return transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user