alkanesjs 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.mjs +50 -12
- package/dist/index.browser.mjs.map +2 -2
- package/dist/index.js +50 -12
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -47545,6 +47545,9 @@ var ProtostoneTransaction = class {
|
|
|
47545
47545
|
});
|
|
47546
47546
|
}
|
|
47547
47547
|
try {
|
|
47548
|
+
if (changeValue < 546) {
|
|
47549
|
+
return false;
|
|
47550
|
+
}
|
|
47548
47551
|
hasChange = true;
|
|
47549
47552
|
this.psbt.addOutput({
|
|
47550
47553
|
address: this.changeAddress,
|
|
@@ -52643,23 +52646,58 @@ var ElectrumApiProvider = class {
|
|
|
52643
52646
|
);
|
|
52644
52647
|
}
|
|
52645
52648
|
}
|
|
52649
|
+
/*
|
|
52650
|
+
async esplora_getbulktransactions(
|
|
52651
|
+
transactionIds: string[],
|
|
52652
|
+
): Promise<BoxedResponse<IEsploraTransaction[], EsploraFetchError>> {
|
|
52653
|
+
try {
|
|
52654
|
+
const requestUrl = `${this.electrumApiUrl}/txs`;
|
|
52655
|
+
|
|
52656
|
+
const httpResponse = await fetch(requestUrl, {
|
|
52657
|
+
method: "POST",
|
|
52658
|
+
headers: { "Content-Type": "application/json" },
|
|
52659
|
+
body: JSON.stringify({ txs: transactionIds }),
|
|
52660
|
+
});
|
|
52661
|
+
|
|
52662
|
+
if (!httpResponse.ok) {
|
|
52663
|
+
return new BoxedError(
|
|
52664
|
+
EsploraFetchError.UnknownError,
|
|
52665
|
+
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`,
|
|
52666
|
+
);
|
|
52667
|
+
}
|
|
52668
|
+
|
|
52669
|
+
const transactions = (await httpResponse.json()) as IEsploraTransaction[];
|
|
52670
|
+
return new BoxedSuccess(transactions);
|
|
52671
|
+
|
|
52672
|
+
|
|
52673
|
+
const txs = await Promise.all(
|
|
52674
|
+
transactionIds.map((txid) => this.esplora_gettransaction(txid)),
|
|
52675
|
+
);
|
|
52676
|
+
|
|
52677
|
+
} catch (error) {
|
|
52678
|
+
return new BoxedError(
|
|
52679
|
+
EsploraFetchError.UnknownError,
|
|
52680
|
+
`Failed to fetch bulk transactions: ${(error as Error).message}`,
|
|
52681
|
+
);
|
|
52682
|
+
}
|
|
52683
|
+
}
|
|
52684
|
+
*/
|
|
52646
52685
|
async esplora_getbulktransactions(transactionIds) {
|
|
52647
52686
|
try {
|
|
52648
|
-
const
|
|
52649
|
-
|
|
52650
|
-
|
|
52651
|
-
|
|
52652
|
-
|
|
52653
|
-
});
|
|
52654
|
-
if (!httpResponse.ok) {
|
|
52655
|
-
return new BoxedError(
|
|
52656
|
-
"UnknownError" /* UnknownError */,
|
|
52657
|
-
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`
|
|
52687
|
+
const allTxs = [];
|
|
52688
|
+
for (let i = 0; i < transactionIds.length; i += 10) {
|
|
52689
|
+
const batch = transactionIds.slice(i, i + 10);
|
|
52690
|
+
const batchResponses = await Promise.all(
|
|
52691
|
+
batch.map((txid) => this.esplora_gettransaction(txid))
|
|
52658
52692
|
);
|
|
52693
|
+
const batchTxs = consumeAll(batchResponses);
|
|
52694
|
+
allTxs.push(...batchTxs);
|
|
52659
52695
|
}
|
|
52660
|
-
|
|
52661
|
-
return new BoxedSuccess(transactions);
|
|
52696
|
+
return new BoxedSuccess(allTxs);
|
|
52662
52697
|
} catch (error) {
|
|
52698
|
+
if (error instanceof BoxedError) {
|
|
52699
|
+
return error;
|
|
52700
|
+
}
|
|
52663
52701
|
return new BoxedError(
|
|
52664
52702
|
"UnknownError" /* UnknownError */,
|
|
52665
52703
|
`Failed to fetch bulk transactions: ${error.message}`
|