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.browser.mjs
CHANGED
|
@@ -47226,19 +47226,21 @@ var ProtostoneTransactionWithInscription = class {
|
|
|
47226
47226
|
commitTxInput.index
|
|
47227
47227
|
)
|
|
47228
47228
|
};
|
|
47229
|
-
|
|
47229
|
+
let dry = await getDummyProtostoneTransaction(this.changeAddress, {
|
|
47230
47230
|
...this.opts,
|
|
47231
47231
|
includeInputs: [commitTxInputOption],
|
|
47232
47232
|
availableUtxoTweak: this.utxoTweak,
|
|
47233
|
-
feeRate: this.baseFeeRate +
|
|
47233
|
+
feeRate: this.baseFeeRate + 1
|
|
47234
47234
|
});
|
|
47235
47235
|
if (isBoxedError(dry)) throw new Error(dry.message);
|
|
47236
|
+
const witnessWeight = this.script.length * 1;
|
|
47237
|
+
dry.data.feeOpts.vsize += Math.ceil(witnessWeight / 4);
|
|
47236
47238
|
this.revealBuilder = new ProtostoneTransaction(this.changeAddress, {
|
|
47237
47239
|
...this.opts,
|
|
47238
47240
|
includeInputs: [commitTxInputOption],
|
|
47239
47241
|
availableUtxoTweak: this.utxoTweak,
|
|
47240
47242
|
feeOpts: dry.data.feeOpts,
|
|
47241
|
-
feeRate: this.baseFeeRate +
|
|
47243
|
+
feeRate: this.baseFeeRate + 1
|
|
47242
47244
|
});
|
|
47243
47245
|
await this.revealBuilder.build();
|
|
47244
47246
|
this.revealPsbt = this.revealBuilder.getPsbt();
|
|
@@ -52646,64 +52648,67 @@ var ElectrumApiProvider = class {
|
|
|
52646
52648
|
);
|
|
52647
52649
|
}
|
|
52648
52650
|
}
|
|
52651
|
+
async esplora_getbulktransactions(transactionIds) {
|
|
52652
|
+
try {
|
|
52653
|
+
const requestUrl = `${this.electrumApiUrl}/txs`;
|
|
52654
|
+
const httpResponse = await fetch(requestUrl, {
|
|
52655
|
+
method: "POST",
|
|
52656
|
+
headers: { "Content-Type": "application/json" },
|
|
52657
|
+
body: JSON.stringify({ txs: transactionIds })
|
|
52658
|
+
});
|
|
52659
|
+
if (!httpResponse.ok) {
|
|
52660
|
+
return new BoxedError(
|
|
52661
|
+
"UnknownError" /* UnknownError */,
|
|
52662
|
+
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`
|
|
52663
|
+
);
|
|
52664
|
+
}
|
|
52665
|
+
const transactions = await httpResponse.json();
|
|
52666
|
+
return new BoxedSuccess(transactions);
|
|
52667
|
+
const txs = await Promise.all(
|
|
52668
|
+
transactionIds.map((txid) => this.esplora_gettransaction(txid))
|
|
52669
|
+
);
|
|
52670
|
+
} catch (error) {
|
|
52671
|
+
return new BoxedError(
|
|
52672
|
+
"UnknownError" /* UnknownError */,
|
|
52673
|
+
`Failed to fetch bulk transactions: ${error.message}`
|
|
52674
|
+
);
|
|
52675
|
+
}
|
|
52676
|
+
}
|
|
52649
52677
|
/*
|
|
52650
52678
|
async esplora_getbulktransactions(
|
|
52651
52679
|
transactionIds: string[],
|
|
52652
52680
|
): Promise<BoxedResponse<IEsploraTransaction[], EsploraFetchError>> {
|
|
52653
52681
|
try {
|
|
52654
|
-
const
|
|
52682
|
+
const allTxs: IEsploraTransaction[] = [];
|
|
52655
52683
|
|
|
52656
|
-
|
|
52657
|
-
|
|
52658
|
-
|
|
52659
|
-
body: JSON.stringify({ txs: transactionIds }),
|
|
52660
|
-
});
|
|
52684
|
+
// ‑‑ process in batches of 10 ------------------------------------------------
|
|
52685
|
+
for (let i = 0; i < transactionIds.length; i += 10) {
|
|
52686
|
+
const batch = transactionIds.slice(i, i + 10);
|
|
52661
52687
|
|
|
52662
|
-
|
|
52663
|
-
|
|
52664
|
-
|
|
52665
|
-
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`,
|
|
52688
|
+
// run the 10 requests in parallel
|
|
52689
|
+
const batchResponses = await Promise.all(
|
|
52690
|
+
batch.map((txid) => this.esplora_gettransaction(txid)),
|
|
52666
52691
|
);
|
|
52667
|
-
}
|
|
52668
52692
|
|
|
52669
|
-
const transactions = (await httpResponse.json()) as IEsploraTransaction[];
|
|
52670
|
-
return new BoxedSuccess(transactions);
|
|
52671
|
-
|
|
52672
52693
|
|
|
52673
|
-
|
|
52674
|
-
|
|
52675
|
-
|
|
52694
|
+
const batchTxs = consumeAll(batchResponses); // IEsploraTransaction[]
|
|
52695
|
+
allTxs.push(...batchTxs);
|
|
52696
|
+
}
|
|
52676
52697
|
|
|
52698
|
+
return new BoxedSuccess(allTxs);
|
|
52677
52699
|
} catch (error) {
|
|
52700
|
+
// if consumeAll returns/throws a BoxedError we land here ⬇
|
|
52701
|
+
if (error instanceof BoxedError) {
|
|
52702
|
+
return error;
|
|
52703
|
+
}
|
|
52704
|
+
|
|
52678
52705
|
return new BoxedError(
|
|
52679
52706
|
EsploraFetchError.UnknownError,
|
|
52680
52707
|
`Failed to fetch bulk transactions: ${(error as Error).message}`,
|
|
52681
52708
|
);
|
|
52682
52709
|
}
|
|
52683
52710
|
}
|
|
52684
|
-
|
|
52685
|
-
async esplora_getbulktransactions(transactionIds) {
|
|
52686
|
-
try {
|
|
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))
|
|
52692
|
-
);
|
|
52693
|
-
const batchTxs = consumeAll(batchResponses);
|
|
52694
|
-
allTxs.push(...batchTxs);
|
|
52695
|
-
}
|
|
52696
|
-
return new BoxedSuccess(allTxs);
|
|
52697
|
-
} catch (error) {
|
|
52698
|
-
if (error instanceof BoxedError) {
|
|
52699
|
-
return error;
|
|
52700
|
-
}
|
|
52701
|
-
return new BoxedError(
|
|
52702
|
-
"UnknownError" /* UnknownError */,
|
|
52703
|
-
`Failed to fetch bulk transactions: ${error.message}`
|
|
52704
|
-
);
|
|
52705
|
-
}
|
|
52706
|
-
}
|
|
52711
|
+
*/
|
|
52707
52712
|
async esplora_gettransaction(transactionId) {
|
|
52708
52713
|
try {
|
|
52709
52714
|
const requestUrl = `${this.electrumApiUrl}/tx/${transactionId}`;
|