alkanesjs 1.1.8 → 1.2.0
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 +48 -43
- package/dist/index.browser.mjs.map +2 -2
- package/dist/index.js +48 -43
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37157,19 +37157,21 @@ var ProtostoneTransactionWithInscription = class {
|
|
|
37157
37157
|
commitTxInput.index
|
|
37158
37158
|
)
|
|
37159
37159
|
};
|
|
37160
|
-
|
|
37160
|
+
let dry = await getDummyProtostoneTransaction(this.changeAddress, {
|
|
37161
37161
|
...this.opts,
|
|
37162
37162
|
includeInputs: [commitTxInputOption],
|
|
37163
37163
|
availableUtxoTweak: this.utxoTweak,
|
|
37164
|
-
feeRate: this.baseFeeRate +
|
|
37164
|
+
feeRate: this.baseFeeRate + 1
|
|
37165
37165
|
});
|
|
37166
37166
|
if (isBoxedError(dry)) throw new Error(dry.message);
|
|
37167
|
+
const witnessWeight = this.script.length * 1;
|
|
37168
|
+
dry.data.feeOpts.vsize += Math.ceil(witnessWeight / 4);
|
|
37167
37169
|
this.revealBuilder = new ProtostoneTransaction(this.changeAddress, {
|
|
37168
37170
|
...this.opts,
|
|
37169
37171
|
includeInputs: [commitTxInputOption],
|
|
37170
37172
|
availableUtxoTweak: this.utxoTweak,
|
|
37171
37173
|
feeOpts: dry.data.feeOpts,
|
|
37172
|
-
feeRate: this.baseFeeRate +
|
|
37174
|
+
feeRate: this.baseFeeRate + 1
|
|
37173
37175
|
});
|
|
37174
37176
|
await this.revealBuilder.build();
|
|
37175
37177
|
this.revealPsbt = this.revealBuilder.getPsbt();
|
|
@@ -42485,64 +42487,67 @@ var ElectrumApiProvider = class {
|
|
|
42485
42487
|
);
|
|
42486
42488
|
}
|
|
42487
42489
|
}
|
|
42490
|
+
async esplora_getbulktransactions(transactionIds) {
|
|
42491
|
+
try {
|
|
42492
|
+
const requestUrl = `${this.electrumApiUrl}/txs`;
|
|
42493
|
+
const httpResponse = await fetch(requestUrl, {
|
|
42494
|
+
method: "POST",
|
|
42495
|
+
headers: { "Content-Type": "application/json" },
|
|
42496
|
+
body: JSON.stringify({ txs: transactionIds })
|
|
42497
|
+
});
|
|
42498
|
+
if (!httpResponse.ok) {
|
|
42499
|
+
return new BoxedError(
|
|
42500
|
+
"UnknownError" /* UnknownError */,
|
|
42501
|
+
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`
|
|
42502
|
+
);
|
|
42503
|
+
}
|
|
42504
|
+
const transactions = await httpResponse.json();
|
|
42505
|
+
return new BoxedSuccess(transactions);
|
|
42506
|
+
const txs = await Promise.all(
|
|
42507
|
+
transactionIds.map((txid) => this.esplora_gettransaction(txid))
|
|
42508
|
+
);
|
|
42509
|
+
} catch (error) {
|
|
42510
|
+
return new BoxedError(
|
|
42511
|
+
"UnknownError" /* UnknownError */,
|
|
42512
|
+
`Failed to fetch bulk transactions: ${error.message}`
|
|
42513
|
+
);
|
|
42514
|
+
}
|
|
42515
|
+
}
|
|
42488
42516
|
/*
|
|
42489
42517
|
async esplora_getbulktransactions(
|
|
42490
42518
|
transactionIds: string[],
|
|
42491
42519
|
): Promise<BoxedResponse<IEsploraTransaction[], EsploraFetchError>> {
|
|
42492
42520
|
try {
|
|
42493
|
-
const
|
|
42521
|
+
const allTxs: IEsploraTransaction[] = [];
|
|
42494
42522
|
|
|
42495
|
-
|
|
42496
|
-
|
|
42497
|
-
|
|
42498
|
-
body: JSON.stringify({ txs: transactionIds }),
|
|
42499
|
-
});
|
|
42523
|
+
// ‑‑ process in batches of 10 ------------------------------------------------
|
|
42524
|
+
for (let i = 0; i < transactionIds.length; i += 10) {
|
|
42525
|
+
const batch = transactionIds.slice(i, i + 10);
|
|
42500
42526
|
|
|
42501
|
-
|
|
42502
|
-
|
|
42503
|
-
|
|
42504
|
-
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`,
|
|
42527
|
+
// run the 10 requests in parallel
|
|
42528
|
+
const batchResponses = await Promise.all(
|
|
42529
|
+
batch.map((txid) => this.esplora_gettransaction(txid)),
|
|
42505
42530
|
);
|
|
42506
|
-
}
|
|
42507
42531
|
|
|
42508
|
-
const transactions = (await httpResponse.json()) as IEsploraTransaction[];
|
|
42509
|
-
return new BoxedSuccess(transactions);
|
|
42510
|
-
|
|
42511
42532
|
|
|
42512
|
-
|
|
42513
|
-
|
|
42514
|
-
|
|
42533
|
+
const batchTxs = consumeAll(batchResponses); // IEsploraTransaction[]
|
|
42534
|
+
allTxs.push(...batchTxs);
|
|
42535
|
+
}
|
|
42515
42536
|
|
|
42537
|
+
return new BoxedSuccess(allTxs);
|
|
42516
42538
|
} catch (error) {
|
|
42539
|
+
// if consumeAll returns/throws a BoxedError we land here ⬇
|
|
42540
|
+
if (error instanceof BoxedError) {
|
|
42541
|
+
return error;
|
|
42542
|
+
}
|
|
42543
|
+
|
|
42517
42544
|
return new BoxedError(
|
|
42518
42545
|
EsploraFetchError.UnknownError,
|
|
42519
42546
|
`Failed to fetch bulk transactions: ${(error as Error).message}`,
|
|
42520
42547
|
);
|
|
42521
42548
|
}
|
|
42522
42549
|
}
|
|
42523
|
-
|
|
42524
|
-
async esplora_getbulktransactions(transactionIds) {
|
|
42525
|
-
try {
|
|
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))
|
|
42531
|
-
);
|
|
42532
|
-
const batchTxs = consumeAll(batchResponses);
|
|
42533
|
-
allTxs.push(...batchTxs);
|
|
42534
|
-
}
|
|
42535
|
-
return new BoxedSuccess(allTxs);
|
|
42536
|
-
} catch (error) {
|
|
42537
|
-
if (error instanceof BoxedError) {
|
|
42538
|
-
return error;
|
|
42539
|
-
}
|
|
42540
|
-
return new BoxedError(
|
|
42541
|
-
"UnknownError" /* UnknownError */,
|
|
42542
|
-
`Failed to fetch bulk transactions: ${error.message}`
|
|
42543
|
-
);
|
|
42544
|
-
}
|
|
42545
|
-
}
|
|
42550
|
+
*/
|
|
42546
42551
|
async esplora_gettransaction(transactionId) {
|
|
42547
42552
|
try {
|
|
42548
42553
|
const requestUrl = `${this.electrumApiUrl}/tx/${transactionId}`;
|