@arkade-os/sdk 0.5.5 → 0.5.6
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/adapters/expo.cjs +6 -6
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-BbH-THYJ.d.cts → asyncStorageTaskQueue-Bh2n0msM.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-BlvkJyTa.d.ts → asyncStorageTaskQueue-CpkstKZ5.d.ts} +2 -2
- package/dist/{chunk-BCA6D255.js → chunk-47Z4LEIW.js} +3 -3
- package/dist/{chunk-BCA6D255.js.map → chunk-47Z4LEIW.js.map} +1 -1
- package/dist/{chunk-HQQ4NRXI.cjs → chunk-4X67IB2V.cjs} +15 -15
- package/dist/{chunk-HQQ4NRXI.cjs.map → chunk-4X67IB2V.cjs.map} +1 -1
- package/dist/{chunk-7GIKLFHC.js → chunk-C7NY6WSA.js} +3 -3
- package/dist/{chunk-7GIKLFHC.js.map → chunk-C7NY6WSA.js.map} +1 -1
- package/dist/{chunk-CE46RS6L.js → chunk-DJYX73W2.js} +4 -4
- package/dist/{chunk-CE46RS6L.js.map → chunk-DJYX73W2.js.map} +1 -1
- package/dist/{chunk-XWUCNMPN.cjs → chunk-HKEPJBTY.cjs} +16 -16
- package/dist/{chunk-XWUCNMPN.cjs.map → chunk-HKEPJBTY.cjs.map} +1 -1
- package/dist/{chunk-KCL5AVML.cjs → chunk-LZAINCGU.cjs} +3 -3
- package/dist/{chunk-KCL5AVML.cjs.map → chunk-LZAINCGU.cjs.map} +1 -1
- package/dist/{chunk-AMH7Q3DF.cjs → chunk-NDQ4LB4X.cjs} +8 -8
- package/dist/{chunk-AMH7Q3DF.cjs.map → chunk-NDQ4LB4X.cjs.map} +1 -1
- package/dist/{chunk-4I53THL6.js → chunk-QTMK34TP.js} +3 -3
- package/dist/{chunk-4I53THL6.js.map → chunk-QTMK34TP.js.map} +1 -1
- package/dist/{chunk-FVVXCDNE.js → chunk-VWW2ZBPI.js} +4 -4
- package/dist/{chunk-FVVXCDNE.js.map → chunk-VWW2ZBPI.js.map} +1 -1
- package/dist/{chunk-T254PXSN.cjs → chunk-Y3CDDPWI.cjs} +454 -443
- package/dist/chunk-Y3CDDPWI.cjs.map +1 -0
- package/dist/{chunk-OO2KEK64.js → chunk-YKT4NAQG.js} +45 -34
- package/dist/chunk-YKT4NAQG.js.map +1 -0
- package/dist/{chunk-5SYUEVJH.cjs → chunk-YS76JSGP.cjs} +10 -10
- package/dist/{chunk-5SYUEVJH.cjs.map → chunk-YS76JSGP.cjs.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +2 -2
- package/dist/contracts/handlers/index.d.ts +2 -2
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{index-Bx-iArDs.d.ts → index-2wKMrT0a.d.ts} +1 -1
- package/dist/{index-BWwVnJhU.d.cts → index-46g577Ka.d.cts} +1 -1
- package/dist/{index-DCml4QJn.d.ts → index-C66rjxz2.d.ts} +25 -25
- package/dist/{index-DkyzIzKL.d.cts → index-Dqk07NwJ.d.cts} +25 -25
- package/dist/index.cjs +311 -311
- package/dist/index.d.cts +23 -23
- package/dist/index.d.ts +23 -23
- package/dist/index.js +4 -4
- package/dist/{keyringDescriptorProvider-CS4w4PWd.d.ts → keyringDescriptorProvider-DiBM4GmB.d.ts} +9 -9
- package/dist/{keyringDescriptorProvider-CmHXrIXd.d.cts → keyringDescriptorProvider-DnaLUC7v.d.cts} +9 -9
- package/dist/repositories/realm/index.cjs +37 -37
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +6 -6
- package/dist/repositories/realm/index.d.ts +6 -6
- package/dist/repositories/realm/index.js +6 -6
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +35 -35
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +6 -6
- package/dist/repositories/sqlite/index.d.ts +6 -6
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-DgMLSk_O.d.ts → taskRunner-BM6IAKlS.d.ts} +2 -2
- package/dist/{taskRunner-buh6aFpG.d.cts → taskRunner-BmDIZiSl.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +15 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +6 -6
- package/dist/wallet/expo/index.d.ts +6 -6
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-OO2KEK64.js.map +0 -1
- package/dist/chunk-T254PXSN.cjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkX6ZI53DZ_cjs = require('./chunk-X6ZI53DZ.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkHKEPJBTY_cjs = require('./chunk-HKEPJBTY.cjs');
|
|
5
|
+
var chunkNDQ4LB4X_cjs = require('./chunk-NDQ4LB4X.cjs');
|
|
6
6
|
var chunkJFJNB7ZH_cjs = require('./chunk-JFJNB7ZH.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkLZAINCGU_cjs = require('./chunk-LZAINCGU.cjs');
|
|
8
8
|
var chunkFLPWNMX3_cjs = require('./chunk-FLPWNMX3.cjs');
|
|
9
9
|
var bip39 = require('@scure/bip39');
|
|
10
10
|
var english_js = require('@scure/bip39/wordlists/english.js');
|
|
@@ -325,7 +325,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
325
325
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
326
326
|
const tx = this.graph.find(txid);
|
|
327
327
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
328
|
-
const cosigners =
|
|
328
|
+
const cosigners = chunkLZAINCGU_cjs.getArkPsbtFields(tx.root, 0, chunkLZAINCGU_cjs.CosignerPublicKey).map(
|
|
329
329
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
330
330
|
// xonly pubkey
|
|
331
331
|
);
|
|
@@ -377,7 +377,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
377
377
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
378
378
|
const prevoutAmounts = [];
|
|
379
379
|
const prevoutScripts = [];
|
|
380
|
-
const cosigners =
|
|
380
|
+
const cosigners = chunkLZAINCGU_cjs.getArkPsbtFields(g.root, 0, chunkLZAINCGU_cjs.CosignerPublicKey).map((c) => c.key);
|
|
381
381
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
382
382
|
taprootTweak: this.scriptRoot
|
|
383
383
|
});
|
|
@@ -460,7 +460,7 @@ var SingleKey = class _SingleKey {
|
|
|
460
460
|
async sign(tx, inputIndexes) {
|
|
461
461
|
const txCpy = tx.clone();
|
|
462
462
|
if (!inputIndexes) {
|
|
463
|
-
|
|
463
|
+
chunkLZAINCGU_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
464
464
|
try {
|
|
465
465
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
466
466
|
throw new Error("Failed to sign transaction");
|
|
@@ -560,7 +560,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
560
560
|
let network;
|
|
561
561
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
562
562
|
descriptor = opts.descriptor;
|
|
563
|
-
network =
|
|
563
|
+
network = chunkNDQ4LB4X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
564
564
|
} else {
|
|
565
565
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
566
566
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -637,7 +637,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
637
637
|
}
|
|
638
638
|
/** Returns true when `descriptor` is derived from this identity's seed. */
|
|
639
639
|
ownsDescriptor(descriptor) {
|
|
640
|
-
return
|
|
640
|
+
return chunkNDQ4LB4X_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
641
641
|
}
|
|
642
642
|
/**
|
|
643
643
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -676,7 +676,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
676
676
|
}
|
|
677
677
|
// ── internal helpers ─────────────────────────────────────────────
|
|
678
678
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
679
|
-
const network =
|
|
679
|
+
const network = chunkNDQ4LB4X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
680
680
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
681
681
|
if (expansion.isRanged) {
|
|
682
682
|
throw new Error(
|
|
@@ -701,7 +701,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
701
701
|
signTxWithKey(tx, key, inputIndexes) {
|
|
702
702
|
const txCpy = tx.clone();
|
|
703
703
|
if (!inputIndexes) {
|
|
704
|
-
|
|
704
|
+
chunkLZAINCGU_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
705
705
|
try {
|
|
706
706
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
707
707
|
throw new Error("Failed to sign transaction");
|
|
@@ -802,7 +802,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
802
802
|
/** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
|
|
803
803
|
descriptor;
|
|
804
804
|
constructor(descriptor) {
|
|
805
|
-
const network =
|
|
805
|
+
const network = chunkNDQ4LB4X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
806
806
|
let expansion;
|
|
807
807
|
try {
|
|
808
808
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -837,7 +837,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
837
837
|
}
|
|
838
838
|
/** Returns true when `descriptor` derives from this identity's xpub. */
|
|
839
839
|
ownsDescriptor(descriptor) {
|
|
840
|
-
return
|
|
840
|
+
return chunkNDQ4LB4X_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
841
841
|
}
|
|
842
842
|
};
|
|
843
843
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -980,10 +980,10 @@ var DescriptorIdentity = class {
|
|
|
980
980
|
this.base = base;
|
|
981
981
|
}
|
|
982
982
|
async xOnlyPublicKey() {
|
|
983
|
-
return
|
|
983
|
+
return chunkNDQ4LB4X_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
984
984
|
}
|
|
985
985
|
async compressedPublicKey() {
|
|
986
|
-
return
|
|
986
|
+
return chunkNDQ4LB4X_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
987
987
|
}
|
|
988
988
|
async sign(tx, inputIndexes) {
|
|
989
989
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -1043,8 +1043,8 @@ var StaticDescriptorProvider = class _StaticDescriptorProvider {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
isOurs(descriptor) {
|
|
1045
1045
|
try {
|
|
1046
|
-
const normalized =
|
|
1047
|
-
const pubKey =
|
|
1046
|
+
const normalized = chunkNDQ4LB4X_cjs.normalizeToDescriptor(descriptor);
|
|
1047
|
+
const pubKey = chunkNDQ4LB4X_cjs.extractPubKey(normalized);
|
|
1048
1048
|
return pubKey.toLowerCase() === this.pubKeyHex.toLowerCase();
|
|
1049
1049
|
} catch {
|
|
1050
1050
|
return false;
|
|
@@ -1386,7 +1386,7 @@ function unwrapKeyring(provider) {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
function keyOf(descriptor) {
|
|
1388
1388
|
try {
|
|
1389
|
-
return
|
|
1389
|
+
return chunkNDQ4LB4X_cjs.extractPubKey(chunkNDQ4LB4X_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
|
|
1390
1390
|
} catch {
|
|
1391
1391
|
return void 0;
|
|
1392
1392
|
}
|
|
@@ -1477,12 +1477,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
|
1477
1477
|
signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
|
|
1478
1478
|
} : void 0;
|
|
1479
1479
|
const owner = providerOwner ?? identityOwner;
|
|
1480
|
-
if (owner &&
|
|
1480
|
+
if (owner && chunkNDQ4LB4X_cjs.parseHDDescriptor(descriptor)) {
|
|
1481
1481
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
1482
1482
|
}
|
|
1483
1483
|
let key;
|
|
1484
1484
|
try {
|
|
1485
|
-
key =
|
|
1485
|
+
key = chunkNDQ4LB4X_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1486
1486
|
} catch {
|
|
1487
1487
|
throw new ForeignDescriptorError(descriptor);
|
|
1488
1488
|
}
|
|
@@ -1535,14 +1535,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
var PREIMAGE_INDEX = 0;
|
|
1537
1537
|
function isPerArtifactDescriptor(descriptor) {
|
|
1538
|
-
return
|
|
1538
|
+
return chunkNDQ4LB4X_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1539
1539
|
}
|
|
1540
1540
|
async function provisionDescriptor(wallet) {
|
|
1541
1541
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1542
|
-
return allocated ?? await
|
|
1542
|
+
return allocated ?? await chunkNDQ4LB4X_cjs.identityDescriptor(wallet.identity);
|
|
1543
1543
|
}
|
|
1544
1544
|
async function provisionRefundKey(wallet) {
|
|
1545
|
-
const descriptorPromise =
|
|
1545
|
+
const descriptorPromise = chunkNDQ4LB4X_cjs.identityDescriptor(wallet.identity);
|
|
1546
1546
|
const identityPubkeyPromise = wallet.identity.xOnlyPublicKey();
|
|
1547
1547
|
void identityPubkeyPromise.catch(() => void 0);
|
|
1548
1548
|
const descriptor = await descriptorPromise;
|
|
@@ -1605,7 +1605,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1605
1605
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1606
1606
|
let expected;
|
|
1607
1607
|
try {
|
|
1608
|
-
expected =
|
|
1608
|
+
expected = chunkNDQ4LB4X_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1609
1609
|
} catch (cause) {
|
|
1610
1610
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1611
1611
|
}
|
|
@@ -1687,7 +1687,7 @@ function debugLog(debug, ...args) {
|
|
|
1687
1687
|
}
|
|
1688
1688
|
function normalizeOptions(pathOrOptions) {
|
|
1689
1689
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
1690
|
-
|
|
1690
|
+
chunkLZAINCGU_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
1691
1691
|
return {
|
|
1692
1692
|
path: o.path,
|
|
1693
1693
|
updateViaCache: o.updateViaCache ?? "none",
|
|
@@ -1810,14 +1810,14 @@ var RestDelegateProvider = class {
|
|
|
1810
1810
|
*/
|
|
1811
1811
|
async delegate(intent, forfeitTxs, options) {
|
|
1812
1812
|
const url = `${this.url}/v1/delegate`;
|
|
1813
|
-
const response = await
|
|
1813
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(url, {
|
|
1814
1814
|
method: "POST",
|
|
1815
1815
|
headers: {
|
|
1816
1816
|
"Content-Type": "application/json"
|
|
1817
1817
|
},
|
|
1818
1818
|
body: JSON.stringify({
|
|
1819
1819
|
intent: {
|
|
1820
|
-
message:
|
|
1820
|
+
message: chunkLZAINCGU_cjs.Proof.encodeMessage(intent.message),
|
|
1821
1821
|
proof: intent.proof
|
|
1822
1822
|
},
|
|
1823
1823
|
forfeit_txs: forfeitTxs,
|
|
@@ -1836,7 +1836,7 @@ var RestDelegateProvider = class {
|
|
|
1836
1836
|
*/
|
|
1837
1837
|
async getDelegateInfo() {
|
|
1838
1838
|
const url = `${this.url}/v1/delegator/info`;
|
|
1839
|
-
const response = await
|
|
1839
|
+
const response = await chunkLZAINCGU_cjs.rateGate.runHttp(url, () => chunkLZAINCGU_cjs.baseFetch(url));
|
|
1840
1840
|
if (!response.ok) {
|
|
1841
1841
|
const errorText2 = await response.text();
|
|
1842
1842
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1893,7 +1893,7 @@ async function collectPages(read) {
|
|
|
1893
1893
|
}
|
|
1894
1894
|
|
|
1895
1895
|
// src/repositories/intentRepository.ts
|
|
1896
|
-
var
|
|
1896
|
+
var ALL_BATCH_REGISTRATION_STATES = [
|
|
1897
1897
|
"waiting_to_submit",
|
|
1898
1898
|
"waiting_for_batch",
|
|
1899
1899
|
"batch_in_progress",
|
|
@@ -1909,7 +1909,7 @@ var BATCH_REGISTRATION_TERMINAL_STATES = /* @__PURE__ */ new Set([
|
|
|
1909
1909
|
function isTerminalBatchRegistrationState(s) {
|
|
1910
1910
|
return BATCH_REGISTRATION_TERMINAL_STATES.has(s);
|
|
1911
1911
|
}
|
|
1912
|
-
var
|
|
1912
|
+
var collectBatchRegistrations = (repository, filter) => collectPages((page) => repository.getBatchRegistrationsPage(filter, page));
|
|
1913
1913
|
function assertIntentIdUnique(intent, existing) {
|
|
1914
1914
|
if (intent.registrationId === void 0) return;
|
|
1915
1915
|
for (const e of existing) {
|
|
@@ -1941,7 +1941,7 @@ function intentMatchesFilter(i, f) {
|
|
|
1941
1941
|
}
|
|
1942
1942
|
var isTerminalIntentState = isTerminalBatchRegistrationState;
|
|
1943
1943
|
var INTENT_TERMINAL_STATES = BATCH_REGISTRATION_TERMINAL_STATES;
|
|
1944
|
-
var
|
|
1944
|
+
var collectIntents = collectBatchRegistrations;
|
|
1945
1945
|
|
|
1946
1946
|
// src/repositories/contractRepository.ts
|
|
1947
1947
|
function contractFilterMatchesNothing(filter) {
|
|
@@ -1973,7 +1973,7 @@ var EsploraProvider = class {
|
|
|
1973
1973
|
*/
|
|
1974
1974
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1975
1975
|
async getCoins(address) {
|
|
1976
|
-
const response = await
|
|
1976
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1977
1977
|
if (!response.ok) {
|
|
1978
1978
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1979
1979
|
}
|
|
@@ -1982,12 +1982,12 @@ var EsploraProvider = class {
|
|
|
1982
1982
|
async getFeeRate() {
|
|
1983
1983
|
let url = `${this.baseUrl}/fee-estimates`;
|
|
1984
1984
|
let key = "1";
|
|
1985
|
-
let response = await
|
|
1985
|
+
let response = await chunkLZAINCGU_cjs.baseFetch(url);
|
|
1986
1986
|
if (response.status === 404) {
|
|
1987
1987
|
await response.body?.cancel();
|
|
1988
1988
|
url = `${this.baseUrl}/v1/fees/recommended`;
|
|
1989
1989
|
key = "fastestFee";
|
|
1990
|
-
response = await
|
|
1990
|
+
response = await chunkLZAINCGU_cjs.baseFetch(url);
|
|
1991
1991
|
}
|
|
1992
1992
|
if (response.status === 404) {
|
|
1993
1993
|
await response.body?.cancel();
|
|
@@ -2024,7 +2024,7 @@ var EsploraProvider = class {
|
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
2026
|
async getTxOutspends(txid) {
|
|
2027
|
-
const response = await
|
|
2027
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
2028
2028
|
if (!response.ok) {
|
|
2029
2029
|
const error = await response.text();
|
|
2030
2030
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -2032,7 +2032,7 @@ var EsploraProvider = class {
|
|
|
2032
2032
|
return response.json();
|
|
2033
2033
|
}
|
|
2034
2034
|
async getTransactions(address) {
|
|
2035
|
-
const response = await
|
|
2035
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
2036
2036
|
if (!response.ok) {
|
|
2037
2037
|
const error = await response.text();
|
|
2038
2038
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -2041,14 +2041,14 @@ var EsploraProvider = class {
|
|
|
2041
2041
|
}
|
|
2042
2042
|
/** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
|
|
2043
2043
|
async getAddressStats(address) {
|
|
2044
|
-
const response = await
|
|
2044
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
2045
2045
|
if (!response.ok) {
|
|
2046
2046
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
2047
2047
|
}
|
|
2048
2048
|
return response.json();
|
|
2049
2049
|
}
|
|
2050
2050
|
async getRawTransaction(txid) {
|
|
2051
|
-
const response = await
|
|
2051
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
2052
2052
|
if (!response.ok) {
|
|
2053
2053
|
const error = await response.text();
|
|
2054
2054
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -2056,7 +2056,7 @@ var EsploraProvider = class {
|
|
|
2056
2056
|
return base.hex.decode((await response.text()).trim());
|
|
2057
2057
|
}
|
|
2058
2058
|
async getTxStatus(txid) {
|
|
2059
|
-
const txresponse = await
|
|
2059
|
+
const txresponse = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
2060
2060
|
if (!txresponse.ok) {
|
|
2061
2061
|
throw new Error(txresponse.statusText);
|
|
2062
2062
|
}
|
|
@@ -2064,7 +2064,7 @@ var EsploraProvider = class {
|
|
|
2064
2064
|
if (!tx.status.confirmed) {
|
|
2065
2065
|
return { confirmed: false };
|
|
2066
2066
|
}
|
|
2067
|
-
const response = await
|
|
2067
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
2068
2068
|
if (!response.ok) {
|
|
2069
2069
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
2070
2070
|
}
|
|
@@ -2338,9 +2338,9 @@ var EsploraProvider = class {
|
|
|
2338
2338
|
return { subscribers, teardown, started };
|
|
2339
2339
|
}
|
|
2340
2340
|
async getChainTip() {
|
|
2341
|
-
let tipBlocks = await
|
|
2341
|
+
let tipBlocks = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2342
2342
|
if (tipBlocks.status === 404) {
|
|
2343
|
-
tipBlocks = await
|
|
2343
|
+
tipBlocks = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2344
2344
|
}
|
|
2345
2345
|
if (!tipBlocks.ok) {
|
|
2346
2346
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2364,7 +2364,7 @@ var EsploraProvider = class {
|
|
|
2364
2364
|
if (!Number.isInteger(height) || height < 0) {
|
|
2365
2365
|
throw new Error(`Invalid block height for median-time-past: ${height}`);
|
|
2366
2366
|
}
|
|
2367
|
-
const hashResponse = await
|
|
2367
|
+
const hashResponse = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/block-height/${height}`);
|
|
2368
2368
|
if (!hashResponse.ok) {
|
|
2369
2369
|
throw new Error(
|
|
2370
2370
|
`Failed to get block hash at height ${height}: ${hashResponse.statusText}`
|
|
@@ -2372,7 +2372,7 @@ var EsploraProvider = class {
|
|
|
2372
2372
|
}
|
|
2373
2373
|
const hash = (await hashResponse.text()).trim();
|
|
2374
2374
|
if (!hash) throw new Error(`No block hash returned at height ${height}`);
|
|
2375
|
-
const blockResponse = await
|
|
2375
|
+
const blockResponse = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/block/${hash}`);
|
|
2376
2376
|
if (!blockResponse.ok) {
|
|
2377
2377
|
throw new Error(`Failed to get block ${hash}: ${blockResponse.statusText}`);
|
|
2378
2378
|
}
|
|
@@ -2383,7 +2383,7 @@ var EsploraProvider = class {
|
|
|
2383
2383
|
return block.mediantime;
|
|
2384
2384
|
}
|
|
2385
2385
|
async broadcastPackage(parent, child) {
|
|
2386
|
-
const response = await
|
|
2386
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2387
2387
|
method: "POST",
|
|
2388
2388
|
headers: {
|
|
2389
2389
|
"Content-Type": "application/json"
|
|
@@ -2399,7 +2399,7 @@ var EsploraProvider = class {
|
|
|
2399
2399
|
return result;
|
|
2400
2400
|
}
|
|
2401
2401
|
async broadcastTx(tx) {
|
|
2402
|
-
const response = await
|
|
2402
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2403
2403
|
method: "POST",
|
|
2404
2404
|
headers: {
|
|
2405
2405
|
"Content-Type": "text/plain"
|
|
@@ -2571,7 +2571,7 @@ function findP2AOutput(tx) {
|
|
|
2571
2571
|
var CHILD_DUST_AMOUNT = 546;
|
|
2572
2572
|
function buildAnchorChild(params) {
|
|
2573
2573
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2574
|
-
const child = new
|
|
2574
|
+
const child = new chunkLZAINCGU_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2575
2575
|
const anchor = findP2AOutput(parent);
|
|
2576
2576
|
child.addInput(anchor);
|
|
2577
2577
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
@@ -2620,7 +2620,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2620
2620
|
);
|
|
2621
2621
|
}
|
|
2622
2622
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2623
|
-
const tx = new
|
|
2623
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({
|
|
2624
2624
|
version: 3,
|
|
2625
2625
|
lockTime: txLocktime
|
|
2626
2626
|
});
|
|
@@ -2647,7 +2647,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
|
|
|
2647
2647
|
connectorsGraph.validate();
|
|
2648
2648
|
if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
|
|
2649
2649
|
const rootInput = connectorsGraph.root.getInput(0);
|
|
2650
|
-
const settlementTx =
|
|
2650
|
+
const settlementTx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
|
|
2651
2651
|
if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
|
|
2652
2652
|
throw ErrInvalidSettlementTxOutputs;
|
|
2653
2653
|
const expectedRootTxid = settlementTx.id;
|
|
@@ -2696,7 +2696,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2696
2696
|
if (previousScriptKey.length !== 32) {
|
|
2697
2697
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2698
2698
|
}
|
|
2699
|
-
const cosigners =
|
|
2699
|
+
const cosigners = chunkLZAINCGU_cjs.getArkPsbtFields(child.root, 0, chunkLZAINCGU_cjs.CosignerPublicKey);
|
|
2700
2700
|
if (cosigners.length === 0) {
|
|
2701
2701
|
throw ErrMissingCosignersPublicKeys;
|
|
2702
2702
|
}
|
|
@@ -2754,7 +2754,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2754
2754
|
return new _EmulatorPacket(entries);
|
|
2755
2755
|
}
|
|
2756
2756
|
static fromBytes(data) {
|
|
2757
|
-
const reader = new
|
|
2757
|
+
const reader = new chunkHKEPJBTY_cjs.BufferReader(data);
|
|
2758
2758
|
const entryCount = reader.readCompactSize();
|
|
2759
2759
|
const entries = [];
|
|
2760
2760
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2772,7 +2772,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2772
2772
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2773
2773
|
}
|
|
2774
2774
|
serialize() {
|
|
2775
|
-
const writer = new
|
|
2775
|
+
const writer = new chunkHKEPJBTY_cjs.BufferWriter();
|
|
2776
2776
|
writer.writeCompactSize(this.entries.length);
|
|
2777
2777
|
for (const entry of this.entries) {
|
|
2778
2778
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2859,7 +2859,7 @@ var Extension = class _Extension {
|
|
|
2859
2859
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2860
2860
|
);
|
|
2861
2861
|
}
|
|
2862
|
-
const reader = new
|
|
2862
|
+
const reader = new chunkHKEPJBTY_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2863
2863
|
const packets = [];
|
|
2864
2864
|
while (reader.remaining() > 0) {
|
|
2865
2865
|
const packetType = reader.readByte();
|
|
@@ -2932,7 +2932,7 @@ var Extension = class _Extension {
|
|
|
2932
2932
|
* getAssetPacket returns the embedded Packet, or null if not present.
|
|
2933
2933
|
*/
|
|
2934
2934
|
getAssetPacket() {
|
|
2935
|
-
return this.packets.find((p) => p instanceof
|
|
2935
|
+
return this.packets.find((p) => p instanceof chunkHKEPJBTY_cjs.Packet) ?? null;
|
|
2936
2936
|
}
|
|
2937
2937
|
/**
|
|
2938
2938
|
* getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
|
|
@@ -2956,8 +2956,8 @@ var Extension = class _Extension {
|
|
|
2956
2956
|
};
|
|
2957
2957
|
function parsePacket(packetType, data) {
|
|
2958
2958
|
switch (packetType) {
|
|
2959
|
-
case
|
|
2960
|
-
return
|
|
2959
|
+
case chunkHKEPJBTY_cjs.Packet.PACKET_TYPE:
|
|
2960
|
+
return chunkHKEPJBTY_cjs.Packet.fromBytes(data);
|
|
2961
2961
|
case EmulatorPacket.PACKET_TYPE:
|
|
2962
2962
|
return EmulatorPacket.fromBytes(data);
|
|
2963
2963
|
default:
|
|
@@ -3004,22 +3004,22 @@ function buildOpReturnScript(data) {
|
|
|
3004
3004
|
}
|
|
3005
3005
|
return script;
|
|
3006
3006
|
}
|
|
3007
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
3008
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
3007
|
+
var ErrOffchainOutputNotFound = (address) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
3008
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3009
3009
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
3010
3010
|
);
|
|
3011
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
3012
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
3011
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
3012
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3013
3013
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
3014
3014
|
);
|
|
3015
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
3016
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
3015
|
+
var ErrOnchainOutputNotFound = (address) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
3016
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3017
3017
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
3018
3018
|
);
|
|
3019
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
3019
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3020
3020
|
`${kind} output ${index} of the proof is not present in what the server built`
|
|
3021
3021
|
);
|
|
3022
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
3022
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3023
3023
|
`offchain output ${index} of the proof cannot be validated: virtual output tree signing did not run`
|
|
3024
3024
|
);
|
|
3025
3025
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -3028,7 +3028,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
3028
3028
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
3029
3029
|
if (!validatedCommitmentTxid) return;
|
|
3030
3030
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
3031
|
-
throw new
|
|
3031
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3032
3032
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
3033
3033
|
);
|
|
3034
3034
|
}
|
|
@@ -3059,7 +3059,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
3059
3059
|
}
|
|
3060
3060
|
}
|
|
3061
3061
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
3062
|
-
const proof =
|
|
3062
|
+
const proof = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
3063
3063
|
const onchain = new Set(onchainOutputIndexes);
|
|
3064
3064
|
const declared = [];
|
|
3065
3065
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3351,7 +3351,7 @@ function assetMintResolver() {
|
|
|
3351
3351
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3352
3352
|
const minted = tx.assets.filter((a) => {
|
|
3353
3353
|
try {
|
|
3354
|
-
return base.hex.encode(
|
|
3354
|
+
return base.hex.encode(chunkHKEPJBTY_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3355
3355
|
} catch {
|
|
3356
3356
|
return false;
|
|
3357
3357
|
}
|
|
@@ -3428,7 +3428,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3428
3428
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3429
3429
|
inputsByAssetId.set(asset.assetId, [
|
|
3430
3430
|
...existing ?? [],
|
|
3431
|
-
|
|
3431
|
+
chunkHKEPJBTY_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3432
3432
|
]);
|
|
3433
3433
|
}
|
|
3434
3434
|
}
|
|
@@ -3440,7 +3440,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3440
3440
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3441
3441
|
outputsByAssetId.set(asset.assetId, [
|
|
3442
3442
|
...existing ?? [],
|
|
3443
|
-
|
|
3443
|
+
chunkHKEPJBTY_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3444
3444
|
]);
|
|
3445
3445
|
}
|
|
3446
3446
|
}
|
|
@@ -3451,7 +3451,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3451
3451
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3452
3452
|
outputsByAssetId.set(asset.assetId, [
|
|
3453
3453
|
...existing ?? [],
|
|
3454
|
-
|
|
3454
|
+
chunkHKEPJBTY_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3455
3455
|
]);
|
|
3456
3456
|
}
|
|
3457
3457
|
}
|
|
@@ -3460,11 +3460,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3460
3460
|
for (const assetIdStr of allAssetIds) {
|
|
3461
3461
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3462
3462
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3463
|
-
const assetId =
|
|
3464
|
-
const group =
|
|
3463
|
+
const assetId = chunkHKEPJBTY_cjs.AssetId.fromString(assetIdStr);
|
|
3464
|
+
const group = chunkHKEPJBTY_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3465
3465
|
groups.push(group);
|
|
3466
3466
|
}
|
|
3467
|
-
return
|
|
3467
|
+
return chunkHKEPJBTY_cjs.Packet.create(groups);
|
|
3468
3468
|
}
|
|
3469
3469
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3470
3470
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3595,14 +3595,14 @@ var toTimelock = (value) => ({
|
|
|
3595
3595
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3596
3596
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3597
3597
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3598
|
-
throw new
|
|
3598
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3599
3599
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3600
3600
|
);
|
|
3601
3601
|
}
|
|
3602
3602
|
const seconds = toSeconds(timelock);
|
|
3603
3603
|
if (seconds < policy.minSeconds) {
|
|
3604
3604
|
const remedy = overrideOption ? `; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it` : "";
|
|
3605
|
-
throw new
|
|
3605
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3606
3606
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor${remedy}`
|
|
3607
3607
|
);
|
|
3608
3608
|
}
|
|
@@ -3623,7 +3623,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3623
3623
|
}
|
|
3624
3624
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3625
3625
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3626
|
-
throw new
|
|
3626
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3627
3627
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3628
3628
|
);
|
|
3629
3629
|
}
|
|
@@ -3634,19 +3634,19 @@ function assertValidServerUnrollScript(checkpointTapscript, network, advertisedF
|
|
|
3634
3634
|
try {
|
|
3635
3635
|
script = chunkFLPWNMX3_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3636
3636
|
} catch (e) {
|
|
3637
|
-
throw new
|
|
3637
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3638
3638
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3639
3639
|
);
|
|
3640
3640
|
}
|
|
3641
3641
|
if (advertisedForfeitPubkey !== void 0) {
|
|
3642
3642
|
const { pubkeys } = script.params;
|
|
3643
3643
|
if (pubkeys.length !== 1) {
|
|
3644
|
-
throw new
|
|
3644
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3645
3645
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3646
3646
|
);
|
|
3647
3647
|
}
|
|
3648
3648
|
if (!utils_js.equalBytes(pubkeys[0], advertisedForfeitPubkey)) {
|
|
3649
|
-
throw new
|
|
3649
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3650
3650
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(advertisedForfeitPubkey)}`
|
|
3651
3651
|
);
|
|
3652
3652
|
}
|
|
@@ -3701,7 +3701,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3701
3701
|
}
|
|
3702
3702
|
}
|
|
3703
3703
|
}
|
|
3704
|
-
const tx = new
|
|
3704
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({
|
|
3705
3705
|
version: 3,
|
|
3706
3706
|
lockTime: Number(lockTime)
|
|
3707
3707
|
});
|
|
@@ -3716,7 +3716,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3716
3716
|
},
|
|
3717
3717
|
tapLeafScript: [input.tapLeafScript]
|
|
3718
3718
|
});
|
|
3719
|
-
|
|
3719
|
+
chunkLZAINCGU_cjs.setArkPsbtField(tx, i, chunkLZAINCGU_cjs.VtxoTaprootTree, input.tapTree);
|
|
3720
3720
|
}
|
|
3721
3721
|
for (const output of outputs) {
|
|
3722
3722
|
tx.addOutput(output);
|
|
@@ -3862,7 +3862,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3862
3862
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3863
3863
|
const sig = signature.subarray(0, 64);
|
|
3864
3864
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3865
|
-
const sighashName =
|
|
3865
|
+
const sighashName = chunkLZAINCGU_cjs.formatSighash(sighashType);
|
|
3866
3866
|
throw new Error(
|
|
3867
3867
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3868
3868
|
);
|
|
@@ -3944,16 +3944,16 @@ function isValidArkAddress(address) {
|
|
|
3944
3944
|
}
|
|
3945
3945
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3946
3946
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3947
|
-
throw new
|
|
3947
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3948
3948
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3949
3949
|
);
|
|
3950
3950
|
}
|
|
3951
3951
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3952
3952
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3953
|
-
const server =
|
|
3953
|
+
const server = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3954
3954
|
const local = byTxid.get(server.id);
|
|
3955
3955
|
if (!local) {
|
|
3956
|
-
throw new
|
|
3956
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3957
3957
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3958
3958
|
);
|
|
3959
3959
|
}
|
|
@@ -3963,14 +3963,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3963
3963
|
}
|
|
3964
3964
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3965
3965
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3966
|
-
throw new
|
|
3966
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3967
3967
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3968
3968
|
);
|
|
3969
3969
|
}
|
|
3970
3970
|
if (response.finalArkTx === void 0) return;
|
|
3971
|
-
const finalTxid =
|
|
3971
|
+
const finalTxid = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3972
3972
|
if (finalTxid !== signedArkTx.id) {
|
|
3973
|
-
throw new
|
|
3973
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3974
3974
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3975
3975
|
);
|
|
3976
3976
|
}
|
|
@@ -3989,13 +3989,13 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3989
3989
|
(key) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(key, "leaf key"))
|
|
3990
3990
|
);
|
|
3991
3991
|
} catch (error) {
|
|
3992
|
-
throw new
|
|
3992
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3993
3993
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3994
3994
|
);
|
|
3995
3995
|
}
|
|
3996
3996
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3997
3997
|
if (!signer) {
|
|
3998
|
-
throw new
|
|
3998
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
3999
3999
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
4000
4000
|
);
|
|
4001
4001
|
}
|
|
@@ -4009,7 +4009,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
4009
4009
|
payment_js.tapLeafHash(script)
|
|
4010
4010
|
);
|
|
4011
4011
|
} catch (error) {
|
|
4012
|
-
throw new
|
|
4012
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
4013
4013
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
4014
4014
|
);
|
|
4015
4015
|
}
|
|
@@ -4018,20 +4018,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
4018
4018
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
4019
4019
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
4020
4020
|
if (checkpoint.inputsLength !== 1) {
|
|
4021
|
-
throw new
|
|
4021
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
4022
4022
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
4023
4023
|
);
|
|
4024
4024
|
}
|
|
4025
4025
|
const spent = checkpoint.getInput(0);
|
|
4026
4026
|
if (!spent.txid || spent.index === void 0) {
|
|
4027
|
-
throw new
|
|
4027
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
4028
4028
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
4029
4029
|
);
|
|
4030
4030
|
}
|
|
4031
4031
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
4032
4032
|
const input = byOutpoint.get(outpoint);
|
|
4033
4033
|
if (!input) {
|
|
4034
|
-
throw new
|
|
4034
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
4035
4035
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
4036
4036
|
);
|
|
4037
4037
|
}
|
|
@@ -4039,7 +4039,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
4039
4039
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
4040
4040
|
);
|
|
4041
4041
|
if (!rebuilt) {
|
|
4042
|
-
throw new
|
|
4042
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
4043
4043
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
4044
4044
|
);
|
|
4045
4045
|
}
|
|
@@ -4068,9 +4068,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
4068
4068
|
if (!oneShot) {
|
|
4069
4069
|
matched.forEach(({ server }, index) => {
|
|
4070
4070
|
try {
|
|
4071
|
-
|
|
4071
|
+
chunkLZAINCGU_cjs.assertAllowedSighashTypes(server);
|
|
4072
4072
|
} catch (error) {
|
|
4073
|
-
throw new
|
|
4073
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
4074
4074
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
4075
4075
|
);
|
|
4076
4076
|
}
|
|
@@ -4079,11 +4079,11 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
4079
4079
|
const verify = options?.verifyServerSignatures;
|
|
4080
4080
|
if (verify) {
|
|
4081
4081
|
if (response.finalArkTx === void 0) {
|
|
4082
|
-
throw new
|
|
4082
|
+
throw new chunkLZAINCGU_cjs.ServerResponseMismatchError(
|
|
4083
4083
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
4084
4084
|
);
|
|
4085
4085
|
}
|
|
4086
|
-
const finalArkTx =
|
|
4086
|
+
const finalArkTx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
4087
4087
|
const serverPubkeys = new Set(
|
|
4088
4088
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
4089
4089
|
(key) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(key, "server key"))
|
|
@@ -4134,19 +4134,19 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
4134
4134
|
return result;
|
|
4135
4135
|
}
|
|
4136
4136
|
function carryConditionWitness(ours, server) {
|
|
4137
|
-
if (
|
|
4138
|
-
const [witness] =
|
|
4139
|
-
if (witness)
|
|
4137
|
+
if (chunkLZAINCGU_cjs.getArkPsbtFields(server, 0, chunkLZAINCGU_cjs.ConditionWitness).length > 0) return;
|
|
4138
|
+
const [witness] = chunkLZAINCGU_cjs.getArkPsbtFields(ours, 0, chunkLZAINCGU_cjs.ConditionWitness);
|
|
4139
|
+
if (witness) chunkLZAINCGU_cjs.setArkPsbtField(server, 0, chunkLZAINCGU_cjs.ConditionWitness, witness);
|
|
4140
4140
|
}
|
|
4141
4141
|
function withArkInputWitness(checkpoint, signedArkTx) {
|
|
4142
|
-
if (
|
|
4142
|
+
if (chunkLZAINCGU_cjs.getArkPsbtFields(checkpoint, 0, chunkLZAINCGU_cjs.ConditionWitness).length > 0) return checkpoint;
|
|
4143
4143
|
for (let i = 0; i < signedArkTx.inputsLength; i++) {
|
|
4144
4144
|
const { txid } = signedArkTx.getInput(i);
|
|
4145
4145
|
if (!txid || base.hex.encode(txid) !== checkpoint.id) continue;
|
|
4146
|
-
const [witness] =
|
|
4146
|
+
const [witness] = chunkLZAINCGU_cjs.getArkPsbtFields(signedArkTx, i, chunkLZAINCGU_cjs.ConditionWitness);
|
|
4147
4147
|
if (!witness) return checkpoint;
|
|
4148
4148
|
const carried = checkpoint.clone();
|
|
4149
|
-
|
|
4149
|
+
chunkLZAINCGU_cjs.setArkPsbtField(carried, 0, chunkLZAINCGU_cjs.ConditionWitness, witness);
|
|
4150
4150
|
return carried;
|
|
4151
4151
|
}
|
|
4152
4152
|
return checkpoint;
|
|
@@ -4187,7 +4187,7 @@ async function submitViaEmulator(emulator, offchainTx, signer, opts) {
|
|
|
4187
4187
|
base.base64.encode(arkTx.toPSBT()),
|
|
4188
4188
|
checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
4189
4189
|
);
|
|
4190
|
-
const txid =
|
|
4190
|
+
const txid = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
|
|
4191
4191
|
assertSubmittedArkTxid({ arkTxid: txid }, arkTx, "emulator submitTx");
|
|
4192
4192
|
return { txid, signedArkTx: res.signedArkTx, signedCheckpointTxs: res.signedCheckpointTxs };
|
|
4193
4193
|
}
|
|
@@ -4195,12 +4195,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
4195
4195
|
return {
|
|
4196
4196
|
...identity,
|
|
4197
4197
|
sign: async (tx, inputIndexes) => {
|
|
4198
|
-
const signed =
|
|
4198
|
+
const signed = chunkLZAINCGU_cjs.Transaction.fromPSBT(
|
|
4199
4199
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
4200
4200
|
);
|
|
4201
4201
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
4202
4202
|
for (const index of indexes) {
|
|
4203
|
-
|
|
4203
|
+
chunkLZAINCGU_cjs.setArkPsbtField(signed, index, chunkLZAINCGU_cjs.ConditionWitness, [preimage]);
|
|
4204
4204
|
}
|
|
4205
4205
|
return signed;
|
|
4206
4206
|
}
|
|
@@ -4209,7 +4209,7 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
4209
4209
|
|
|
4210
4210
|
// src/contracts/scope.ts
|
|
4211
4211
|
function scopeOf(contract) {
|
|
4212
|
-
return contract.scope ??
|
|
4212
|
+
return contract.scope ?? chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type)?.defaultScope ?? "offchain";
|
|
4213
4213
|
}
|
|
4214
4214
|
function isOnchainScoped(contract) {
|
|
4215
4215
|
return scopeOf(contract) !== "offchain";
|
|
@@ -4286,9 +4286,9 @@ async function collectScriptVtxos(repository, script, options) {
|
|
|
4286
4286
|
return [...byOutpoint.values()].map((row) => row.vtxo);
|
|
4287
4287
|
}
|
|
4288
4288
|
function unspentScriptVtxos(rows, copies) {
|
|
4289
|
-
const spent = copies.filter((copy) =>
|
|
4289
|
+
const spent = copies.filter((copy) => chunkLZAINCGU_cjs.isVtxoSpent(copy.vtxo));
|
|
4290
4290
|
return rows.filter(
|
|
4291
|
-
(row) => !
|
|
4291
|
+
(row) => !chunkLZAINCGU_cjs.isVtxoSpent(row.vtxo) && !spent.some(
|
|
4292
4292
|
(copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
|
|
4293
4293
|
)
|
|
4294
4294
|
);
|
|
@@ -4345,7 +4345,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
4345
4345
|
};
|
|
4346
4346
|
}
|
|
4347
4347
|
function deriveContractTapscripts(contract) {
|
|
4348
|
-
const handler =
|
|
4348
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
4349
4349
|
if (!handler) {
|
|
4350
4350
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
4351
4351
|
}
|
|
@@ -4548,8 +4548,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
|
|
|
4548
4548
|
}
|
|
4549
4549
|
async function getVtxosForContract(repo, contract, options) {
|
|
4550
4550
|
const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
|
|
4551
|
-
const normalized = vtxos.map(
|
|
4552
|
-
return options?.unspentOnly ? normalized.filter((vtxo) => !
|
|
4551
|
+
const normalized = vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo);
|
|
4552
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !chunkLZAINCGU_cjs.isVtxoSpent(vtxo)) : normalized;
|
|
4553
4553
|
}
|
|
4554
4554
|
async function hasVtxosForContract(repo, contract) {
|
|
4555
4555
|
if (repo.getVtxosForScriptPage) {
|
|
@@ -4631,7 +4631,7 @@ async function saveVtxosForContract(repo, contract, vtxos) {
|
|
|
4631
4631
|
// src/contracts/onchainCoins.ts
|
|
4632
4632
|
var MIGRATED_KEY = "legacyUtxosMigrated";
|
|
4633
4633
|
function createScript(contract) {
|
|
4634
|
-
const handler =
|
|
4634
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
4635
4635
|
if (!handler) throw new Error(`No handler for contract type '${contract.type}'`);
|
|
4636
4636
|
return handler.createScript(contract.params);
|
|
4637
4637
|
}
|
|
@@ -4690,7 +4690,7 @@ async function migrateLegacyUtxos(deps) {
|
|
|
4690
4690
|
let migrated = 0;
|
|
4691
4691
|
for (const contract of await collectContracts(contractRepository)) {
|
|
4692
4692
|
if (!isOnchainScoped(contract)) continue;
|
|
4693
|
-
if (!
|
|
4693
|
+
if (!chunkNDQ4LB4X_cjs.contractHandlers.has(contract.type)) {
|
|
4694
4694
|
console.warn("Skipping legacy utxos of a contract with no handler", contract.type);
|
|
4695
4695
|
continue;
|
|
4696
4696
|
}
|
|
@@ -4716,7 +4716,7 @@ var DEFAULT_COSIGN_MARGIN_BLOCKS = 6;
|
|
|
4716
4716
|
var MAX_COSIGN_INPUTS = 64;
|
|
4717
4717
|
var ONCHAIN_RENEW_WINDOW_BLOCKS = 144;
|
|
4718
4718
|
function exitCsvOf(contract) {
|
|
4719
|
-
const sequence =
|
|
4719
|
+
const sequence = chunkNDQ4LB4X_cjs.exitSequence(contract);
|
|
4720
4720
|
return sequence === void 0 ? void 0 : chunkFLPWNMX3_cjs.sequenceToTimelock(sequence);
|
|
4721
4721
|
}
|
|
4722
4722
|
var ONCHAIN_COSIGN_PREFLIGHT_PREFIX = "Onchain cosign preflight failed: ";
|
|
@@ -4734,7 +4734,7 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
|
|
|
4734
4734
|
tx.updateInput(index, { tapLeafScript: void 0, tapScriptSig: void 0 }, true);
|
|
4735
4735
|
}
|
|
4736
4736
|
const kept = unknown?.filter(
|
|
4737
|
-
(u) =>
|
|
4737
|
+
(u) => chunkLZAINCGU_cjs.VtxoTaprootTree.decode(u) === null && chunkLZAINCGU_cjs.ConditionWitness.decode(u) === null
|
|
4738
4738
|
);
|
|
4739
4739
|
if (kept && kept.length !== unknown.length) {
|
|
4740
4740
|
tx.updateInput(index, { unknown: void 0 }, true);
|
|
@@ -4745,9 +4745,9 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
|
|
|
4745
4745
|
tapLeafScript: [path.leaf],
|
|
4746
4746
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
4747
4747
|
});
|
|
4748
|
-
|
|
4748
|
+
chunkLZAINCGU_cjs.setArkPsbtField(tx, index, chunkLZAINCGU_cjs.VtxoTaprootTree, tapTree);
|
|
4749
4749
|
if (path.extraWitness?.length) {
|
|
4750
|
-
|
|
4750
|
+
chunkLZAINCGU_cjs.setArkPsbtField(tx, index, chunkLZAINCGU_cjs.ConditionWitness, path.extraWitness);
|
|
4751
4751
|
}
|
|
4752
4752
|
}
|
|
4753
4753
|
function emulatorInputIndexes(tx) {
|
|
@@ -4794,7 +4794,7 @@ function isBoardingContract(contract, boardingCsv) {
|
|
|
4794
4794
|
if (!isOnchainScoped(contract)) return false;
|
|
4795
4795
|
if (contract.type === "boarding") return true;
|
|
4796
4796
|
if (contract.type !== "default" || scopeOf(contract) !== "both") return false;
|
|
4797
|
-
return
|
|
4797
|
+
return chunkNDQ4LB4X_cjs.exitSequence(contract) === chunkFLPWNMX3_cjs.timelockToSequence(boardingCsv);
|
|
4798
4798
|
}
|
|
4799
4799
|
function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFAULT_COSIGN_MARGIN_BLOCKS) {
|
|
4800
4800
|
if (!isBoardingContract(contract, boardingCsv) || !isExplorerCoin(coin)) return false;
|
|
@@ -4806,7 +4806,7 @@ function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFA
|
|
|
4806
4806
|
return left.remaining > margin && left.remaining <= margin + window2;
|
|
4807
4807
|
}
|
|
4808
4808
|
function finalizeOwnedInput(tx, index) {
|
|
4809
|
-
const condition =
|
|
4809
|
+
const condition = chunkLZAINCGU_cjs.getArkPsbtFields(tx, index, chunkLZAINCGU_cjs.ConditionWitness)[0];
|
|
4810
4810
|
if (!condition) {
|
|
4811
4811
|
tx.finalizeIdx(index);
|
|
4812
4812
|
return;
|
|
@@ -4829,27 +4829,27 @@ var DEFINITE_COSIGN_REJECTIONS = /* @__PURE__ */ new Set([
|
|
|
4829
4829
|
"TX_TOO_LARGE"
|
|
4830
4830
|
]);
|
|
4831
4831
|
function isCosignRejectedAfterSigning(e) {
|
|
4832
|
-
return e instanceof
|
|
4832
|
+
return e instanceof chunkLZAINCGU_cjs.OnchainCosignRejectedError && !isCosignFallback(e);
|
|
4833
4833
|
}
|
|
4834
4834
|
function isCosignFallback(e) {
|
|
4835
|
-
if (e instanceof
|
|
4835
|
+
if (e instanceof chunkLZAINCGU_cjs.OnchainCosignRejectedError) {
|
|
4836
4836
|
return !!e.arkErrorName && DEFINITE_COSIGN_REJECTIONS.has(e.arkErrorName);
|
|
4837
4837
|
}
|
|
4838
|
-
return e instanceof
|
|
4838
|
+
return e instanceof chunkLZAINCGU_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError;
|
|
4839
4839
|
}
|
|
4840
4840
|
function rehydrateCosignError(e) {
|
|
4841
|
-
if (!(e instanceof Error) || e instanceof
|
|
4841
|
+
if (!(e instanceof Error) || e instanceof chunkLZAINCGU_cjs.OnchainCosignRejectedError || e instanceof chunkLZAINCGU_cjs.OnchainCosignAmbiguousError || e instanceof chunkLZAINCGU_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError) {
|
|
4842
4842
|
return e;
|
|
4843
4843
|
}
|
|
4844
4844
|
const { message } = e;
|
|
4845
|
-
if (message.startsWith(
|
|
4846
|
-
const rest = message.slice(
|
|
4845
|
+
if (message.startsWith(chunkLZAINCGU_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX)) {
|
|
4846
|
+
const rest = message.slice(chunkLZAINCGU_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX.length);
|
|
4847
4847
|
const named = rest.match(/^\[([A-Z0-9_]+)\] ([\s\S]*)$/);
|
|
4848
|
-
return named ? new
|
|
4848
|
+
return named ? new chunkLZAINCGU_cjs.OnchainCosignRejectedError(named[2], named[1]) : new chunkLZAINCGU_cjs.OnchainCosignRejectedError(rest);
|
|
4849
4849
|
}
|
|
4850
|
-
if (message.startsWith(
|
|
4851
|
-
return new
|
|
4852
|
-
message.slice(
|
|
4850
|
+
if (message.startsWith(chunkLZAINCGU_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX)) {
|
|
4851
|
+
return new chunkLZAINCGU_cjs.OnchainCosignAmbiguousError(
|
|
4852
|
+
message.slice(chunkLZAINCGU_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX.length)
|
|
4853
4853
|
);
|
|
4854
4854
|
}
|
|
4855
4855
|
if (message.startsWith(ONCHAIN_COSIGN_PREFLIGHT_PREFIX)) {
|
|
@@ -4857,8 +4857,8 @@ function rehydrateCosignError(e) {
|
|
|
4857
4857
|
message.slice(ONCHAIN_COSIGN_PREFLIGHT_PREFIX.length)
|
|
4858
4858
|
);
|
|
4859
4859
|
}
|
|
4860
|
-
if (message.startsWith(
|
|
4861
|
-
return new
|
|
4860
|
+
if (message.startsWith(chunkLZAINCGU_cjs.ONCHAIN_COSIGN_UNSUPPORTED_PREFIX))
|
|
4861
|
+
return new chunkLZAINCGU_cjs.OnchainCosignUnsupportedError();
|
|
4862
4862
|
return e;
|
|
4863
4863
|
}
|
|
4864
4864
|
function estimateOnchainCosignFee(nIn, nOut, feeRate) {
|
|
@@ -4874,13 +4874,13 @@ async function submitOnchainSpend(tx, arkInputs, deps) {
|
|
|
4874
4874
|
throw new Error("emulator inputs present but no emulator provider configured");
|
|
4875
4875
|
}
|
|
4876
4876
|
const { signedTx } = await deps.emulator.submitOnchainTx(base.base64.encode(tx.toPSBT()));
|
|
4877
|
-
tx =
|
|
4877
|
+
tx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(signedTx));
|
|
4878
4878
|
}
|
|
4879
4879
|
if (arkInputs.size > 0) {
|
|
4880
4880
|
if (!deps.arkProvider) {
|
|
4881
4881
|
throw new Error("arkd-cosigned inputs present but no arkProvider configured");
|
|
4882
4882
|
}
|
|
4883
|
-
if (!deps.arkProvider.cosignOnchainTx) throw new
|
|
4883
|
+
if (!deps.arkProvider.cosignOnchainTx) throw new chunkLZAINCGU_cjs.OnchainCosignUnsupportedError();
|
|
4884
4884
|
return deps.arkProvider.cosignOnchainTx(base.base64.encode(tx.toPSBT()));
|
|
4885
4885
|
}
|
|
4886
4886
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
@@ -5031,7 +5031,7 @@ function parseProgram(text, env) {
|
|
|
5031
5031
|
|
|
5032
5032
|
// src/contracts/spendability.ts
|
|
5033
5033
|
function isContractGenericallySpendable(contract) {
|
|
5034
|
-
return
|
|
5034
|
+
return chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
5035
5035
|
}
|
|
5036
5036
|
function gatedContracts(contracts) {
|
|
5037
5037
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -5053,7 +5053,7 @@ function gateExclusion(gated) {
|
|
|
5053
5053
|
return (vtxo) => {
|
|
5054
5054
|
const type = gatedTypeOf(vtxo, gated);
|
|
5055
5055
|
if (type === void 0) return void 0;
|
|
5056
|
-
if (!
|
|
5056
|
+
if (!chunkNDQ4LB4X_cjs.contractHandlers.has(type)) {
|
|
5057
5057
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
5058
5058
|
}
|
|
5059
5059
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -5089,7 +5089,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
5089
5089
|
continue;
|
|
5090
5090
|
}
|
|
5091
5091
|
for (const v of vtxos) {
|
|
5092
|
-
if (!
|
|
5092
|
+
if (!chunkLZAINCGU_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
5093
5093
|
out.add(`${v.txid}:${v.vout}`);
|
|
5094
5094
|
}
|
|
5095
5095
|
}
|
|
@@ -5131,14 +5131,14 @@ function byValueDescending(vtxos) {
|
|
|
5131
5131
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
5132
5132
|
}
|
|
5133
5133
|
async function fetchTimeHeight(wallet) {
|
|
5134
|
-
return
|
|
5134
|
+
return chunkLZAINCGU_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
5135
5135
|
}
|
|
5136
5136
|
function heldVtxosOf(wallet) {
|
|
5137
5137
|
const held = wallet.getHeldVtxos;
|
|
5138
5138
|
return typeof held === "function" ? held.call(wallet) : Promise.resolve([]);
|
|
5139
5139
|
}
|
|
5140
5140
|
function canMigrateBySend(vtxo, now) {
|
|
5141
|
-
if (!
|
|
5141
|
+
if (!chunkLZAINCGU_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
5142
5142
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
5143
5143
|
}
|
|
5144
5144
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -5146,7 +5146,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
5146
5146
|
if (vtxo.isSwept) return -Infinity;
|
|
5147
5147
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
5148
5148
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
5149
|
-
return
|
|
5149
|
+
return chunkLZAINCGU_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
5150
5150
|
}
|
|
5151
5151
|
return Infinity;
|
|
5152
5152
|
};
|
|
@@ -5173,7 +5173,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
5173
5173
|
const payable = [];
|
|
5174
5174
|
const net = /* @__PURE__ */ new Map();
|
|
5175
5175
|
for (const vtxo of vtxos) {
|
|
5176
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5176
|
+
const inputFee = estimator.evalOffchainInput(chunkLZAINCGU_cjs.toOffchainInputFeeParams(vtxo));
|
|
5177
5177
|
if (inputFee.satoshis >= vtxo.value) {
|
|
5178
5178
|
continue;
|
|
5179
5179
|
}
|
|
@@ -5253,10 +5253,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
5253
5253
|
};
|
|
5254
5254
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
5255
5255
|
return vtxos.filter((vtxo) => {
|
|
5256
|
-
if (
|
|
5256
|
+
if (chunkLZAINCGU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
5257
5257
|
return true;
|
|
5258
5258
|
}
|
|
5259
|
-
if (
|
|
5259
|
+
if (chunkLZAINCGU_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
5260
5260
|
return true;
|
|
5261
5261
|
}
|
|
5262
5262
|
return false;
|
|
@@ -5288,7 +5288,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
5288
5288
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
5289
5289
|
if (vtxo.isUnrolled) return false;
|
|
5290
5290
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
5291
|
-
const expiresAt =
|
|
5291
|
+
const expiresAt = chunkLZAINCGU_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
5292
5292
|
if (expiresAt === void 0) return false;
|
|
5293
5293
|
const now = Date.now();
|
|
5294
5294
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -5299,7 +5299,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
5299
5299
|
return vtxos.filter(
|
|
5300
5300
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
5301
5301
|
// property and would otherwise re-admit an exited coin on its own.
|
|
5302
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
5302
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkLZAINCGU_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
5303
5303
|
);
|
|
5304
5304
|
}
|
|
5305
5305
|
function isMigrationCapable(wallet) {
|
|
@@ -5359,7 +5359,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5359
5359
|
constructor(wallet, settlementConfig) {
|
|
5360
5360
|
this.wallet = wallet;
|
|
5361
5361
|
if (settlementConfig !== false) {
|
|
5362
|
-
|
|
5362
|
+
chunkLZAINCGU_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
|
|
5363
5363
|
}
|
|
5364
5364
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
5365
5365
|
this.contractEventsSubscriptionReady = this.initializeSubscription();
|
|
@@ -5671,7 +5671,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5671
5671
|
* {@link recoverImportedContracts}).
|
|
5672
5672
|
*/
|
|
5673
5673
|
async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
|
|
5674
|
-
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !
|
|
5674
|
+
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkLZAINCGU_cjs.isVtxoSpent(vtxo));
|
|
5675
5675
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
5676
5676
|
const { payable, net } = priceSettlementInputs(recoverable, estimator);
|
|
5677
5677
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
@@ -5693,7 +5693,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5693
5693
|
if (vtxos.length === 0) return;
|
|
5694
5694
|
const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
|
|
5695
5695
|
const stillSpendable = vtxos.some(
|
|
5696
|
-
(vtxo) => !
|
|
5696
|
+
(vtxo) => !chunkLZAINCGU_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
5697
5697
|
);
|
|
5698
5698
|
if (!stillSpendable) {
|
|
5699
5699
|
await wallet.removeRecoveryContract(contract.script);
|
|
@@ -5935,7 +5935,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5935
5935
|
return txid;
|
|
5936
5936
|
} catch (e) {
|
|
5937
5937
|
if (!isCosignFallback(e)) throw e;
|
|
5938
|
-
if (e instanceof
|
|
5938
|
+
if (e instanceof chunkLZAINCGU_cjs.OnchainCosignRejectedError) {
|
|
5939
5939
|
console.warn("Onchain cosign sweep rejected, falling back to CSV exit:", e.message);
|
|
5940
5940
|
}
|
|
5941
5941
|
return void 0;
|
|
@@ -6012,7 +6012,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6012
6012
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
6013
6013
|
);
|
|
6014
6014
|
}
|
|
6015
|
-
const tx = new
|
|
6015
|
+
const tx = new chunkLZAINCGU_cjs.Transaction();
|
|
6016
6016
|
for (const { utxo, script, leaf } of inputs) {
|
|
6017
6017
|
tx.addInput({
|
|
6018
6018
|
txid: utxo.txid,
|
|
@@ -6250,8 +6250,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
6250
6250
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
6251
6251
|
if (cls.status === "CURRENT") continue;
|
|
6252
6252
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
6253
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
6254
|
-
const spendable = live.filter((v) => !
|
|
6253
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkLZAINCGU_cjs.isVtxoSpent(v));
|
|
6254
|
+
const spendable = live.filter((v) => !chunkLZAINCGU_cjs.isVtxoSpent(v) && !v.isSwept);
|
|
6255
6255
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
6256
6256
|
let recoverableCount = 0;
|
|
6257
6257
|
let recoverableValue = 0;
|
|
@@ -6607,8 +6607,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
6607
6607
|
}
|
|
6608
6608
|
/** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
|
|
6609
6609
|
extractSpentOutpoint(error) {
|
|
6610
|
-
const ark =
|
|
6611
|
-
if (!
|
|
6610
|
+
const ark = chunkLZAINCGU_cjs.maybeArkError(error);
|
|
6611
|
+
if (!chunkLZAINCGU_cjs.isArkError(ark, chunkLZAINCGU_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
6612
6612
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
6613
6613
|
if (typeof raw !== "string") return void 0;
|
|
6614
6614
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -6789,7 +6789,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6789
6789
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
6790
6790
|
break;
|
|
6791
6791
|
}
|
|
6792
|
-
const inputFee = estimator.evalOffchainInput(
|
|
6792
|
+
const inputFee = estimator.evalOffchainInput(chunkLZAINCGU_cjs.toOffchainInputFeeParams(v));
|
|
6793
6793
|
if (inputFee.satoshis >= v.value) {
|
|
6794
6794
|
continue;
|
|
6795
6795
|
}
|
|
@@ -7098,7 +7098,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
7098
7098
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
7099
7099
|
}
|
|
7100
7100
|
get vtxoScript() {
|
|
7101
|
-
return new
|
|
7101
|
+
return new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({
|
|
7102
7102
|
pubKey: this._publicKey,
|
|
7103
7103
|
serverPubKey: this._serverPubKey,
|
|
7104
7104
|
csvTimelock: this.csvTimelock
|
|
@@ -7110,14 +7110,12 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
7110
7110
|
};
|
|
7111
7111
|
|
|
7112
7112
|
// src/wallet/intentReconciliation.ts
|
|
7113
|
-
var NON_TERMINAL_INTENT_STATES =
|
|
7114
|
-
(s) => !isTerminalIntentState(s)
|
|
7115
|
-
);
|
|
7113
|
+
var NON_TERMINAL_INTENT_STATES = ALL_BATCH_REGISTRATION_STATES.filter((s) => !isTerminalBatchRegistrationState(s));
|
|
7116
7114
|
function isConsumed(vtxo) {
|
|
7117
|
-
return vtxo !== void 0 &&
|
|
7115
|
+
return vtxo !== void 0 && chunkLZAINCGU_cjs.isVtxoSpent(vtxo);
|
|
7118
7116
|
}
|
|
7119
7117
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
7120
|
-
if (
|
|
7118
|
+
if (isTerminalBatchRegistrationState(intent.state)) return void 0;
|
|
7121
7119
|
const inputs = intent.proofInputs;
|
|
7122
7120
|
const consumed = inputs.map((o) => vtxosByOutpoint.get(outpointKey(o)));
|
|
7123
7121
|
if (inputs.length > 0 && consumed.every(isConsumed)) {
|
|
@@ -7140,7 +7138,7 @@ async function reconcileIntents(deps) {
|
|
|
7140
7138
|
const now = deps.now ?? Date.now;
|
|
7141
7139
|
let intents;
|
|
7142
7140
|
try {
|
|
7143
|
-
intents = await
|
|
7141
|
+
intents = await collectBatchRegistrations(deps.intentRepository, {
|
|
7144
7142
|
states: [...NON_TERMINAL_INTENT_STATES]
|
|
7145
7143
|
});
|
|
7146
7144
|
} catch (e) {
|
|
@@ -7152,7 +7150,7 @@ async function reconcileIntents(deps) {
|
|
|
7152
7150
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
7153
7151
|
if (outpoints.length > 0) {
|
|
7154
7152
|
try {
|
|
7155
|
-
const { vtxos } = await
|
|
7153
|
+
const { vtxos } = await chunkLZAINCGU_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
7156
7154
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
7157
7155
|
} catch (e) {
|
|
7158
7156
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -7165,7 +7163,7 @@ async function reconcileIntents(deps) {
|
|
|
7165
7163
|
if (isInFlight(intent, deps)) continue;
|
|
7166
7164
|
const next = await classifyIntent(intent, vtxosByOutpoint, nowMs) ?? await releaseFromServer(intent, deps, nowMs);
|
|
7167
7165
|
if (!next) continue;
|
|
7168
|
-
const [fresh] = await
|
|
7166
|
+
const [fresh] = await collectBatchRegistrations(deps.intentRepository, {
|
|
7169
7167
|
proofTxIds: [intent.proofTxId]
|
|
7170
7168
|
});
|
|
7171
7169
|
if (!fresh || fresh.state !== intent.state) continue;
|
|
@@ -7178,7 +7176,7 @@ async function reconcileIntents(deps) {
|
|
|
7178
7176
|
async function releaseIntents(deps) {
|
|
7179
7177
|
let intents;
|
|
7180
7178
|
try {
|
|
7181
|
-
intents = await
|
|
7179
|
+
intents = await collectBatchRegistrations(deps.intentRepository, {
|
|
7182
7180
|
states: [...NON_TERMINAL_INTENT_STATES]
|
|
7183
7181
|
});
|
|
7184
7182
|
} catch (e) {
|
|
@@ -7212,7 +7210,7 @@ async function releaseFromServer(intent, deps, now) {
|
|
|
7212
7210
|
});
|
|
7213
7211
|
}
|
|
7214
7212
|
function isNoMatchingIntentsError(e) {
|
|
7215
|
-
return
|
|
7213
|
+
return chunkLZAINCGU_cjs.isArkError(e, chunkLZAINCGU_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
|
|
7216
7214
|
}
|
|
7217
7215
|
function terminal(intent, state, now, patch) {
|
|
7218
7216
|
return { ...intent, ...patch, state, updatedAt: now };
|
|
@@ -7234,7 +7232,7 @@ function dedupeOutpoints(outpoints) {
|
|
|
7234
7232
|
|
|
7235
7233
|
// src/wallet/intentStateReducer.ts
|
|
7236
7234
|
function reduceIntentState(current, event) {
|
|
7237
|
-
if (
|
|
7235
|
+
if (isTerminalBatchRegistrationState(current)) return current;
|
|
7238
7236
|
switch (event.type) {
|
|
7239
7237
|
case "batch_started" /* BatchStarted */:
|
|
7240
7238
|
return "batch_in_progress";
|
|
@@ -7267,7 +7265,7 @@ async function persistTransition(deps, event) {
|
|
|
7267
7265
|
const repo = deps.intentRepository;
|
|
7268
7266
|
if (!repo) return;
|
|
7269
7267
|
try {
|
|
7270
|
-
const cur = (await
|
|
7268
|
+
const cur = (await collectBatchRegistrations(repo, { proofTxIds: [deps.intentTxId] }))[0];
|
|
7271
7269
|
if (!cur) return;
|
|
7272
7270
|
const next = applySettlementEventToIntent(cur, event);
|
|
7273
7271
|
if (next) await repo.saveBatchRegistration(next);
|
|
@@ -7439,7 +7437,7 @@ async function captureExitBranch(params) {
|
|
|
7439
7437
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
7440
7438
|
if (nonCommitment.length > 0) {
|
|
7441
7439
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
7442
|
-
psbtByTxid.set(
|
|
7440
|
+
psbtByTxid.set(chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
7443
7441
|
}
|
|
7444
7442
|
}
|
|
7445
7443
|
}
|
|
@@ -7482,10 +7480,10 @@ var IndexerExitDataSource = class {
|
|
|
7482
7480
|
while (hasMore) {
|
|
7483
7481
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
7484
7482
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
7485
|
-
{ pageIndex, pageSize:
|
|
7483
|
+
{ pageIndex, pageSize: chunkLZAINCGU_cjs.DEFAULT_PAGE_SIZE }
|
|
7486
7484
|
);
|
|
7487
7485
|
chain.push(...page);
|
|
7488
|
-
hasMore = meta ? page.length ===
|
|
7486
|
+
hasMore = meta ? page.length === chunkLZAINCGU_cjs.DEFAULT_PAGE_SIZE : false;
|
|
7489
7487
|
pageIndex++;
|
|
7490
7488
|
}
|
|
7491
7489
|
return chain;
|
|
@@ -7497,12 +7495,12 @@ var IndexerExitDataSource = class {
|
|
|
7497
7495
|
while (hasMore) {
|
|
7498
7496
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
7499
7497
|
pageIndex,
|
|
7500
|
-
pageSize:
|
|
7498
|
+
pageSize: chunkLZAINCGU_cjs.DEFAULT_PAGE_SIZE
|
|
7501
7499
|
});
|
|
7502
7500
|
for (const psbt of txs) {
|
|
7503
|
-
out.set(
|
|
7501
|
+
out.set(chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
7504
7502
|
}
|
|
7505
|
-
hasMore = page ? txs.length ===
|
|
7503
|
+
hasMore = page ? txs.length === chunkLZAINCGU_cjs.DEFAULT_PAGE_SIZE : false;
|
|
7506
7504
|
pageIndex++;
|
|
7507
7505
|
}
|
|
7508
7506
|
return out;
|
|
@@ -7523,7 +7521,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
7523
7521
|
}
|
|
7524
7522
|
}
|
|
7525
7523
|
function psbtInputTxids(psbtBase64) {
|
|
7526
|
-
return txInputTxids(
|
|
7524
|
+
return txInputTxids(chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
|
|
7527
7525
|
}
|
|
7528
7526
|
function txInputTxids(tx) {
|
|
7529
7527
|
const ids = [];
|
|
@@ -7830,10 +7828,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
7830
7828
|
try {
|
|
7831
7829
|
info = await arkProvider.getInfo();
|
|
7832
7830
|
} catch (err) {
|
|
7833
|
-
if (opts?.requireLive || !
|
|
7831
|
+
if (opts?.requireLive || !chunkLZAINCGU_cjs.isRetryableProviderError(err)) throw err;
|
|
7834
7832
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
7835
7833
|
if (!snapshot) {
|
|
7836
|
-
throw new
|
|
7834
|
+
throw new chunkLZAINCGU_cjs.ProviderUnavailableError(
|
|
7837
7835
|
"Operator info is unavailable and no cached snapshot exists",
|
|
7838
7836
|
{ cause: err }
|
|
7839
7837
|
);
|
|
@@ -8025,7 +8023,7 @@ function buildGraph(rootTxid, chunksByTxid) {
|
|
|
8025
8023
|
return new TxTree(rootTx, children);
|
|
8026
8024
|
}
|
|
8027
8025
|
function decodeNode(chunk) {
|
|
8028
|
-
const tx =
|
|
8026
|
+
const tx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
|
|
8029
8027
|
return { tx, children: chunk.children };
|
|
8030
8028
|
}
|
|
8031
8029
|
exports.Batch = void 0;
|
|
@@ -8249,7 +8247,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
8249
8247
|
return [...txids];
|
|
8250
8248
|
}
|
|
8251
8249
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
8252
|
-
const normalized = vtxos.map(
|
|
8250
|
+
const normalized = vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
8253
8251
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
8254
8252
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
8255
8253
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -8436,7 +8434,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8436
8434
|
withRecoverable: false,
|
|
8437
8435
|
genericallySpendableOnly: true
|
|
8438
8436
|
});
|
|
8439
|
-
const controlAssetRef = params.controlAssetId ?
|
|
8437
|
+
const controlAssetRef = params.controlAssetId ? chunkHKEPJBTY_cjs.AssetRef.fromId(chunkHKEPJBTY_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
8440
8438
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
8441
8439
|
let totalBtcSelected = 0n;
|
|
8442
8440
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -8449,8 +8447,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8449
8447
|
}
|
|
8450
8448
|
}
|
|
8451
8449
|
const groups = [];
|
|
8452
|
-
const issuedAssetOutput =
|
|
8453
|
-
const issuedAssetGroup =
|
|
8450
|
+
const issuedAssetOutput = chunkHKEPJBTY_cjs.AssetOutput.create(0, params.amount);
|
|
8451
|
+
const issuedAssetGroup = chunkHKEPJBTY_cjs.AssetGroup.create(
|
|
8454
8452
|
null,
|
|
8455
8453
|
controlAssetRef,
|
|
8456
8454
|
[],
|
|
@@ -8463,11 +8461,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8463
8461
|
for (const [assetId, amount] of assetChanges) {
|
|
8464
8462
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
8465
8463
|
groups.push(
|
|
8466
|
-
|
|
8467
|
-
|
|
8464
|
+
chunkHKEPJBTY_cjs.AssetGroup.create(
|
|
8465
|
+
chunkHKEPJBTY_cjs.AssetId.fromString(assetId),
|
|
8468
8466
|
null,
|
|
8469
8467
|
changeInputs,
|
|
8470
|
-
[
|
|
8468
|
+
[chunkHKEPJBTY_cjs.AssetOutput.create(0, amount)],
|
|
8471
8469
|
[]
|
|
8472
8470
|
)
|
|
8473
8471
|
);
|
|
@@ -8482,7 +8480,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8482
8480
|
);
|
|
8483
8481
|
return {
|
|
8484
8482
|
arkTxId: arkTxid,
|
|
8485
|
-
assetId:
|
|
8483
|
+
assetId: chunkHKEPJBTY_cjs.AssetId.create(arkTxid, 0).toString()
|
|
8486
8484
|
};
|
|
8487
8485
|
}
|
|
8488
8486
|
/**
|
|
@@ -8556,23 +8554,23 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8556
8554
|
const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
|
|
8557
8555
|
const reissueInputs = inputsForAsset(assetInputs, params.assetId);
|
|
8558
8556
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
8559
|
-
const reissueAssetIdObj =
|
|
8560
|
-
const reissueAssetGroup =
|
|
8557
|
+
const reissueAssetIdObj = chunkHKEPJBTY_cjs.AssetId.fromString(params.assetId);
|
|
8558
|
+
const reissueAssetGroup = chunkHKEPJBTY_cjs.AssetGroup.create(
|
|
8561
8559
|
reissueAssetIdObj,
|
|
8562
8560
|
null,
|
|
8563
8561
|
reissueInputs,
|
|
8564
|
-
[
|
|
8562
|
+
[chunkHKEPJBTY_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
8565
8563
|
[]
|
|
8566
8564
|
);
|
|
8567
8565
|
const groups = [reissueAssetGroup];
|
|
8568
8566
|
for (const [assetId, amount] of assetChanges) {
|
|
8569
8567
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
8570
8568
|
groups.push(
|
|
8571
|
-
|
|
8572
|
-
|
|
8569
|
+
chunkHKEPJBTY_cjs.AssetGroup.create(
|
|
8570
|
+
chunkHKEPJBTY_cjs.AssetId.fromString(assetId),
|
|
8573
8571
|
null,
|
|
8574
8572
|
changeInputs,
|
|
8575
|
-
[
|
|
8573
|
+
[chunkHKEPJBTY_cjs.AssetOutput.create(0, amount)],
|
|
8576
8574
|
[]
|
|
8577
8575
|
)
|
|
8578
8576
|
);
|
|
@@ -8643,11 +8641,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8643
8641
|
for (const [assetId, amount] of assetChanges) {
|
|
8644
8642
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
8645
8643
|
groups.push(
|
|
8646
|
-
|
|
8647
|
-
|
|
8644
|
+
chunkHKEPJBTY_cjs.AssetGroup.create(
|
|
8645
|
+
chunkHKEPJBTY_cjs.AssetId.fromString(assetId),
|
|
8648
8646
|
null,
|
|
8649
8647
|
changeInputs,
|
|
8650
|
-
amount > 0n ? [
|
|
8648
|
+
amount > 0n ? [chunkHKEPJBTY_cjs.AssetOutput.create(0, amount)] : [],
|
|
8651
8649
|
[]
|
|
8652
8650
|
)
|
|
8653
8651
|
);
|
|
@@ -8660,7 +8658,7 @@ function inputsForAsset(assetInputs, assetId) {
|
|
|
8660
8658
|
for (const [inputIndex, assets] of assetInputs) {
|
|
8661
8659
|
for (const asset of assets) {
|
|
8662
8660
|
if (asset.assetId !== assetId) continue;
|
|
8663
|
-
inputs.push(
|
|
8661
|
+
inputs.push(chunkHKEPJBTY_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
8664
8662
|
}
|
|
8665
8663
|
}
|
|
8666
8664
|
return inputs;
|
|
@@ -8669,7 +8667,7 @@ async function submitToSelf(submit, wallet, inputs, amount, groups) {
|
|
|
8669
8667
|
const outputAddress = chunkFLPWNMX3_cjs.ArkAddress.decode(await wallet.getAddress());
|
|
8670
8668
|
const outputs = [
|
|
8671
8669
|
{ script: outputAddress.pkScript, amount: BigInt(amount) },
|
|
8672
|
-
Extension.create([
|
|
8670
|
+
Extension.create([chunkHKEPJBTY_cjs.Packet.create(groups)]).txOut()
|
|
8673
8671
|
];
|
|
8674
8672
|
const { arkTxid } = await submit(inputs, outputs);
|
|
8675
8673
|
return arkTxid;
|
|
@@ -8693,7 +8691,7 @@ function castMetadata(metadata) {
|
|
|
8693
8691
|
} else {
|
|
8694
8692
|
throw new Error("Invalid metadata value type");
|
|
8695
8693
|
}
|
|
8696
|
-
md.push(
|
|
8694
|
+
md.push(chunkHKEPJBTY_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
8697
8695
|
}
|
|
8698
8696
|
return md;
|
|
8699
8697
|
}
|
|
@@ -8719,7 +8717,7 @@ var DelegateManagerImpl = class {
|
|
|
8719
8717
|
this.arkInfoProvider.getInfo(),
|
|
8720
8718
|
this.delegateProvider.getDelegateInfo()
|
|
8721
8719
|
]);
|
|
8722
|
-
const eligible = vtxos.map(
|
|
8720
|
+
const eligible = vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo).filter(
|
|
8723
8721
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
8724
8722
|
);
|
|
8725
8723
|
if (eligible.length === 0) {
|
|
@@ -8751,7 +8749,7 @@ var DelegateManagerImpl = class {
|
|
|
8751
8749
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
8752
8750
|
let recoverableVtxos = [];
|
|
8753
8751
|
for (const vtxo of eligible) {
|
|
8754
|
-
if (
|
|
8752
|
+
if (chunkLZAINCGU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
8755
8753
|
recoverableVtxos.push(vtxo);
|
|
8756
8754
|
continue;
|
|
8757
8755
|
}
|
|
@@ -8803,7 +8801,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8803
8801
|
}
|
|
8804
8802
|
if (!delegateAt) {
|
|
8805
8803
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
8806
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
8804
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkLZAINCGU_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
|
|
8807
8805
|
(min, coin) => Math.min(min, coin.expiresAt.getTime()),
|
|
8808
8806
|
Number.MAX_SAFE_INTEGER
|
|
8809
8807
|
);
|
|
@@ -8823,7 +8821,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8823
8821
|
let amount = 0n;
|
|
8824
8822
|
for (const coin of vtxos) {
|
|
8825
8823
|
const inputFee = estimator.evalOffchainInput({
|
|
8826
|
-
...
|
|
8824
|
+
...chunkLZAINCGU_cjs.toOffchainInputFeeParams(coin),
|
|
8827
8825
|
type: "vtxo"
|
|
8828
8826
|
});
|
|
8829
8827
|
if (inputFee.satoshis >= coin.value) {
|
|
@@ -8873,7 +8871,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8873
8871
|
btcSigner.Address(chunkFLPWNMX3_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
8874
8872
|
);
|
|
8875
8873
|
const forfeits = await Promise.all(
|
|
8876
|
-
vtxos.filter((v) =>
|
|
8874
|
+
vtxos.filter((v) => chunkLZAINCGU_cjs.requiresForfeit(v)).map(async (coin) => {
|
|
8877
8875
|
const forfeit = await makeDelegateForfeitTx(
|
|
8878
8876
|
coin,
|
|
8879
8877
|
dust,
|
|
@@ -8956,7 +8954,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
8956
8954
|
expire_at: 0,
|
|
8957
8955
|
cosigners_public_keys: cosignerPubKeys
|
|
8958
8956
|
};
|
|
8959
|
-
const proof =
|
|
8957
|
+
const proof = chunkLZAINCGU_cjs.Proof.create(message, coins, outputs);
|
|
8960
8958
|
const signedProof = await identity.sign(proof);
|
|
8961
8959
|
return {
|
|
8962
8960
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9019,7 +9017,8 @@ var InMemoryBatchRegistrationRepository = class {
|
|
|
9019
9017
|
async getLockedVtxoOutpoints() {
|
|
9020
9018
|
const out = [];
|
|
9021
9019
|
for (const i of this.byId.values())
|
|
9022
|
-
if (!
|
|
9020
|
+
if (!isTerminalBatchRegistrationState(i.state))
|
|
9021
|
+
for (const o of i.proofInputs) out.push({ ...o });
|
|
9023
9022
|
return out;
|
|
9024
9023
|
}
|
|
9025
9024
|
/** @deprecated Use {@link saveBatchRegistration}. */
|
|
@@ -9512,7 +9511,8 @@ var IndexedDBBatchRegistrationRepository = class {
|
|
|
9512
9511
|
const all = await promisifyRequest(store.getAll());
|
|
9513
9512
|
const out = [];
|
|
9514
9513
|
for (const i of all)
|
|
9515
|
-
if (!
|
|
9514
|
+
if (!isTerminalBatchRegistrationState(i.state))
|
|
9515
|
+
for (const o of i.intentVtxos) out.push(o);
|
|
9516
9516
|
return out;
|
|
9517
9517
|
}
|
|
9518
9518
|
/** @deprecated Use {@link saveBatchRegistration}. */
|
|
@@ -9696,7 +9696,7 @@ function decodeArkContract(encoded) {
|
|
|
9696
9696
|
}
|
|
9697
9697
|
function contractFromArkContract(encoded, options = {}) {
|
|
9698
9698
|
const parsed = decodeArkContract(encoded);
|
|
9699
|
-
const handler =
|
|
9699
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(parsed.type);
|
|
9700
9700
|
if (!handler) {
|
|
9701
9701
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
9702
9702
|
}
|
|
@@ -9712,7 +9712,7 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
9712
9712
|
}
|
|
9713
9713
|
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkFLPWNMX3_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
9714
9714
|
const parsed = decodeArkContract(encoded);
|
|
9715
|
-
const handler =
|
|
9715
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
9716
9716
|
const params = parsed.data;
|
|
9717
9717
|
const vtxoScript = handler.createScript(params);
|
|
9718
9718
|
return {
|
|
@@ -9769,10 +9769,10 @@ var ContractWatcher = class {
|
|
|
9769
9769
|
eventSourceReported = false;
|
|
9770
9770
|
/** @see ContractWatcherConfig */
|
|
9771
9771
|
constructor(config) {
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9772
|
+
chunkLZAINCGU_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
|
|
9773
|
+
chunkLZAINCGU_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
|
|
9774
|
+
chunkLZAINCGU_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
|
|
9775
|
+
chunkLZAINCGU_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
|
|
9776
9776
|
if (config.subscriptionRequestTimeoutMs === 0) {
|
|
9777
9777
|
throw new Error("subscriptionRequestTimeoutMs must be greater than 0");
|
|
9778
9778
|
}
|
|
@@ -9995,9 +9995,9 @@ var ContractWatcher = class {
|
|
|
9995
9995
|
this.reconnectAttempts = 0;
|
|
9996
9996
|
this.listenLoop().catch((e) => {
|
|
9997
9997
|
if (!this.isWatching || signal?.aborted) return;
|
|
9998
|
-
if (
|
|
9998
|
+
if (chunkLZAINCGU_cjs.isEventSourceError(e)) {
|
|
9999
9999
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
10000
|
-
} else if (!
|
|
10000
|
+
} else if (!chunkLZAINCGU_cjs.isEventSourceUnavailableError(e)) {
|
|
10001
10001
|
console.error(e);
|
|
10002
10002
|
}
|
|
10003
10003
|
this.connectionState = "disconnected";
|
|
@@ -10007,7 +10007,7 @@ var ContractWatcher = class {
|
|
|
10007
10007
|
});
|
|
10008
10008
|
} catch (error) {
|
|
10009
10009
|
if (!this.isWatching || signal?.aborted) return;
|
|
10010
|
-
if (!
|
|
10010
|
+
if (!chunkLZAINCGU_cjs.isEventSourceUnavailableError(error)) {
|
|
10011
10011
|
console.error("ContractWatcher connection failed:", error);
|
|
10012
10012
|
}
|
|
10013
10013
|
this.connectionState = "disconnected";
|
|
@@ -10023,7 +10023,7 @@ var ContractWatcher = class {
|
|
|
10023
10023
|
* few seconds.
|
|
10024
10024
|
*/
|
|
10025
10025
|
reportEventSourceUnavailable(error) {
|
|
10026
|
-
if (!
|
|
10026
|
+
if (!chunkLZAINCGU_cjs.isEventSourceUnavailableError(error)) return false;
|
|
10027
10027
|
if (!this.eventSourceReported) {
|
|
10028
10028
|
this.eventSourceReported = true;
|
|
10029
10029
|
console.warn(
|
|
@@ -10088,7 +10088,7 @@ var ContractWatcher = class {
|
|
|
10088
10088
|
const now = Date.now();
|
|
10089
10089
|
let current;
|
|
10090
10090
|
try {
|
|
10091
|
-
current = await
|
|
10091
|
+
current = await chunkLZAINCGU_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
10092
10092
|
spendableOnly: true
|
|
10093
10093
|
});
|
|
10094
10094
|
} catch (error) {
|
|
@@ -10370,14 +10370,14 @@ var ContractWatcher = class {
|
|
|
10370
10370
|
const timestamp = Date.now();
|
|
10371
10371
|
if (update.newVtxos?.length) {
|
|
10372
10372
|
this.processSubscriptionVtxos(
|
|
10373
|
-
update.newVtxos.map(
|
|
10373
|
+
update.newVtxos.map(chunkLZAINCGU_cjs.normalizeVtxo),
|
|
10374
10374
|
"vtxo_received",
|
|
10375
10375
|
timestamp
|
|
10376
10376
|
);
|
|
10377
10377
|
}
|
|
10378
10378
|
if (update.spentVtxos?.length) {
|
|
10379
10379
|
this.processSubscriptionVtxos(
|
|
10380
|
-
update.spentVtxos.map(
|
|
10380
|
+
update.spentVtxos.map(chunkLZAINCGU_cjs.normalizeVtxo),
|
|
10381
10381
|
"vtxo_spent",
|
|
10382
10382
|
timestamp
|
|
10383
10383
|
);
|
|
@@ -10402,8 +10402,8 @@ var ContractWatcher = class {
|
|
|
10402
10402
|
continue;
|
|
10403
10403
|
}
|
|
10404
10404
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
10405
|
-
const n =
|
|
10406
|
-
if (
|
|
10405
|
+
const n = chunkLZAINCGU_cjs.normalizeVtxo(vtxo);
|
|
10406
|
+
if (chunkLZAINCGU_cjs.isVtxoSpent(n) || n.isSwept || chunkLZAINCGU_cjs.isPastExpiry(n, now)) continue;
|
|
10407
10407
|
}
|
|
10408
10408
|
let bucket = target.get(vtxo.script);
|
|
10409
10409
|
if (!bucket) {
|
|
@@ -10591,7 +10591,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
10591
10591
|
if (!contract) continue;
|
|
10592
10592
|
try {
|
|
10593
10593
|
const key = contractKey(contract);
|
|
10594
|
-
const handler =
|
|
10594
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
10595
10595
|
const hit = memo?.get(script);
|
|
10596
10596
|
let tapscripts;
|
|
10597
10597
|
if (hit && hit.key === key && hit.handler === handler) {
|
|
@@ -10623,7 +10623,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
10623
10623
|
}
|
|
10624
10624
|
function annotateAgainst(vtxos, byScript, tapscripts = /* @__PURE__ */ new Map()) {
|
|
10625
10625
|
return vtxos.map(
|
|
10626
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10626
|
+
(vtxo) => extendVirtualCoinForContract(chunkLZAINCGU_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
|
|
10627
10627
|
);
|
|
10628
10628
|
}
|
|
10629
10629
|
var SCAN_MAX_INDEX = 1e4;
|
|
@@ -10672,8 +10672,8 @@ var ContractManager = class _ContractManager {
|
|
|
10672
10672
|
/** Serializes onchain read-modify-writes so a pending spender is never overwritten. */
|
|
10673
10673
|
onchainChain = Promise.resolve();
|
|
10674
10674
|
constructor(config) {
|
|
10675
|
-
|
|
10676
|
-
|
|
10675
|
+
chunkLZAINCGU_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
|
|
10676
|
+
chunkLZAINCGU_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
|
|
10677
10677
|
this.config = { ...config };
|
|
10678
10678
|
if (config.onchainProvider && config.network) {
|
|
10679
10679
|
this.onchainWatcher = new OnchainContractWatcher({
|
|
@@ -10718,12 +10718,12 @@ var ContractManager = class _ContractManager {
|
|
|
10718
10718
|
}
|
|
10719
10719
|
/** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
|
|
10720
10720
|
setVtxoSyncMaxAge(maxAgeMs) {
|
|
10721
|
-
|
|
10721
|
+
chunkLZAINCGU_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
|
|
10722
10722
|
this.config.vtxoSyncMaxAgeMs = maxAgeMs;
|
|
10723
10723
|
}
|
|
10724
10724
|
/** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
|
|
10725
10725
|
setVtxoSyncOverlap(overlapMs) {
|
|
10726
|
-
|
|
10726
|
+
chunkLZAINCGU_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
|
|
10727
10727
|
this.config.vtxoSyncOverlapMs = overlapMs;
|
|
10728
10728
|
}
|
|
10729
10729
|
markSyncOnline() {
|
|
@@ -10787,7 +10787,7 @@ var ContractManager = class _ContractManager {
|
|
|
10787
10787
|
if (this.unsupportedContracts.get(contract.script) === key) return true;
|
|
10788
10788
|
if (this.tapscriptMemo.get(contract.script)?.key === key) return false;
|
|
10789
10789
|
try {
|
|
10790
|
-
|
|
10790
|
+
chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
|
|
10791
10791
|
return false;
|
|
10792
10792
|
} catch (err) {
|
|
10793
10793
|
if (!(err instanceof chunkJFJNB7ZH_cjs.UnsupportedProgramVersionError)) return false;
|
|
@@ -10803,7 +10803,7 @@ var ContractManager = class _ContractManager {
|
|
|
10803
10803
|
this.markSyncOnline();
|
|
10804
10804
|
return void 0;
|
|
10805
10805
|
} catch (err) {
|
|
10806
|
-
if (!
|
|
10806
|
+
if (!chunkLZAINCGU_cjs.isRetryableProviderError(err)) throw err;
|
|
10807
10807
|
this.markSyncDegraded(err);
|
|
10808
10808
|
return err;
|
|
10809
10809
|
}
|
|
@@ -10826,7 +10826,7 @@ var ContractManager = class _ContractManager {
|
|
|
10826
10826
|
try {
|
|
10827
10827
|
await this.scheduleLookAheadDrain();
|
|
10828
10828
|
} catch (err) {
|
|
10829
|
-
if (!
|
|
10829
|
+
if (!chunkLZAINCGU_cjs.isRetryableProviderError(err)) throw err;
|
|
10830
10830
|
this.lookAheadRefillOwed = true;
|
|
10831
10831
|
this.markSyncDegraded(err);
|
|
10832
10832
|
}
|
|
@@ -10889,7 +10889,7 @@ var ContractManager = class _ContractManager {
|
|
|
10889
10889
|
/** No throw: construction returned long ago, so the state is the channel. */
|
|
10890
10890
|
reportBackgroundFailure(stage, err) {
|
|
10891
10891
|
this.markSyncDegraded(err);
|
|
10892
|
-
if (!
|
|
10892
|
+
if (!chunkLZAINCGU_cjs.isRetryableProviderError(err)) {
|
|
10893
10893
|
console.error(`[contracts] background ${stage} failed`, err);
|
|
10894
10894
|
}
|
|
10895
10895
|
}
|
|
@@ -10991,7 +10991,7 @@ var ContractManager = class _ContractManager {
|
|
|
10991
10991
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
10992
10992
|
const to = watermark + lookAhead.size;
|
|
10993
10993
|
const deps = lookAhead.candidateDeps();
|
|
10994
|
-
const handlers =
|
|
10994
|
+
const handlers = chunkNDQ4LB4X_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkNDQ4LB4X_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
10995
10995
|
const band = /* @__PURE__ */ new Map();
|
|
10996
10996
|
for (let index = from; index <= to; index++) {
|
|
10997
10997
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -11002,7 +11002,7 @@ var ContractManager = class _ContractManager {
|
|
|
11002
11002
|
index,
|
|
11003
11003
|
params: {
|
|
11004
11004
|
...candidate,
|
|
11005
|
-
...
|
|
11005
|
+
...chunkNDQ4LB4X_cjs.speculativeReceiveMetadata(descriptor)
|
|
11006
11006
|
}
|
|
11007
11007
|
});
|
|
11008
11008
|
}
|
|
@@ -11061,7 +11061,7 @@ var ContractManager = class _ContractManager {
|
|
|
11061
11061
|
});
|
|
11062
11062
|
for (const entry of pending) entry.catchUpPending = false;
|
|
11063
11063
|
} catch (err) {
|
|
11064
|
-
if (!
|
|
11064
|
+
if (!chunkLZAINCGU_cjs.isRetryableProviderError(err)) throw err;
|
|
11065
11065
|
this.markSyncDegraded(err);
|
|
11066
11066
|
}
|
|
11067
11067
|
}
|
|
@@ -11152,7 +11152,7 @@ var ContractManager = class _ContractManager {
|
|
|
11152
11152
|
return result;
|
|
11153
11153
|
}
|
|
11154
11154
|
async upsertContractRow(params) {
|
|
11155
|
-
const handler =
|
|
11155
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(params.type);
|
|
11156
11156
|
if (!handler) {
|
|
11157
11157
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
11158
11158
|
}
|
|
@@ -11254,7 +11254,7 @@ var ContractManager = class _ContractManager {
|
|
|
11254
11254
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
11255
11255
|
);
|
|
11256
11256
|
}
|
|
11257
|
-
const registered =
|
|
11257
|
+
const registered = chunkNDQ4LB4X_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkNDQ4LB4X_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
11258
11258
|
const discoverables = [
|
|
11259
11259
|
...registered.filter((h) => h.type === "boarding"),
|
|
11260
11260
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -11385,7 +11385,7 @@ var ContractManager = class _ContractManager {
|
|
|
11385
11385
|
return contracts.filter((contract) => this.isUnsupported(contract));
|
|
11386
11386
|
}
|
|
11387
11387
|
async getContractsWithVtxos(filter, pageSize, options) {
|
|
11388
|
-
|
|
11388
|
+
chunkLZAINCGU_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
|
|
11389
11389
|
const contracts = await this.getContracts(filter);
|
|
11390
11390
|
if (this.syncedWithin(
|
|
11391
11391
|
contracts,
|
|
@@ -11493,7 +11493,7 @@ var ContractManager = class _ContractManager {
|
|
|
11493
11493
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
11494
11494
|
const asking = vtxos.filter((vtxo) => {
|
|
11495
11495
|
const contract = byScript.get(vtxo.script);
|
|
11496
|
-
return contract !== void 0 &&
|
|
11496
|
+
return contract !== void 0 && chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
11497
11497
|
});
|
|
11498
11498
|
if (asking.length === 0) return refused;
|
|
11499
11499
|
const [tip, walletDescriptorValue] = await Promise.all([
|
|
@@ -11502,7 +11502,7 @@ var ContractManager = class _ContractManager {
|
|
|
11502
11502
|
]);
|
|
11503
11503
|
for (const vtxo of asking) {
|
|
11504
11504
|
const contract = byScript.get(vtxo.script);
|
|
11505
|
-
const handler =
|
|
11505
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
11506
11506
|
if (!handler?.assertSpendableNow) continue;
|
|
11507
11507
|
const context = {
|
|
11508
11508
|
collaborative: true,
|
|
@@ -11512,7 +11512,7 @@ var ContractManager = class _ContractManager {
|
|
|
11512
11512
|
walletDescriptor: walletDescriptorValue,
|
|
11513
11513
|
// `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
|
|
11514
11514
|
// reads `vtxo.status.block_time` unguarded, so require `status` too.
|
|
11515
|
-
vtxo:
|
|
11515
|
+
vtxo: chunkLZAINCGU_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
11516
11516
|
};
|
|
11517
11517
|
try {
|
|
11518
11518
|
await handler.assertSpendableNow(
|
|
@@ -11626,7 +11626,7 @@ var ContractManager = class _ContractManager {
|
|
|
11626
11626
|
const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
|
|
11627
11627
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
11628
11628
|
if (!contract) return [];
|
|
11629
|
-
const handler =
|
|
11629
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
11630
11630
|
if (!handler) return [];
|
|
11631
11631
|
const script = handler.createScript(contract.params);
|
|
11632
11632
|
const tip = await this.currentChainTip();
|
|
@@ -11648,7 +11648,7 @@ var ContractManager = class _ContractManager {
|
|
|
11648
11648
|
const { contractScript, collaborative = true, walletDescriptor } = options;
|
|
11649
11649
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
11650
11650
|
if (!contract) return [];
|
|
11651
|
-
const handler =
|
|
11651
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
11652
11652
|
if (!handler) return [];
|
|
11653
11653
|
const script = handler.createScript(contract.params);
|
|
11654
11654
|
const context = {
|
|
@@ -11694,7 +11694,7 @@ var ContractManager = class _ContractManager {
|
|
|
11694
11694
|
}
|
|
11695
11695
|
async refreshOutpoints(outpoints) {
|
|
11696
11696
|
if (outpoints.length === 0) return;
|
|
11697
|
-
const { vtxos } = await
|
|
11697
|
+
const { vtxos } = await chunkLZAINCGU_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
11698
11698
|
outpoints
|
|
11699
11699
|
});
|
|
11700
11700
|
if (vtxos.length === 0) return;
|
|
@@ -11819,7 +11819,7 @@ var ContractManager = class _ContractManager {
|
|
|
11819
11819
|
...Object.values(pending).map((p) => p.script)
|
|
11820
11820
|
]);
|
|
11821
11821
|
const targets = contracts.filter(
|
|
11822
|
-
(c) =>
|
|
11822
|
+
(c) => chunkNDQ4LB4X_cjs.contractHandlers.has(c.type) && (c.state === "active" && isOnchainScoped(c) || owners.has(c.script))
|
|
11823
11823
|
);
|
|
11824
11824
|
const wanted = scripts && new Set(scripts);
|
|
11825
11825
|
const settled = [];
|
|
@@ -11854,7 +11854,7 @@ var ContractManager = class _ContractManager {
|
|
|
11854
11854
|
).catch((e) => console.warn("[contracts] onchain watch failed", e));
|
|
11855
11855
|
}
|
|
11856
11856
|
async syncOnchainContract(contract, onchainProvider, network, pending, tipHeight, prefetched) {
|
|
11857
|
-
|
|
11857
|
+
chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type).createScript(contract.params);
|
|
11858
11858
|
const coins = prefetched ?? await onchainProvider.getCoins(onchainAddressOf(contract, network));
|
|
11859
11859
|
const stored = new Map(
|
|
11860
11860
|
(await getVtxosForContract(this.config.walletRepository, contract)).map((v) => [
|
|
@@ -11952,8 +11952,8 @@ var ContractManager = class _ContractManager {
|
|
|
11952
11952
|
const found = /* @__PURE__ */ new Map();
|
|
11953
11953
|
if (!indexerProvider.getUtxos || rows.length === 0) return found;
|
|
11954
11954
|
try {
|
|
11955
|
-
for (let i = 0; i < rows.length; i +=
|
|
11956
|
-
const outpoints = rows.slice(i, i +
|
|
11955
|
+
for (let i = 0; i < rows.length; i += chunkLZAINCGU_cjs.OUTPOINT_QUERY_CHUNK_SIZE) {
|
|
11956
|
+
const outpoints = rows.slice(i, i + chunkLZAINCGU_cjs.OUTPOINT_QUERY_CHUNK_SIZE).map(({ txid, vout }) => ({ txid, vout }));
|
|
11957
11957
|
let pageIndex;
|
|
11958
11958
|
let pages = 0;
|
|
11959
11959
|
do {
|
|
@@ -11963,7 +11963,7 @@ var ContractManager = class _ContractManager {
|
|
|
11963
11963
|
const { utxos, page } = await indexerProvider.getUtxos({
|
|
11964
11964
|
outpoints,
|
|
11965
11965
|
pageIndex,
|
|
11966
|
-
pageSize:
|
|
11966
|
+
pageSize: chunkLZAINCGU_cjs.OUTPOINT_QUERY_CHUNK_SIZE
|
|
11967
11967
|
});
|
|
11968
11968
|
for (const utxo of utxos) found.set(vtxoOutpoint(utxo), utxo);
|
|
11969
11969
|
const more = page && page.current < page.total && page.next > page.current;
|
|
@@ -11971,7 +11971,7 @@ var ContractManager = class _ContractManager {
|
|
|
11971
11971
|
} while (pageIndex !== void 0);
|
|
11972
11972
|
}
|
|
11973
11973
|
} catch (e) {
|
|
11974
|
-
if (e instanceof
|
|
11974
|
+
if (e instanceof chunkHKEPJBTY_cjs.IndexerUtxosUnsupportedError) return found;
|
|
11975
11975
|
console.warn("[contracts] arkd spend lookup failed; using the explorer", e);
|
|
11976
11976
|
return void 0;
|
|
11977
11977
|
}
|
|
@@ -12024,7 +12024,7 @@ var ContractManager = class _ContractManager {
|
|
|
12024
12024
|
break;
|
|
12025
12025
|
}
|
|
12026
12026
|
} catch (err) {
|
|
12027
|
-
if (!
|
|
12027
|
+
if (!chunkLZAINCGU_cjs.isRetryableProviderError(err)) throw err;
|
|
12028
12028
|
this.markSyncDegraded(err);
|
|
12029
12029
|
synced = false;
|
|
12030
12030
|
}
|
|
@@ -12112,7 +12112,7 @@ var ContractManager = class _ContractManager {
|
|
|
12112
12112
|
*/
|
|
12113
12113
|
async reconcilePendingFrontier(contracts) {
|
|
12114
12114
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
12115
|
-
const vtxos = await
|
|
12115
|
+
const vtxos = await chunkLZAINCGU_cjs.getAllNormalizedVtxos(
|
|
12116
12116
|
this.config.indexerProvider,
|
|
12117
12117
|
contracts.map((c) => c.script),
|
|
12118
12118
|
{ pendingOnly: true }
|
|
@@ -12187,7 +12187,7 @@ var ContractManager = class _ContractManager {
|
|
|
12187
12187
|
}
|
|
12188
12188
|
return result;
|
|
12189
12189
|
}
|
|
12190
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
12190
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkLZAINCGU_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
12191
12191
|
if (contracts.length === 0) {
|
|
12192
12192
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
12193
12193
|
}
|
|
@@ -12203,7 +12203,7 @@ var ContractManager = class _ContractManager {
|
|
|
12203
12203
|
before: syncWindow.before
|
|
12204
12204
|
}
|
|
12205
12205
|
} : {};
|
|
12206
|
-
const vtxos = await
|
|
12206
|
+
const vtxos = await chunkLZAINCGU_cjs.getAllNormalizedVtxos(
|
|
12207
12207
|
this.config.indexerProvider,
|
|
12208
12208
|
contracts.map((c) => c.script),
|
|
12209
12209
|
{ ...windowOpts, pageSize }
|
|
@@ -12310,7 +12310,7 @@ function parseLegacyExpiry(batchExpiry) {
|
|
|
12310
12310
|
if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
|
|
12311
12311
|
return {};
|
|
12312
12312
|
}
|
|
12313
|
-
if (batchExpiry >=
|
|
12313
|
+
if (batchExpiry >= chunkLZAINCGU_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
12314
12314
|
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
12315
12315
|
}
|
|
12316
12316
|
function legacyVtxoFacts(status) {
|
|
@@ -12548,7 +12548,7 @@ function backfillContractWatchState(store) {
|
|
|
12548
12548
|
};
|
|
12549
12549
|
readPage();
|
|
12550
12550
|
}
|
|
12551
|
-
var unspentFlag = (vtxo) =>
|
|
12551
|
+
var unspentFlag = (vtxo) => chunkLZAINCGU_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
12552
12552
|
function backfillVtxoIndexFields(transaction) {
|
|
12553
12553
|
const store = transaction.objectStore(STORE_VTXOS);
|
|
12554
12554
|
const pageSize = 1e3;
|
|
@@ -12579,7 +12579,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
|
|
|
12579
12579
|
var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
|
|
12580
12580
|
function normalizeOptions2(pathOrOptions) {
|
|
12581
12581
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
12582
|
-
|
|
12582
|
+
chunkLZAINCGU_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
12583
12583
|
return {
|
|
12584
12584
|
path: o.path,
|
|
12585
12585
|
activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
|
|
@@ -12807,7 +12807,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
12807
12807
|
var deserializeVtxo = ({
|
|
12808
12808
|
intentTapLeafScript,
|
|
12809
12809
|
...o
|
|
12810
|
-
}) =>
|
|
12810
|
+
}) => chunkLZAINCGU_cjs.normalizeVtxo({
|
|
12811
12811
|
...o,
|
|
12812
12812
|
createdAt: new Date(o.createdAt),
|
|
12813
12813
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -13207,7 +13207,7 @@ var RestEmulatorProvider = class {
|
|
|
13207
13207
|
serverUrl;
|
|
13208
13208
|
async getInfo() {
|
|
13209
13209
|
const url = `${this.serverUrl}/v1/info`;
|
|
13210
|
-
const response = await
|
|
13210
|
+
const response = await chunkLZAINCGU_cjs.baseFetch(url);
|
|
13211
13211
|
if (!response.ok) {
|
|
13212
13212
|
const errorText2 = await response.text();
|
|
13213
13213
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -13331,7 +13331,7 @@ function arkadeServiceUrl(service) {
|
|
|
13331
13331
|
}
|
|
13332
13332
|
async function resolveArkadeService(service, opts = {}) {
|
|
13333
13333
|
const operatorUrl = arkadeServiceUrl(service);
|
|
13334
|
-
const arkProvider = opts.arkProvider ?? new
|
|
13334
|
+
const arkProvider = opts.arkProvider ?? new chunkLZAINCGU_cjs.RestOperatorProvider(operatorUrl);
|
|
13335
13335
|
const info = opts.info ?? await arkProvider.getInfo();
|
|
13336
13336
|
if ("network" in service && service.network !== info.network) {
|
|
13337
13337
|
throw new Error(
|
|
@@ -13350,7 +13350,7 @@ async function resolveArkadeService(service, opts = {}) {
|
|
|
13350
13350
|
}
|
|
13351
13351
|
return {
|
|
13352
13352
|
arkProvider,
|
|
13353
|
-
indexerProvider: new
|
|
13353
|
+
indexerProvider: new chunkHKEPJBTY_cjs.RestIndexerProvider(operatorUrl),
|
|
13354
13354
|
onchainProvider: new EsploraProvider(esploraUrl),
|
|
13355
13355
|
emulator,
|
|
13356
13356
|
info
|
|
@@ -13434,7 +13434,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
13434
13434
|
*/
|
|
13435
13435
|
materializeDescriptorAt(index) {
|
|
13436
13436
|
const descriptor = this.identity.descriptor;
|
|
13437
|
-
const network =
|
|
13437
|
+
const network = chunkNDQ4LB4X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
13438
13438
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
13439
13439
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
13440
13440
|
if (!keyInfo?.keyExpression) {
|
|
@@ -13502,7 +13502,7 @@ function signingDescriptorIndex(descriptor) {
|
|
|
13502
13502
|
}
|
|
13503
13503
|
function newestWalletReceiveContract(contracts, serverPubKeyHex) {
|
|
13504
13504
|
return contracts.filter(
|
|
13505
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
13505
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkNDQ4LB4X_cjs.WALLET_RECEIVE_SOURCE
|
|
13506
13506
|
).sort((a, b) => {
|
|
13507
13507
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
13508
13508
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -13553,7 +13553,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
13553
13553
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
13554
13554
|
if (!provider) return void 0;
|
|
13555
13555
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
13556
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
13556
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
13557
13557
|
const factoryOpts = {
|
|
13558
13558
|
walletRepository: setup.walletRepository,
|
|
13559
13559
|
contractRepository: setup.contractRepository,
|
|
@@ -13713,7 +13713,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
13713
13713
|
};
|
|
13714
13714
|
function deriveLeafPubkey(descriptor) {
|
|
13715
13715
|
try {
|
|
13716
|
-
return
|
|
13716
|
+
return chunkNDQ4LB4X_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
13717
13717
|
} catch (e) {
|
|
13718
13718
|
throw new NonRangeableDescriptorError(
|
|
13719
13719
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -13733,11 +13733,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
13733
13733
|
// Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
|
|
13734
13734
|
// it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
13735
13735
|
metadata: {
|
|
13736
|
-
...tagSource && { source:
|
|
13736
|
+
...tagSource && { source: chunkNDQ4LB4X_cjs.WALLET_RECEIVE_SOURCE },
|
|
13737
13737
|
signingDescriptor: descriptor
|
|
13738
13738
|
}
|
|
13739
13739
|
};
|
|
13740
|
-
const params = tapscript instanceof
|
|
13740
|
+
const params = tapscript instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script ? {
|
|
13741
13741
|
...base$1,
|
|
13742
13742
|
type: "delegate",
|
|
13743
13743
|
params: {
|
|
@@ -13758,10 +13758,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
13758
13758
|
return { tapscript, params };
|
|
13759
13759
|
}
|
|
13760
13760
|
function rebuildTapscript(current, pubKey) {
|
|
13761
|
-
if (current instanceof
|
|
13762
|
-
return new
|
|
13761
|
+
if (current instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script) {
|
|
13762
|
+
return new chunkNDQ4LB4X_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
13763
13763
|
}
|
|
13764
|
-
return new
|
|
13764
|
+
return new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
13765
13765
|
}
|
|
13766
13766
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
13767
13767
|
const candidates = await collectContracts(contractRepository, {
|
|
@@ -13814,7 +13814,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
13814
13814
|
try {
|
|
13815
13815
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
13816
13816
|
for (const psbt of txs) {
|
|
13817
|
-
const tx =
|
|
13817
|
+
const tx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
13818
13818
|
resolved.set(tx.id, tx.toBytes());
|
|
13819
13819
|
}
|
|
13820
13820
|
} catch (err) {
|
|
@@ -13847,7 +13847,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
13847
13847
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
13848
13848
|
const pending = [];
|
|
13849
13849
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
13850
|
-
if (
|
|
13850
|
+
if (chunkLZAINCGU_cjs.getArkPsbtFields(tx, i, chunkLZAINCGU_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
13851
13851
|
}
|
|
13852
13852
|
if (pending.length === 0) return;
|
|
13853
13853
|
const resolved = await resolvePrevTxs(
|
|
@@ -13856,13 +13856,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
13856
13856
|
onchain
|
|
13857
13857
|
);
|
|
13858
13858
|
for (const i of pending) {
|
|
13859
|
-
|
|
13859
|
+
chunkLZAINCGU_cjs.setArkPsbtField(tx, i, chunkLZAINCGU_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
13860
13860
|
}
|
|
13861
13861
|
}
|
|
13862
13862
|
async function attachPrevoutTxs(tx, source) {
|
|
13863
13863
|
const pending = [];
|
|
13864
13864
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
13865
|
-
if (
|
|
13865
|
+
if (chunkLZAINCGU_cjs.getArkPsbtFields(tx, i, chunkLZAINCGU_cjs.PrevoutTxField).length > 0) continue;
|
|
13866
13866
|
const input = tx.getInput(i);
|
|
13867
13867
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
13868
13868
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -13877,7 +13877,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
13877
13877
|
resolved.set(txids[i], result.value);
|
|
13878
13878
|
}
|
|
13879
13879
|
for (const { index, txid } of pending) {
|
|
13880
|
-
|
|
13880
|
+
chunkLZAINCGU_cjs.setArkPsbtField(tx, index, chunkLZAINCGU_cjs.PrevoutTxField, resolved.get(txid));
|
|
13881
13881
|
}
|
|
13882
13882
|
}
|
|
13883
13883
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -13918,7 +13918,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
13918
13918
|
}
|
|
13919
13919
|
};
|
|
13920
13920
|
for (const vtxo of vtxos) {
|
|
13921
|
-
if (
|
|
13921
|
+
if (chunkLZAINCGU_cjs.isVtxoSpent(vtxo)) continue;
|
|
13922
13922
|
addAssets(owned, vtxo);
|
|
13923
13923
|
if (vtxo.isUnrolled) {
|
|
13924
13924
|
unrolled += vtxo.value;
|
|
@@ -13928,11 +13928,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
13928
13928
|
deprecatedSignerLocked += vtxo.value;
|
|
13929
13929
|
continue;
|
|
13930
13930
|
}
|
|
13931
|
-
if (
|
|
13931
|
+
if (chunkLZAINCGU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
13932
13932
|
recoverable += vtxo.value;
|
|
13933
13933
|
continue;
|
|
13934
13934
|
}
|
|
13935
|
-
if (!
|
|
13935
|
+
if (!chunkLZAINCGU_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
13936
13936
|
if (vtxo.isPreconfirmed) {
|
|
13937
13937
|
preconfirmed += vtxo.value;
|
|
13938
13938
|
} else {
|
|
@@ -14207,7 +14207,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
14207
14207
|
if (!newest?.params.pubKey) return baseline;
|
|
14208
14208
|
try {
|
|
14209
14209
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
14210
|
-
return new
|
|
14210
|
+
return new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
14211
14211
|
} catch (e) {
|
|
14212
14212
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
14213
14213
|
return baseline;
|
|
@@ -14239,21 +14239,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
|
|
|
14239
14239
|
if (vtxo.isUnrolled) {
|
|
14240
14240
|
return !!f.withUnrolled;
|
|
14241
14241
|
}
|
|
14242
|
-
if (
|
|
14242
|
+
if (chunkLZAINCGU_cjs.isVtxoSpent(vtxo)) {
|
|
14243
14243
|
return false;
|
|
14244
14244
|
}
|
|
14245
|
-
if (!f.withRecoverable &&
|
|
14245
|
+
if (!f.withRecoverable && chunkLZAINCGU_cjs.canRecoverOnchain(vtxo, now)) {
|
|
14246
14246
|
return false;
|
|
14247
14247
|
}
|
|
14248
14248
|
return true;
|
|
14249
14249
|
});
|
|
14250
14250
|
}
|
|
14251
14251
|
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
14252
|
-
const candidates = inputs.filter(
|
|
14252
|
+
const candidates = inputs.filter(chunkLZAINCGU_cjs.isVirtualCoin).map(chunkLZAINCGU_cjs.normalizeVtxo).filter((v) => !v.isSwept);
|
|
14253
14253
|
if (candidates.length === 0) return inputs;
|
|
14254
|
-
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await
|
|
14254
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkLZAINCGU_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
14255
14255
|
const suspects = candidates.filter(
|
|
14256
|
-
(v) =>
|
|
14256
|
+
(v) => chunkLZAINCGU_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
14257
14257
|
);
|
|
14258
14258
|
if (suspects.length === 0) return inputs;
|
|
14259
14259
|
let sweptNow;
|
|
@@ -14267,12 +14267,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
|
14267
14267
|
);
|
|
14268
14268
|
} catch (e) {
|
|
14269
14269
|
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
14270
|
-
throw
|
|
14270
|
+
throw chunkLZAINCGU_cjs.isRetryableProviderError(e) ? new chunkLZAINCGU_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
14271
14271
|
}
|
|
14272
14272
|
if (sweptNow.size === 0) return inputs;
|
|
14273
14273
|
return inputs.map((input) => {
|
|
14274
|
-
if (!
|
|
14275
|
-
return { ...
|
|
14274
|
+
if (!chunkLZAINCGU_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
14275
|
+
return { ...chunkLZAINCGU_cjs.normalizeVtxo(input), isSwept: true };
|
|
14276
14276
|
});
|
|
14277
14277
|
}
|
|
14278
14278
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
@@ -14542,7 +14542,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14542
14542
|
* before binding the answer into a covenant to fail closed instead of getting the snapshot.
|
|
14543
14543
|
*
|
|
14544
14544
|
* @returns The operator's info
|
|
14545
|
-
* @see
|
|
14545
|
+
* @see OperatorInfo
|
|
14546
14546
|
*/
|
|
14547
14547
|
async getOperatorInfo(opts) {
|
|
14548
14548
|
const { info, source, lastOnlineAt } = await resolveArkInfo(
|
|
@@ -14571,7 +14571,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14571
14571
|
async getArkadeReader() {
|
|
14572
14572
|
const indexer = this.indexerProvider;
|
|
14573
14573
|
return {
|
|
14574
|
-
getVtxos: (opts) =>
|
|
14574
|
+
getVtxos: (opts) => chunkLZAINCGU_cjs.getNormalizedVtxos(indexer, opts),
|
|
14575
14575
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
14576
14576
|
};
|
|
14577
14577
|
}
|
|
@@ -14621,7 +14621,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14621
14621
|
"Pass either `service` or `operatorProvider`/`indexerProvider`/`onchainProvider`, not both"
|
|
14622
14622
|
);
|
|
14623
14623
|
}
|
|
14624
|
-
const arkProvider = callerProvider || new
|
|
14624
|
+
const arkProvider = callerProvider || new chunkLZAINCGU_cjs.RestOperatorProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
|
|
14625
14625
|
let indexerProvider = config.indexerProvider;
|
|
14626
14626
|
if (!indexerProvider && !config.service) {
|
|
14627
14627
|
const derived = extractOperatorProviderUrl(arkProvider);
|
|
@@ -14630,7 +14630,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14630
14630
|
"indexerProvider is required when operatorProvider is provided without a discoverable serverUrl"
|
|
14631
14631
|
);
|
|
14632
14632
|
}
|
|
14633
|
-
indexerProvider = new
|
|
14633
|
+
indexerProvider = new chunkHKEPJBTY_cjs.RestIndexerProvider(derived ?? chunkFLPWNMX3_cjs.DEFAULT_ARKADE_SERVER_URL);
|
|
14634
14634
|
}
|
|
14635
14635
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
14636
14636
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -14645,7 +14645,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14645
14645
|
if (!resolvedService) throw new Error("indexerProvider is unresolved");
|
|
14646
14646
|
indexerProvider = resolvedService.indexerProvider;
|
|
14647
14647
|
}
|
|
14648
|
-
const network = chunkFLPWNMX3_cjs.
|
|
14648
|
+
const network = chunkFLPWNMX3_cjs.networkFromOperatorInfo(info);
|
|
14649
14649
|
if ("descriptor" in config.identity) {
|
|
14650
14650
|
const descriptor = config.identity.descriptor;
|
|
14651
14651
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -14688,8 +14688,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14688
14688
|
serverPubKey,
|
|
14689
14689
|
csvTimelock: exitTimelock
|
|
14690
14690
|
};
|
|
14691
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
14692
|
-
const boardingTapscript =
|
|
14691
|
+
const offchainTapscript = !delegatePubKey ? new chunkNDQ4LB4X_cjs.DefaultVtxo.Script(offchainOptions) : new chunkNDQ4LB4X_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
14692
|
+
const boardingTapscript = chunkNDQ4LB4X_cjs.BoardingContractHandler.createScript({
|
|
14693
14693
|
pubKey: base.hex.encode(pubKey),
|
|
14694
14694
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
14695
14695
|
csvTimelock: chunkFLPWNMX3_cjs.timelockToSequence(boardingTimelock).toString()
|
|
@@ -14858,7 +14858,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14858
14858
|
if (!filter?.withUnrolled) {
|
|
14859
14859
|
logExcludedVtxos(
|
|
14860
14860
|
"getSpendableVtxos",
|
|
14861
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
14861
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkLZAINCGU_cjs.isVtxoSpent(vtxo)),
|
|
14862
14862
|
[() => UNROLLED_REASON]
|
|
14863
14863
|
);
|
|
14864
14864
|
}
|
|
@@ -15003,7 +15003,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15003
15003
|
this.getBoardingTxs()
|
|
15004
15004
|
]);
|
|
15005
15005
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
15006
|
-
const resolveTxCreatedAt = (txids) =>
|
|
15006
|
+
const resolveTxCreatedAt = (txids) => chunkLZAINCGU_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
15007
15007
|
return buildTransactionHistory(
|
|
15008
15008
|
allVtxos,
|
|
15009
15009
|
boardingTxs,
|
|
@@ -15203,11 +15203,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15203
15203
|
const currentServerPubKey = this.boardingTapscript.options.serverPubKey;
|
|
15204
15204
|
const currentServerSigner = toXOnlySignerHex(base.hex.encode(currentServerPubKey));
|
|
15205
15205
|
const signers = /* @__PURE__ */ new Set([currentServerSigner, ...allowedSigners ?? []]);
|
|
15206
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
15206
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkNDQ4LB4X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
15207
15207
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
15208
15208
|
for (const signer of signers) {
|
|
15209
15209
|
add(
|
|
15210
|
-
new
|
|
15210
|
+
new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({
|
|
15211
15211
|
pubKey: baselinePubkey,
|
|
15212
15212
|
serverPubKey: base.hex.decode(signer),
|
|
15213
15213
|
csvTimelock: boardingCsv
|
|
@@ -15228,7 +15228,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15228
15228
|
continue;
|
|
15229
15229
|
}
|
|
15230
15230
|
add(
|
|
15231
|
-
c.type === "default" ?
|
|
15231
|
+
c.type === "default" ? chunkNDQ4LB4X_cjs.DefaultContractHandler.createScript(c.params) : chunkNDQ4LB4X_cjs.BoardingContractHandler.createScript(c.params)
|
|
15232
15232
|
);
|
|
15233
15233
|
} catch (e) {
|
|
15234
15234
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
@@ -15277,7 +15277,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15277
15277
|
tapscripts.map(async (tapscript, i) => {
|
|
15278
15278
|
const contract = contracts.get(scripts[i]);
|
|
15279
15279
|
const spent = new Set(
|
|
15280
|
-
contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(
|
|
15280
|
+
contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(chunkLZAINCGU_cjs.isVtxoSpent).map(vtxoOutpoint) : []
|
|
15281
15281
|
);
|
|
15282
15282
|
const utxos = fetched[i].filter((c) => !spent.has(vtxoOutpoint(c))).map((utxo) => extendCoinWithTapscript(tapscript, utxo));
|
|
15283
15283
|
return {
|
|
@@ -15306,10 +15306,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15306
15306
|
timer = setTimeout(
|
|
15307
15307
|
() => reject(
|
|
15308
15308
|
new Error(
|
|
15309
|
-
`Boarding address lookup timed out after ${
|
|
15309
|
+
`Boarding address lookup timed out after ${chunkLZAINCGU_cjs.READ_TIMEOUT_MS}ms`
|
|
15310
15310
|
)
|
|
15311
15311
|
),
|
|
15312
|
-
|
|
15312
|
+
chunkLZAINCGU_cjs.READ_TIMEOUT_MS
|
|
15313
15313
|
);
|
|
15314
15314
|
})
|
|
15315
15315
|
]);
|
|
@@ -15495,7 +15495,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15495
15495
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
15496
15496
|
async fetchPendingTxs() {
|
|
15497
15497
|
const scripts = await this.getWalletScripts();
|
|
15498
|
-
const vtxos = await
|
|
15498
|
+
const vtxos = await chunkLZAINCGU_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
15499
15499
|
return vtxos.filter(
|
|
15500
15500
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
15501
15501
|
).map((_) => _.arkTxId);
|
|
@@ -15526,7 +15526,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15526
15526
|
});
|
|
15527
15527
|
for (const contract of contracts) {
|
|
15528
15528
|
if (map.has(contract.script)) continue;
|
|
15529
|
-
const handler =
|
|
15529
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
15530
15530
|
if (handler) {
|
|
15531
15531
|
const script = handler.createScript(contract.params);
|
|
15532
15532
|
map.set(contract.script, script);
|
|
@@ -15645,7 +15645,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15645
15645
|
});
|
|
15646
15646
|
try {
|
|
15647
15647
|
const baselinePubkey = await baselinePubkeyPromise;
|
|
15648
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
15648
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
15649
15649
|
const baselineSigners = [
|
|
15650
15650
|
this.offchainTapscript.options.serverPubKey,
|
|
15651
15651
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -15655,7 +15655,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15655
15655
|
for (const serverPubKey of baselineSigners) {
|
|
15656
15656
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
15657
15657
|
const csvTimelockStr = chunkFLPWNMX3_cjs.timelockToSequence(csvTimelock).toString();
|
|
15658
|
-
const defaultScript = new
|
|
15658
|
+
const defaultScript = new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({
|
|
15659
15659
|
pubKey: baselinePubkey,
|
|
15660
15660
|
serverPubKey,
|
|
15661
15661
|
csvTimelock
|
|
@@ -15676,7 +15676,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15676
15676
|
});
|
|
15677
15677
|
}
|
|
15678
15678
|
if (delegatePubKey) {
|
|
15679
|
-
const delegateScript = new
|
|
15679
|
+
const delegateScript = new chunkNDQ4LB4X_cjs.DelegateVtxo.Script({
|
|
15680
15680
|
pubKey: baselinePubkey,
|
|
15681
15681
|
serverPubKey,
|
|
15682
15682
|
delegatePubKey,
|
|
@@ -15700,9 +15700,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15700
15700
|
}
|
|
15701
15701
|
}
|
|
15702
15702
|
}
|
|
15703
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
15703
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkNDQ4LB4X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
15704
15704
|
for (const serverPubKey of baselineSigners) {
|
|
15705
|
-
const baselineBoarding = new
|
|
15705
|
+
const baselineBoarding = new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({
|
|
15706
15706
|
pubKey: baselinePubkey,
|
|
15707
15707
|
serverPubKey,
|
|
15708
15708
|
csvTimelock: boardingCsvTimelock
|
|
@@ -15919,7 +15919,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15919
15919
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
15920
15920
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
15921
15921
|
csvTimelocks: this.walletContractTimelocks,
|
|
15922
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
15922
|
+
delegatePubKey: this.offchainTapscript instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
15923
15923
|
};
|
|
15924
15924
|
}
|
|
15925
15925
|
_signerRouter;
|
|
@@ -15957,7 +15957,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15957
15957
|
}
|
|
15958
15958
|
/**
|
|
15959
15959
|
* @internal Sole write path for `serverUnrollScript`; called by
|
|
15960
|
-
* {@link Wallet._doRotateServerSigner} with the rotating `
|
|
15960
|
+
* {@link Wallet._doRotateServerSigner} with the rotating `OperatorInfo`'s checkpoint script.
|
|
15961
15961
|
*/
|
|
15962
15962
|
setServerUnrollScriptForRotation(script) {
|
|
15963
15963
|
this._serverUnrollScript = script;
|
|
@@ -16081,7 +16081,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16081
16081
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
16082
16082
|
const persisted = row?.metadata?.signingDescriptor;
|
|
16083
16083
|
if (typeof persisted === "string") return persisted;
|
|
16084
|
-
return
|
|
16084
|
+
return chunkNDQ4LB4X_cjs.identityDescriptor(this.identity);
|
|
16085
16085
|
}
|
|
16086
16086
|
/**
|
|
16087
16087
|
* Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
|
|
@@ -16091,7 +16091,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16091
16091
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
16092
16092
|
if (type === "boarding") {
|
|
16093
16093
|
const built2 = this.buildBoardingContract(
|
|
16094
|
-
|
|
16094
|
+
chunkNDQ4LB4X_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
16095
16095
|
descriptor,
|
|
16096
16096
|
tagSource
|
|
16097
16097
|
);
|
|
@@ -16128,11 +16128,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16128
16128
|
* (offchain analogue: {@link buildReceiveContract}).
|
|
16129
16129
|
*/
|
|
16130
16130
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
16131
|
-
const tapscript = new
|
|
16131
|
+
const tapscript = new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({
|
|
16132
16132
|
...this._boardingTapscript.options,
|
|
16133
16133
|
pubKey
|
|
16134
16134
|
});
|
|
16135
|
-
const csvTimelock = tapscript.options.csvTimelock ??
|
|
16135
|
+
const csvTimelock = tapscript.options.csvTimelock ?? chunkNDQ4LB4X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
16136
16136
|
return {
|
|
16137
16137
|
tapscript,
|
|
16138
16138
|
params: {
|
|
@@ -16146,7 +16146,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16146
16146
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
16147
16147
|
state: "active",
|
|
16148
16148
|
metadata: {
|
|
16149
|
-
...tagSource && { source:
|
|
16149
|
+
...tagSource && { source: chunkNDQ4LB4X_cjs.WALLET_RECEIVE_SOURCE },
|
|
16150
16150
|
signingDescriptor: descriptor
|
|
16151
16151
|
}
|
|
16152
16152
|
}
|
|
@@ -16168,7 +16168,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16168
16168
|
if (this._hdProvider) {
|
|
16169
16169
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
16170
16170
|
}
|
|
16171
|
-
return
|
|
16171
|
+
return chunkNDQ4LB4X_cjs.identityDescriptor(this.identity);
|
|
16172
16172
|
}
|
|
16173
16173
|
/**
|
|
16174
16174
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -16274,21 +16274,21 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16274
16274
|
]);
|
|
16275
16275
|
const [currentOffchainRow] = offchainRows2;
|
|
16276
16276
|
const [currentBoardingRow] = boardingRows;
|
|
16277
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
16277
|
+
const newOffchain = this.offchainTapscript instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script ? new chunkNDQ4LB4X_cjs.DelegateVtxo.Script({
|
|
16278
16278
|
...this.offchainTapscript.options,
|
|
16279
16279
|
serverPubKey: xonly
|
|
16280
|
-
}) : new
|
|
16280
|
+
}) : new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({
|
|
16281
16281
|
...this.offchainTapscript.options,
|
|
16282
16282
|
serverPubKey: xonly
|
|
16283
16283
|
});
|
|
16284
|
-
const newBoarding = new
|
|
16284
|
+
const newBoarding = new chunkNDQ4LB4X_cjs.DefaultVtxo.Script({
|
|
16285
16285
|
...this._boardingTapscript.options,
|
|
16286
16286
|
serverPubKey: xonly
|
|
16287
16287
|
});
|
|
16288
16288
|
const offchainCsv = chunkFLPWNMX3_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
16289
16289
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
16290
16290
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
16291
|
-
if (newOffchain instanceof
|
|
16291
|
+
if (newOffchain instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script) {
|
|
16292
16292
|
await manager.createContract({
|
|
16293
16293
|
type: "delegate",
|
|
16294
16294
|
params: {
|
|
@@ -16316,7 +16316,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16316
16316
|
metadata: currentOffchainRow?.metadata
|
|
16317
16317
|
});
|
|
16318
16318
|
}
|
|
16319
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
16319
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkNDQ4LB4X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
16320
16320
|
await manager.createContract({
|
|
16321
16321
|
type: "boarding",
|
|
16322
16322
|
params: {
|
|
@@ -16350,14 +16350,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16350
16350
|
_restoreInFlight;
|
|
16351
16351
|
_addPendingSpends(inputs) {
|
|
16352
16352
|
for (const input of inputs) {
|
|
16353
|
-
if (
|
|
16353
|
+
if (chunkLZAINCGU_cjs.isVirtualCoin(input)) {
|
|
16354
16354
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
16355
16355
|
}
|
|
16356
16356
|
}
|
|
16357
16357
|
}
|
|
16358
16358
|
_removePendingSpends(inputs) {
|
|
16359
16359
|
for (const input of inputs) {
|
|
16360
|
-
if (
|
|
16360
|
+
if (chunkLZAINCGU_cjs.isVirtualCoin(input)) {
|
|
16361
16361
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
16362
16362
|
}
|
|
16363
16363
|
}
|
|
@@ -16421,7 +16421,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16421
16421
|
if (clashing.length > 0) throw new VtxoReservedError(clashing, "in-flight");
|
|
16422
16422
|
}
|
|
16423
16423
|
_assertNotHeld(inputs) {
|
|
16424
|
-
const held = coinKeys(inputs.filter(
|
|
16424
|
+
const held = coinKeys(inputs.filter(chunkLZAINCGU_cjs.isVirtualCoin)).filter(
|
|
16425
16425
|
(key) => this._heldOutpoints.has(key)
|
|
16426
16426
|
);
|
|
16427
16427
|
if (held.length > 0) throw new VtxoReservedError(held, "held");
|
|
@@ -16460,11 +16460,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16460
16460
|
const hd = provider !== void 0;
|
|
16461
16461
|
const [manager, staticDescriptor, arkInfo] = await Promise.all([
|
|
16462
16462
|
this.getContractManager(),
|
|
16463
|
-
hd ? void 0 :
|
|
16463
|
+
hd ? void 0 : chunkNDQ4LB4X_cjs.identityDescriptor(this.identity),
|
|
16464
16464
|
this.arkProvider.getInfo()
|
|
16465
16465
|
]);
|
|
16466
16466
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
16467
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
16467
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkNDQ4LB4X_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
16468
16468
|
const currentSignerPubKey = chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
16469
16469
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
16470
16470
|
(s) => chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
@@ -16479,7 +16479,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16479
16479
|
deprecatedSignerPubKeys,
|
|
16480
16480
|
csvTimelocks: this.walletContractTimelocks,
|
|
16481
16481
|
// Boarding-exit CSV, distinct from the unilateral-exit matrix.
|
|
16482
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
16482
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkNDQ4LB4X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
16483
16483
|
delegatePubKey
|
|
16484
16484
|
};
|
|
16485
16485
|
const result = await manager.scanContracts({
|
|
@@ -16812,7 +16812,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16812
16812
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
16813
16813
|
break;
|
|
16814
16814
|
}
|
|
16815
|
-
const inputFee = estimator.evalOffchainInput(
|
|
16815
|
+
const inputFee = estimator.evalOffchainInput(chunkLZAINCGU_cjs.toOffchainInputFeeParams(vtxo));
|
|
16816
16816
|
if (inputFee.satoshis >= vtxo.value) {
|
|
16817
16817
|
continue;
|
|
16818
16818
|
}
|
|
@@ -16936,11 +16936,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16936
16936
|
]);
|
|
16937
16937
|
let intentTxId;
|
|
16938
16938
|
try {
|
|
16939
|
-
intentTxId =
|
|
16939
|
+
intentTxId = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
|
|
16940
16940
|
} catch {
|
|
16941
16941
|
intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
|
|
16942
16942
|
}
|
|
16943
|
-
const settleInputVtxos = params.inputs.filter(
|
|
16943
|
+
const settleInputVtxos = params.inputs.filter(chunkLZAINCGU_cjs.isVirtualCoin);
|
|
16944
16944
|
const contractManager = await this.getContractManager();
|
|
16945
16945
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
16946
16946
|
await contractManager.assertSpendableNow?.(
|
|
@@ -16949,7 +16949,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16949
16949
|
);
|
|
16950
16950
|
if (picked) this._assertNotHeld(params.inputs);
|
|
16951
16951
|
this._addPendingSpends(params.inputs);
|
|
16952
|
-
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !
|
|
16952
|
+
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkLZAINCGU_cjs.isVirtualCoin(i))) : [];
|
|
16953
16953
|
for (const key of boardingKeys) this._pendingSpendOutpoints.add(key);
|
|
16954
16954
|
const settlingKeys = params.inputs.map((i) => `${i.txid}:${i.vout}`);
|
|
16955
16955
|
for (const key of settlingKeys) this._settlingOutpoints.add(key);
|
|
@@ -17059,7 +17059,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17059
17059
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
17060
17060
|
if (!this._descriptorProvider) return;
|
|
17061
17061
|
const consumedBoarding = inputs.some(
|
|
17062
|
-
(input) => typeof input !== "string" && !
|
|
17062
|
+
(input) => typeof input !== "string" && !chunkLZAINCGU_cjs.isVirtualCoin(input)
|
|
17063
17063
|
);
|
|
17064
17064
|
if (!consumedBoarding) return;
|
|
17065
17065
|
try {
|
|
@@ -17070,7 +17070,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17070
17070
|
}
|
|
17071
17071
|
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
|
|
17072
17072
|
const signedForfeits = [];
|
|
17073
|
-
let settlementPsbt =
|
|
17073
|
+
let settlementPsbt = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
17074
17074
|
assertFinalCommitmentMatchesValidated(
|
|
17075
17075
|
settlementPsbt,
|
|
17076
17076
|
validatedCommitmentTxid,
|
|
@@ -17083,7 +17083,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17083
17083
|
let connectorIndex = 0;
|
|
17084
17084
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
17085
17085
|
for (const input of inputs) {
|
|
17086
|
-
if (!
|
|
17086
|
+
if (!chunkLZAINCGU_cjs.isVirtualCoin(input)) {
|
|
17087
17087
|
let matched = false;
|
|
17088
17088
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
17089
17089
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -17121,7 +17121,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17121
17121
|
}
|
|
17122
17122
|
continue;
|
|
17123
17123
|
}
|
|
17124
|
-
if (!
|
|
17124
|
+
if (!chunkLZAINCGU_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
17125
17125
|
continue;
|
|
17126
17126
|
}
|
|
17127
17127
|
if (connectorsLeaves.length === 0) {
|
|
@@ -17248,7 +17248,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17248
17248
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
17249
17249
|
return { skip: true };
|
|
17250
17250
|
}
|
|
17251
|
-
const commitmentTx =
|
|
17251
|
+
const commitmentTx = chunkLZAINCGU_cjs.Transaction.fromPSBT(
|
|
17252
17252
|
base.base64.decode(event.unsignedCommitmentTx)
|
|
17253
17253
|
);
|
|
17254
17254
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
@@ -17322,7 +17322,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17322
17322
|
if (!repo) return;
|
|
17323
17323
|
try {
|
|
17324
17324
|
const now = Date.now();
|
|
17325
|
-
const existing = (await
|
|
17325
|
+
const existing = (await collectBatchRegistrations(repo, { proofTxIds: [intentTxId] }))[0];
|
|
17326
17326
|
if (existing && isTerminalBatchRegistrationState(existing.state)) {
|
|
17327
17327
|
return;
|
|
17328
17328
|
}
|
|
@@ -17330,9 +17330,9 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17330
17330
|
...existing ?? {},
|
|
17331
17331
|
proofTxId: intentTxId,
|
|
17332
17332
|
registerProof: intent.proof,
|
|
17333
|
-
registerProofMessage:
|
|
17333
|
+
registerProofMessage: chunkLZAINCGU_cjs.Proof.encodeMessage(intent.message),
|
|
17334
17334
|
deleteProof: deleteIntent.proof,
|
|
17335
|
-
deleteProofMessage:
|
|
17335
|
+
deleteProofMessage: chunkLZAINCGU_cjs.Proof.encodeMessage(deleteIntent.message),
|
|
17336
17336
|
proofInputs: inputs.map((i) => ({
|
|
17337
17337
|
txid: i.txid,
|
|
17338
17338
|
vout: i.vout
|
|
@@ -17363,7 +17363,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17363
17363
|
}
|
|
17364
17364
|
/** @see IWallet.cosignOnchainTx */
|
|
17365
17365
|
async cosignOnchainTx(psbt) {
|
|
17366
|
-
const tx = typeof psbt === "string" ?
|
|
17366
|
+
const tx = typeof psbt === "string" ? chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(psbt)) : psbt;
|
|
17367
17367
|
return this._withTxLock(async () => {
|
|
17368
17368
|
await (await this.getContractManager()).syncOnchain();
|
|
17369
17369
|
return this._cosignOnchainTxImpl(tx);
|
|
@@ -17428,7 +17428,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17428
17428
|
if (reasons.length > 0) throw new OnchainCosignPreflightError(reasons.join("; "));
|
|
17429
17429
|
}
|
|
17430
17430
|
const feeRate = await this.onchainProvider.getFeeRate() ?? 1;
|
|
17431
|
-
const tx = new
|
|
17431
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({ version: 2 });
|
|
17432
17432
|
if (sweepTo) {
|
|
17433
17433
|
const swept = candidates.slice(0, MAX_COSIGN_INPUTS);
|
|
17434
17434
|
for (const { coin } of swept) {
|
|
@@ -17489,7 +17489,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17489
17489
|
continue;
|
|
17490
17490
|
}
|
|
17491
17491
|
const { coin, contract, script } = mine;
|
|
17492
|
-
const path =
|
|
17492
|
+
const path = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type).selectPath(script, contract, {
|
|
17493
17493
|
collaborative: true,
|
|
17494
17494
|
currentTime: Date.now(),
|
|
17495
17495
|
blockHeight: tip.height,
|
|
@@ -17539,7 +17539,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17539
17539
|
onchainProvider: this.onchainProvider
|
|
17540
17540
|
});
|
|
17541
17541
|
} catch (e) {
|
|
17542
|
-
if (e instanceof
|
|
17542
|
+
if (e instanceof chunkLZAINCGU_cjs.OnchainCosignAmbiguousError || isCosignRejectedAfterSigning(e)) {
|
|
17543
17543
|
await markPending(signed.id);
|
|
17544
17544
|
}
|
|
17545
17545
|
throw e;
|
|
@@ -17559,7 +17559,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17559
17559
|
this.lockedOutpoints(),
|
|
17560
17560
|
this.onchainCoins(manager)
|
|
17561
17561
|
]);
|
|
17562
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
17562
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkNDQ4LB4X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
17563
17563
|
return coins.filter(
|
|
17564
17564
|
({ coin, contract }) => !locked.has(vtxoOutpoint(coin)) && needsOnchainSweep(coin, contract, boardingCsv, tip, this._cosignMarginBlocks)
|
|
17565
17565
|
).slice(0, MAX_COSIGN_INPUTS).map(({ coin }) => ({ txid: coin.txid, vout: coin.vout }));
|
|
@@ -17571,8 +17571,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17571
17571
|
unspentOnly: true
|
|
17572
17572
|
});
|
|
17573
17573
|
return snapshot.flatMap(({ contract, vtxos }) => {
|
|
17574
|
-
const handler =
|
|
17575
|
-
const coins = vtxos.filter((v) => v.isUnrolled && !
|
|
17574
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
17575
|
+
const coins = vtxos.filter((v) => v.isUnrolled && !chunkLZAINCGU_cjs.isVtxoSpent(v));
|
|
17576
17576
|
if (!handler || coins.length === 0) return [];
|
|
17577
17577
|
const script = handler.createScript(contract.params);
|
|
17578
17578
|
return coins.map((coin) => ({ coin, contract, script }));
|
|
@@ -17582,7 +17582,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17582
17582
|
try {
|
|
17583
17583
|
return await this.arkProvider.registerIntent(intent);
|
|
17584
17584
|
} catch (error) {
|
|
17585
|
-
if (error instanceof
|
|
17585
|
+
if (error instanceof chunkLZAINCGU_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
17586
17586
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
17587
17587
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
17588
17588
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -17598,7 +17598,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17598
17598
|
expire_at: 0,
|
|
17599
17599
|
cosigners_public_keys: cosignerPubKeys
|
|
17600
17600
|
};
|
|
17601
|
-
const proof =
|
|
17601
|
+
const proof = chunkLZAINCGU_cjs.Proof.create(message, coins, outputs);
|
|
17602
17602
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
17603
17603
|
return {
|
|
17604
17604
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -17610,7 +17610,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17610
17610
|
type: "delete",
|
|
17611
17611
|
expire_at: 0
|
|
17612
17612
|
};
|
|
17613
|
-
const proof =
|
|
17613
|
+
const proof = chunkLZAINCGU_cjs.Proof.create(message, coins, []);
|
|
17614
17614
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
17615
17615
|
return {
|
|
17616
17616
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -17622,7 +17622,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17622
17622
|
type: "get-pending-tx",
|
|
17623
17623
|
expire_at: 0
|
|
17624
17624
|
};
|
|
17625
|
-
const proof =
|
|
17625
|
+
const proof = chunkLZAINCGU_cjs.Proof.create(message, coins, []);
|
|
17626
17626
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
17627
17627
|
return {
|
|
17628
17628
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -17643,7 +17643,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17643
17643
|
if (!vtxos || vtxos.length === 0) {
|
|
17644
17644
|
const scriptMap = await this.getScriptMap();
|
|
17645
17645
|
const allExtended = [];
|
|
17646
|
-
const fetchedVtxos = await
|
|
17646
|
+
const fetchedVtxos = await chunkLZAINCGU_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
17647
17647
|
...scriptMap.keys()
|
|
17648
17648
|
]);
|
|
17649
17649
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -17686,8 +17686,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17686
17686
|
batchPending.push(pendingTx.arkTxid);
|
|
17687
17687
|
try {
|
|
17688
17688
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
17689
|
-
const tx =
|
|
17690
|
-
|
|
17689
|
+
const tx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
17690
|
+
chunkLZAINCGU_cjs.assertAllowedSighashTypes(tx);
|
|
17691
17691
|
return tx;
|
|
17692
17692
|
});
|
|
17693
17693
|
assertCheckpointsMatchInputs(
|
|
@@ -18064,7 +18064,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18064
18064
|
const recoverable = [];
|
|
18065
18065
|
const unclaimed = [];
|
|
18066
18066
|
for (const vtxo of vtxos) {
|
|
18067
|
-
if (
|
|
18067
|
+
if (chunkLZAINCGU_cjs.isVtxoSpent(vtxo)) {
|
|
18068
18068
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
18069
18069
|
} else if (vtxo.isUnrolled) {
|
|
18070
18070
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -18086,7 +18086,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18086
18086
|
const all = [];
|
|
18087
18087
|
const seen = /* @__PURE__ */ new Set();
|
|
18088
18088
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
18089
|
-
const { vtxos, page } = await
|
|
18089
|
+
const { vtxos, page } = await chunkLZAINCGU_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
18090
18090
|
scripts,
|
|
18091
18091
|
pageIndex,
|
|
18092
18092
|
pageSize
|
|
@@ -18124,7 +18124,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18124
18124
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_PROOF) {
|
|
18125
18125
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_PROOF);
|
|
18126
18126
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
18127
|
-
const proof =
|
|
18127
|
+
const proof = chunkLZAINCGU_cjs.Proof.create(message, batch, []);
|
|
18128
18128
|
const signedProof = await identity.sign(
|
|
18129
18129
|
proof,
|
|
18130
18130
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -18145,8 +18145,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18145
18145
|
for (const pendingTx of pendingTxs) {
|
|
18146
18146
|
try {
|
|
18147
18147
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
18148
|
-
const tx =
|
|
18149
|
-
|
|
18148
|
+
const tx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
18149
|
+
chunkLZAINCGU_cjs.assertAllowedSighashTypes(tx);
|
|
18150
18150
|
return tx;
|
|
18151
18151
|
});
|
|
18152
18152
|
assertCheckpointsMatchInputs(
|
|
@@ -18186,7 +18186,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18186
18186
|
}
|
|
18187
18187
|
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
18188
18188
|
arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
|
|
18189
|
-
const arkTx =
|
|
18189
|
+
const arkTx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
|
|
18190
18190
|
let total = 0;
|
|
18191
18191
|
for (let i = 0; i < arkTx.outputsLength; i++) {
|
|
18192
18192
|
const output = arkTx.getOutput(i);
|
|
@@ -18245,7 +18245,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18245
18245
|
throw new Error("send({ maxChangeFee }): expected a non-negative safe integer");
|
|
18246
18246
|
}
|
|
18247
18247
|
if (selectedVtxos) {
|
|
18248
|
-
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(
|
|
18248
|
+
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkLZAINCGU_cjs.normalizeVtxo);
|
|
18249
18249
|
if (inputExpiryFloor && selectedVtxos.some((coin) => !meetsInputExpiryFloor(coin, inputExpiryFloor))) {
|
|
18250
18250
|
throw new Error("send({ selectedVtxos }): input expiry floor not met");
|
|
18251
18251
|
}
|
|
@@ -18572,10 +18572,10 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18572
18572
|
const serverPubKey = this.arkServerPublicKey;
|
|
18573
18573
|
const serverUnrollScript = this.serverUnrollScript;
|
|
18574
18574
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
18575
|
-
const normalizedInputs = inputs.map(
|
|
18576
|
-
const at = now ?? await
|
|
18575
|
+
const normalizedInputs = inputs.map(chunkLZAINCGU_cjs.normalizeVtxo);
|
|
18576
|
+
const at = now ?? await chunkLZAINCGU_cjs.resolveTimeHeight(this.onchainProvider);
|
|
18577
18577
|
for (const input of normalizedInputs) {
|
|
18578
|
-
if (!
|
|
18578
|
+
if (!chunkLZAINCGU_cjs.canSpendOffchain(input, at)) {
|
|
18579
18579
|
throw new Error(
|
|
18580
18580
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
18581
18581
|
);
|
|
@@ -18769,7 +18769,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18769
18769
|
}
|
|
18770
18770
|
const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
|
|
18771
18771
|
for (const encoded of signedCheckpointTxs) {
|
|
18772
|
-
const checkpoint =
|
|
18772
|
+
const checkpoint = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
18773
18773
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
18774
18774
|
const input = checkpoint.getInput(i);
|
|
18775
18775
|
if (!input.txid) continue;
|
|
@@ -18886,12 +18886,12 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18886
18886
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
18887
18887
|
const boardingScripts = /* @__PURE__ */ new Set();
|
|
18888
18888
|
const boardingOutpoints = [];
|
|
18889
|
-
const vtxoInputs = inputs.filter(
|
|
18889
|
+
const vtxoInputs = inputs.filter(chunkLZAINCGU_cjs.isVirtualCoin);
|
|
18890
18890
|
const cm = await this.getContractManager();
|
|
18891
18891
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
18892
18892
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
18893
18893
|
for (const input of inputs) {
|
|
18894
|
-
if (
|
|
18894
|
+
if (chunkLZAINCGU_cjs.isVirtualCoin(input)) {
|
|
18895
18895
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
18896
18896
|
const vtxo = annotatedByKey.get(outpoint);
|
|
18897
18897
|
if (!vtxo) {
|
|
@@ -18974,7 +18974,7 @@ function bySelectionOrder(a, b) {
|
|
|
18974
18974
|
return b.value - a.value;
|
|
18975
18975
|
}
|
|
18976
18976
|
function selectVirtualCoins(coins, targetAmount) {
|
|
18977
|
-
const sortedCoins = coins.map(
|
|
18977
|
+
const sortedCoins = coins.map(chunkLZAINCGU_cjs.normalizeVtxo).sort(bySelectionOrder);
|
|
18978
18978
|
const selectedCoins = [];
|
|
18979
18979
|
let selectedAmount = 0;
|
|
18980
18980
|
for (const coin of sortedCoins) {
|
|
@@ -19026,13 +19026,20 @@ async function waitForIncomingFunds(wallet, options) {
|
|
|
19026
19026
|
let settled = false;
|
|
19027
19027
|
let timeoutId;
|
|
19028
19028
|
let onAbort;
|
|
19029
|
+
const stopSafely = (stop) => {
|
|
19030
|
+
try {
|
|
19031
|
+
stop();
|
|
19032
|
+
} catch (e) {
|
|
19033
|
+
console.warn("waitForIncomingFunds teardown failed", e);
|
|
19034
|
+
}
|
|
19035
|
+
};
|
|
19029
19036
|
return new Promise((resolve, reject) => {
|
|
19030
19037
|
const settle = (deliver) => {
|
|
19031
19038
|
if (settled) return;
|
|
19032
19039
|
settled = true;
|
|
19033
19040
|
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
19034
19041
|
if (onAbort) signal?.removeEventListener("abort", onAbort);
|
|
19035
|
-
stopFunc
|
|
19042
|
+
if (stopFunc) stopSafely(stopFunc);
|
|
19036
19043
|
deliver();
|
|
19037
19044
|
};
|
|
19038
19045
|
const cancel = (reason) => settle(() => reject(reason));
|
|
@@ -19046,16 +19053,20 @@ async function waitForIncomingFunds(wallet, options) {
|
|
|
19046
19053
|
timeoutMs
|
|
19047
19054
|
);
|
|
19048
19055
|
}
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
|
|
19056
|
+
try {
|
|
19057
|
+
wallet.notifyIncomingFunds((funds) => {
|
|
19058
|
+
const hasFunds = funds.type === "utxo" ? funds.coins.length > 0 : funds.newVtxos.length > 0;
|
|
19059
|
+
if (settled || !hasFunds) return;
|
|
19060
|
+
settle(() => resolve(funds));
|
|
19061
|
+
}).then((stop) => {
|
|
19062
|
+
stopFunc = stop;
|
|
19063
|
+
if (settled) stopSafely(stop);
|
|
19064
|
+
}).catch((error) => {
|
|
19065
|
+
cancel(error);
|
|
19066
|
+
});
|
|
19067
|
+
} catch (error) {
|
|
19057
19068
|
cancel(error);
|
|
19058
|
-
}
|
|
19069
|
+
}
|
|
19059
19070
|
});
|
|
19060
19071
|
}
|
|
19061
19072
|
|
|
@@ -19091,7 +19102,7 @@ function assertTimeoutMap(name, timeouts) {
|
|
|
19091
19102
|
if (value === void 0) {
|
|
19092
19103
|
throw new Error(`${name}.${key} must be a non-negative safe integer`);
|
|
19093
19104
|
}
|
|
19094
|
-
|
|
19105
|
+
chunkLZAINCGU_cjs.assertTimerMs(`${name}.${key}`, value);
|
|
19095
19106
|
}
|
|
19096
19107
|
}
|
|
19097
19108
|
var MessageBus = class {
|
|
@@ -19108,8 +19119,8 @@ var MessageBus = class {
|
|
|
19108
19119
|
}) {
|
|
19109
19120
|
this.walletRepository = walletRepository;
|
|
19110
19121
|
this.contractRepository = contractRepository;
|
|
19111
|
-
|
|
19112
|
-
|
|
19122
|
+
chunkLZAINCGU_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
|
|
19123
|
+
chunkLZAINCGU_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
|
|
19113
19124
|
assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
|
|
19114
19125
|
this.intentRepository = intentRepository;
|
|
19115
19126
|
this.onchainProvider = onchainProvider;
|
|
@@ -19365,14 +19376,14 @@ var MessageBus = class {
|
|
|
19365
19376
|
this.initialized = true;
|
|
19366
19377
|
}
|
|
19367
19378
|
async buildServices(config) {
|
|
19368
|
-
const arkProvider = new
|
|
19379
|
+
const arkProvider = new chunkLZAINCGU_cjs.RestOperatorProvider(config.arkServer.url);
|
|
19369
19380
|
const storage = {
|
|
19370
19381
|
walletRepository: this.walletRepository,
|
|
19371
19382
|
contractRepository: this.contractRepository,
|
|
19372
19383
|
...this.intentRepository && { intentRepository: this.intentRepository }
|
|
19373
19384
|
};
|
|
19374
19385
|
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
|
|
19375
|
-
const indexerProvider = new
|
|
19386
|
+
const indexerProvider = new chunkHKEPJBTY_cjs.RestIndexerProvider(config.arkServer.url);
|
|
19376
19387
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
19377
19388
|
if (isSigningSerialized(serialized)) {
|
|
19378
19389
|
const identity2 = hydrateIdentity(serialized);
|
|
@@ -19755,7 +19766,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
19755
19766
|
const inputs = [];
|
|
19756
19767
|
let subtotal = 0n;
|
|
19757
19768
|
for (const vtxo of vtxos) {
|
|
19758
|
-
const inputFee = estimator.evalOffchainInput(
|
|
19769
|
+
const inputFee = estimator.evalOffchainInput(chunkLZAINCGU_cjs.toOffchainInputFeeParams(vtxo));
|
|
19759
19770
|
if (inputFee.satoshis >= vtxo.value) {
|
|
19760
19771
|
if (named) {
|
|
19761
19772
|
throw new Error(
|
|
@@ -20020,7 +20031,7 @@ var Ramps = class {
|
|
|
20020
20031
|
const ordered = [...candidates].sort(bySelectionOrder);
|
|
20021
20032
|
let covered = 0n;
|
|
20022
20033
|
for (let i = 0; i < ordered.length && i < MAX_VTXOS_PER_SETTLEMENT; i++) {
|
|
20023
|
-
const fee = estimator.evalOffchainInput(
|
|
20034
|
+
const fee = estimator.evalOffchainInput(chunkLZAINCGU_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
|
|
20024
20035
|
covered += BigInt(ordered[i].value) - BigInt(fee);
|
|
20025
20036
|
if (covered < needed) continue;
|
|
20026
20037
|
try {
|
|
@@ -21016,7 +21027,7 @@ var WalletMessageHandler = class {
|
|
|
21016
21027
|
this.lazyBoardingInit = payload.lazyBoarding ?? false;
|
|
21017
21028
|
this.boardingEpoch++;
|
|
21018
21029
|
this.boardingLoaded = false;
|
|
21019
|
-
this.indexerProvider = new
|
|
21030
|
+
this.indexerProvider = new chunkHKEPJBTY_cjs.RestIndexerProvider(arkServerUrl);
|
|
21020
21031
|
await this.onWalletInitialized();
|
|
21021
21032
|
}
|
|
21022
21033
|
/** @see RequestInitWallet.payload.lazyBoarding */
|
|
@@ -21464,7 +21475,7 @@ var WalletMessageHandler = class {
|
|
|
21464
21475
|
this.readonlyWallet.getBoardingTxs()
|
|
21465
21476
|
]);
|
|
21466
21477
|
const indexerProvider = this.indexerProvider;
|
|
21467
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
21478
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkLZAINCGU_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
21468
21479
|
return buildTransactionHistory(
|
|
21469
21480
|
vtxos,
|
|
21470
21481
|
boardingTxs,
|
|
@@ -21533,9 +21544,9 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
21533
21544
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
21534
21545
|
// page deadline fires — lowering it below the budget would time the page
|
|
21535
21546
|
// out while the worker is still seconds from answering from cache.
|
|
21536
|
-
GET_OPERATOR_INFO:
|
|
21547
|
+
GET_OPERATOR_INFO: chunkLZAINCGU_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
21537
21548
|
/** @deprecated Use `GET_OPERATOR_INFO`. */
|
|
21538
|
-
GET_ARKADE_INFO:
|
|
21549
|
+
GET_ARKADE_INFO: chunkLZAINCGU_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
21539
21550
|
INDEXER_GET_VTXOS: 2e4,
|
|
21540
21551
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
21541
21552
|
GET_VTXOS: 2e4,
|
|
@@ -21633,10 +21644,10 @@ function getRequestDedupKey(request) {
|
|
|
21633
21644
|
}
|
|
21634
21645
|
function cosignWorkerError(e) {
|
|
21635
21646
|
if (e instanceof Error && e.message === "Unknown message") {
|
|
21636
|
-
return new
|
|
21647
|
+
return new chunkLZAINCGU_cjs.OnchainCosignUnsupportedError();
|
|
21637
21648
|
}
|
|
21638
21649
|
if (e instanceof ServiceWorkerTimeoutError) {
|
|
21639
|
-
return new
|
|
21650
|
+
return new chunkLZAINCGU_cjs.OnchainCosignAmbiguousError(e.message, { cause: e });
|
|
21640
21651
|
}
|
|
21641
21652
|
return rehydrateCosignError(e);
|
|
21642
21653
|
}
|
|
@@ -21691,7 +21702,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
|
|
|
21691
21702
|
}
|
|
21692
21703
|
};
|
|
21693
21704
|
var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
|
|
21694
|
-
|
|
21705
|
+
chunkLZAINCGU_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
|
|
21695
21706
|
const initCmd = {
|
|
21696
21707
|
tag: "INITIALIZE_MESSAGE_BUS",
|
|
21697
21708
|
id: getRandomId(),
|
|
@@ -21789,7 +21800,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
21789
21800
|
Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
|
|
21790
21801
|
);
|
|
21791
21802
|
for (const [key, value] of Object.entries(overrides)) {
|
|
21792
|
-
|
|
21803
|
+
chunkLZAINCGU_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
|
|
21793
21804
|
}
|
|
21794
21805
|
const messageTimeouts = {
|
|
21795
21806
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -22134,7 +22145,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22134
22145
|
try {
|
|
22135
22146
|
const response = await this.sendMessage(message);
|
|
22136
22147
|
const { vtxos, page } = response.payload;
|
|
22137
|
-
return { vtxos: vtxos.map(
|
|
22148
|
+
return { vtxos: vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo), page: page && { ...page } };
|
|
22138
22149
|
} catch (cause) {
|
|
22139
22150
|
throw new Error(`Failed to get vtxos: ${cause}`, { cause });
|
|
22140
22151
|
}
|
|
@@ -22243,7 +22254,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22243
22254
|
};
|
|
22244
22255
|
try {
|
|
22245
22256
|
const response = await this.sendMessage(message);
|
|
22246
|
-
return response.payload.vtxos.map(
|
|
22257
|
+
return response.payload.vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo);
|
|
22247
22258
|
} catch (error) {
|
|
22248
22259
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
22249
22260
|
}
|
|
@@ -22274,7 +22285,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22274
22285
|
"Service worker does not support the requested contract scope or freshness check"
|
|
22275
22286
|
);
|
|
22276
22287
|
}
|
|
22277
|
-
return payload.vtxos.map(
|
|
22288
|
+
return payload.vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo);
|
|
22278
22289
|
} catch (error) {
|
|
22279
22290
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
22280
22291
|
}
|
|
@@ -22469,7 +22480,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22469
22480
|
};
|
|
22470
22481
|
try {
|
|
22471
22482
|
const response = await sendContractMessage(message);
|
|
22472
|
-
return response.payload.vtxos.map(
|
|
22483
|
+
return response.payload.vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo);
|
|
22473
22484
|
} catch (cause) {
|
|
22474
22485
|
throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
|
|
22475
22486
|
}
|
|
@@ -23141,7 +23152,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
23141
23152
|
};
|
|
23142
23153
|
try {
|
|
23143
23154
|
const response = await wallet.sendMessage(message);
|
|
23144
|
-
return response.payload.vtxos.map(
|
|
23155
|
+
return response.payload.vtxos.map(chunkLZAINCGU_cjs.normalizeVtxo);
|
|
23145
23156
|
} catch (e) {
|
|
23146
23157
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
23147
23158
|
}
|
|
@@ -23363,7 +23374,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
23363
23374
|
feeRate,
|
|
23364
23375
|
params.address
|
|
23365
23376
|
);
|
|
23366
|
-
let tx = new
|
|
23377
|
+
let tx = new chunkLZAINCGU_cjs.Transaction();
|
|
23367
23378
|
for (const input of inputs) {
|
|
23368
23379
|
tx.addInput({
|
|
23369
23380
|
txid: input.txid,
|
|
@@ -23421,7 +23432,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
23421
23432
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
23422
23433
|
*/
|
|
23423
23434
|
async bumpAnchor(parentHex, feeRate) {
|
|
23424
|
-
const parent =
|
|
23435
|
+
const parent = chunkLZAINCGU_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
23425
23436
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
23426
23437
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
23427
23438
|
return [parent.hex, child.hex];
|
|
@@ -24273,7 +24284,7 @@ var CachingOperatorProvider = class {
|
|
|
24273
24284
|
constructor(inner, ttlMs = DEFAULT_TTL_MS) {
|
|
24274
24285
|
this.inner = inner;
|
|
24275
24286
|
this.ttlMs = ttlMs;
|
|
24276
|
-
|
|
24287
|
+
chunkLZAINCGU_cjs.assertNonNegativeMs("ttlMs", ttlMs);
|
|
24277
24288
|
this.unsubscribe = inner.onServerInfoChanged?.((info) => {
|
|
24278
24289
|
this.cached = info;
|
|
24279
24290
|
this.expiresAt = Date.now() + this.ttlMs;
|
|
@@ -24360,7 +24371,7 @@ exports.BIP322 = void 0;
|
|
|
24360
24371
|
async function sign2(message, identity, network) {
|
|
24361
24372
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
24362
24373
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
24363
|
-
const toSpend =
|
|
24374
|
+
const toSpend = chunkLZAINCGU_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
24364
24375
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
24365
24376
|
const signed = await identity.sign(toSign, [0]);
|
|
24366
24377
|
signed.finalizeIdx(0);
|
|
@@ -24418,7 +24429,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
24418
24429
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
24419
24430
|
return false;
|
|
24420
24431
|
}
|
|
24421
|
-
const toSpend =
|
|
24432
|
+
const toSpend = chunkLZAINCGU_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
24422
24433
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
|
|
24423
24434
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
24424
24435
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -24439,7 +24450,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
24439
24450
|
}
|
|
24440
24451
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
24441
24452
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
24442
|
-
const toSpend =
|
|
24453
|
+
const toSpend = chunkLZAINCGU_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
24443
24454
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
24444
24455
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
24445
24456
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -24492,7 +24503,7 @@ function encodeCompactSize(n) {
|
|
|
24492
24503
|
return buf;
|
|
24493
24504
|
}
|
|
24494
24505
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
24495
|
-
const tx = new
|
|
24506
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({ version: 0 });
|
|
24496
24507
|
tx.addInput({
|
|
24497
24508
|
txid: toSpend.id,
|
|
24498
24509
|
index: 0,
|
|
@@ -24506,12 +24517,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
24506
24517
|
});
|
|
24507
24518
|
tx.addOutput({
|
|
24508
24519
|
amount: 0n,
|
|
24509
|
-
script:
|
|
24520
|
+
script: chunkLZAINCGU_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
24510
24521
|
});
|
|
24511
24522
|
return tx;
|
|
24512
24523
|
}
|
|
24513
24524
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
24514
|
-
const tx = new
|
|
24525
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({ version: 0 });
|
|
24515
24526
|
tx.addInput({
|
|
24516
24527
|
txid: toSpend.id,
|
|
24517
24528
|
index: 0,
|
|
@@ -24523,12 +24534,12 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
24523
24534
|
});
|
|
24524
24535
|
tx.addOutput({
|
|
24525
24536
|
amount: 0n,
|
|
24526
|
-
script:
|
|
24537
|
+
script: chunkLZAINCGU_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
24527
24538
|
});
|
|
24528
24539
|
return tx;
|
|
24529
24540
|
}
|
|
24530
24541
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
24531
|
-
const tx =
|
|
24542
|
+
const tx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
24532
24543
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
24533
24544
|
const input = tx.getInput(0);
|
|
24534
24545
|
if (!input) {
|
|
@@ -24562,7 +24573,7 @@ async function resolveUnilateralPath(params) {
|
|
|
24562
24573
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
24563
24574
|
const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
|
|
24564
24575
|
if (contract) {
|
|
24565
|
-
const handler =
|
|
24576
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
24566
24577
|
if (!handler) {
|
|
24567
24578
|
throw new ExitPathError(
|
|
24568
24579
|
"no-handler",
|
|
@@ -24798,7 +24809,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
24798
24809
|
let totalAmount = 0n;
|
|
24799
24810
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
24800
24811
|
for (const vtxo of vtxos) {
|
|
24801
|
-
if (!
|
|
24812
|
+
if (!chunkLZAINCGU_cjs.canSweepOnchain(vtxo)) {
|
|
24802
24813
|
throw new Error(
|
|
24803
24814
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
24804
24815
|
);
|
|
@@ -24850,7 +24861,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
24850
24861
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
24851
24862
|
);
|
|
24852
24863
|
}
|
|
24853
|
-
const tx = new
|
|
24864
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({ version: 2 });
|
|
24854
24865
|
for (const input of inputs) {
|
|
24855
24866
|
tx.addInput(input);
|
|
24856
24867
|
}
|
|
@@ -24933,7 +24944,7 @@ async function buildSignedSweep(params) {
|
|
|
24933
24944
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
24934
24945
|
);
|
|
24935
24946
|
}
|
|
24936
|
-
const tx = new
|
|
24947
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({ version: 2 });
|
|
24937
24948
|
tx.addInput({
|
|
24938
24949
|
txid: vtxo.txid,
|
|
24939
24950
|
index: vtxo.vout,
|
|
@@ -24988,7 +24999,7 @@ async function resolveFeeRate(opts) {
|
|
|
24988
24999
|
}
|
|
24989
25000
|
async function selectExitVtxos(opts) {
|
|
24990
25001
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
24991
|
-
const res = await
|
|
25002
|
+
const res = await chunkLZAINCGU_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
24992
25003
|
const scripts = [
|
|
24993
25004
|
...new Set(res.vtxos.filter((vtxo) => !vtxo.isSpent).map((vtxo) => vtxo.script))
|
|
24994
25005
|
];
|
|
@@ -25006,7 +25017,7 @@ async function selectExitVtxos(opts) {
|
|
|
25006
25017
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
25007
25018
|
);
|
|
25008
25019
|
}
|
|
25009
|
-
const handler =
|
|
25020
|
+
const handler = chunkNDQ4LB4X_cjs.contractHandlers.get(contract.type);
|
|
25010
25021
|
if (!handler) {
|
|
25011
25022
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
25012
25023
|
}
|
|
@@ -25040,7 +25051,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
25040
25051
|
if (pendingNodes.length > 0) {
|
|
25041
25052
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
25042
25053
|
for (const psbt of txs) {
|
|
25043
|
-
psbts.set(
|
|
25054
|
+
psbts.set(chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
25044
25055
|
}
|
|
25045
25056
|
}
|
|
25046
25057
|
const childVsize = Number(
|
|
@@ -25205,7 +25216,7 @@ var Executor = class {
|
|
|
25205
25216
|
constructor(pkg, provider, opts) {
|
|
25206
25217
|
this.pkg = pkg;
|
|
25207
25218
|
this.provider = provider;
|
|
25208
|
-
|
|
25219
|
+
chunkLZAINCGU_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
|
|
25209
25220
|
this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
|
|
25210
25221
|
this.feeWallet = opts?.feeWallet;
|
|
25211
25222
|
this.signal = opts?.signal;
|
|
@@ -25589,7 +25600,7 @@ async function prepare(opts) {
|
|
|
25589
25600
|
if (newFee <= splitterFee) break;
|
|
25590
25601
|
splitterFee = newFee;
|
|
25591
25602
|
}
|
|
25592
|
-
const splitter = new
|
|
25603
|
+
const splitter = new chunkLZAINCGU_cjs.Transaction({ version: 2 });
|
|
25593
25604
|
for (const coin of selected.inputs) {
|
|
25594
25605
|
splitter.addInput({
|
|
25595
25606
|
txid: coin.txid,
|
|
@@ -25768,7 +25779,7 @@ chunkFLPWNMX3_cjs.__export(arkade_exports, {
|
|
|
25768
25779
|
validateProgram: () => chunkJFJNB7ZH_cjs.validateProgram,
|
|
25769
25780
|
witnessRefToBytes: () => chunkJFJNB7ZH_cjs.witnessRefToBytes
|
|
25770
25781
|
});
|
|
25771
|
-
var isVtxoCoin = (input) =>
|
|
25782
|
+
var isVtxoCoin = (input) => chunkLZAINCGU_cjs.isVirtualCoin(input);
|
|
25772
25783
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
25773
25784
|
if (!signer && inputs.some((input) => !isVtxoCoin(input))) {
|
|
25774
25785
|
throw new Error("createArkadeBatchHandler: boarding inputs need a signer");
|
|
@@ -25811,7 +25822,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25811
25822
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
25812
25823
|
return { skip: true };
|
|
25813
25824
|
}
|
|
25814
|
-
const commitmentTx =
|
|
25825
|
+
const commitmentTx = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
25815
25826
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
25816
25827
|
if (recipients && recipients.length > 0) {
|
|
25817
25828
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -25849,7 +25860,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25849
25860
|
if (connectorTree) {
|
|
25850
25861
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
25851
25862
|
}
|
|
25852
|
-
let commitmentPsbt =
|
|
25863
|
+
let commitmentPsbt = chunkLZAINCGU_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
25853
25864
|
assertFinalCommitmentMatchesValidated(
|
|
25854
25865
|
commitmentPsbt,
|
|
25855
25866
|
validatedCommitmentTxid,
|
|
@@ -25891,7 +25902,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25891
25902
|
boardingIndices.push(boardingIdx);
|
|
25892
25903
|
continue;
|
|
25893
25904
|
}
|
|
25894
|
-
if (!
|
|
25905
|
+
if (!chunkLZAINCGU_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
25895
25906
|
continue;
|
|
25896
25907
|
}
|
|
25897
25908
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -25929,7 +25940,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25929
25940
|
forfeitOutputScript
|
|
25930
25941
|
);
|
|
25931
25942
|
if (input.extraWitness?.length) {
|
|
25932
|
-
|
|
25943
|
+
chunkLZAINCGU_cjs.setArkPsbtField(forfeitTx, 0, chunkLZAINCGU_cjs.ConditionWitness, input.extraWitness);
|
|
25933
25944
|
}
|
|
25934
25945
|
if (signer) forfeitTx = await signer.sign(forfeitTx, [0]);
|
|
25935
25946
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -26024,7 +26035,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
|
|
|
26024
26035
|
});
|
|
26025
26036
|
const { fees } = await arkProvider.getInfo();
|
|
26026
26037
|
const fee = new Estimator(fees?.intentFee ?? {}).evaluate(
|
|
26027
|
-
legs.map(({ coin }) =>
|
|
26038
|
+
legs.map(({ coin }) => chunkLZAINCGU_cjs.toOffchainInputFeeParams(chunkLZAINCGU_cjs.normalizeVtxo(coin))),
|
|
26028
26039
|
[],
|
|
26029
26040
|
legs.map(({ contract, coin }) => ({
|
|
26030
26041
|
amount: BigInt(coin.value),
|
|
@@ -26087,7 +26098,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
|
|
|
26087
26098
|
const [signedProof, deleteProof] = await Promise.all(
|
|
26088
26099
|
[message, deleteMessage].map(
|
|
26089
26100
|
(m) => emulator.submitIntent({
|
|
26090
|
-
proof: base.base64.encode(
|
|
26101
|
+
proof: base.base64.encode(chunkLZAINCGU_cjs.Proof.create(m, coins, outputs).toPSBT()),
|
|
26091
26102
|
message: m
|
|
26092
26103
|
})
|
|
26093
26104
|
)
|
|
@@ -26564,17 +26575,17 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
26564
26575
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
26565
26576
|
if (registered) {
|
|
26566
26577
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
26567
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
26578
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkLZAINCGU_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
26568
26579
|
}
|
|
26569
26580
|
}
|
|
26570
26581
|
if (!this.client.indexer) {
|
|
26571
26582
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
26572
26583
|
}
|
|
26573
|
-
const { vtxos } = await
|
|
26584
|
+
const { vtxos } = await chunkLZAINCGU_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
26574
26585
|
scripts: [scriptHex],
|
|
26575
26586
|
spendableOnly: true
|
|
26576
26587
|
});
|
|
26577
|
-
return vtxos.filter((v) => !
|
|
26588
|
+
return vtxos.filter((v) => !chunkLZAINCGU_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
26578
26589
|
}
|
|
26579
26590
|
/** Total spendable balance (requires an indexer). */
|
|
26580
26591
|
async getBalance() {
|
|
@@ -26740,7 +26751,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
26740
26751
|
this.client.checkpoint
|
|
26741
26752
|
);
|
|
26742
26753
|
inputs.forEach(({ coin }, i) => {
|
|
26743
|
-
if (coin.sourceTx)
|
|
26754
|
+
if (coin.sourceTx) chunkLZAINCGU_cjs.setArkPsbtField(arkTx, i, chunkLZAINCGU_cjs.PrevArkTxField, coin.sourceTx);
|
|
26744
26755
|
});
|
|
26745
26756
|
if (inputs.some(({ unlocker }) => unlocker.fn.arkadeScript)) {
|
|
26746
26757
|
const indexer = this.client.indexer;
|
|
@@ -26760,8 +26771,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
26760
26771
|
(w) => witnessBytes(unlocker, w)
|
|
26761
26772
|
);
|
|
26762
26773
|
if (condition.length === 0) return;
|
|
26763
|
-
|
|
26764
|
-
|
|
26774
|
+
chunkLZAINCGU_cjs.setArkPsbtField(arkTx, i, chunkLZAINCGU_cjs.ConditionWitness, condition);
|
|
26775
|
+
chunkLZAINCGU_cjs.setArkPsbtField(checkpoints[i], 0, chunkLZAINCGU_cjs.ConditionWitness, condition);
|
|
26765
26776
|
});
|
|
26766
26777
|
const packets = [];
|
|
26767
26778
|
if (this.assetSpecs.length > 0) {
|
|
@@ -26824,7 +26835,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
26824
26835
|
);
|
|
26825
26836
|
}
|
|
26826
26837
|
const { sequence, lockTime } = this.leafTimelocks(fn);
|
|
26827
|
-
const tx = new
|
|
26838
|
+
const tx = new chunkLZAINCGU_cjs.Transaction({ version: 2, lockTime });
|
|
26828
26839
|
tx.addInput({ txid: base.hex.decode(coin.txid), index: coin.vout, sequence });
|
|
26829
26840
|
for (const o of outputs) tx.addOutput(o);
|
|
26830
26841
|
const condition = (fn.def.tapscript.witness ?? []).map((w) => witnessBytes(unlocker, w));
|
|
@@ -26988,20 +26999,20 @@ var ArkadeTransactionBuilder = class {
|
|
|
26988
26999
|
* A caller's packet counts for every input, unread; arkd checks what it actually routes.
|
|
26989
27000
|
*/
|
|
26990
27001
|
routesAssetsFrom(vin) {
|
|
26991
|
-
return this.extraPackets.some((p) => p.type() ===
|
|
27002
|
+
return this.extraPackets.some((p) => p.type() === chunkHKEPJBTY_cjs.Packet.PACKET_TYPE) || this.assetSpecs.some((spec) => spec.inputs.some((i) => i.vin === vin));
|
|
26992
27003
|
}
|
|
26993
27004
|
buildAssetPacket() {
|
|
26994
27005
|
const groups = this.assetSpecs.map((s) => {
|
|
26995
|
-
const id = typeof s.assetId === "string" ?
|
|
26996
|
-
return
|
|
27006
|
+
const id = typeof s.assetId === "string" ? chunkHKEPJBTY_cjs.AssetId.fromString(s.assetId) : chunkHKEPJBTY_cjs.AssetId.fromBytes(s.assetId);
|
|
27007
|
+
return chunkHKEPJBTY_cjs.AssetGroup.create(
|
|
26997
27008
|
id,
|
|
26998
27009
|
null,
|
|
26999
|
-
s.inputs.map((i) =>
|
|
27000
|
-
s.outputs.map((o) =>
|
|
27001
|
-
(s.metadata ?? []).map((m) =>
|
|
27010
|
+
s.inputs.map((i) => chunkHKEPJBTY_cjs.AssetInput.create(i.vin, i.amount)),
|
|
27011
|
+
s.outputs.map((o) => chunkHKEPJBTY_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
27012
|
+
(s.metadata ?? []).map((m) => chunkHKEPJBTY_cjs.Metadata.create(m.key, m.value))
|
|
27002
27013
|
);
|
|
27003
27014
|
});
|
|
27004
|
-
return
|
|
27015
|
+
return chunkHKEPJBTY_cjs.Packet.create(groups);
|
|
27005
27016
|
}
|
|
27006
27017
|
};
|
|
27007
27018
|
function unspendable(coin, now) {
|
|
@@ -27474,14 +27485,14 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
27474
27485
|
function offchainInputFees(vtxos, fees) {
|
|
27475
27486
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
27476
27487
|
return vtxos.reduce(
|
|
27477
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
27488
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkLZAINCGU_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
27478
27489
|
0
|
|
27479
27490
|
);
|
|
27480
27491
|
}
|
|
27481
27492
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
27482
27493
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
27483
27494
|
const net = inputs.reduce(
|
|
27484
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
27495
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkLZAINCGU_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
27485
27496
|
0n
|
|
27486
27497
|
);
|
|
27487
27498
|
const script = base.hex.encode(chunkFLPWNMX3_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
@@ -27806,5 +27817,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
27806
27817
|
exports.walletFeeSource = walletFeeSource;
|
|
27807
27818
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
27808
27819
|
exports.withPrevTxs = withPrevTxs;
|
|
27809
|
-
//# sourceMappingURL=chunk-
|
|
27810
|
-
//# sourceMappingURL=chunk-
|
|
27820
|
+
//# sourceMappingURL=chunk-Y3CDDPWI.cjs.map
|
|
27821
|
+
//# sourceMappingURL=chunk-Y3CDDPWI.cjs.map
|