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.js
CHANGED
|
@@ -37476,6 +37476,9 @@ var ProtostoneTransaction = class {
|
|
|
37476
37476
|
});
|
|
37477
37477
|
}
|
|
37478
37478
|
try {
|
|
37479
|
+
if (changeValue < 546) {
|
|
37480
|
+
return false;
|
|
37481
|
+
}
|
|
37479
37482
|
hasChange = true;
|
|
37480
37483
|
this.psbt.addOutput({
|
|
37481
37484
|
address: this.changeAddress,
|
|
@@ -42482,23 +42485,58 @@ var ElectrumApiProvider = class {
|
|
|
42482
42485
|
);
|
|
42483
42486
|
}
|
|
42484
42487
|
}
|
|
42488
|
+
/*
|
|
42489
|
+
async esplora_getbulktransactions(
|
|
42490
|
+
transactionIds: string[],
|
|
42491
|
+
): Promise<BoxedResponse<IEsploraTransaction[], EsploraFetchError>> {
|
|
42492
|
+
try {
|
|
42493
|
+
const requestUrl = `${this.electrumApiUrl}/txs`;
|
|
42494
|
+
|
|
42495
|
+
const httpResponse = await fetch(requestUrl, {
|
|
42496
|
+
method: "POST",
|
|
42497
|
+
headers: { "Content-Type": "application/json" },
|
|
42498
|
+
body: JSON.stringify({ txs: transactionIds }),
|
|
42499
|
+
});
|
|
42500
|
+
|
|
42501
|
+
if (!httpResponse.ok) {
|
|
42502
|
+
return new BoxedError(
|
|
42503
|
+
EsploraFetchError.UnknownError,
|
|
42504
|
+
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`,
|
|
42505
|
+
);
|
|
42506
|
+
}
|
|
42507
|
+
|
|
42508
|
+
const transactions = (await httpResponse.json()) as IEsploraTransaction[];
|
|
42509
|
+
return new BoxedSuccess(transactions);
|
|
42510
|
+
|
|
42511
|
+
|
|
42512
|
+
const txs = await Promise.all(
|
|
42513
|
+
transactionIds.map((txid) => this.esplora_gettransaction(txid)),
|
|
42514
|
+
);
|
|
42515
|
+
|
|
42516
|
+
} catch (error) {
|
|
42517
|
+
return new BoxedError(
|
|
42518
|
+
EsploraFetchError.UnknownError,
|
|
42519
|
+
`Failed to fetch bulk transactions: ${(error as Error).message}`,
|
|
42520
|
+
);
|
|
42521
|
+
}
|
|
42522
|
+
}
|
|
42523
|
+
*/
|
|
42485
42524
|
async esplora_getbulktransactions(transactionIds) {
|
|
42486
42525
|
try {
|
|
42487
|
-
const
|
|
42488
|
-
|
|
42489
|
-
|
|
42490
|
-
|
|
42491
|
-
|
|
42492
|
-
});
|
|
42493
|
-
if (!httpResponse.ok) {
|
|
42494
|
-
return new BoxedError(
|
|
42495
|
-
"UnknownError" /* UnknownError */,
|
|
42496
|
-
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`
|
|
42526
|
+
const allTxs = [];
|
|
42527
|
+
for (let i = 0; i < transactionIds.length; i += 10) {
|
|
42528
|
+
const batch = transactionIds.slice(i, i + 10);
|
|
42529
|
+
const batchResponses = await Promise.all(
|
|
42530
|
+
batch.map((txid) => this.esplora_gettransaction(txid))
|
|
42497
42531
|
);
|
|
42532
|
+
const batchTxs = consumeAll(batchResponses);
|
|
42533
|
+
allTxs.push(...batchTxs);
|
|
42498
42534
|
}
|
|
42499
|
-
|
|
42500
|
-
return new BoxedSuccess(transactions);
|
|
42535
|
+
return new BoxedSuccess(allTxs);
|
|
42501
42536
|
} catch (error) {
|
|
42537
|
+
if (error instanceof BoxedError) {
|
|
42538
|
+
return error;
|
|
42539
|
+
}
|
|
42502
42540
|
return new BoxedError(
|
|
42503
42541
|
"UnknownError" /* UnknownError */,
|
|
42504
42542
|
`Failed to fetch bulk transactions: ${error.message}`
|