@arkade-os/sdk 0.5.0-rc.26 → 0.5.0-rc.28

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.
Files changed (76) hide show
  1. package/README.md +37 -0
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +4 -4
  4. package/dist/adapters/expo.d.ts +4 -4
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/{index-BfvbSL0W.d.cts → ark-CgZYyMpf.d.cts} +4369 -4205
  7. package/dist/{index-BfvbSL0W.d.ts → ark-CgZYyMpf.d.ts} +4369 -4205
  8. package/dist/{asyncStorageTaskQueue-CFWscYpG.d.cts → asyncStorageTaskQueue-B099Jii3.d.cts} +1 -1
  9. package/dist/{asyncStorageTaskQueue-DrFapzPg.d.ts → asyncStorageTaskQueue-BeQji1Ee.d.ts} +1 -1
  10. package/dist/{chunk-K2YTDYQF.cjs → chunk-3P7SXAAC.cjs} +16 -16
  11. package/dist/{chunk-K2YTDYQF.cjs.map → chunk-3P7SXAAC.cjs.map} +1 -1
  12. package/dist/{chunk-B2YMUJD5.cjs → chunk-4BT6HBZQ.cjs} +1155 -701
  13. package/dist/chunk-4BT6HBZQ.cjs.map +1 -0
  14. package/dist/{chunk-FEBAG2K2.cjs → chunk-6BJJ47JM.cjs} +18 -18
  15. package/dist/{chunk-FEBAG2K2.cjs.map → chunk-6BJJ47JM.cjs.map} +1 -1
  16. package/dist/{chunk-HPUKFTZV.js → chunk-BDTASM5W.js} +4 -4
  17. package/dist/{chunk-HPUKFTZV.js.map → chunk-BDTASM5W.js.map} +1 -1
  18. package/dist/{chunk-U5ZRDVVB.js → chunk-BIN2DVKS.js} +675 -222
  19. package/dist/chunk-BIN2DVKS.js.map +1 -0
  20. package/dist/{chunk-HTCIPDVW.js → chunk-CG7S6CDR.js} +5 -4
  21. package/dist/chunk-CG7S6CDR.js.map +1 -0
  22. package/dist/{chunk-N2VM6V6K.js → chunk-CR5YHHEM.js} +154 -51
  23. package/dist/chunk-CR5YHHEM.js.map +1 -0
  24. package/dist/{chunk-VVFCCNU2.cjs → chunk-FGKBQH5S.cjs} +5 -3
  25. package/dist/chunk-FGKBQH5S.cjs.map +1 -0
  26. package/dist/{chunk-Y5VSJURH.js → chunk-FSSINCR6.js} +4 -4
  27. package/dist/{chunk-Y5VSJURH.js.map → chunk-FSSINCR6.js.map} +1 -1
  28. package/dist/{chunk-QCD3SJOL.cjs → chunk-HFSC7T5I.cjs} +10 -10
  29. package/dist/{chunk-QCD3SJOL.cjs.map → chunk-HFSC7T5I.cjs.map} +1 -1
  30. package/dist/{chunk-5JQ5EOYE.js → chunk-PHSUZSRH.js} +3 -3
  31. package/dist/{chunk-5JQ5EOYE.js.map → chunk-PHSUZSRH.js.map} +1 -1
  32. package/dist/{chunk-CFOIHLON.cjs → chunk-YFQOJTG3.cjs} +201 -96
  33. package/dist/chunk-YFQOJTG3.cjs.map +1 -0
  34. package/dist/contracts/handlers/index.cjs +9 -9
  35. package/dist/contracts/handlers/index.d.cts +5 -5
  36. package/dist/contracts/handlers/index.d.ts +5 -5
  37. package/dist/contracts/handlers/index.js +2 -2
  38. package/dist/{delegate-Cz8FnLqi.d.ts → delegate-B8KSoeVz.d.ts} +1 -1
  39. package/dist/{delegate-r3jh7UcH.d.cts → delegate-wuf6DBpr.d.cts} +1 -1
  40. package/dist/{index-DOION7Ta.d.cts → index-1pLGuueL.d.ts} +58 -52
  41. package/dist/{index-Chgwl4dO.d.ts → index-CP3v0PVS.d.cts} +58 -52
  42. package/dist/index.cjs +328 -316
  43. package/dist/index.d.cts +332 -286
  44. package/dist/index.d.ts +332 -286
  45. package/dist/index.js +4 -4
  46. package/dist/repositories/realm/index.cjs +35 -35
  47. package/dist/repositories/realm/index.d.cts +4 -4
  48. package/dist/repositories/realm/index.d.ts +4 -4
  49. package/dist/repositories/realm/index.js +5 -5
  50. package/dist/repositories/sqlite/index.cjs +33 -33
  51. package/dist/repositories/sqlite/index.d.cts +4 -4
  52. package/dist/repositories/sqlite/index.d.ts +4 -4
  53. package/dist/repositories/sqlite/index.js +5 -5
  54. package/dist/{taskRunner-CXAcjtdU.d.ts → taskRunner-D4IF7tc8.d.cts} +1 -1
  55. package/dist/{taskRunner-BO8a-SQh.d.cts → taskRunner-DzEg63qV.d.ts} +1 -1
  56. package/dist/wallet/expo/background.cjs +14 -14
  57. package/dist/wallet/expo/background.d.cts +5 -5
  58. package/dist/wallet/expo/background.d.ts +5 -5
  59. package/dist/wallet/expo/background.js +6 -6
  60. package/dist/wallet/expo/index.cjs +15 -15
  61. package/dist/wallet/expo/index.d.cts +4 -4
  62. package/dist/wallet/expo/index.d.ts +4 -4
  63. package/dist/wallet/expo/index.js +5 -5
  64. package/dist/{wallet-CFIfUlQP.d.ts → walletRepository-BA5C6Slk.d.cts} +29 -29
  65. package/dist/{wallet-s90p-vIk.d.cts → walletRepository-BE2yiIHF.d.ts} +29 -29
  66. package/dist/worker/expo/index.cjs +9 -9
  67. package/dist/worker/expo/index.d.cts +6 -6
  68. package/dist/worker/expo/index.d.ts +6 -6
  69. package/dist/worker/expo/index.js +5 -5
  70. package/package.json +1 -1
  71. package/dist/chunk-B2YMUJD5.cjs.map +0 -1
  72. package/dist/chunk-CFOIHLON.cjs.map +0 -1
  73. package/dist/chunk-HTCIPDVW.js.map +0 -1
  74. package/dist/chunk-N2VM6V6K.js.map +0 -1
  75. package/dist/chunk-U5ZRDVVB.js.map +0 -1
  76. package/dist/chunk-VVFCCNU2.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkFEBAG2K2_cjs = require('./chunk-FEBAG2K2.cjs');
4
- var chunkCFOIHLON_cjs = require('./chunk-CFOIHLON.cjs');
5
- var chunkVVFCCNU2_cjs = require('./chunk-VVFCCNU2.cjs');
3
+ var chunk6BJJ47JM_cjs = require('./chunk-6BJJ47JM.cjs');
4
+ var chunkYFQOJTG3_cjs = require('./chunk-YFQOJTG3.cjs');
5
+ var chunkFGKBQH5S_cjs = require('./chunk-FGKBQH5S.cjs');
6
6
  var utils_js = require('@scure/btc-signer/utils.js');
7
7
  var btcSigner = require('@scure/btc-signer');
8
8
  var base = require('@scure/base');
@@ -187,7 +187,7 @@ var TreeSignerSession = class _TreeSignerSession {
187
187
  noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
188
188
  const tx = this.graph.find(txid);
189
189
  if (!tx) throw new Error(`missing tx for txid ${txid}`);
190
- const cosigners = chunkVVFCCNU2_cjs.getArkPsbtFields(tx.root, 0, chunkVVFCCNU2_cjs.CosignerPublicKey).map(
190
+ const cosigners = chunkFGKBQH5S_cjs.getArkPsbtFields(tx.root, 0, chunkFGKBQH5S_cjs.CosignerPublicKey).map(
191
191
  (c) => base.hex.encode(c.key.subarray(1))
192
192
  // xonly pubkey
193
193
  );
@@ -239,7 +239,7 @@ var TreeSignerSession = class _TreeSignerSession {
239
239
  if (!aggNonce) throw new Error("missing aggregate nonce");
240
240
  const prevoutAmounts = [];
241
241
  const prevoutScripts = [];
242
- const cosigners = chunkVVFCCNU2_cjs.getArkPsbtFields(g.root, 0, chunkVVFCCNU2_cjs.CosignerPublicKey).map((c) => c.key);
242
+ const cosigners = chunkFGKBQH5S_cjs.getArkPsbtFields(g.root, 0, chunkFGKBQH5S_cjs.CosignerPublicKey).map((c) => c.key);
243
243
  const { finalKey } = aggregateKeys(cosigners, true, {
244
244
  taprootTweak: this.scriptRoot
245
245
  });
@@ -322,7 +322,7 @@ var SingleKey = class _SingleKey {
322
322
  async sign(tx, inputIndexes) {
323
323
  const txCpy = tx.clone();
324
324
  if (!inputIndexes) {
325
- chunkVVFCCNU2_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
325
+ chunkFGKBQH5S_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
326
326
  try {
327
327
  if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
328
328
  throw new Error("Failed to sign transaction");
@@ -422,7 +422,7 @@ var SeedIdentity = class _SeedIdentity {
422
422
  let network;
423
423
  if ("descriptor" in opts && typeof opts.descriptor === "string") {
424
424
  descriptor = opts.descriptor;
425
- network = chunkCFOIHLON_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
425
+ network = chunkYFQOJTG3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
426
426
  } else {
427
427
  network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
428
428
  descriptor = descriptorsScure.scriptExpressions.trBIP32({
@@ -499,7 +499,7 @@ var SeedIdentity = class _SeedIdentity {
499
499
  }
500
500
  /** Returns true when `descriptor` is derived from this identity's seed. */
501
501
  ownsDescriptor(descriptor) {
502
- return chunkCFOIHLON_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
502
+ return chunkYFQOJTG3_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
503
503
  }
504
504
  /**
505
505
  * Signs each request with the key derived from its descriptor.
@@ -538,7 +538,7 @@ var SeedIdentity = class _SeedIdentity {
538
538
  }
539
539
  // ── internal helpers ─────────────────────────────────────────────
540
540
  derivePrivateKeyForDescriptor(descriptor) {
541
- const network = chunkCFOIHLON_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
541
+ const network = chunkYFQOJTG3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
542
542
  const expansion = descriptorsScure.expand({ descriptor, network });
543
543
  if (expansion.isRanged) {
544
544
  throw new Error(
@@ -563,7 +563,7 @@ var SeedIdentity = class _SeedIdentity {
563
563
  signTxWithKey(tx, key, inputIndexes) {
564
564
  const txCpy = tx.clone();
565
565
  if (!inputIndexes) {
566
- chunkVVFCCNU2_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
566
+ chunkFGKBQH5S_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
567
567
  try {
568
568
  if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
569
569
  throw new Error("Failed to sign transaction");
@@ -615,7 +615,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
615
615
  /** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
616
616
  descriptor;
617
617
  constructor(descriptor) {
618
- const network = chunkCFOIHLON_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
618
+ const network = chunkYFQOJTG3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
619
619
  let expansion;
620
620
  try {
621
621
  expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
@@ -650,7 +650,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
650
650
  }
651
651
  /** Returns true when `descriptor` derives from this identity's xpub. */
652
652
  ownsDescriptor(descriptor) {
653
- return chunkCFOIHLON_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
653
+ return chunkYFQOJTG3_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
654
654
  }
655
655
  };
656
656
  function serializeSeedOwnedSigningIdentity(identity) {
@@ -793,10 +793,10 @@ var DescriptorIdentity = class {
793
793
  this.base = base;
794
794
  }
795
795
  async xOnlyPublicKey() {
796
- return chunkCFOIHLON_cjs.deriveDescriptorLeafPubKey(this.descriptor);
796
+ return chunkYFQOJTG3_cjs.deriveDescriptorLeafPubKey(this.descriptor);
797
797
  }
798
798
  async compressedPublicKey() {
799
- return chunkCFOIHLON_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
799
+ return chunkYFQOJTG3_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
800
800
  }
801
801
  async sign(tx, inputIndexes) {
802
802
  const [signed] = await this.signer.signWithDescriptor([
@@ -856,8 +856,8 @@ var StaticDescriptorProvider = class _StaticDescriptorProvider {
856
856
  }
857
857
  isOurs(descriptor) {
858
858
  try {
859
- const normalized = chunkCFOIHLON_cjs.normalizeToDescriptor(descriptor);
860
- const pubKey = chunkCFOIHLON_cjs.extractPubKey(normalized);
859
+ const normalized = chunkYFQOJTG3_cjs.normalizeToDescriptor(descriptor);
860
+ const pubKey = chunkYFQOJTG3_cjs.extractPubKey(normalized);
861
861
  return pubKey.toLowerCase() === this.pubKeyHex.toLowerCase();
862
862
  } catch {
863
863
  return false;
@@ -1194,7 +1194,7 @@ function unwrapKeyring(provider) {
1194
1194
  }
1195
1195
  function keyOf(descriptor) {
1196
1196
  try {
1197
- return chunkCFOIHLON_cjs.extractPubKey(chunkCFOIHLON_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
1197
+ return chunkYFQOJTG3_cjs.extractPubKey(chunkYFQOJTG3_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
1198
1198
  } catch {
1199
1199
  return void 0;
1200
1200
  }
@@ -1285,12 +1285,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
1285
1285
  signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
1286
1286
  } : void 0;
1287
1287
  const owner = providerOwner ?? identityOwner;
1288
- if (owner && chunkCFOIHLON_cjs.parseHDDescriptor(descriptor)) {
1288
+ if (owner && chunkYFQOJTG3_cjs.parseHDDescriptor(descriptor)) {
1289
1289
  return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
1290
1290
  }
1291
1291
  let key;
1292
1292
  try {
1293
- key = chunkCFOIHLON_cjs.deriveDescriptorLeafPubKey(descriptor);
1293
+ key = chunkYFQOJTG3_cjs.deriveDescriptorLeafPubKey(descriptor);
1294
1294
  } catch {
1295
1295
  throw new ForeignDescriptorError(descriptor);
1296
1296
  }
@@ -1343,14 +1343,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
1343
1343
  }
1344
1344
  var PREIMAGE_INDEX = 0;
1345
1345
  function isPerArtifactDescriptor(descriptor) {
1346
- return chunkCFOIHLON_cjs.parseHDDescriptor(descriptor) !== null;
1346
+ return chunkYFQOJTG3_cjs.parseHDDescriptor(descriptor) !== null;
1347
1347
  }
1348
1348
  async function provisionDescriptor(wallet) {
1349
1349
  const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
1350
- return allocated ?? await chunkCFOIHLON_cjs.identityDescriptor(wallet.identity);
1350
+ return allocated ?? await chunkYFQOJTG3_cjs.identityDescriptor(wallet.identity);
1351
1351
  }
1352
1352
  async function provisionRefundKey(wallet) {
1353
- const descriptor = await chunkCFOIHLON_cjs.identityDescriptor(wallet.identity);
1353
+ const descriptor = await chunkYFQOJTG3_cjs.identityDescriptor(wallet.identity);
1354
1354
  const signer = await contractSigner(wallet, descriptor);
1355
1355
  const pubkey = await signer.xOnlyPublicKey();
1356
1356
  const identityPubkey = await wallet.identity.xOnlyPublicKey();
@@ -1360,7 +1360,7 @@ async function provisionRefundKey(wallet) {
1360
1360
  );
1361
1361
  }
1362
1362
  const address = await wallet.getAddress();
1363
- const { pkScript } = chunkVVFCCNU2_cjs.ArkAddress.decode(address);
1363
+ const { pkScript } = chunkFGKBQH5S_cjs.ArkAddress.decode(address);
1364
1364
  return { descriptor, pubkey, pkScript, address };
1365
1365
  }
1366
1366
  async function provisionClaimSecret(wallet, opts = {}) {
@@ -1406,7 +1406,7 @@ async function contractSigner(wallet, descriptor) {
1406
1406
  const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
1407
1407
  let expected;
1408
1408
  try {
1409
- expected = chunkCFOIHLON_cjs.deriveDescriptorLeafPubKey(descriptor);
1409
+ expected = chunkYFQOJTG3_cjs.deriveDescriptorLeafPubKey(descriptor);
1410
1410
  } catch (cause) {
1411
1411
  throw new ForeignDescriptorError(descriptor, { cause });
1412
1412
  }
@@ -1488,7 +1488,7 @@ function debugLog(debug, ...args) {
1488
1488
  }
1489
1489
  function normalizeOptions(pathOrOptions) {
1490
1490
  const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
1491
- chunkVVFCCNU2_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
1491
+ chunkFGKBQH5S_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
1492
1492
  return {
1493
1493
  path: o.path,
1494
1494
  updateViaCache: o.updateViaCache ?? "none",
@@ -1611,14 +1611,14 @@ var RestDelegateProvider = class {
1611
1611
  */
1612
1612
  async delegate(intent, forfeitTxs, options) {
1613
1613
  const url = `${this.url}/v1/delegate`;
1614
- const response = await chunkVVFCCNU2_cjs.baseFetch(url, {
1614
+ const response = await chunkFGKBQH5S_cjs.baseFetch(url, {
1615
1615
  method: "POST",
1616
1616
  headers: {
1617
1617
  "Content-Type": "application/json"
1618
1618
  },
1619
1619
  body: JSON.stringify({
1620
1620
  intent: {
1621
- message: chunkVVFCCNU2_cjs.Intent.encodeMessage(intent.message),
1621
+ message: chunkFGKBQH5S_cjs.Intent.encodeMessage(intent.message),
1622
1622
  proof: intent.proof
1623
1623
  },
1624
1624
  forfeit_txs: forfeitTxs,
@@ -1637,7 +1637,7 @@ var RestDelegateProvider = class {
1637
1637
  */
1638
1638
  async getDelegateInfo() {
1639
1639
  const url = `${this.url}/v1/delegator/info`;
1640
- const response = await chunkVVFCCNU2_cjs.rateGate.runHttp(url, () => chunkVVFCCNU2_cjs.baseFetch(url));
1640
+ const response = await chunkFGKBQH5S_cjs.rateGate.runHttp(url, () => chunkFGKBQH5S_cjs.baseFetch(url));
1641
1641
  if (!response.ok) {
1642
1642
  const errorText2 = await response.text();
1643
1643
  throw new Error(`Failed to get delegate info: ${errorText2}`);
@@ -1693,7 +1693,7 @@ async function collectPages(read) {
1693
1693
  return items;
1694
1694
  }
1695
1695
  function scriptFromArkAddress(address) {
1696
- return base.hex.encode(chunkVVFCCNU2_cjs.ArkAddress.decode(address).pkScript);
1696
+ return base.hex.encode(chunkFGKBQH5S_cjs.ArkAddress.decode(address).pkScript);
1697
1697
  }
1698
1698
 
1699
1699
  // src/repositories/walletRepository.ts
@@ -1755,9 +1755,9 @@ async function collectScriptVtxos(repository, script, options) {
1755
1755
  return [...byOutpoint.values()].map((row) => row.vtxo);
1756
1756
  }
1757
1757
  function unspentScriptVtxos(rows, copies) {
1758
- const spent = copies.filter((copy) => chunkVVFCCNU2_cjs.isVtxoSpent(copy.vtxo));
1758
+ const spent = copies.filter((copy) => chunkFGKBQH5S_cjs.isVtxoSpent(copy.vtxo));
1759
1759
  return rows.filter(
1760
- (row) => !chunkVVFCCNU2_cjs.isVtxoSpent(row.vtxo) && !spent.some(
1760
+ (row) => !chunkFGKBQH5S_cjs.isVtxoSpent(row.vtxo) && !spent.some(
1761
1761
  (copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
1762
1762
  )
1763
1763
  );
@@ -1840,7 +1840,7 @@ var ESPLORA_URL = {
1840
1840
  regtest: "http://localhost:3000/api"
1841
1841
  };
1842
1842
  var EsploraProvider = class {
1843
- constructor(baseUrl = ESPLORA_URL[chunkVVFCCNU2_cjs.DEFAULT_NETWORK_NAME], opts) {
1843
+ constructor(baseUrl = ESPLORA_URL[chunkFGKBQH5S_cjs.DEFAULT_NETWORK_NAME], opts) {
1844
1844
  this.baseUrl = baseUrl;
1845
1845
  this.pollingInterval = opts?.pollingInterval ?? 15e3;
1846
1846
  this.forcePolling = opts?.forcePolling ?? false;
@@ -1855,7 +1855,7 @@ var EsploraProvider = class {
1855
1855
  */
1856
1856
  addressWatches = /* @__PURE__ */ new Map();
1857
1857
  async getCoins(address) {
1858
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1858
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1859
1859
  if (!response.ok) {
1860
1860
  throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
1861
1861
  }
@@ -1864,12 +1864,12 @@ var EsploraProvider = class {
1864
1864
  async getFeeRate() {
1865
1865
  let url = `${this.baseUrl}/fee-estimates`;
1866
1866
  let key = "1";
1867
- let response = await chunkVVFCCNU2_cjs.baseFetch(url);
1867
+ let response = await chunkFGKBQH5S_cjs.baseFetch(url);
1868
1868
  if (response.status === 404) {
1869
1869
  await response.body?.cancel();
1870
1870
  url = `${this.baseUrl}/v1/fees/recommended`;
1871
1871
  key = "fastestFee";
1872
- response = await chunkVVFCCNU2_cjs.baseFetch(url);
1872
+ response = await chunkFGKBQH5S_cjs.baseFetch(url);
1873
1873
  }
1874
1874
  if (response.status === 404) {
1875
1875
  await response.body?.cancel();
@@ -1906,7 +1906,7 @@ var EsploraProvider = class {
1906
1906
  }
1907
1907
  }
1908
1908
  async getTxOutspends(txid) {
1909
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1909
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1910
1910
  if (!response.ok) {
1911
1911
  const error = await response.text();
1912
1912
  throw new Error(`Failed to get transaction outspends: ${error}`);
@@ -1914,7 +1914,7 @@ var EsploraProvider = class {
1914
1914
  return response.json();
1915
1915
  }
1916
1916
  async getTransactions(address) {
1917
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1917
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1918
1918
  if (!response.ok) {
1919
1919
  const error = await response.text();
1920
1920
  throw new Error(`Failed to get transactions: ${error}`);
@@ -1923,14 +1923,14 @@ var EsploraProvider = class {
1923
1923
  }
1924
1924
  /** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
1925
1925
  async getAddressStats(address) {
1926
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1926
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1927
1927
  if (!response.ok) {
1928
1928
  throw new Error(`Failed to get address stats: ${response.statusText}`);
1929
1929
  }
1930
1930
  return response.json();
1931
1931
  }
1932
1932
  async getRawTransaction(txid) {
1933
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1933
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1934
1934
  if (!response.ok) {
1935
1935
  const error = await response.text();
1936
1936
  throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
@@ -1938,7 +1938,7 @@ var EsploraProvider = class {
1938
1938
  return base.hex.decode((await response.text()).trim());
1939
1939
  }
1940
1940
  async getTxStatus(txid) {
1941
- const txresponse = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1941
+ const txresponse = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1942
1942
  if (!txresponse.ok) {
1943
1943
  throw new Error(txresponse.statusText);
1944
1944
  }
@@ -1946,7 +1946,7 @@ var EsploraProvider = class {
1946
1946
  if (!tx.status.confirmed) {
1947
1947
  return { confirmed: false };
1948
1948
  }
1949
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1949
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1950
1950
  if (!response.ok) {
1951
1951
  throw new Error(`Failed to get transaction status: ${response.statusText}`);
1952
1952
  }
@@ -2220,9 +2220,9 @@ var EsploraProvider = class {
2220
2220
  return { subscribers, teardown, started };
2221
2221
  }
2222
2222
  async getChainTip() {
2223
- let tipBlocks = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/blocks`);
2223
+ let tipBlocks = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/blocks`);
2224
2224
  if (tipBlocks.status === 404) {
2225
- tipBlocks = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2225
+ tipBlocks = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2226
2226
  }
2227
2227
  if (!tipBlocks.ok) {
2228
2228
  throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
@@ -2243,7 +2243,7 @@ var EsploraProvider = class {
2243
2243
  };
2244
2244
  }
2245
2245
  async broadcastPackage(parent, child) {
2246
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2246
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2247
2247
  method: "POST",
2248
2248
  headers: {
2249
2249
  "Content-Type": "application/json"
@@ -2259,7 +2259,7 @@ var EsploraProvider = class {
2259
2259
  return result;
2260
2260
  }
2261
2261
  async broadcastTx(tx) {
2262
- const response = await chunkVVFCCNU2_cjs.baseFetch(`${this.baseUrl}/tx`, {
2262
+ const response = await chunkFGKBQH5S_cjs.baseFetch(`${this.baseUrl}/tx`, {
2263
2263
  method: "POST",
2264
2264
  headers: {
2265
2265
  "Content-Type": "text/plain"
@@ -2431,7 +2431,7 @@ function findP2AOutput(tx) {
2431
2431
  var CHILD_DUST_AMOUNT = 546;
2432
2432
  function buildAnchorChild(params) {
2433
2433
  const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
2434
- const child = new chunkVVFCCNU2_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2434
+ const child = new chunkFGKBQH5S_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2435
2435
  const anchor = findP2AOutput(parent);
2436
2436
  child.addInput(anchor);
2437
2437
  const estimator = TxWeightEstimator.create().addP2AInput();
@@ -2480,7 +2480,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
2480
2480
  );
2481
2481
  }
2482
2482
  function buildForfeitTxWithOutput(inputs, output, txLocktime) {
2483
- const tx = new chunkVVFCCNU2_cjs.Transaction({
2483
+ const tx = new chunkFGKBQH5S_cjs.Transaction({
2484
2484
  version: 3,
2485
2485
  lockTime: txLocktime
2486
2486
  });
@@ -2507,7 +2507,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
2507
2507
  connectorsGraph.validate();
2508
2508
  if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
2509
2509
  const rootInput = connectorsGraph.root.getInput(0);
2510
- const settlementTx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
2510
+ const settlementTx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
2511
2511
  if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
2512
2512
  throw ErrInvalidSettlementTxOutputs;
2513
2513
  const expectedRootTxid = settlementTx.id;
@@ -2556,7 +2556,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2556
2556
  if (previousScriptKey.length !== 32) {
2557
2557
  throw new Error(`parent output ${childIndex} has invalid script`);
2558
2558
  }
2559
- const cosigners = chunkVVFCCNU2_cjs.getArkPsbtFields(child.root, 0, chunkVVFCCNU2_cjs.CosignerPublicKey);
2559
+ const cosigners = chunkFGKBQH5S_cjs.getArkPsbtFields(child.root, 0, chunkFGKBQH5S_cjs.CosignerPublicKey);
2560
2560
  if (cosigners.length === 0) {
2561
2561
  throw ErrMissingCosignersPublicKeys;
2562
2562
  }
@@ -2614,7 +2614,7 @@ var EmulatorPacket = class _EmulatorPacket {
2614
2614
  return new _EmulatorPacket(entries);
2615
2615
  }
2616
2616
  static fromBytes(data) {
2617
- const reader = new chunkFEBAG2K2_cjs.BufferReader(data);
2617
+ const reader = new chunk6BJJ47JM_cjs.BufferReader(data);
2618
2618
  const entryCount = reader.readCompactSize();
2619
2619
  const entries = [];
2620
2620
  for (let i = 0; i < entryCount; i++) {
@@ -2632,7 +2632,7 @@ var EmulatorPacket = class _EmulatorPacket {
2632
2632
  return _EmulatorPacket.PACKET_TYPE;
2633
2633
  }
2634
2634
  serialize() {
2635
- const writer = new chunkFEBAG2K2_cjs.BufferWriter();
2635
+ const writer = new chunk6BJJ47JM_cjs.BufferWriter();
2636
2636
  writer.writeCompactSize(this.entries.length);
2637
2637
  for (const entry of this.entries) {
2638
2638
  writer.writeUint16LE(entry.vin);
@@ -2719,7 +2719,7 @@ var Extension = class _Extension {
2719
2719
  `expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
2720
2720
  );
2721
2721
  }
2722
- const reader = new chunkFEBAG2K2_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2722
+ const reader = new chunk6BJJ47JM_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2723
2723
  const packets = [];
2724
2724
  while (reader.remaining() > 0) {
2725
2725
  const packetType = reader.readByte();
@@ -2792,7 +2792,7 @@ var Extension = class _Extension {
2792
2792
  * getAssetPacket returns the embedded Packet, or null if not present.
2793
2793
  */
2794
2794
  getAssetPacket() {
2795
- return this.packets.find((p) => p instanceof chunkFEBAG2K2_cjs.Packet) ?? null;
2795
+ return this.packets.find((p) => p instanceof chunk6BJJ47JM_cjs.Packet) ?? null;
2796
2796
  }
2797
2797
  /**
2798
2798
  * getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
@@ -2816,8 +2816,8 @@ var Extension = class _Extension {
2816
2816
  };
2817
2817
  function parsePacket(packetType, data) {
2818
2818
  switch (packetType) {
2819
- case chunkFEBAG2K2_cjs.Packet.PACKET_TYPE:
2820
- return chunkFEBAG2K2_cjs.Packet.fromBytes(data);
2819
+ case chunk6BJJ47JM_cjs.Packet.PACKET_TYPE:
2820
+ return chunk6BJJ47JM_cjs.Packet.fromBytes(data);
2821
2821
  case EmulatorPacket.PACKET_TYPE:
2822
2822
  return EmulatorPacket.fromBytes(data);
2823
2823
  default:
@@ -2864,22 +2864,22 @@ function buildOpReturnScript(data) {
2864
2864
  }
2865
2865
  return script;
2866
2866
  }
2867
- var ErrOffchainOutputNotFound = (address) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2868
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
2867
+ var ErrOffchainOutputNotFound = (address) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2868
+ var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
2869
2869
  `invalid asset output amount for ${assetId}: got ${got}, want ${want}`
2870
2870
  );
2871
- var ErrAssetGroupNotFound = (assetId) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2872
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
2871
+ var ErrAssetGroupNotFound = (assetId) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2872
+ var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
2873
2873
  `asset output not found in asset group ${assetId} at index ${outputIndex}`
2874
2874
  );
2875
- var ErrOnchainOutputNotFound = (address) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2876
- var ErrUnvalidatedOffchainOutput = (address) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
2875
+ var ErrOnchainOutputNotFound = (address) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2876
+ var ErrUnvalidatedOffchainOutput = (address) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
2877
2877
  `offchain output ${address} cannot be validated: virtual output tree signing did not run`
2878
2878
  );
2879
- var ErrIntentOutputNotFound = (index, kind) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
2879
+ var ErrIntentOutputNotFound = (index, kind) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
2880
2880
  `${kind} output ${index} of the intent proof is not present in what the server built`
2881
2881
  );
2882
- var ErrUnvalidatedIntentOutput = (index) => new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
2882
+ var ErrUnvalidatedIntentOutput = (index) => new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
2883
2883
  `offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
2884
2884
  );
2885
2885
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
@@ -2888,7 +2888,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
2888
2888
  function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
2889
2889
  if (!validatedCommitmentTxid) return;
2890
2890
  if (finalCommitmentTx.id === validatedCommitmentTxid) return;
2891
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
2891
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
2892
2892
  `${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
2893
2893
  );
2894
2894
  }
@@ -2898,7 +2898,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
2898
2898
  for (const recipient of recipients) {
2899
2899
  let arkAddress;
2900
2900
  try {
2901
- arkAddress = chunkVVFCCNU2_cjs.ArkAddress.decode(recipient.address);
2901
+ arkAddress = chunkFGKBQH5S_cjs.ArkAddress.decode(recipient.address);
2902
2902
  } catch {
2903
2903
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2904
2904
  continue;
@@ -2910,7 +2910,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2910
2910
  const usedOnchainOutputs = /* @__PURE__ */ new Set();
2911
2911
  for (const recipient of recipients) {
2912
2912
  try {
2913
- chunkVVFCCNU2_cjs.ArkAddress.decode(recipient.address);
2913
+ chunkFGKBQH5S_cjs.ArkAddress.decode(recipient.address);
2914
2914
  } catch {
2915
2915
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2916
2916
  continue;
@@ -2919,7 +2919,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2919
2919
  }
2920
2920
  }
2921
2921
  function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
2922
- const proof = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
2922
+ const proof = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
2923
2923
  const onchain = new Set(onchainOutputIndexes);
2924
2924
  const declared = [];
2925
2925
  for (let i = 0; i < proof.outputsLength; i++) {
@@ -3211,7 +3211,7 @@ function assetMintResolver() {
3211
3211
  if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
3212
3212
  const minted = tx.assets.filter((a) => {
3213
3213
  try {
3214
- return base.hex.encode(chunkFEBAG2K2_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3214
+ return base.hex.encode(chunk6BJJ47JM_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3215
3215
  } catch {
3216
3216
  return false;
3217
3217
  }
@@ -3288,7 +3288,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3288
3288
  const existing = inputsByAssetId.get(asset.assetId);
3289
3289
  inputsByAssetId.set(asset.assetId, [
3290
3290
  ...existing ?? [],
3291
- chunkFEBAG2K2_cjs.AssetInput.create(inputIndex, asset.amount)
3291
+ chunk6BJJ47JM_cjs.AssetInput.create(inputIndex, asset.amount)
3292
3292
  ]);
3293
3293
  }
3294
3294
  }
@@ -3300,7 +3300,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3300
3300
  const existing = outputsByAssetId.get(asset.assetId);
3301
3301
  outputsByAssetId.set(asset.assetId, [
3302
3302
  ...existing ?? [],
3303
- chunkFEBAG2K2_cjs.AssetOutput.create(outputIndex, asset.amount)
3303
+ chunk6BJJ47JM_cjs.AssetOutput.create(outputIndex, asset.amount)
3304
3304
  ]);
3305
3305
  }
3306
3306
  }
@@ -3311,7 +3311,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3311
3311
  const existing = outputsByAssetId.get(asset.assetId);
3312
3312
  outputsByAssetId.set(asset.assetId, [
3313
3313
  ...existing ?? [],
3314
- chunkFEBAG2K2_cjs.AssetOutput.create(outputIndex, asset.amount)
3314
+ chunk6BJJ47JM_cjs.AssetOutput.create(outputIndex, asset.amount)
3315
3315
  ]);
3316
3316
  }
3317
3317
  }
@@ -3320,11 +3320,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3320
3320
  for (const assetIdStr of allAssetIds) {
3321
3321
  const inputs = inputsByAssetId.get(assetIdStr);
3322
3322
  const outputs = outputsByAssetId.get(assetIdStr);
3323
- const assetId = chunkFEBAG2K2_cjs.AssetId.fromString(assetIdStr);
3324
- const group = chunkFEBAG2K2_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3323
+ const assetId = chunk6BJJ47JM_cjs.AssetId.fromString(assetIdStr);
3324
+ const group = chunk6BJJ47JM_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3325
3325
  groups.push(group);
3326
3326
  }
3327
- return chunkFEBAG2K2_cjs.Packet.create(groups);
3327
+ return chunk6BJJ47JM_cjs.Packet.create(groups);
3328
3328
  }
3329
3329
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
3330
3330
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -3408,7 +3408,7 @@ function meetsInputExpiryFloor(coin, floor) {
3408
3408
  }
3409
3409
  function toXOnlySignerHex(pubkeyHex) {
3410
3410
  const bytes = base.hex.decode(pubkeyHex);
3411
- if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkCFOIHLON_cjs.toXOnly(bytes, "signer key"));
3411
+ if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkYFQOJTG3_cjs.toXOnly(bytes, "signer key"));
3412
3412
  throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
3413
3413
  }
3414
3414
  function signerSetFromInfo(info) {
@@ -3455,13 +3455,13 @@ var toTimelock = (value) => ({
3455
3455
  var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
3456
3456
  function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
3457
3457
  if (policy.requireSeconds && timelock.type === "blocks") {
3458
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3458
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3459
3459
  `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
3460
3460
  );
3461
3461
  }
3462
3462
  const seconds = toSeconds(timelock);
3463
3463
  if (seconds < policy.minSeconds) {
3464
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3464
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3465
3465
  `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
3466
3466
  );
3467
3467
  }
@@ -3482,7 +3482,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
3482
3482
  }
3483
3483
  function assertValidBatchExpiry(batchExpiry, policy) {
3484
3484
  if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
3485
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3485
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3486
3486
  `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
3487
3487
  );
3488
3488
  }
@@ -3512,21 +3512,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
3512
3512
  function assertValidServerUnrollScript(checkpointTapscript, policy) {
3513
3513
  let script;
3514
3514
  try {
3515
- script = chunkVVFCCNU2_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3515
+ script = chunkFGKBQH5S_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3516
3516
  } catch (e) {
3517
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3517
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3518
3518
  `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
3519
3519
  );
3520
3520
  }
3521
3521
  if (policy.advertisedForfeitPubkey !== void 0) {
3522
3522
  const { pubkeys } = script.params;
3523
3523
  if (pubkeys.length !== 1) {
3524
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3524
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3525
3525
  `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
3526
3526
  );
3527
3527
  }
3528
3528
  if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
3529
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3529
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3530
3530
  `checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
3531
3531
  );
3532
3532
  }
@@ -3570,8 +3570,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
3570
3570
  function buildVirtualTx(inputs, outputs) {
3571
3571
  let lockTime = 0n;
3572
3572
  for (const input of inputs) {
3573
- const tapscript = chunkVVFCCNU2_cjs.decodeTapscript(chunkVVFCCNU2_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3574
- if (chunkVVFCCNU2_cjs.CLTVMultisigTapscript.is(tapscript)) {
3573
+ const tapscript = chunkFGKBQH5S_cjs.decodeTapscript(chunkFGKBQH5S_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3574
+ if (chunkFGKBQH5S_cjs.CLTVMultisigTapscript.is(tapscript)) {
3575
3575
  if (lockTime !== 0n) {
3576
3576
  if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
3577
3577
  throw new Error("cannot mix seconds and blocks locktime");
@@ -3582,7 +3582,7 @@ function buildVirtualTx(inputs, outputs) {
3582
3582
  }
3583
3583
  }
3584
3584
  }
3585
- const tx = new chunkVVFCCNU2_cjs.Transaction({
3585
+ const tx = new chunkFGKBQH5S_cjs.Transaction({
3586
3586
  version: 3,
3587
3587
  lockTime: Number(lockTime)
3588
3588
  });
@@ -3592,12 +3592,12 @@ function buildVirtualTx(inputs, outputs) {
3592
3592
  index: input.vout,
3593
3593
  sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
3594
3594
  witnessUtxo: {
3595
- script: chunkVVFCCNU2_cjs.VtxoScript.decode(input.tapTree).pkScript,
3595
+ script: chunkFGKBQH5S_cjs.VtxoScript.decode(input.tapTree).pkScript,
3596
3596
  amount: BigInt(input.value)
3597
3597
  },
3598
3598
  tapLeafScript: [input.tapLeafScript]
3599
3599
  });
3600
- chunkVVFCCNU2_cjs.setArkPsbtField(tx, i, chunkVVFCCNU2_cjs.VtxoTaprootTree, input.tapTree);
3600
+ chunkFGKBQH5S_cjs.setArkPsbtField(tx, i, chunkFGKBQH5S_cjs.VtxoTaprootTree, input.tapTree);
3601
3601
  }
3602
3602
  for (const output of outputs) {
3603
3603
  tx.addOutput(output);
@@ -3608,8 +3608,8 @@ function buildVirtualTx(inputs, outputs) {
3608
3608
  return tx;
3609
3609
  }
3610
3610
  function buildCheckpointTx(vtxo, serverUnrollScript) {
3611
- const collaborativeClosure = chunkVVFCCNU2_cjs.decodeTapscript(chunkVVFCCNU2_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3612
- const checkpointVtxoScript = new chunkVVFCCNU2_cjs.VtxoScript([
3611
+ const collaborativeClosure = chunkFGKBQH5S_cjs.decodeTapscript(chunkFGKBQH5S_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3612
+ const checkpointVtxoScript = new chunkFGKBQH5S_cjs.VtxoScript([
3613
3613
  serverUnrollScript.script,
3614
3614
  collaborativeClosure.script
3615
3615
  ]);
@@ -3685,7 +3685,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
3685
3685
  const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
3686
3686
  const sig = signature.subarray(0, 64);
3687
3687
  if (!allowedSighashTypes.includes(sighashType)) {
3688
- const sighashName = chunkVVFCCNU2_cjs.formatSighash(sighashType);
3688
+ const sighashName = chunkFGKBQH5S_cjs.formatSighash(sighashType);
3689
3689
  throw new Error(
3690
3690
  `Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
3691
3691
  );
@@ -3759,7 +3759,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
3759
3759
  }
3760
3760
  function isValidArkAddress(address) {
3761
3761
  try {
3762
- chunkVVFCCNU2_cjs.ArkAddress.decode(address);
3762
+ chunkFGKBQH5S_cjs.ArkAddress.decode(address);
3763
3763
  return true;
3764
3764
  } catch (e) {
3765
3765
  return false;
@@ -3767,16 +3767,16 @@ function isValidArkAddress(address) {
3767
3767
  }
3768
3768
  function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
3769
3769
  if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
3770
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3770
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3771
3771
  `${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
3772
3772
  );
3773
3773
  }
3774
3774
  const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
3775
3775
  return serverCheckpointTxs.map((encoded, index) => {
3776
- const server = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3776
+ const server = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3777
3777
  const local = byTxid.get(server.id);
3778
3778
  if (!local) {
3779
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3779
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3780
3780
  `${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
3781
3781
  );
3782
3782
  }
@@ -3786,14 +3786,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
3786
3786
  }
3787
3787
  function assertSubmittedArkTxid(response, signedArkTx, context) {
3788
3788
  if (response.arkTxid !== signedArkTx.id) {
3789
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3789
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3790
3790
  `${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
3791
3791
  );
3792
3792
  }
3793
3793
  if (response.finalArkTx === void 0) return;
3794
- const finalTxid = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3794
+ const finalTxid = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3795
3795
  if (finalTxid !== signedArkTx.id) {
3796
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3796
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3797
3797
  `${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
3798
3798
  );
3799
3799
  }
@@ -3805,20 +3805,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
3805
3805
  `${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
3806
3806
  );
3807
3807
  }
3808
- const script = chunkVVFCCNU2_cjs.scriptFromTapLeafScript(leaf);
3808
+ const script = chunkFGKBQH5S_cjs.scriptFromTapLeafScript(leaf);
3809
3809
  let leafPubkeys;
3810
3810
  try {
3811
- leafPubkeys = chunkVVFCCNU2_cjs.decodeTapscript(script).params.pubkeys.map(
3812
- (key) => base.hex.encode(chunkCFOIHLON_cjs.toXOnly(key, "leaf key"))
3811
+ leafPubkeys = chunkFGKBQH5S_cjs.decodeTapscript(script).params.pubkeys.map(
3812
+ (key) => base.hex.encode(chunkYFQOJTG3_cjs.toXOnly(key, "leaf key"))
3813
3813
  );
3814
3814
  } catch (error) {
3815
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3815
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3816
3816
  `${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
3817
3817
  );
3818
3818
  }
3819
3819
  const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
3820
3820
  if (!signer) {
3821
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3821
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3822
3822
  `${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
3823
3823
  );
3824
3824
  }
@@ -3832,7 +3832,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
3832
3832
  payment_js.tapLeafHash(script)
3833
3833
  );
3834
3834
  } catch (error) {
3835
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3835
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3836
3836
  `${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
3837
3837
  );
3838
3838
  }
@@ -3841,20 +3841,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3841
3841
  const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
3842
3842
  for (const [index, checkpoint] of checkpoints.entries()) {
3843
3843
  if (checkpoint.inputsLength !== 1) {
3844
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3844
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3845
3845
  `${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
3846
3846
  );
3847
3847
  }
3848
3848
  const spent = checkpoint.getInput(0);
3849
3849
  if (!spent.txid || spent.index === void 0) {
3850
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3850
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3851
3851
  `${context}: checkpoint ${index} has no input outpoint`
3852
3852
  );
3853
3853
  }
3854
3854
  const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
3855
3855
  const input = byOutpoint.get(outpoint);
3856
3856
  if (!input) {
3857
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3857
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3858
3858
  `${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
3859
3859
  );
3860
3860
  }
@@ -3862,7 +3862,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3862
3862
  (unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
3863
3863
  );
3864
3864
  if (!rebuilt) {
3865
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3865
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3866
3866
  `${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
3867
3867
  );
3868
3868
  }
@@ -3888,9 +3888,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3888
3888
  const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
3889
3889
  matched.forEach(({ server }, index) => {
3890
3890
  try {
3891
- chunkVVFCCNU2_cjs.assertAllowedSighashTypes(server);
3891
+ chunkFGKBQH5S_cjs.assertAllowedSighashTypes(server);
3892
3892
  } catch (error) {
3893
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3893
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3894
3894
  `submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
3895
3895
  );
3896
3896
  }
@@ -3898,14 +3898,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3898
3898
  const verify = options?.verifyServerSignatures;
3899
3899
  if (verify) {
3900
3900
  if (response.finalArkTx === void 0) {
3901
- throw new chunkVVFCCNU2_cjs.ServerResponseMismatchError(
3901
+ throw new chunkFGKBQH5S_cjs.ServerResponseMismatchError(
3902
3902
  "submitTx: server returned no final ark tx to verify its signatures against"
3903
3903
  );
3904
3904
  }
3905
- const finalArkTx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3905
+ const finalArkTx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3906
3906
  const serverPubkeys = new Set(
3907
3907
  [verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
3908
- (key) => base.hex.encode(chunkCFOIHLON_cjs.toXOnly(key, "server key"))
3908
+ (key) => base.hex.encode(chunkYFQOJTG3_cjs.toXOnly(key, "server key"))
3909
3909
  )
3910
3910
  );
3911
3911
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
@@ -3969,7 +3969,7 @@ async function submitViaEmulator(emulator, offchainTx, signer, opts) {
3969
3969
  base.base64.encode(arkTx.toPSBT()),
3970
3970
  checkpoints.map((c) => base.base64.encode(c.toPSBT()))
3971
3971
  );
3972
- const txid = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
3972
+ const txid = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
3973
3973
  assertSubmittedArkTxid({ arkTxid: txid }, arkTx, "emulator submitTx");
3974
3974
  return { txid, signedArkTx: res.signedArkTx, signedCheckpointTxs: res.signedCheckpointTxs };
3975
3975
  }
@@ -3977,12 +3977,12 @@ function claimWithPreimageIdentity(identity, preimage) {
3977
3977
  return {
3978
3978
  ...identity,
3979
3979
  sign: async (tx, inputIndexes) => {
3980
- const signed = chunkVVFCCNU2_cjs.Transaction.fromPSBT(
3980
+ const signed = chunkFGKBQH5S_cjs.Transaction.fromPSBT(
3981
3981
  (await identity.sign(tx.clone(), inputIndexes)).toPSBT()
3982
3982
  );
3983
3983
  const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
3984
3984
  for (const index of indexes) {
3985
- chunkVVFCCNU2_cjs.setArkPsbtField(signed, index, chunkVVFCCNU2_cjs.ConditionWitness, [preimage]);
3985
+ chunkFGKBQH5S_cjs.setArkPsbtField(signed, index, chunkFGKBQH5S_cjs.ConditionWitness, [preimage]);
3986
3986
  }
3987
3987
  return signed;
3988
3988
  }
@@ -4165,7 +4165,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
4165
4165
  };
4166
4166
  }
4167
4167
  function deriveContractTapscripts(contract) {
4168
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
4168
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
4169
4169
  if (!handler) {
4170
4170
  throw new Error(`No handler for contract type '${contract.type}'`);
4171
4171
  }
@@ -4268,7 +4268,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
4268
4268
  function assertTapTreeDerivesAddress(encoded, tapTree, address) {
4269
4269
  let derived;
4270
4270
  try {
4271
- derived = chunkVVFCCNU2_cjs.VtxoScript.decode(tapTree).pkScript;
4271
+ derived = chunkFGKBQH5S_cjs.VtxoScript.decode(tapTree).pkScript;
4272
4272
  } catch (e) {
4273
4273
  throw new Error(
4274
4274
  `Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
@@ -4285,7 +4285,7 @@ function validateRecipients(recipients, dustAmount, context) {
4285
4285
  for (const recipient of recipients) {
4286
4286
  let address;
4287
4287
  try {
4288
- address = chunkVVFCCNU2_cjs.ArkAddress.decode(recipient.address);
4288
+ address = chunkFGKBQH5S_cjs.ArkAddress.decode(recipient.address);
4289
4289
  } catch (e) {
4290
4290
  throw new Error(`Invalid Arkade address: ${recipient.address}`);
4291
4291
  }
@@ -4310,7 +4310,7 @@ function validateRecipients(recipients, dustAmount, context) {
4310
4310
 
4311
4311
  // src/contracts/spendability.ts
4312
4312
  function isContractGenericallySpendable(contract) {
4313
- return chunkCFOIHLON_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
4313
+ return chunkYFQOJTG3_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
4314
4314
  }
4315
4315
  function gatedContracts(contracts) {
4316
4316
  const gated = /* @__PURE__ */ new Map();
@@ -4332,7 +4332,7 @@ function gateExclusion(gated) {
4332
4332
  return (vtxo) => {
4333
4333
  const type = gatedTypeOf(vtxo, gated);
4334
4334
  if (type === void 0) return void 0;
4335
- if (!chunkCFOIHLON_cjs.contractHandlers.has(type)) {
4335
+ if (!chunkYFQOJTG3_cjs.contractHandlers.has(type)) {
4336
4336
  return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
4337
4337
  }
4338
4338
  return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
@@ -4368,7 +4368,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
4368
4368
  continue;
4369
4369
  }
4370
4370
  for (const v of vtxos) {
4371
- if (!chunkVVFCCNU2_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
4371
+ if (!chunkFGKBQH5S_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
4372
4372
  out.add(`${v.txid}:${v.vout}`);
4373
4373
  }
4374
4374
  }
@@ -4404,14 +4404,14 @@ function byValueDescending(vtxos) {
4404
4404
  return [...vtxos].sort((a, b) => b.value - a.value);
4405
4405
  }
4406
4406
  async function fetchTimeHeight(wallet) {
4407
- return chunkVVFCCNU2_cjs.resolveTimeHeight(wallet.onchainProvider);
4407
+ return chunkFGKBQH5S_cjs.resolveTimeHeight(wallet.onchainProvider);
4408
4408
  }
4409
4409
  function heldVtxosOf(wallet) {
4410
4410
  const held = wallet.getHeldVtxos;
4411
4411
  return typeof held === "function" ? held.call(wallet) : Promise.resolve([]);
4412
4412
  }
4413
4413
  function canMigrateBySend(vtxo, now) {
4414
- if (!chunkVVFCCNU2_cjs.canSpendOffchain(vtxo, now)) return false;
4414
+ if (!chunkFGKBQH5S_cjs.canSpendOffchain(vtxo, now)) return false;
4415
4415
  return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
4416
4416
  }
4417
4417
  function byExpiryAscending(vtxos, now) {
@@ -4419,7 +4419,7 @@ function byExpiryAscending(vtxos, now) {
4419
4419
  if (vtxo.isSwept) return -Infinity;
4420
4420
  if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
4421
4421
  if (vtxo.expiresAtHeight !== void 0) {
4422
- return chunkVVFCCNU2_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4422
+ return chunkFGKBQH5S_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4423
4423
  }
4424
4424
  return Infinity;
4425
4425
  };
@@ -4446,7 +4446,7 @@ function priceSettlementInputs(vtxos, estimator) {
4446
4446
  const payable = [];
4447
4447
  const net = /* @__PURE__ */ new Map();
4448
4448
  for (const vtxo of vtxos) {
4449
- const inputFee = estimator.evalOffchainInput(chunkVVFCCNU2_cjs.toOffchainInputFeeParams(vtxo));
4449
+ const inputFee = estimator.evalOffchainInput(chunkFGKBQH5S_cjs.toOffchainInputFeeParams(vtxo));
4450
4450
  if (inputFee.satoshis >= vtxo.value) {
4451
4451
  continue;
4452
4452
  }
@@ -4475,7 +4475,7 @@ function offchainOutputFee(amount, estimator, arkAddress) {
4475
4475
  }
4476
4476
  const outputFee = estimator.evalOffchainOutput({
4477
4477
  amount,
4478
- script: base.hex.encode(chunkVVFCCNU2_cjs.ArkAddress.decode(arkAddress).pkScript)
4478
+ script: base.hex.encode(chunkFGKBQH5S_cjs.ArkAddress.decode(arkAddress).pkScript)
4479
4479
  });
4480
4480
  return BigInt(outputFee.satoshis);
4481
4481
  }
@@ -4526,10 +4526,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
4526
4526
  };
4527
4527
  function getRecoverableVtxos(vtxos, dustAmount, now) {
4528
4528
  return vtxos.filter((vtxo) => {
4529
- if (chunkVVFCCNU2_cjs.canRecoverOnchain(vtxo, now)) {
4529
+ if (chunkFGKBQH5S_cjs.canRecoverOnchain(vtxo, now)) {
4530
4530
  return true;
4531
4531
  }
4532
- if (chunkVVFCCNU2_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4532
+ if (chunkFGKBQH5S_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4533
4533
  return true;
4534
4534
  }
4535
4535
  return false;
@@ -4561,7 +4561,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
4561
4561
  function isVtxoExpiringSoon(vtxo, thresholdMs) {
4562
4562
  if (vtxo.isUnrolled) return false;
4563
4563
  const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
4564
- const expiresAt = chunkVVFCCNU2_cjs.normalizeVtxo(vtxo).expiresAt;
4564
+ const expiresAt = chunkFGKBQH5S_cjs.normalizeVtxo(vtxo).expiresAt;
4565
4565
  if (expiresAt === void 0) return false;
4566
4566
  const now = Date.now();
4567
4567
  const batchExpiry = expiresAt.getTime();
@@ -4572,7 +4572,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
4572
4572
  return vtxos.filter(
4573
4573
  // The leading exclusion covers the `isSubdust` arm too, which is a value
4574
4574
  // property and would otherwise re-admit an exited coin on its own.
4575
- (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkVVFCCNU2_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4575
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkFGKBQH5S_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4576
4576
  );
4577
4577
  }
4578
4578
  function isMigrationCapable(wallet) {
@@ -4632,7 +4632,7 @@ var VtxoManager = class _VtxoManager {
4632
4632
  constructor(wallet, settlementConfig) {
4633
4633
  this.wallet = wallet;
4634
4634
  if (settlementConfig !== false) {
4635
- chunkVVFCCNU2_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
4635
+ chunkFGKBQH5S_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
4636
4636
  }
4637
4637
  this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
4638
4638
  this.contractEventsSubscriptionReady = this.initializeSubscription();
@@ -4939,7 +4939,7 @@ var VtxoManager = class _VtxoManager {
4939
4939
  * {@link recoverImportedContracts}).
4940
4940
  */
4941
4941
  async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
4942
- const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkVVFCCNU2_cjs.isVtxoSpent(vtxo));
4942
+ const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkFGKBQH5S_cjs.isVtxoSpent(vtxo));
4943
4943
  const estimator = new Estimator(info?.fees.intentFee ?? {});
4944
4944
  const { payable, net } = priceSettlementInputs(recoverable, estimator);
4945
4945
  const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
@@ -4961,7 +4961,7 @@ var VtxoManager = class _VtxoManager {
4961
4961
  if (vtxos.length === 0) return;
4962
4962
  const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
4963
4963
  const stillSpendable = vtxos.some(
4964
- (vtxo) => !chunkVVFCCNU2_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
4964
+ (vtxo) => !chunkFGKBQH5S_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
4965
4965
  );
4966
4966
  if (!stillSpendable) {
4967
4967
  await wallet.removeRecoveryContract(contract.script);
@@ -5253,11 +5253,11 @@ var VtxoManager = class _VtxoManager {
5253
5253
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
5254
5254
  );
5255
5255
  }
5256
- const tx = new chunkVVFCCNU2_cjs.Transaction();
5256
+ const tx = new chunkFGKBQH5S_cjs.Transaction();
5257
5257
  for (const utxo of expiredUtxos) {
5258
- const utxoScript = chunkVVFCCNU2_cjs.VtxoScript.decode(utxo.tapTree);
5258
+ const utxoScript = chunkFGKBQH5S_cjs.VtxoScript.decode(utxo.tapTree);
5259
5259
  const utxoExitLeaf = utxoScript.leaves.find(
5260
- (leaf) => chunkVVFCCNU2_cjs.CSVMultisigTapscript.isScriptValid(chunkVVFCCNU2_cjs.scriptFromTapLeafScript(leaf)) === true
5260
+ (leaf) => chunkFGKBQH5S_cjs.CSVMultisigTapscript.isScriptValid(chunkFGKBQH5S_cjs.scriptFromTapLeafScript(leaf)) === true
5261
5261
  );
5262
5262
  if (!utxoExitLeaf) {
5263
5263
  throw new Error(
@@ -5272,7 +5272,7 @@ var VtxoManager = class _VtxoManager {
5272
5272
  amount: BigInt(utxo.value)
5273
5273
  },
5274
5274
  tapLeafScript: [utxoExitLeaf],
5275
- sequence: chunkVVFCCNU2_cjs.getSequence(utxoExitLeaf)
5275
+ sequence: chunkFGKBQH5S_cjs.getSequence(utxoExitLeaf)
5276
5276
  });
5277
5277
  }
5278
5278
  tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
@@ -5498,8 +5498,8 @@ var VtxoManager = class _VtxoManager {
5498
5498
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
5499
5499
  if (cls.status === "CURRENT") continue;
5500
5500
  const live = vtxos.filter((v) => !v.isUnrolled);
5501
- const recoverable = live.filter((v) => v.isSwept && !chunkVVFCCNU2_cjs.isVtxoSpent(v));
5502
- const spendable = live.filter((v) => !chunkVVFCCNU2_cjs.isVtxoSpent(v) && !v.isSwept);
5501
+ const recoverable = live.filter((v) => v.isSwept && !chunkFGKBQH5S_cjs.isVtxoSpent(v));
5502
+ const spendable = live.filter((v) => !chunkFGKBQH5S_cjs.isVtxoSpent(v) && !v.isSwept);
5503
5503
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
5504
5504
  let recoverableCount = 0;
5505
5505
  let recoverableValue = 0;
@@ -5739,7 +5739,7 @@ var VtxoManager = class _VtxoManager {
5739
5739
  }
5740
5740
  getBoardingTimelock() {
5741
5741
  const wallet = this.getSweepWallet();
5742
- const exitScript = chunkVVFCCNU2_cjs.CSVMultisigTapscript.decode(
5742
+ const exitScript = chunkFGKBQH5S_cjs.CSVMultisigTapscript.decode(
5743
5743
  base.hex.decode(wallet.boardingTapscript.exitScript)
5744
5744
  );
5745
5745
  return exitScript.params.timelock;
@@ -5847,8 +5847,8 @@ var VtxoManager = class _VtxoManager {
5847
5847
  }
5848
5848
  /** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
5849
5849
  extractSpentOutpoint(error) {
5850
- const ark = chunkVVFCCNU2_cjs.maybeArkError(error);
5851
- if (!chunkVVFCCNU2_cjs.isArkError(ark, chunkVVFCCNU2_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5850
+ const ark = chunkFGKBQH5S_cjs.maybeArkError(error);
5851
+ if (!chunkFGKBQH5S_cjs.isArkError(ark, chunkFGKBQH5S_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5852
5852
  const raw = ark.metadata?.vtxo_outpoint;
5853
5853
  if (typeof raw !== "string") return void 0;
5854
5854
  const [txid, voutStr] = raw.split(":");
@@ -6022,7 +6022,7 @@ var VtxoManager = class _VtxoManager {
6022
6022
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
6023
6023
  break;
6024
6024
  }
6025
- const inputFee = estimator.evalOffchainInput(chunkVVFCCNU2_cjs.toOffchainInputFeeParams(v));
6025
+ const inputFee = estimator.evalOffchainInput(chunkFGKBQH5S_cjs.toOffchainInputFeeParams(v));
6026
6026
  if (inputFee.satoshis >= v.value) {
6027
6027
  continue;
6028
6028
  }
@@ -6042,7 +6042,7 @@ var VtxoManager = class _VtxoManager {
6042
6042
  const arkAddress = await this.wallet.getAddress();
6043
6043
  const outputFee = estimator.evalOffchainOutput({
6044
6044
  amount: totalAmount,
6045
- script: base.hex.encode(chunkVVFCCNU2_cjs.ArkAddress.decode(arkAddress).pkScript)
6045
+ script: base.hex.encode(chunkFGKBQH5S_cjs.ArkAddress.decode(arkAddress).pkScript)
6046
6046
  });
6047
6047
  totalAmount -= BigInt(outputFee.satoshis);
6048
6048
  if (totalAmount < dustAmount) return;
@@ -6126,7 +6126,7 @@ var ArkNote = class _ArkNote {
6126
6126
  this.value = value;
6127
6127
  this.HRP = HRP;
6128
6128
  const preimageHash = utils_js.sha256(this.preimage);
6129
- this.vtxoScript = new chunkVVFCCNU2_cjs.VtxoScript([noteTapscript(preimageHash)]);
6129
+ this.vtxoScript = new chunkFGKBQH5S_cjs.VtxoScript([noteTapscript(preimageHash)]);
6130
6130
  const leaf = this.vtxoScript.leaves[0];
6131
6131
  this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
6132
6132
  this.tapTree = this.vtxoScript.encode();
@@ -6299,7 +6299,7 @@ var ArkadeCash = class _ArkadeCash {
6299
6299
  const privateKey = data.slice(1, 33);
6300
6300
  const serverPubKey = data.slice(33, 65);
6301
6301
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
6302
- const csvTimelock2 = chunkVVFCCNU2_cjs.sequenceToTimelock(sequence);
6302
+ const csvTimelock2 = chunkFGKBQH5S_cjs.sequenceToTimelock(sequence);
6303
6303
  return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
6304
6304
  }
6305
6305
  toString() {
@@ -6307,7 +6307,7 @@ var ArkadeCash = class _ArkadeCash {
6307
6307
  data[0] = _ArkadeCash.Version;
6308
6308
  data.set(this._privateKey, 1);
6309
6309
  data.set(this._serverPubKey, 33);
6310
- const sequence = chunkVVFCCNU2_cjs.timelockToSequence(this.csvTimelock);
6310
+ const sequence = chunkFGKBQH5S_cjs.timelockToSequence(this.csvTimelock);
6311
6311
  new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
6312
6312
  const words = base.bech32m.toWords(data);
6313
6313
  return base.bech32m.encode(this.hrp, words, 1023);
@@ -6316,7 +6316,7 @@ var ArkadeCash = class _ArkadeCash {
6316
6316
  return SingleKey.fromPrivateKey(this._privateKey);
6317
6317
  }
6318
6318
  get vtxoScript() {
6319
- return new chunkCFOIHLON_cjs.DefaultVtxo.Script({
6319
+ return new chunkYFQOJTG3_cjs.DefaultVtxo.Script({
6320
6320
  pubKey: this._publicKey,
6321
6321
  serverPubKey: this._serverPubKey,
6322
6322
  csvTimelock: this.csvTimelock
@@ -6332,7 +6332,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
6332
6332
  (s) => !isTerminalIntentState(s)
6333
6333
  );
6334
6334
  function isConsumed(vtxo) {
6335
- return vtxo !== void 0 && chunkVVFCCNU2_cjs.isVtxoSpent(vtxo);
6335
+ return vtxo !== void 0 && chunkFGKBQH5S_cjs.isVtxoSpent(vtxo);
6336
6336
  }
6337
6337
  async function classifyIntent(intent, vtxosByOutpoint, now) {
6338
6338
  if (isTerminalIntentState(intent.state)) return void 0;
@@ -6375,7 +6375,7 @@ async function reconcileIntents(deps) {
6375
6375
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
6376
6376
  if (outpoints.length > 0) {
6377
6377
  try {
6378
- const { vtxos } = await chunkVVFCCNU2_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
6378
+ const { vtxos } = await chunkFGKBQH5S_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
6379
6379
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
6380
6380
  } catch (e) {
6381
6381
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -6435,7 +6435,7 @@ async function releaseFromServer(intent, deps, now) {
6435
6435
  });
6436
6436
  }
6437
6437
  function isNoMatchingIntentsError(e) {
6438
- return chunkVVFCCNU2_cjs.isArkError(e, chunkVVFCCNU2_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
6438
+ return chunkFGKBQH5S_cjs.isArkError(e, chunkFGKBQH5S_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
6439
6439
  }
6440
6440
  function terminal(intent, state, now, patch) {
6441
6441
  return { ...intent, ...patch, state, updatedAt: now };
@@ -6654,7 +6654,7 @@ async function captureExitBranch(params) {
6654
6654
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
6655
6655
  if (nonCommitment.length > 0) {
6656
6656
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
6657
- psbtByTxid.set(chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6657
+ psbtByTxid.set(chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6658
6658
  }
6659
6659
  }
6660
6660
  }
@@ -6697,10 +6697,10 @@ var IndexerExitDataSource = class {
6697
6697
  while (hasMore) {
6698
6698
  const { chain: page, page: meta } = await this.indexer.getVtxoChain(
6699
6699
  { txid: vtxo.txid, vout: vtxo.vout },
6700
- { pageIndex, pageSize: chunkVVFCCNU2_cjs.DEFAULT_PAGE_SIZE }
6700
+ { pageIndex, pageSize: chunkFGKBQH5S_cjs.DEFAULT_PAGE_SIZE }
6701
6701
  );
6702
6702
  chain.push(...page);
6703
- hasMore = meta ? page.length === chunkVVFCCNU2_cjs.DEFAULT_PAGE_SIZE : false;
6703
+ hasMore = meta ? page.length === chunkFGKBQH5S_cjs.DEFAULT_PAGE_SIZE : false;
6704
6704
  pageIndex++;
6705
6705
  }
6706
6706
  return chain;
@@ -6712,12 +6712,12 @@ var IndexerExitDataSource = class {
6712
6712
  while (hasMore) {
6713
6713
  const { txs, page } = await this.indexer.getVirtualTxs(txids, {
6714
6714
  pageIndex,
6715
- pageSize: chunkVVFCCNU2_cjs.DEFAULT_PAGE_SIZE
6715
+ pageSize: chunkFGKBQH5S_cjs.DEFAULT_PAGE_SIZE
6716
6716
  });
6717
6717
  for (const psbt of txs) {
6718
- out.set(chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6718
+ out.set(chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6719
6719
  }
6720
- hasMore = page ? txs.length === chunkVVFCCNU2_cjs.DEFAULT_PAGE_SIZE : false;
6720
+ hasMore = page ? txs.length === chunkFGKBQH5S_cjs.DEFAULT_PAGE_SIZE : false;
6721
6721
  pageIndex++;
6722
6722
  }
6723
6723
  return out;
@@ -6738,7 +6738,7 @@ function chainedTxTypeToChainTxType(t) {
6738
6738
  }
6739
6739
  }
6740
6740
  function psbtInputTxids(psbtBase64) {
6741
- return txInputTxids(chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
6741
+ return txInputTxids(chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
6742
6742
  }
6743
6743
  function txInputTxids(tx) {
6744
6744
  const ids = [];
@@ -7042,10 +7042,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
7042
7042
  try {
7043
7043
  info = await arkProvider.getInfo();
7044
7044
  } catch (err) {
7045
- if (opts?.requireLive || !chunkVVFCCNU2_cjs.isRetryableProviderError(err)) throw err;
7045
+ if (opts?.requireLive || !chunkFGKBQH5S_cjs.isRetryableProviderError(err)) throw err;
7046
7046
  const snapshot = await loadArkInfoSnapshot(walletRepository);
7047
7047
  if (!snapshot) {
7048
- throw new chunkVVFCCNU2_cjs.ProviderUnavailableError(
7048
+ throw new chunkFGKBQH5S_cjs.ProviderUnavailableError(
7049
7049
  "Arkade server info is unavailable and no cached snapshot exists",
7050
7050
  { cause: err }
7051
7051
  );
@@ -7237,7 +7237,7 @@ function buildGraph(rootTxid, chunksByTxid) {
7237
7237
  return new TxTree(rootTx, children);
7238
7238
  }
7239
7239
  function decodeNode(chunk) {
7240
- const tx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
7240
+ const tx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
7241
7241
  return { tx, children: chunk.children };
7242
7242
  }
7243
7243
  exports.Batch = void 0;
@@ -7440,7 +7440,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
7440
7440
  return [...txids];
7441
7441
  }
7442
7442
  async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
7443
- const normalized = vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7443
+ const normalized = vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7444
7444
  const localCreatedAt = localCreatedAtByTxid(normalized);
7445
7445
  const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
7446
7446
  const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
@@ -7618,7 +7618,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7618
7618
  withRecoverable: false,
7619
7619
  genericallySpendableOnly: true
7620
7620
  });
7621
- const controlAssetRef = params.controlAssetId ? chunkFEBAG2K2_cjs.AssetRef.fromId(chunkFEBAG2K2_cjs.AssetId.fromString(params.controlAssetId)) : null;
7621
+ const controlAssetRef = params.controlAssetId ? chunk6BJJ47JM_cjs.AssetRef.fromId(chunk6BJJ47JM_cjs.AssetId.fromString(params.controlAssetId)) : null;
7622
7622
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
7623
7623
  let totalBtcSelected = 0n;
7624
7624
  const assetChanges = /* @__PURE__ */ new Map();
@@ -7631,8 +7631,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7631
7631
  }
7632
7632
  }
7633
7633
  const groups = [];
7634
- const issuedAssetOutput = chunkFEBAG2K2_cjs.AssetOutput.create(0, params.amount);
7635
- const issuedAssetGroup = chunkFEBAG2K2_cjs.AssetGroup.create(
7634
+ const issuedAssetOutput = chunk6BJJ47JM_cjs.AssetOutput.create(0, params.amount);
7635
+ const issuedAssetGroup = chunk6BJJ47JM_cjs.AssetGroup.create(
7636
7636
  null,
7637
7637
  controlAssetRef,
7638
7638
  [],
@@ -7645,11 +7645,11 @@ var AssetManager = class extends ReadonlyAssetManager {
7645
7645
  for (const [assetId, amount] of assetChanges) {
7646
7646
  const changeInputs = inputsForAsset(assetInputs, assetId);
7647
7647
  groups.push(
7648
- chunkFEBAG2K2_cjs.AssetGroup.create(
7649
- chunkFEBAG2K2_cjs.AssetId.fromString(assetId),
7648
+ chunk6BJJ47JM_cjs.AssetGroup.create(
7649
+ chunk6BJJ47JM_cjs.AssetId.fromString(assetId),
7650
7650
  null,
7651
7651
  changeInputs,
7652
- [chunkFEBAG2K2_cjs.AssetOutput.create(0, amount)],
7652
+ [chunk6BJJ47JM_cjs.AssetOutput.create(0, amount)],
7653
7653
  []
7654
7654
  )
7655
7655
  );
@@ -7664,7 +7664,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7664
7664
  );
7665
7665
  return {
7666
7666
  arkTxId: arkTxid,
7667
- assetId: chunkFEBAG2K2_cjs.AssetId.create(arkTxid, 0).toString()
7667
+ assetId: chunk6BJJ47JM_cjs.AssetId.create(arkTxid, 0).toString()
7668
7668
  };
7669
7669
  }
7670
7670
  /**
@@ -7738,23 +7738,23 @@ var AssetManager = class extends ReadonlyAssetManager {
7738
7738
  const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
7739
7739
  const reissueInputs = inputsForAsset(assetInputs, params.assetId);
7740
7740
  const totalAssetAmount = assetToReissueAmount + params.amount;
7741
- const reissueAssetIdObj = chunkFEBAG2K2_cjs.AssetId.fromString(params.assetId);
7742
- const reissueAssetGroup = chunkFEBAG2K2_cjs.AssetGroup.create(
7741
+ const reissueAssetIdObj = chunk6BJJ47JM_cjs.AssetId.fromString(params.assetId);
7742
+ const reissueAssetGroup = chunk6BJJ47JM_cjs.AssetGroup.create(
7743
7743
  reissueAssetIdObj,
7744
7744
  null,
7745
7745
  reissueInputs,
7746
- [chunkFEBAG2K2_cjs.AssetOutput.create(0, totalAssetAmount)],
7746
+ [chunk6BJJ47JM_cjs.AssetOutput.create(0, totalAssetAmount)],
7747
7747
  []
7748
7748
  );
7749
7749
  const groups = [reissueAssetGroup];
7750
7750
  for (const [assetId, amount] of assetChanges) {
7751
7751
  const changeInputs = inputsForAsset(assetInputs, assetId);
7752
7752
  groups.push(
7753
- chunkFEBAG2K2_cjs.AssetGroup.create(
7754
- chunkFEBAG2K2_cjs.AssetId.fromString(assetId),
7753
+ chunk6BJJ47JM_cjs.AssetGroup.create(
7754
+ chunk6BJJ47JM_cjs.AssetId.fromString(assetId),
7755
7755
  null,
7756
7756
  changeInputs,
7757
- [chunkFEBAG2K2_cjs.AssetOutput.create(0, amount)],
7757
+ [chunk6BJJ47JM_cjs.AssetOutput.create(0, amount)],
7758
7758
  []
7759
7759
  )
7760
7760
  );
@@ -7825,11 +7825,11 @@ var AssetManager = class extends ReadonlyAssetManager {
7825
7825
  for (const [assetId, amount] of assetChanges) {
7826
7826
  const changeInputs = inputsForAsset(assetInputs, assetId);
7827
7827
  groups.push(
7828
- chunkFEBAG2K2_cjs.AssetGroup.create(
7829
- chunkFEBAG2K2_cjs.AssetId.fromString(assetId),
7828
+ chunk6BJJ47JM_cjs.AssetGroup.create(
7829
+ chunk6BJJ47JM_cjs.AssetId.fromString(assetId),
7830
7830
  null,
7831
7831
  changeInputs,
7832
- amount > 0n ? [chunkFEBAG2K2_cjs.AssetOutput.create(0, amount)] : [],
7832
+ amount > 0n ? [chunk6BJJ47JM_cjs.AssetOutput.create(0, amount)] : [],
7833
7833
  []
7834
7834
  )
7835
7835
  );
@@ -7842,16 +7842,16 @@ function inputsForAsset(assetInputs, assetId) {
7842
7842
  for (const [inputIndex, assets] of assetInputs) {
7843
7843
  for (const asset of assets) {
7844
7844
  if (asset.assetId !== assetId) continue;
7845
- inputs.push(chunkFEBAG2K2_cjs.AssetInput.create(inputIndex, asset.amount));
7845
+ inputs.push(chunk6BJJ47JM_cjs.AssetInput.create(inputIndex, asset.amount));
7846
7846
  }
7847
7847
  }
7848
7848
  return inputs;
7849
7849
  }
7850
7850
  async function submitToSelf(submit, wallet, inputs, amount, groups) {
7851
- const outputAddress = chunkVVFCCNU2_cjs.ArkAddress.decode(await wallet.getAddress());
7851
+ const outputAddress = chunkFGKBQH5S_cjs.ArkAddress.decode(await wallet.getAddress());
7852
7852
  const outputs = [
7853
7853
  { script: outputAddress.pkScript, amount: BigInt(amount) },
7854
- Extension.create([chunkFEBAG2K2_cjs.Packet.create(groups)]).txOut()
7854
+ Extension.create([chunk6BJJ47JM_cjs.Packet.create(groups)]).txOut()
7855
7855
  ];
7856
7856
  const { arkTxid } = await submit(inputs, outputs);
7857
7857
  return arkTxid;
@@ -7875,7 +7875,7 @@ function castMetadata(metadata) {
7875
7875
  } else {
7876
7876
  throw new Error("Invalid metadata value type");
7877
7877
  }
7878
- md.push(chunkFEBAG2K2_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7878
+ md.push(chunk6BJJ47JM_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7879
7879
  }
7880
7880
  return md;
7881
7881
  }
@@ -7896,10 +7896,10 @@ var DelegateManagerImpl = class {
7896
7896
  if (vtxos.length === 0) {
7897
7897
  return { delegated: [], failed: [] };
7898
7898
  }
7899
- const destinationScript = chunkVVFCCNU2_cjs.ArkAddress.decode(destination).pkScript;
7899
+ const destinationScript = chunkFGKBQH5S_cjs.ArkAddress.decode(destination).pkScript;
7900
7900
  const arkInfo = await this.arkInfoProvider.getInfo();
7901
7901
  const delegateInfo = await this.delegateProvider.getDelegateInfo();
7902
- const eligible = vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo).filter(
7902
+ const eligible = vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo).filter(
7903
7903
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
7904
7904
  );
7905
7905
  if (eligible.length === 0) {
@@ -7931,7 +7931,7 @@ var DelegateManagerImpl = class {
7931
7931
  const groupByExpiry = /* @__PURE__ */ new Map();
7932
7932
  let recoverableVtxos = [];
7933
7933
  for (const vtxo of eligible) {
7934
- if (chunkVVFCCNU2_cjs.canRecoverOnchain(vtxo, now)) {
7934
+ if (chunkFGKBQH5S_cjs.canRecoverOnchain(vtxo, now)) {
7935
7935
  recoverableVtxos.push(vtxo);
7936
7936
  continue;
7937
7937
  }
@@ -7983,7 +7983,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7983
7983
  }
7984
7984
  if (!delegateAt) {
7985
7985
  const now = { timestamp: /* @__PURE__ */ new Date() };
7986
- const expiryTimestamp = vtxos.filter((coin) => !chunkVVFCCNU2_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
7986
+ const expiryTimestamp = vtxos.filter((coin) => !chunkFGKBQH5S_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
7987
7987
  (min, coin) => Math.min(min, coin.expiresAt.getTime()),
7988
7988
  Number.MAX_SAFE_INTEGER
7989
7989
  );
@@ -8010,7 +8010,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
8010
8010
  let amount = 0n;
8011
8011
  for (const coin of vtxos) {
8012
8012
  const inputFee = estimator.evalOffchainInput({
8013
- ...chunkVVFCCNU2_cjs.toOffchainInputFeeParams(coin),
8013
+ ...chunkFGKBQH5S_cjs.toOffchainInputFeeParams(coin),
8014
8014
  type: "vtxo"
8015
8015
  });
8016
8016
  if (inputFee.satoshis >= coin.value) {
@@ -8024,7 +8024,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
8024
8024
  const delegateFee = BigInt(Number(fee));
8025
8025
  if (delegateFee > 0n) {
8026
8026
  outputs.push({
8027
- script: chunkVVFCCNU2_cjs.ArkAddress.decode(delegateAddress).pkScript,
8027
+ script: chunkFGKBQH5S_cjs.ArkAddress.decode(delegateAddress).pkScript,
8028
8028
  amount: delegateFee
8029
8029
  });
8030
8030
  }
@@ -8057,10 +8057,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
8057
8057
  destinationScript
8058
8058
  );
8059
8059
  const forfeitOutputScript = btcSigner.OutScript.encode(
8060
- btcSigner.Address(chunkVVFCCNU2_cjs.getNetwork(network)).decode(forfeitAddress)
8060
+ btcSigner.Address(chunkFGKBQH5S_cjs.getNetwork(network)).decode(forfeitAddress)
8061
8061
  );
8062
8062
  const forfeits = await Promise.all(
8063
- vtxos.filter((v) => chunkVVFCCNU2_cjs.requiresForfeit(v)).map(async (coin) => {
8063
+ vtxos.filter((v) => chunkFGKBQH5S_cjs.requiresForfeit(v)).map(async (coin) => {
8064
8064
  const forfeit = await makeDelegateForfeitTx(
8065
8065
  coin,
8066
8066
  dust,
@@ -8085,7 +8085,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
8085
8085
  index: input.vout,
8086
8086
  witnessUtxo: {
8087
8087
  amount: BigInt(input.value),
8088
- script: chunkVVFCCNU2_cjs.VtxoScript.decode(input.tapTree).pkScript
8088
+ script: chunkFGKBQH5S_cjs.VtxoScript.decode(input.tapTree).pkScript
8089
8089
  },
8090
8090
  sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
8091
8091
  tapLeafScript: [delegateTapLeaf]
@@ -8143,7 +8143,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
8143
8143
  expire_at: 0,
8144
8144
  cosigners_public_keys: cosignerPubKeys
8145
8145
  };
8146
- const proof = chunkVVFCCNU2_cjs.Intent.create(message, coins, outputs);
8146
+ const proof = chunkFGKBQH5S_cjs.Intent.create(message, coins, outputs);
8147
8147
  const signedProof = await identity.sign(proof);
8148
8148
  return {
8149
8149
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -8169,10 +8169,10 @@ function getDayTimestamp(timestamp) {
8169
8169
  function findDelegateTapLeaf(vtxo, delegatePubkey) {
8170
8170
  if (!vtxo.tapTree) return void 0;
8171
8171
  const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
8172
- const vtxoScript = chunkVVFCCNU2_cjs.VtxoScript.decode(vtxo.tapTree);
8172
+ const vtxoScript = chunkFGKBQH5S_cjs.VtxoScript.decode(vtxo.tapTree);
8173
8173
  return vtxoScript.leaves.find((tapLeaf) => {
8174
- const arkTapscript = chunkVVFCCNU2_cjs.decodeTapscript(chunkVVFCCNU2_cjs.scriptFromTapLeafScript(tapLeaf));
8175
- if (!chunkVVFCCNU2_cjs.MultisigTapscript.is(arkTapscript)) return false;
8174
+ const arkTapscript = chunkFGKBQH5S_cjs.decodeTapscript(chunkFGKBQH5S_cjs.scriptFromTapLeafScript(tapLeaf));
8175
+ if (!chunkFGKBQH5S_cjs.MultisigTapscript.is(arkTapscript)) return false;
8176
8176
  return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
8177
8177
  });
8178
8178
  }
@@ -8728,8 +8728,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
8728
8728
  }
8729
8729
  async function getVtxosForContract(repo, contract, options) {
8730
8730
  const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
8731
- const normalized = vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo);
8732
- return options?.unspentOnly ? normalized.filter((vtxo) => !chunkVVFCCNU2_cjs.isVtxoSpent(vtxo)) : normalized;
8731
+ const normalized = vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo);
8732
+ return options?.unspentOnly ? normalized.filter((vtxo) => !chunkFGKBQH5S_cjs.isVtxoSpent(vtxo)) : normalized;
8733
8733
  }
8734
8734
  async function hasVtxosForContract(repo, contract) {
8735
8735
  if (repo.getVtxosForScriptPage) {
@@ -8960,7 +8960,7 @@ function decodeArkContract(encoded) {
8960
8960
  }
8961
8961
  function contractFromArkContract(encoded, options = {}) {
8962
8962
  const parsed = decodeArkContract(encoded);
8963
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(parsed.type);
8963
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(parsed.type);
8964
8964
  if (!handler) {
8965
8965
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
8966
8966
  }
@@ -8974,9 +8974,9 @@ function contractFromArkContract(encoded, options = {}) {
8974
8974
  metadata: options.metadata
8975
8975
  };
8976
8976
  }
8977
- function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkVVFCCNU2_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8977
+ function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkFGKBQH5S_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8978
8978
  const parsed = decodeArkContract(encoded);
8979
- const handler = chunkCFOIHLON_cjs.contractHandlers.getOrThrow(parsed.type);
8979
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.getOrThrow(parsed.type);
8980
8980
  const params = parsed.data;
8981
8981
  const vtxoScript = handler.createScript(params);
8982
8982
  return {
@@ -9033,10 +9033,10 @@ var ContractWatcher = class {
9033
9033
  eventSourceReported = false;
9034
9034
  /** @see ContractWatcherConfig */
9035
9035
  constructor(config) {
9036
- chunkVVFCCNU2_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
9037
- chunkVVFCCNU2_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
9038
- chunkVVFCCNU2_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
9039
- chunkVVFCCNU2_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
9036
+ chunkFGKBQH5S_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
9037
+ chunkFGKBQH5S_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
9038
+ chunkFGKBQH5S_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
9039
+ chunkFGKBQH5S_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
9040
9040
  if (config.subscriptionRequestTimeoutMs === 0) {
9041
9041
  throw new Error("subscriptionRequestTimeoutMs must be greater than 0");
9042
9042
  }
@@ -9259,9 +9259,9 @@ var ContractWatcher = class {
9259
9259
  this.reconnectAttempts = 0;
9260
9260
  this.listenLoop().catch((e) => {
9261
9261
  if (!this.isWatching || signal?.aborted) return;
9262
- if (chunkVVFCCNU2_cjs.isEventSourceError(e)) {
9262
+ if (chunkFGKBQH5S_cjs.isEventSourceError(e)) {
9263
9263
  console.debug("ContractWatcher subscription disconnected; reconnecting");
9264
- } else if (!chunkVVFCCNU2_cjs.isEventSourceUnavailableError(e)) {
9264
+ } else if (!chunkFGKBQH5S_cjs.isEventSourceUnavailableError(e)) {
9265
9265
  console.error(e);
9266
9266
  }
9267
9267
  this.connectionState = "disconnected";
@@ -9271,7 +9271,7 @@ var ContractWatcher = class {
9271
9271
  });
9272
9272
  } catch (error) {
9273
9273
  if (!this.isWatching || signal?.aborted) return;
9274
- if (!chunkVVFCCNU2_cjs.isEventSourceUnavailableError(error)) {
9274
+ if (!chunkFGKBQH5S_cjs.isEventSourceUnavailableError(error)) {
9275
9275
  console.error("ContractWatcher connection failed:", error);
9276
9276
  }
9277
9277
  this.connectionState = "disconnected";
@@ -9287,7 +9287,7 @@ var ContractWatcher = class {
9287
9287
  * few seconds.
9288
9288
  */
9289
9289
  reportEventSourceUnavailable(error) {
9290
- if (!chunkVVFCCNU2_cjs.isEventSourceUnavailableError(error)) return false;
9290
+ if (!chunkFGKBQH5S_cjs.isEventSourceUnavailableError(error)) return false;
9291
9291
  if (!this.eventSourceReported) {
9292
9292
  this.eventSourceReported = true;
9293
9293
  console.warn(
@@ -9352,7 +9352,7 @@ var ContractWatcher = class {
9352
9352
  const now = Date.now();
9353
9353
  let current;
9354
9354
  try {
9355
- current = await chunkVVFCCNU2_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9355
+ current = await chunkFGKBQH5S_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9356
9356
  spendableOnly: true
9357
9357
  });
9358
9358
  } catch (error) {
@@ -9634,14 +9634,14 @@ var ContractWatcher = class {
9634
9634
  const timestamp = Date.now();
9635
9635
  if (update.newVtxos?.length) {
9636
9636
  this.processSubscriptionVtxos(
9637
- update.newVtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo),
9637
+ update.newVtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo),
9638
9638
  "vtxo_received",
9639
9639
  timestamp
9640
9640
  );
9641
9641
  }
9642
9642
  if (update.spentVtxos?.length) {
9643
9643
  this.processSubscriptionVtxos(
9644
- update.spentVtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo),
9644
+ update.spentVtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo),
9645
9645
  "vtxo_spent",
9646
9646
  timestamp
9647
9647
  );
@@ -9666,8 +9666,8 @@ var ContractWatcher = class {
9666
9666
  continue;
9667
9667
  }
9668
9668
  if (target === byWatchedScript && eventType === "vtxo_received") {
9669
- const n = chunkVVFCCNU2_cjs.normalizeVtxo(vtxo);
9670
- if (chunkVVFCCNU2_cjs.isVtxoSpent(n) || n.isSwept || chunkVVFCCNU2_cjs.isPastExpiry(n, now)) continue;
9669
+ const n = chunkFGKBQH5S_cjs.normalizeVtxo(vtxo);
9670
+ if (chunkFGKBQH5S_cjs.isVtxoSpent(n) || n.isSwept || chunkFGKBQH5S_cjs.isPastExpiry(n, now)) continue;
9671
9671
  }
9672
9672
  let bucket = target.get(vtxo.script);
9673
9673
  if (!bucket) {
@@ -9795,16 +9795,20 @@ function toWatchOnlyContract(params) {
9795
9795
  return { ...params, state: params.state ?? "active", createdAt: Date.now() };
9796
9796
  }
9797
9797
  var TAPSCRIPT_MEMO_MAX_ENTRIES = 1024;
9798
+ function contractKey(contract) {
9799
+ return `${contract.type}\0${contract.script}\0${JSON.stringify(contract.params)}`;
9800
+ }
9798
9801
  function annotatableIn(scriptToContract, vtxos, memo) {
9799
9802
  const scripts = /* @__PURE__ */ new Set();
9800
9803
  const cache = /* @__PURE__ */ new Map();
9801
9804
  const failures = /* @__PURE__ */ new Map();
9805
+ const unsupported = /* @__PURE__ */ new Map();
9802
9806
  for (const script of new Set(vtxos.map((vtxo) => vtxo.script))) {
9803
9807
  const contract = scriptToContract.get(script);
9804
9808
  if (!contract) continue;
9805
9809
  try {
9806
- const key = `${contract.type}\0${script}\0${JSON.stringify(contract.params)}`;
9807
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
9810
+ const key = contractKey(contract);
9811
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
9808
9812
  const hit = memo?.get(script);
9809
9813
  let tapscripts;
9810
9814
  if (hit && hit.key === key && hit.handler === handler) {
@@ -9824,17 +9828,19 @@ function annotatableIn(scriptToContract, vtxos, memo) {
9824
9828
  cache.set(script, tapscripts);
9825
9829
  scripts.add(script);
9826
9830
  } catch (err) {
9827
- failures.set(
9828
- script,
9829
- `'${contract.type}' at ${script}: ${err instanceof Error ? err.message : String(err)}`
9830
- );
9831
+ const reason = `'${contract.type}' at ${script}: ${err instanceof Error ? err.message : String(err)}`;
9832
+ if (err instanceof chunkYFQOJTG3_cjs.UnsupportedProgramVersionError) {
9833
+ unsupported.set(script, { key: contractKey(contract), reason });
9834
+ } else {
9835
+ failures.set(script, reason);
9836
+ }
9831
9837
  }
9832
9838
  }
9833
- return { scripts, cache, failures };
9839
+ return { scripts, cache, failures, unsupported };
9834
9840
  }
9835
9841
  function annotateAgainst(vtxos, byScript, tapscripts = /* @__PURE__ */ new Map()) {
9836
9842
  return vtxos.map(
9837
- (vtxo) => extendVirtualCoinForContract(chunkVVFCCNU2_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
9843
+ (vtxo) => extendVirtualCoinForContract(chunkFGKBQH5S_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
9838
9844
  );
9839
9845
  }
9840
9846
  var SCAN_MAX_INDEX = 1e4;
@@ -9878,8 +9884,8 @@ var ContractManager = class _ContractManager {
9878
9884
  * `dispose()`, so it re-checks this at every await rather than run on a torn-down watcher. */
9879
9885
  disposed = false;
9880
9886
  constructor(config) {
9881
- chunkVVFCCNU2_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
9882
- chunkVVFCCNU2_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
9887
+ chunkFGKBQH5S_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
9888
+ chunkFGKBQH5S_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
9883
9889
  this.config = { ...config };
9884
9890
  this.watcher = new ContractWatcher({
9885
9891
  indexerProvider: config.indexerProvider,
@@ -9915,12 +9921,12 @@ var ContractManager = class _ContractManager {
9915
9921
  }
9916
9922
  /** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
9917
9923
  setVtxoSyncMaxAge(maxAgeMs) {
9918
- chunkVVFCCNU2_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
9924
+ chunkFGKBQH5S_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
9919
9925
  this.config.vtxoSyncMaxAgeMs = maxAgeMs;
9920
9926
  }
9921
9927
  /** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
9922
9928
  setVtxoSyncOverlap(overlapMs) {
9923
- chunkVVFCCNU2_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
9929
+ chunkFGKBQH5S_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
9924
9930
  this.config.vtxoSyncOverlapMs = overlapMs;
9925
9931
  }
9926
9932
  markSyncOnline() {
@@ -9945,6 +9951,11 @@ var ContractManager = class _ContractManager {
9945
9951
  watcherStartFailure;
9946
9952
  /** Contracts a sync could not annotate, as `script → reason`. */
9947
9953
  annotationFailures = /* @__PURE__ */ new Map();
9954
+ /**
9955
+ * Rows in a program version this SDK cannot read, as `script → contractKey`. Kept out of
9956
+ * {@link annotationFailures}: they are expected after an upgrade, so they must not degrade sync.
9957
+ */
9958
+ unsupportedContracts = /* @__PURE__ */ new Map();
9948
9959
  annotationDegradedReason() {
9949
9960
  if (this.annotationFailures.size === 0) return void 0;
9950
9961
  return `cannot annotate ${this.annotationFailures.size} contract(s), their vtxos are not being synced \u2014 ${[...this.annotationFailures.values()].join("; ")}`;
@@ -9953,12 +9964,39 @@ var ContractManager = class _ContractManager {
9953
9964
  * Fold one batch's verdict in. Merged, not replaced: a batch may cover only a subset of the
9954
9965
  * wallet's contracts and must not erase what a wider sync found.
9955
9966
  */
9956
- recordAnnotationFailures(annotated, failures) {
9957
- for (const script of annotated) this.annotationFailures.delete(script);
9967
+ recordAnnotationFailures(annotated, failures, unsupported) {
9968
+ for (const script of annotated) {
9969
+ this.annotationFailures.delete(script);
9970
+ this.unsupportedContracts.delete(script);
9971
+ }
9958
9972
  for (const [script, reason] of failures) {
9973
+ this.unsupportedContracts.delete(script);
9959
9974
  this.annotationFailures.set(script, reason);
9960
9975
  console.warn(`[contracts] cannot annotate contract ${reason}; skipping its vtxos`);
9961
9976
  }
9977
+ for (const [script, { key, reason }] of unsupported) {
9978
+ this.annotationFailures.delete(script);
9979
+ if (this.unsupportedContracts.get(script) === key) continue;
9980
+ this.unsupportedContracts.set(script, key);
9981
+ console.warn(`[contracts] cannot annotate contract ${reason}; skipping its vtxos`);
9982
+ }
9983
+ }
9984
+ /**
9985
+ * Whether `contract` is in a program version this SDK cannot read. Memoized per
9986
+ * {@link contractKey}, so a re-created row is never answered from its predecessor's verdict.
9987
+ */
9988
+ isUnsupported(contract) {
9989
+ const key = contractKey(contract);
9990
+ if (this.unsupportedContracts.get(contract.script) === key) return true;
9991
+ if (this.tapscriptMemo.get(contract.script)?.key === key) return false;
9992
+ try {
9993
+ chunkYFQOJTG3_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
9994
+ return false;
9995
+ } catch (err) {
9996
+ if (!(err instanceof chunkYFQOJTG3_cjs.UnsupportedProgramVersionError)) return false;
9997
+ this.unsupportedContracts.set(contract.script, key);
9998
+ return true;
9999
+ }
9962
10000
  }
9963
10001
  /** A retryable failure degrades sync state instead of propagating; terminal ones still throw. */
9964
10002
  /** Returns the swallowed retryable error, if any. */
@@ -9968,7 +10006,7 @@ var ContractManager = class _ContractManager {
9968
10006
  this.markSyncOnline();
9969
10007
  return void 0;
9970
10008
  } catch (err) {
9971
- if (!chunkVVFCCNU2_cjs.isRetryableProviderError(err)) throw err;
10009
+ if (!chunkFGKBQH5S_cjs.isRetryableProviderError(err)) throw err;
9972
10010
  this.markSyncDegraded(err);
9973
10011
  return err;
9974
10012
  }
@@ -9991,7 +10029,7 @@ var ContractManager = class _ContractManager {
9991
10029
  try {
9992
10030
  await this.scheduleLookAheadDrain();
9993
10031
  } catch (err) {
9994
- if (!chunkVVFCCNU2_cjs.isRetryableProviderError(err)) throw err;
10032
+ if (!chunkFGKBQH5S_cjs.isRetryableProviderError(err)) throw err;
9995
10033
  this.lookAheadRefillOwed = true;
9996
10034
  this.markSyncDegraded(err);
9997
10035
  }
@@ -10054,7 +10092,7 @@ var ContractManager = class _ContractManager {
10054
10092
  /** No throw: construction returned long ago, so the state is the channel. */
10055
10093
  reportBackgroundFailure(stage, err) {
10056
10094
  this.markSyncDegraded(err);
10057
- if (!chunkVVFCCNU2_cjs.isRetryableProviderError(err)) {
10095
+ if (!chunkFGKBQH5S_cjs.isRetryableProviderError(err)) {
10058
10096
  console.error(`[contracts] background ${stage} failed`, err);
10059
10097
  }
10060
10098
  }
@@ -10156,7 +10194,7 @@ var ContractManager = class _ContractManager {
10156
10194
  const from = Math.max(0, watermark - lookAhead.size);
10157
10195
  const to = watermark + lookAhead.size;
10158
10196
  const deps = lookAhead.candidateDeps();
10159
- const handlers = chunkCFOIHLON_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCFOIHLON_cjs.contractHandlers.get(t)).filter(hasCandidates);
10197
+ const handlers = chunkYFQOJTG3_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkYFQOJTG3_cjs.contractHandlers.get(t)).filter(hasCandidates);
10160
10198
  const band = /* @__PURE__ */ new Map();
10161
10199
  for (let index = from; index <= to; index++) {
10162
10200
  const descriptor = lookAhead.materialize(index);
@@ -10167,7 +10205,7 @@ var ContractManager = class _ContractManager {
10167
10205
  index,
10168
10206
  params: {
10169
10207
  ...candidate,
10170
- ...chunkCFOIHLON_cjs.speculativeReceiveMetadata(descriptor)
10208
+ ...chunkYFQOJTG3_cjs.speculativeReceiveMetadata(descriptor)
10171
10209
  }
10172
10210
  });
10173
10211
  }
@@ -10226,7 +10264,7 @@ var ContractManager = class _ContractManager {
10226
10264
  });
10227
10265
  for (const entry of pending) entry.catchUpPending = false;
10228
10266
  } catch (err) {
10229
- if (!chunkVVFCCNU2_cjs.isRetryableProviderError(err)) throw err;
10267
+ if (!chunkFGKBQH5S_cjs.isRetryableProviderError(err)) throw err;
10230
10268
  this.markSyncDegraded(err);
10231
10269
  }
10232
10270
  }
@@ -10317,7 +10355,7 @@ var ContractManager = class _ContractManager {
10317
10355
  return result;
10318
10356
  }
10319
10357
  async upsertContractRow(params) {
10320
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(params.type);
10358
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(params.type);
10321
10359
  if (!handler) {
10322
10360
  throw new Error(`No handler registered for contract type '${params.type}'`);
10323
10361
  }
@@ -10339,7 +10377,13 @@ var ContractManager = class _ContractManager {
10339
10377
  }
10340
10378
  const [existing] = await this.getContracts({ script: params.script });
10341
10379
  if (existing) {
10342
- if (existing.type === params.type) return { contract: existing, persisted: false };
10380
+ if (existing.type === params.type) {
10381
+ if (!this.isUnsupported(existing)) return { contract: existing, persisted: false };
10382
+ return {
10383
+ contract: await this.replaceUnsupported(existing, params),
10384
+ persisted: true
10385
+ };
10386
+ }
10343
10387
  if (areCoalescibleContractTypes(existing.type, params.type)) {
10344
10388
  return { contract: existing, persisted: false };
10345
10389
  }
@@ -10355,6 +10399,31 @@ var ContractManager = class _ContractManager {
10355
10399
  await this.config.contractRepository.saveContract(contract);
10356
10400
  return { contract, persisted: true };
10357
10401
  }
10402
+ /**
10403
+ * Overwrite a row this SDK cannot read with `params`, already verified to lock its script. One
10404
+ * write, so the script never goes without a row. The row's history (`createdAt`, `state`,
10405
+ * `watch`) survives, as do its `label` and `metadata` unless the caller passes new ones. The
10406
+ * first writer's generic-spend gate holds: a closed one stays closed, and an open one stays
10407
+ * open unless the caller sets the flag explicitly.
10408
+ */
10409
+ async replaceUnsupported(existing, params) {
10410
+ const label = params.label ?? existing.label;
10411
+ const given = params.metadata ?? existing.metadata;
10412
+ const wasOpen = existing.metadata?.genericallySpendable === true;
10413
+ const metadata = wasOpen && given?.genericallySpendable === void 0 ? { ...given, genericallySpendable: true } : given?.genericallySpendable === true && !wasOpen ? { ...given, genericallySpendable: false } : given;
10414
+ const { watch: _, label: _label, metadata: _metadata, ...rest } = params;
10415
+ const contract = {
10416
+ ...rest,
10417
+ ...label !== void 0 && { label },
10418
+ ...metadata !== void 0 && { metadata },
10419
+ ...existing.watch !== void 0 && { watch: existing.watch },
10420
+ createdAt: existing.createdAt,
10421
+ state: existing.state
10422
+ };
10423
+ await this.config.contractRepository.saveContract(contract);
10424
+ this.unsupportedContracts.delete(contract.script);
10425
+ return contract;
10426
+ }
10358
10427
  /**
10359
10428
  * Gap-limit contract discovery (error contract: {@link IContractManager.scanContracts}).
10360
10429
  * Hits go through {@link persistAndWatchContract}; `Wallet.restore` then hydrates with one
@@ -10385,7 +10454,7 @@ var ContractManager = class _ContractManager {
10385
10454
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
10386
10455
  );
10387
10456
  }
10388
- const registered = chunkCFOIHLON_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCFOIHLON_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10457
+ const registered = chunkYFQOJTG3_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkYFQOJTG3_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10389
10458
  const discoverables = [
10390
10459
  ...registered.filter((h) => h.type === "boarding"),
10391
10460
  ...registered.filter((h) => h.type !== "boarding")
@@ -10510,8 +10579,13 @@ var ContractManager = class _ContractManager {
10510
10579
  const dbFilter = this.buildContractsDbFilter(filter ?? {});
10511
10580
  return await collectContracts(this.config.contractRepository, dbFilter);
10512
10581
  }
10582
+ /** @inheritdoc */
10583
+ async getUnsupportedContracts() {
10584
+ const contracts = await this.getContracts();
10585
+ return contracts.filter((contract) => this.isUnsupported(contract));
10586
+ }
10513
10587
  async getContractsWithVtxos(filter, pageSize, options) {
10514
- chunkVVFCCNU2_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
10588
+ chunkFGKBQH5S_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
10515
10589
  const contracts = await this.getContracts(filter);
10516
10590
  if (this.syncedWithin(
10517
10591
  contracts,
@@ -10582,11 +10656,12 @@ var ContractManager = class _ContractManager {
10582
10656
  const contracts = await collectContracts(this.config.contractRepository, {
10583
10657
  script: Array.from(new Set(vtxos.map((vtxo) => vtxo.script)))
10584
10658
  });
10585
- const { scripts, failures } = annotatableIn(
10659
+ const { scripts, failures, unsupported } = annotatableIn(
10586
10660
  new Map(contracts.map((contract) => [contract.script, contract])),
10587
10661
  vtxos,
10588
10662
  this.tapscriptMemo
10589
10663
  );
10664
+ for (const [script, { reason }] of unsupported) failures.set(script, reason);
10590
10665
  const orphans = vtxos.filter(
10591
10666
  (vtxo) => !scripts.has(vtxo.script) && !failures.has(vtxo.script)
10592
10667
  );
@@ -10618,14 +10693,14 @@ var ContractManager = class _ContractManager {
10618
10693
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
10619
10694
  const asking = vtxos.filter((vtxo) => {
10620
10695
  const contract = byScript.get(vtxo.script);
10621
- return contract !== void 0 && chunkCFOIHLON_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10696
+ return contract !== void 0 && chunkYFQOJTG3_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10622
10697
  });
10623
10698
  if (asking.length === 0) return refused;
10624
10699
  const tip = await this.currentChainTip();
10625
10700
  const walletDescriptorValue = await walletDescriptor?.();
10626
10701
  for (const vtxo of asking) {
10627
10702
  const contract = byScript.get(vtxo.script);
10628
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
10703
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
10629
10704
  if (!handler?.assertSpendableNow) continue;
10630
10705
  const context = {
10631
10706
  collaborative: true,
@@ -10635,7 +10710,7 @@ var ContractManager = class _ContractManager {
10635
10710
  walletDescriptor: walletDescriptorValue,
10636
10711
  // `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
10637
10712
  // reads `vtxo.status.block_time` unguarded, so require `status` too.
10638
- vtxo: chunkVVFCCNU2_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10713
+ vtxo: chunkFGKBQH5S_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10639
10714
  };
10640
10715
  try {
10641
10716
  await handler.assertSpendableNow(
@@ -10748,7 +10823,7 @@ var ContractManager = class _ContractManager {
10748
10823
  const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
10749
10824
  const [contract] = await this.getContracts({ script: contractScript });
10750
10825
  if (!contract) return [];
10751
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
10826
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
10752
10827
  if (!handler) return [];
10753
10828
  const script = handler.createScript(contract.params);
10754
10829
  const tip = await this.currentChainTip();
@@ -10770,7 +10845,7 @@ var ContractManager = class _ContractManager {
10770
10845
  const { contractScript, collaborative = true, walletDescriptor } = options;
10771
10846
  const [contract] = await this.getContracts({ script: contractScript });
10772
10847
  if (!contract) return [];
10773
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
10848
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
10774
10849
  if (!handler) return [];
10775
10850
  const script = handler.createScript(contract.params);
10776
10851
  const context = {
@@ -10816,7 +10891,7 @@ var ContractManager = class _ContractManager {
10816
10891
  }
10817
10892
  async refreshOutpoints(outpoints) {
10818
10893
  if (outpoints.length === 0) return;
10819
- const { vtxos } = await chunkVVFCCNU2_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10894
+ const { vtxos } = await chunkFGKBQH5S_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10820
10895
  outpoints
10821
10896
  });
10822
10897
  if (vtxos.length === 0) return;
@@ -10828,9 +10903,10 @@ var ContractManager = class _ContractManager {
10828
10903
  const {
10829
10904
  scripts: annotatable,
10830
10905
  cache,
10831
- failures
10906
+ failures,
10907
+ unsupported
10832
10908
  } = annotatableIn(scriptToContract, vtxos, this.tapscriptMemo);
10833
- this.recordAnnotationFailures(annotatable, failures);
10909
+ this.recordAnnotationFailures(annotatable, failures, unsupported);
10834
10910
  const owned = vtxos.filter((v) => annotatable.has(v.script));
10835
10911
  if (owned.length === 0) return;
10836
10912
  const annotated = annotateAgainst(owned, scriptToContract, cache);
@@ -10917,7 +10993,7 @@ var ContractManager = class _ContractManager {
10917
10993
  break;
10918
10994
  }
10919
10995
  } catch (err) {
10920
- if (!chunkVVFCCNU2_cjs.isRetryableProviderError(err)) throw err;
10996
+ if (!chunkFGKBQH5S_cjs.isRetryableProviderError(err)) throw err;
10921
10997
  this.markSyncDegraded(err);
10922
10998
  synced = false;
10923
10999
  }
@@ -11005,7 +11081,7 @@ var ContractManager = class _ContractManager {
11005
11081
  */
11006
11082
  async reconcilePendingFrontier(contracts) {
11007
11083
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
11008
- const vtxos = await chunkVVFCCNU2_cjs.getAllNormalizedVtxos(
11084
+ const vtxos = await chunkFGKBQH5S_cjs.getAllNormalizedVtxos(
11009
11085
  this.config.indexerProvider,
11010
11086
  contracts.map((c) => c.script),
11011
11087
  { pendingOnly: true }
@@ -11016,9 +11092,10 @@ var ContractManager = class _ContractManager {
11016
11092
  const {
11017
11093
  scripts: annotatable,
11018
11094
  cache,
11019
- failures
11095
+ failures,
11096
+ unsupported
11020
11097
  } = annotatableIn(scriptToContract, vtxos, this.tapscriptMemo);
11021
- this.recordAnnotationFailures(annotatable, failures);
11098
+ this.recordAnnotationFailures(annotatable, failures, unsupported);
11022
11099
  const owned = vtxos.filter((v) => annotatable.has(v.script));
11023
11100
  const annotated = annotateAgainst(owned, scriptToContract, cache);
11024
11101
  const byContract = /* @__PURE__ */ new Map();
@@ -11079,7 +11156,7 @@ var ContractManager = class _ContractManager {
11079
11156
  }
11080
11157
  return result;
11081
11158
  }
11082
- async fetchContractVtxosBulk(contracts, pageSize = chunkVVFCCNU2_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
11159
+ async fetchContractVtxosBulk(contracts, pageSize = chunkFGKBQH5S_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
11083
11160
  if (contracts.length === 0) {
11084
11161
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
11085
11162
  }
@@ -11095,7 +11172,7 @@ var ContractManager = class _ContractManager {
11095
11172
  before: syncWindow.before
11096
11173
  }
11097
11174
  } : {};
11098
- const vtxos = await chunkVVFCCNU2_cjs.getAllNormalizedVtxos(
11175
+ const vtxos = await chunkFGKBQH5S_cjs.getAllNormalizedVtxos(
11099
11176
  this.config.indexerProvider,
11100
11177
  contracts.map((c) => c.script),
11101
11178
  { ...windowOpts, pageSize }
@@ -11107,9 +11184,10 @@ var ContractManager = class _ContractManager {
11107
11184
  const {
11108
11185
  scripts: annotatable,
11109
11186
  cache,
11110
- failures
11187
+ failures,
11188
+ unsupported
11111
11189
  } = annotatableIn(scriptToContract, vtxos, this.tapscriptMemo);
11112
- this.recordAnnotationFailures(annotatable, failures);
11190
+ this.recordAnnotationFailures(annotatable, failures, unsupported);
11113
11191
  const owned = vtxos.filter((v) => annotatable.has(v.script));
11114
11192
  const annotated = annotateAgainst(owned, scriptToContract, cache);
11115
11193
  for (const vtxo of annotated) {
@@ -11197,7 +11275,7 @@ function parseLegacyExpiry(batchExpiry) {
11197
11275
  if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
11198
11276
  return {};
11199
11277
  }
11200
- if (batchExpiry >= chunkVVFCCNU2_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
11278
+ if (batchExpiry >= chunkFGKBQH5S_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
11201
11279
  return { expiresAtHeight: batchExpiry / 1e3 };
11202
11280
  }
11203
11281
  function legacyVtxoFacts(status) {
@@ -11435,7 +11513,7 @@ function backfillContractWatchState(store) {
11435
11513
  };
11436
11514
  readPage();
11437
11515
  }
11438
- var unspentFlag = (vtxo) => chunkVVFCCNU2_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
11516
+ var unspentFlag = (vtxo) => chunkFGKBQH5S_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
11439
11517
  function backfillVtxoIndexFields(transaction) {
11440
11518
  const store = transaction.objectStore(STORE_VTXOS);
11441
11519
  const pageSize = 1e3;
@@ -11466,7 +11544,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
11466
11544
  var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
11467
11545
  function normalizeOptions2(pathOrOptions) {
11468
11546
  const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
11469
- chunkVVFCCNU2_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
11547
+ chunkFGKBQH5S_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
11470
11548
  return {
11471
11549
  path: o.path,
11472
11550
  activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
@@ -11685,7 +11763,7 @@ var deserializeTapLeaf = (t) => {
11685
11763
  const s = base.hex.decode(t.s);
11686
11764
  return [cb, s];
11687
11765
  };
11688
- var deserializeVtxo = (o) => chunkVVFCCNU2_cjs.normalizeVtxo({
11766
+ var deserializeVtxo = (o) => chunkFGKBQH5S_cjs.normalizeVtxo({
11689
11767
  ...o,
11690
11768
  createdAt: new Date(o.createdAt),
11691
11769
  tapTree: base.hex.decode(o.tapTree),
@@ -12031,6 +12109,164 @@ var scriptVtxoCursorOf = (row) => ({
12031
12109
  txid: row.vtxo.txid,
12032
12110
  vout: row.vtxo.vout
12033
12111
  });
12112
+
12113
+ // src/providers/emulator.ts
12114
+ var RestEmulatorProvider = class {
12115
+ constructor(serverUrl) {
12116
+ this.serverUrl = serverUrl;
12117
+ }
12118
+ serverUrl;
12119
+ async getInfo() {
12120
+ const url = `${this.serverUrl}/v1/info`;
12121
+ const response = await chunkFGKBQH5S_cjs.baseFetch(url);
12122
+ if (!response.ok) {
12123
+ const errorText2 = await response.text();
12124
+ throw new Error(`Failed to get emulator info: ${errorText2}`);
12125
+ }
12126
+ const data = await response.json();
12127
+ const signerPubkey = data.signerPubkey;
12128
+ if (typeof signerPubkey !== "string" || !signerPubkey) {
12129
+ throw new Error("Invalid emulator info response: missing signerPubkey");
12130
+ }
12131
+ return { signerPubkey };
12132
+ }
12133
+ async submitTx(arkTx, checkpointTxs) {
12134
+ const url = `${this.serverUrl}/v1/tx`;
12135
+ const response = await fetch(url, {
12136
+ method: "POST",
12137
+ headers: { "Content-Type": "application/json" },
12138
+ body: JSON.stringify({
12139
+ arkTx,
12140
+ checkpointTxs
12141
+ })
12142
+ });
12143
+ if (!response.ok) {
12144
+ const errorText2 = await response.text();
12145
+ throw new Error(`Failed to submit tx to emulator: ${errorText2}`);
12146
+ }
12147
+ const data = await response.json();
12148
+ if (typeof data.signedArkTx !== "string" || !data.signedArkTx) {
12149
+ throw new Error("Invalid emulator submitTx response: missing signedArkTx");
12150
+ }
12151
+ if (!Array.isArray(data.signedCheckpointTxs) || !data.signedCheckpointTxs.every((item) => typeof item === "string")) {
12152
+ throw new Error(
12153
+ "Invalid emulator submitTx response: signedCheckpointTxs must be an array of strings"
12154
+ );
12155
+ }
12156
+ return {
12157
+ signedArkTx: data.signedArkTx,
12158
+ signedCheckpointTxs: data.signedCheckpointTxs
12159
+ };
12160
+ }
12161
+ async submitIntent(intent) {
12162
+ const url = `${this.serverUrl}/v1/intent`;
12163
+ const response = await fetch(url, {
12164
+ method: "POST",
12165
+ headers: { "Content-Type": "application/json" },
12166
+ body: JSON.stringify({
12167
+ intent: {
12168
+ proof: intent.proof,
12169
+ message: JSON.stringify(intent.message)
12170
+ }
12171
+ })
12172
+ });
12173
+ if (!response.ok) {
12174
+ const errorText2 = await response.text();
12175
+ throw new Error(`Failed to submit intent to emulator: ${errorText2}`);
12176
+ }
12177
+ const data = await response.json();
12178
+ if (typeof data.signedProof !== "string" || !data.signedProof) {
12179
+ throw new Error("Invalid emulator submitIntent response: missing signedProof");
12180
+ }
12181
+ return data.signedProof;
12182
+ }
12183
+ async submitFinalization(intent, forfeits, connectorTree, commitmentTx) {
12184
+ const url = `${this.serverUrl}/v1/finalization`;
12185
+ const response = await fetch(url, {
12186
+ method: "POST",
12187
+ headers: { "Content-Type": "application/json" },
12188
+ // Uses "signedIntent" (not "intent") because the proof was already
12189
+ // co-signed by the emulator via submitIntent in a prior step.
12190
+ body: JSON.stringify({
12191
+ signedIntent: {
12192
+ proof: intent.proof,
12193
+ message: JSON.stringify(intent.message)
12194
+ },
12195
+ forfeits,
12196
+ connectorTree,
12197
+ commitmentTx
12198
+ })
12199
+ });
12200
+ if (!response.ok) {
12201
+ const errorText2 = await response.text();
12202
+ throw new Error(`Failed to submit finalization to emulator: ${errorText2}`);
12203
+ }
12204
+ const data = await response.json();
12205
+ if (!Array.isArray(data.signedForfeits) || !data.signedForfeits.every((item) => typeof item === "string")) {
12206
+ throw new Error(
12207
+ "Invalid emulator submitFinalization response: signedForfeits must be an array of strings"
12208
+ );
12209
+ }
12210
+ if ("signedCommitmentTx" in data && typeof data.signedCommitmentTx !== "string") {
12211
+ throw new Error(
12212
+ "Invalid emulator submitFinalization response: invalid signedCommitmentTx"
12213
+ );
12214
+ }
12215
+ return {
12216
+ signedForfeits: data.signedForfeits,
12217
+ signedCommitmentTx: data.signedCommitmentTx
12218
+ };
12219
+ }
12220
+ async submitOnchainTx(tx) {
12221
+ const url = `${this.serverUrl}/v1/onchain-tx`;
12222
+ const response = await fetch(url, {
12223
+ method: "POST",
12224
+ headers: { "Content-Type": "application/json" },
12225
+ body: JSON.stringify({ tx })
12226
+ });
12227
+ if (!response.ok) {
12228
+ const errorText2 = await response.text();
12229
+ throw new Error(`Failed to submit onchain tx to emulator: ${errorText2}`);
12230
+ }
12231
+ const data = await response.json();
12232
+ if (typeof data.signedTx !== "string" || !data.signedTx) {
12233
+ throw new Error("Invalid emulator submitOnchainTx response: missing signedTx");
12234
+ }
12235
+ return { signedTx: data.signedTx };
12236
+ }
12237
+ };
12238
+
12239
+ // src/arkade/service.ts
12240
+ function arkadeServiceUrl(service) {
12241
+ return "operatorUrl" in service ? service.operatorUrl : chunkFGKBQH5S_cjs.DEFAULT_ARKADE_SERVER_URL;
12242
+ }
12243
+ async function resolveArkadeService(service, opts = {}) {
12244
+ const operatorUrl = arkadeServiceUrl(service);
12245
+ const arkProvider = opts.arkProvider ?? new chunkFGKBQH5S_cjs.RestArkProvider(operatorUrl);
12246
+ const info = opts.info ?? await arkProvider.getInfo();
12247
+ if ("network" in service && service.network !== info.network) {
12248
+ throw new Error(
12249
+ `Arkade service network mismatch: requested '${service.network}' but the operator at ${operatorUrl} reports '${info.network}'`
12250
+ );
12251
+ }
12252
+ const esploraUrl = ESPLORA_URL[info.network];
12253
+ if (!esploraUrl) {
12254
+ throw new Error(`Arkade service: no default esplora URL for network '${info.network}'`);
12255
+ }
12256
+ let emulator;
12257
+ if ("network" in service) {
12258
+ emulator = new RestEmulatorProvider(chunkFGKBQH5S_cjs.DEFAULT_ARKADE_EMULATOR_URL);
12259
+ } else if (service.emulatorUrl) {
12260
+ emulator = new RestEmulatorProvider(service.emulatorUrl);
12261
+ }
12262
+ return {
12263
+ arkProvider,
12264
+ indexerProvider: new chunk6BJJ47JM_cjs.RestIndexerProvider(operatorUrl),
12265
+ onchainProvider: new EsploraProvider(esploraUrl),
12266
+ emulator,
12267
+ info
12268
+ };
12269
+ }
12034
12270
  var HD_SETTINGS_KEY = "hd";
12035
12271
  var HARDENED_INDEX_OFFSET = 2147483648;
12036
12272
  var HDDescriptorProvider = class _HDDescriptorProvider {
@@ -12109,7 +12345,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
12109
12345
  */
12110
12346
  materializeDescriptorAt(index) {
12111
12347
  const descriptor = this.identity.descriptor;
12112
- const network = chunkCFOIHLON_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
12348
+ const network = chunkYFQOJTG3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
12113
12349
  const expansion = descriptorsScure.expand({ descriptor, network, index });
12114
12350
  const keyInfo = expansion.expansionMap?.["@0"];
12115
12351
  if (!keyInfo?.keyExpression) {
@@ -12177,7 +12413,7 @@ function signingDescriptorIndex(descriptor) {
12177
12413
  }
12178
12414
  function newestWalletReceiveContract(contracts, serverPubKeyHex) {
12179
12415
  return contracts.filter(
12180
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCFOIHLON_cjs.WALLET_RECEIVE_SOURCE
12416
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkYFQOJTG3_cjs.WALLET_RECEIVE_SOURCE
12181
12417
  ).sort((a, b) => {
12182
12418
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12183
12419
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12228,7 +12464,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12228
12464
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
12229
12465
  if (!provider) return void 0;
12230
12466
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
12231
- const expectedContractType = setup.offchainTapscript instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script ? "delegate" : "default";
12467
+ const expectedContractType = setup.offchainTapscript instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script ? "delegate" : "default";
12232
12468
  const factoryOpts = {
12233
12469
  walletRepository: setup.walletRepository,
12234
12470
  contractRepository: setup.contractRepository,
@@ -12385,7 +12621,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12385
12621
  };
12386
12622
  function deriveLeafPubkey(descriptor) {
12387
12623
  try {
12388
- return chunkCFOIHLON_cjs.deriveDescriptorLeafPubKey(descriptor);
12624
+ return chunkYFQOJTG3_cjs.deriveDescriptorLeafPubKey(descriptor);
12389
12625
  } catch (e) {
12390
12626
  throw new NonRangeableDescriptorError(
12391
12627
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -12397,7 +12633,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12397
12633
  const pubKey = deriveLeafPubkey(descriptor);
12398
12634
  const tapscript = rebuildTapscript(current, pubKey);
12399
12635
  const serverPubKey = tapscript.options.serverPubKey;
12400
- const csvTimelock2 = chunkVVFCCNU2_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12636
+ const csvTimelock2 = chunkFGKBQH5S_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12401
12637
  const base$1 = {
12402
12638
  script: base.hex.encode(tapscript.pkScript),
12403
12639
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -12405,11 +12641,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12405
12641
  // Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
12406
12642
  // it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
12407
12643
  metadata: {
12408
- ...tagSource && { source: chunkCFOIHLON_cjs.WALLET_RECEIVE_SOURCE },
12644
+ ...tagSource && { source: chunkYFQOJTG3_cjs.WALLET_RECEIVE_SOURCE },
12409
12645
  signingDescriptor: descriptor
12410
12646
  }
12411
12647
  };
12412
- const params = tapscript instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script ? {
12648
+ const params = tapscript instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script ? {
12413
12649
  ...base$1,
12414
12650
  type: "delegate",
12415
12651
  params: {
@@ -12430,10 +12666,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12430
12666
  return { tapscript, params };
12431
12667
  }
12432
12668
  function rebuildTapscript(current, pubKey) {
12433
- if (current instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script) {
12434
- return new chunkCFOIHLON_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12669
+ if (current instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script) {
12670
+ return new chunkYFQOJTG3_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12435
12671
  }
12436
- return new chunkCFOIHLON_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12672
+ return new chunkYFQOJTG3_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12437
12673
  }
12438
12674
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
12439
12675
  const candidates = await collectContracts(contractRepository, {
@@ -12492,7 +12728,7 @@ function computeOffchainBalance(vtxos, caps) {
12492
12728
  }
12493
12729
  };
12494
12730
  for (const vtxo of vtxos) {
12495
- if (chunkVVFCCNU2_cjs.isVtxoSpent(vtxo)) continue;
12731
+ if (chunkFGKBQH5S_cjs.isVtxoSpent(vtxo)) continue;
12496
12732
  addAssets(owned, vtxo);
12497
12733
  if (vtxo.isUnrolled) {
12498
12734
  unrolled += vtxo.value;
@@ -12502,11 +12738,11 @@ function computeOffchainBalance(vtxos, caps) {
12502
12738
  pendingRecovery += vtxo.value;
12503
12739
  continue;
12504
12740
  }
12505
- if (chunkVVFCCNU2_cjs.canRecoverOnchain(vtxo, now)) {
12741
+ if (chunkFGKBQH5S_cjs.canRecoverOnchain(vtxo, now)) {
12506
12742
  recoverable += vtxo.value;
12507
12743
  continue;
12508
12744
  }
12509
- if (!chunkVVFCCNU2_cjs.canSpendOffchain(vtxo, now)) continue;
12745
+ if (!chunkFGKBQH5S_cjs.canSpendOffchain(vtxo, now)) continue;
12510
12746
  if (vtxo.isPreconfirmed) {
12511
12747
  preconfirmed += vtxo.value;
12512
12748
  } else {
@@ -12721,7 +12957,7 @@ function intentProofJobs(coins) {
12721
12957
  if (coins.length === 0) return [];
12722
12958
  const coinJobs = coins.map((coin, i) => ({
12723
12959
  index: i + 1,
12724
- lookupScript: chunkVVFCCNU2_cjs.VtxoScript.decode(coin.tapTree).pkScript
12960
+ lookupScript: chunkFGKBQH5S_cjs.VtxoScript.decode(coin.tapTree).pkScript
12725
12961
  }));
12726
12962
  return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
12727
12963
  }
@@ -12740,6 +12976,20 @@ function extractArkProviderUrl(provider) {
12740
12976
  const serverUrl = provider.serverUrl;
12741
12977
  return typeof serverUrl === "string" && serverUrl.length > 0 ? serverUrl : void 0;
12742
12978
  }
12979
+ function normalizeWalletConfigSpellings(config) {
12980
+ if (config.mode !== void 0 && config.walletMode !== void 0) {
12981
+ throw new Error("Pass either `mode` or `walletMode`, not both");
12982
+ }
12983
+ if (config.settlement !== void 0 && config.settlementConfig !== void 0) {
12984
+ throw new Error("Pass either `settlement` or `settlementConfig`, not both");
12985
+ }
12986
+ const { mode, settlement, ...rest } = config;
12987
+ return {
12988
+ ...rest,
12989
+ ...mode !== void 0 ? { walletMode: mode } : {},
12990
+ ...settlement !== void 0 ? { settlementConfig: settlement } : {}
12991
+ };
12992
+ }
12743
12993
  var DEFAULT_LOOK_AHEAD_WINDOW = 20;
12744
12994
  var MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD = 1e3;
12745
12995
  var MAINNET_UNILATERAL_EXIT_DELAY = 605184n;
@@ -12747,7 +12997,7 @@ function dedupeTimelocks(timelocks) {
12747
12997
  const seen = /* @__PURE__ */ new Set();
12748
12998
  const deduped = [];
12749
12999
  for (const timelock of timelocks) {
12750
- const sequence = chunkVVFCCNU2_cjs.timelockToSequence(timelock).toString();
13000
+ const sequence = chunkFGKBQH5S_cjs.timelockToSequence(timelock).toString();
12751
13001
  if (seen.has(sequence)) continue;
12752
13002
  seen.add(sequence);
12753
13003
  deduped.push(timelock);
@@ -12763,7 +13013,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12763
13013
  if (!newest?.params.pubKey) return baseline;
12764
13014
  try {
12765
13015
  const pubKey = base.hex.decode(newest.params.pubKey);
12766
- return new chunkCFOIHLON_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
13016
+ return new chunkYFQOJTG3_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12767
13017
  } catch (e) {
12768
13018
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
12769
13019
  return baseline;
@@ -12795,21 +13045,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
12795
13045
  if (vtxo.isUnrolled) {
12796
13046
  return !!f.withUnrolled;
12797
13047
  }
12798
- if (chunkVVFCCNU2_cjs.isVtxoSpent(vtxo)) {
13048
+ if (chunkFGKBQH5S_cjs.isVtxoSpent(vtxo)) {
12799
13049
  return false;
12800
13050
  }
12801
- if (!f.withRecoverable && chunkVVFCCNU2_cjs.canRecoverOnchain(vtxo, now)) {
13051
+ if (!f.withRecoverable && chunkFGKBQH5S_cjs.canRecoverOnchain(vtxo, now)) {
12802
13052
  return false;
12803
13053
  }
12804
13054
  return true;
12805
13055
  });
12806
13056
  }
12807
13057
  async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
12808
- const candidates = inputs.filter(chunkVVFCCNU2_cjs.isVirtualCoin).map(chunkVVFCCNU2_cjs.normalizeVtxo).filter((v) => !v.isSwept);
13058
+ const candidates = inputs.filter(chunkFGKBQH5S_cjs.isVirtualCoin).map(chunkFGKBQH5S_cjs.normalizeVtxo).filter((v) => !v.isSwept);
12809
13059
  if (candidates.length === 0) return inputs;
12810
- const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkVVFCCNU2_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
13060
+ const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkFGKBQH5S_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
12811
13061
  const suspects = candidates.filter(
12812
- (v) => chunkVVFCCNU2_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
13062
+ (v) => chunkFGKBQH5S_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
12813
13063
  );
12814
13064
  if (suspects.length === 0) return inputs;
12815
13065
  let sweptNow;
@@ -12823,12 +13073,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
12823
13073
  );
12824
13074
  } catch (e) {
12825
13075
  const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
12826
- throw chunkVVFCCNU2_cjs.isRetryableProviderError(e) ? new chunkVVFCCNU2_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
13076
+ throw chunkFGKBQH5S_cjs.isRetryableProviderError(e) ? new chunkFGKBQH5S_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
12827
13077
  }
12828
13078
  if (sweptNow.size === 0) return inputs;
12829
13079
  return inputs.map((input) => {
12830
- if (!chunkVVFCCNU2_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
12831
- return { ...chunkVVFCCNU2_cjs.normalizeVtxo(input), isSwept: true };
13080
+ if (!chunkFGKBQH5S_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
13081
+ return { ...chunkFGKBQH5S_cjs.normalizeVtxo(input), isSwept: true };
12832
13082
  });
12833
13083
  }
12834
13084
  var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
@@ -13117,7 +13367,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13117
13367
  async getArkadeReader() {
13118
13368
  const indexer = this.indexerProvider;
13119
13369
  return {
13120
- getVtxos: (opts) => chunkVVFCCNU2_cjs.getNormalizedVtxos(indexer, opts),
13370
+ getVtxos: (opts) => chunkFGKBQH5S_cjs.getNormalizedVtxos(indexer, opts),
13121
13371
  getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
13122
13372
  };
13123
13373
  }
@@ -13152,16 +13402,21 @@ var ReadonlyWallet = class _ReadonlyWallet {
13152
13402
  }
13153
13403
  /** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
13154
13404
  static async setupWalletConfig(config, pubKey) {
13155
- const arkProvider = config.arkProvider || new chunkVVFCCNU2_cjs.RestArkProvider();
13405
+ if (config.service && (config.arkProvider || config.indexerProvider || config.onchainProvider)) {
13406
+ throw new Error(
13407
+ "Pass either `service` or `arkProvider`/`indexerProvider`/`onchainProvider`, not both"
13408
+ );
13409
+ }
13410
+ const arkProvider = config.arkProvider || new chunkFGKBQH5S_cjs.RestArkProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
13156
13411
  let indexerProvider = config.indexerProvider;
13157
- if (!indexerProvider) {
13412
+ if (!indexerProvider && !config.service) {
13158
13413
  const derived = extractArkProviderUrl(arkProvider);
13159
13414
  if (!derived && config.arkProvider) {
13160
13415
  throw new Error(
13161
13416
  "indexerProvider is required when arkProvider is provided without a discoverable serverUrl"
13162
13417
  );
13163
13418
  }
13164
- indexerProvider = new chunkFEBAG2K2_cjs.RestIndexerProvider(derived ?? chunkVVFCCNU2_cjs.DEFAULT_ARKADE_SERVER_URL);
13419
+ indexerProvider = new chunk6BJJ47JM_cjs.RestIndexerProvider(derived ?? chunkFGKBQH5S_cjs.DEFAULT_ARKADE_SERVER_URL);
13165
13420
  }
13166
13421
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
13167
13422
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
@@ -13170,7 +13425,12 @@ var ReadonlyWallet = class _ReadonlyWallet {
13170
13425
  source: serverInfoSource,
13171
13426
  lastOnlineAt: serverInfoLastOnlineAt
13172
13427
  } = await resolveArkInfo(arkProvider, walletRepository);
13173
- const network = chunkVVFCCNU2_cjs.networkFromArkadeInfo(info);
13428
+ const resolvedService = config.service ? await resolveArkadeService(config.service, { arkProvider, info }) : void 0;
13429
+ if (!indexerProvider) {
13430
+ if (!resolvedService) throw new Error("indexerProvider is unresolved");
13431
+ indexerProvider = resolvedService.indexerProvider;
13432
+ }
13433
+ const network = chunkFGKBQH5S_cjs.networkFromArkadeInfo(info);
13174
13434
  if ("descriptor" in config.identity) {
13175
13435
  const descriptor = config.identity.descriptor;
13176
13436
  const identityIsMainnet = !descriptor.includes("tpub");
@@ -13186,7 +13446,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13186
13446
  );
13187
13447
  }
13188
13448
  }
13189
- const onchainProvider = config.onchainProvider || new EsploraProvider(ESPLORA_URL[info.network]);
13449
+ const onchainProvider = typeof config.onchainProvider === "function" ? config.onchainProvider(info.network) : config.onchainProvider || resolvedService?.onchainProvider || new EsploraProvider(ESPLORA_URL[info.network]);
13190
13450
  if (config.exitTimelock) {
13191
13451
  const { value, type } = config.exitTimelock;
13192
13452
  if (value < 512n && type !== "blocks" || value >= 512n && type !== "seconds") {
@@ -13206,18 +13466,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
13206
13466
  }
13207
13467
  }
13208
13468
  const boardingTimelock = config.boardingTimelock ?? toTimelock(info.boardingExitDelay);
13209
- const serverPubKey = chunkCFOIHLON_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
13210
- const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkCFOIHLON_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
13469
+ const serverPubKey = chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
13470
+ const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
13211
13471
  const offchainOptions = {
13212
13472
  pubKey,
13213
13473
  serverPubKey,
13214
13474
  csvTimelock: exitTimelock
13215
13475
  };
13216
- const offchainTapscript = !delegatePubKey ? new chunkCFOIHLON_cjs.DefaultVtxo.Script(offchainOptions) : new chunkCFOIHLON_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
13217
- const boardingTapscript = chunkCFOIHLON_cjs.BoardingContractHandler.createScript({
13476
+ const offchainTapscript = !delegatePubKey ? new chunkYFQOJTG3_cjs.DefaultVtxo.Script(offchainOptions) : new chunkYFQOJTG3_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
13477
+ const boardingTapscript = chunkYFQOJTG3_cjs.BoardingContractHandler.createScript({
13218
13478
  pubKey: base.hex.encode(pubKey),
13219
13479
  serverPubKey: base.hex.encode(serverPubKey),
13220
- csvTimelock: chunkVVFCCNU2_cjs.timelockToSequence(boardingTimelock).toString()
13480
+ csvTimelock: chunkFGKBQH5S_cjs.timelockToSequence(boardingTimelock).toString()
13221
13481
  });
13222
13482
  return {
13223
13483
  arkProvider,
@@ -13383,7 +13643,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13383
13643
  if (!filter?.withUnrolled) {
13384
13644
  logExcludedVtxos(
13385
13645
  "getSpendableVtxos",
13386
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkVVFCCNU2_cjs.isVtxoSpent(vtxo)),
13646
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkFGKBQH5S_cjs.isVtxoSpent(vtxo)),
13387
13647
  [() => UNROLLED_REASON]
13388
13648
  );
13389
13649
  }
@@ -13526,7 +13786,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13526
13786
  this.getBoardingTxs()
13527
13787
  ]);
13528
13788
  const allVtxos = snapshot.flatMap((_) => _.vtxos);
13529
- const resolveTxCreatedAt = (txids) => chunkVVFCCNU2_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13789
+ const resolveTxCreatedAt = (txids) => chunkFGKBQH5S_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13530
13790
  return buildTransactionHistory(
13531
13791
  allVtxos,
13532
13792
  boardingTxs,
@@ -13680,9 +13940,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13680
13940
  async getBoardingTapscripts(allowedSigners) {
13681
13941
  const byScript = /* @__PURE__ */ new Map();
13682
13942
  const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
13683
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkCFOIHLON_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13943
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkYFQOJTG3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13684
13944
  add(
13685
- new chunkCFOIHLON_cjs.DefaultVtxo.Script({
13945
+ new chunkYFQOJTG3_cjs.DefaultVtxo.Script({
13686
13946
  pubKey: await this.identity.xOnlyPublicKey(),
13687
13947
  serverPubKey: this.boardingTapscript.options.serverPubKey,
13688
13948
  csvTimelock: boardingCsv
@@ -13697,7 +13957,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13697
13957
  for (const c of boardingContracts) {
13698
13958
  if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
13699
13959
  try {
13700
- add(chunkCFOIHLON_cjs.BoardingContractHandler.createScript(c.params));
13960
+ add(chunkYFQOJTG3_cjs.BoardingContractHandler.createScript(c.params));
13701
13961
  } catch (e) {
13702
13962
  console.warn("Skipping malformed boarding contract", c.script, e);
13703
13963
  }
@@ -13726,7 +13986,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13726
13986
  // Per-row CSV delay decoded from THIS tapscript's exit leaf —
13727
13987
  // not the wallet's current boarding timelock, which a signer
13728
13988
  // rotation may have changed.
13729
- csvTimelock: chunkVVFCCNU2_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13989
+ csvTimelock: chunkFGKBQH5S_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13730
13990
  coins: utxos
13731
13991
  };
13732
13992
  })
@@ -13882,7 +14142,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13882
14142
  /** Fetch Arkade transaction ids that are still pending final settlement. */
13883
14143
  async fetchPendingTxs() {
13884
14144
  const scripts = await this.getWalletScripts();
13885
- const vtxos = await chunkVVFCCNU2_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
14145
+ const vtxos = await chunkFGKBQH5S_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13886
14146
  return vtxos.filter(
13887
14147
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
13888
14148
  ).map((_) => _.arkTxId);
@@ -13913,7 +14173,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13913
14173
  });
13914
14174
  for (const contract of contracts) {
13915
14175
  if (map.has(contract.script)) continue;
13916
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
14176
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
13917
14177
  if (handler) {
13918
14178
  const script = handler.createScript(contract.params);
13919
14179
  map.set(contract.script, script);
@@ -14025,7 +14285,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14025
14285
  }
14026
14286
  });
14027
14287
  const baselinePubkey = await this.identity.xOnlyPublicKey();
14028
- const delegatePubKey = this.offchainTapscript instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14288
+ const delegatePubKey = this.offchainTapscript instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14029
14289
  const baselineSigners = [
14030
14290
  this.offchainTapscript.options.serverPubKey,
14031
14291
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
@@ -14033,8 +14293,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
14033
14293
  const seenBaselineScripts = /* @__PURE__ */ new Set();
14034
14294
  for (const serverPubKey of baselineSigners) {
14035
14295
  for (const csvTimelock2 of this.walletContractTimelocks) {
14036
- const csvTimelockStr = chunkVVFCCNU2_cjs.timelockToSequence(csvTimelock2).toString();
14037
- const defaultScript = new chunkCFOIHLON_cjs.DefaultVtxo.Script({
14296
+ const csvTimelockStr = chunkFGKBQH5S_cjs.timelockToSequence(csvTimelock2).toString();
14297
+ const defaultScript = new chunkYFQOJTG3_cjs.DefaultVtxo.Script({
14038
14298
  pubKey: baselinePubkey,
14039
14299
  serverPubKey,
14040
14300
  csvTimelock: csvTimelock2
@@ -14055,7 +14315,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14055
14315
  });
14056
14316
  }
14057
14317
  if (delegatePubKey) {
14058
- const delegateScript = new chunkCFOIHLON_cjs.DelegateVtxo.Script({
14318
+ const delegateScript = new chunkYFQOJTG3_cjs.DelegateVtxo.Script({
14059
14319
  pubKey: baselinePubkey,
14060
14320
  serverPubKey,
14061
14321
  delegatePubKey,
@@ -14079,9 +14339,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
14079
14339
  }
14080
14340
  }
14081
14341
  }
14082
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkCFOIHLON_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14342
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkYFQOJTG3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14083
14343
  for (const serverPubKey of baselineSigners) {
14084
- const baselineBoarding = new chunkCFOIHLON_cjs.DefaultVtxo.Script({
14344
+ const baselineBoarding = new chunkYFQOJTG3_cjs.DefaultVtxo.Script({
14085
14345
  pubKey: baselinePubkey,
14086
14346
  serverPubKey,
14087
14347
  csvTimelock: boardingCsvTimelock
@@ -14094,7 +14354,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14094
14354
  params: {
14095
14355
  pubKey: base.hex.encode(baselineBoarding.options.pubKey),
14096
14356
  serverPubKey: base.hex.encode(serverPubKey),
14097
- csvTimelock: chunkVVFCCNU2_cjs.timelockToSequence(boardingCsvTimelock).toString()
14357
+ csvTimelock: chunkFGKBQH5S_cjs.timelockToSequence(boardingCsvTimelock).toString()
14098
14358
  },
14099
14359
  script: boardingScriptHex,
14100
14360
  address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
@@ -14281,7 +14541,7 @@ var Wallet2 = class extends ReadonlyWallet {
14281
14541
  serverPubKey: this.offchainTapscript.options.serverPubKey,
14282
14542
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
14283
14543
  csvTimelocks: this.walletContractTimelocks,
14284
- delegatePubKey: this.offchainTapscript instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14544
+ delegatePubKey: this.offchainTapscript instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14285
14545
  };
14286
14546
  }
14287
14547
  _signerRouter;
@@ -14441,7 +14701,7 @@ var Wallet2 = class extends ReadonlyWallet {
14441
14701
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
14442
14702
  const persisted = row?.metadata?.signingDescriptor;
14443
14703
  if (typeof persisted === "string") return persisted;
14444
- return chunkCFOIHLON_cjs.identityDescriptor(this.identity);
14704
+ return chunkYFQOJTG3_cjs.identityDescriptor(this.identity);
14445
14705
  }
14446
14706
  /**
14447
14707
  * Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
@@ -14451,7 +14711,7 @@ var Wallet2 = class extends ReadonlyWallet {
14451
14711
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
14452
14712
  if (type === "boarding") {
14453
14713
  const built2 = this.buildBoardingContract(
14454
- chunkCFOIHLON_cjs.deriveDescriptorLeafPubKey(descriptor),
14714
+ chunkYFQOJTG3_cjs.deriveDescriptorLeafPubKey(descriptor),
14455
14715
  descriptor,
14456
14716
  tagSource
14457
14717
  );
@@ -14488,11 +14748,11 @@ var Wallet2 = class extends ReadonlyWallet {
14488
14748
  * (offchain analogue: {@link buildReceiveContract}).
14489
14749
  */
14490
14750
  buildBoardingContract(pubKey, descriptor, tagSource) {
14491
- const tapscript = new chunkCFOIHLON_cjs.DefaultVtxo.Script({
14751
+ const tapscript = new chunkYFQOJTG3_cjs.DefaultVtxo.Script({
14492
14752
  ...this._boardingTapscript.options,
14493
14753
  pubKey
14494
14754
  });
14495
- const csvTimelock2 = tapscript.options.csvTimelock ?? chunkCFOIHLON_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14755
+ const csvTimelock2 = tapscript.options.csvTimelock ?? chunkYFQOJTG3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14496
14756
  return {
14497
14757
  tapscript,
14498
14758
  params: {
@@ -14500,13 +14760,13 @@ var Wallet2 = class extends ReadonlyWallet {
14500
14760
  params: {
14501
14761
  pubKey: base.hex.encode(pubKey),
14502
14762
  serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
14503
- csvTimelock: chunkVVFCCNU2_cjs.timelockToSequence(csvTimelock2).toString()
14763
+ csvTimelock: chunkFGKBQH5S_cjs.timelockToSequence(csvTimelock2).toString()
14504
14764
  },
14505
14765
  script: base.hex.encode(tapscript.pkScript),
14506
14766
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
14507
14767
  state: "active",
14508
14768
  metadata: {
14509
- ...tagSource && { source: chunkCFOIHLON_cjs.WALLET_RECEIVE_SOURCE },
14769
+ ...tagSource && { source: chunkYFQOJTG3_cjs.WALLET_RECEIVE_SOURCE },
14510
14770
  signingDescriptor: descriptor
14511
14771
  }
14512
14772
  }
@@ -14528,7 +14788,7 @@ var Wallet2 = class extends ReadonlyWallet {
14528
14788
  if (this._hdProvider) {
14529
14789
  return (await this.getContractManager()).getNextSigningDescriptor();
14530
14790
  }
14531
- return chunkCFOIHLON_cjs.identityDescriptor(this.identity);
14791
+ return chunkYFQOJTG3_cjs.identityDescriptor(this.identity);
14532
14792
  }
14533
14793
  /**
14534
14794
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -14604,7 +14864,7 @@ var Wallet2 = class extends ReadonlyWallet {
14604
14864
  * the stable public API.
14605
14865
  */
14606
14866
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
14607
- const xonly = chunkCFOIHLON_cjs.toXOnly(newServerPubKey, "ark signer key");
14867
+ const xonly = chunkYFQOJTG3_cjs.toXOnly(newServerPubKey, "ark signer key");
14608
14868
  const newServerUnrollScript = assertValidServerUnrollScript(
14609
14869
  checkpointTapscript,
14610
14870
  resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
@@ -14633,21 +14893,21 @@ var Wallet2 = class extends ReadonlyWallet {
14633
14893
  const [currentBoardingRow] = await manager.getContracts({
14634
14894
  script: currentBoardingScript
14635
14895
  });
14636
- const newOffchain = this.offchainTapscript instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script ? new chunkCFOIHLON_cjs.DelegateVtxo.Script({
14896
+ const newOffchain = this.offchainTapscript instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script ? new chunkYFQOJTG3_cjs.DelegateVtxo.Script({
14637
14897
  ...this.offchainTapscript.options,
14638
14898
  serverPubKey: xonly
14639
- }) : new chunkCFOIHLON_cjs.DefaultVtxo.Script({
14899
+ }) : new chunkYFQOJTG3_cjs.DefaultVtxo.Script({
14640
14900
  ...this.offchainTapscript.options,
14641
14901
  serverPubKey: xonly
14642
14902
  });
14643
- const newBoarding = new chunkCFOIHLON_cjs.DefaultVtxo.Script({
14903
+ const newBoarding = new chunkYFQOJTG3_cjs.DefaultVtxo.Script({
14644
14904
  ...this._boardingTapscript.options,
14645
14905
  serverPubKey: xonly
14646
14906
  });
14647
- const offchainCsv = chunkVVFCCNU2_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14907
+ const offchainCsv = chunkFGKBQH5S_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14648
14908
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
14649
14909
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
14650
- if (newOffchain instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script) {
14910
+ if (newOffchain instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script) {
14651
14911
  await manager.createContract({
14652
14912
  type: "delegate",
14653
14913
  params: {
@@ -14675,13 +14935,13 @@ var Wallet2 = class extends ReadonlyWallet {
14675
14935
  metadata: currentOffchainRow?.metadata
14676
14936
  });
14677
14937
  }
14678
- const boardingCsv = newBoarding.options.csvTimelock ?? chunkCFOIHLON_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14938
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkYFQOJTG3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14679
14939
  await manager.createContract({
14680
14940
  type: "boarding",
14681
14941
  params: {
14682
14942
  pubKey: base.hex.encode(newBoarding.options.pubKey),
14683
14943
  serverPubKey: base.hex.encode(xonly),
14684
- csvTimelock: chunkVVFCCNU2_cjs.timelockToSequence(boardingCsv).toString()
14944
+ csvTimelock: chunkFGKBQH5S_cjs.timelockToSequence(boardingCsv).toString()
14685
14945
  },
14686
14946
  script: base.hex.encode(newBoarding.pkScript),
14687
14947
  address: newBoarding.address(this.network.hrp, xonly).encode(),
@@ -14709,14 +14969,14 @@ var Wallet2 = class extends ReadonlyWallet {
14709
14969
  _restoreInFlight;
14710
14970
  _addPendingSpends(inputs) {
14711
14971
  for (const input of inputs) {
14712
- if (chunkVVFCCNU2_cjs.isVirtualCoin(input)) {
14972
+ if (chunkFGKBQH5S_cjs.isVirtualCoin(input)) {
14713
14973
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
14714
14974
  }
14715
14975
  }
14716
14976
  }
14717
14977
  _removePendingSpends(inputs) {
14718
14978
  for (const input of inputs) {
14719
- if (chunkVVFCCNU2_cjs.isVirtualCoin(input)) {
14979
+ if (chunkFGKBQH5S_cjs.isVirtualCoin(input)) {
14720
14980
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
14721
14981
  }
14722
14982
  }
@@ -14780,7 +15040,7 @@ var Wallet2 = class extends ReadonlyWallet {
14780
15040
  if (clashing.length > 0) throw new VtxoReservedError(clashing, "in-flight");
14781
15041
  }
14782
15042
  _assertNotHeld(inputs) {
14783
- const held = coinKeys(inputs.filter(chunkVVFCCNU2_cjs.isVirtualCoin)).filter(
15043
+ const held = coinKeys(inputs.filter(chunkFGKBQH5S_cjs.isVirtualCoin)).filter(
14784
15044
  (key) => this._heldOutpoints.has(key)
14785
15045
  );
14786
15046
  if (held.length > 0) throw new VtxoReservedError(held, "held");
@@ -14818,13 +15078,13 @@ var Wallet2 = class extends ReadonlyWallet {
14818
15078
  const manager = await this.getContractManager();
14819
15079
  const provider = this._hdProvider;
14820
15080
  const hd = provider !== void 0;
14821
- const staticDescriptor = hd ? void 0 : await chunkCFOIHLON_cjs.identityDescriptor(this.identity);
15081
+ const staticDescriptor = hd ? void 0 : await chunkYFQOJTG3_cjs.identityDescriptor(this.identity);
14822
15082
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
14823
- const delegatePubKey = this.offchainTapscript instanceof chunkCFOIHLON_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
15083
+ const delegatePubKey = this.offchainTapscript instanceof chunkYFQOJTG3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14824
15084
  const arkInfo = await this.arkProvider.getInfo();
14825
- const currentSignerPubKey = chunkCFOIHLON_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
15085
+ const currentSignerPubKey = chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14826
15086
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
14827
- (s) => chunkCFOIHLON_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
15087
+ (s) => chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14828
15088
  );
14829
15089
  const deps = {
14830
15090
  indexerProvider: this.indexerProvider,
@@ -14836,7 +15096,7 @@ var Wallet2 = class extends ReadonlyWallet {
14836
15096
  deprecatedSignerPubKeys,
14837
15097
  csvTimelocks: this.walletContractTimelocks,
14838
15098
  // Boarding-exit CSV, distinct from the unilateral-exit matrix.
14839
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkCFOIHLON_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
15099
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkYFQOJTG3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14840
15100
  delegatePubKey
14841
15101
  };
14842
15102
  const result = await manager.scanContracts({
@@ -14942,6 +15202,7 @@ var Wallet2 = class extends ReadonlyWallet {
14942
15202
  }
14943
15203
  }
14944
15204
  static async create(config) {
15205
+ config = normalizeWalletConfigSpellings(config);
14945
15206
  if (config.lookAheadWindow !== void 0 && (!Number.isInteger(config.lookAheadWindow) || config.lookAheadWindow <= 0)) {
14946
15207
  throw new Error(
14947
15208
  `lookAheadWindow must be a positive integer (got ${String(config.lookAheadWindow)})`
@@ -14952,7 +15213,7 @@ var Wallet2 = class extends ReadonlyWallet {
14952
15213
  throw new Error("Invalid configured public key");
14953
15214
  }
14954
15215
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
14955
- const forfeitPubkey = chunkCFOIHLON_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
15216
+ const forfeitPubkey = chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14956
15217
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
14957
15218
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
14958
15219
  const checkpointExitDelayOverrides = {
@@ -15124,13 +15385,13 @@ var Wallet2 = class extends ReadonlyWallet {
15124
15385
  void this.logUngatedInputs("settle({ inputs })", params.inputs);
15125
15386
  }
15126
15387
  const offchainAddress = await this.getAddress();
15127
- const offchainPkScript = chunkVVFCCNU2_cjs.ArkAddress.decode(offchainAddress).pkScript;
15388
+ const offchainPkScript = chunkFGKBQH5S_cjs.ArkAddress.decode(offchainAddress).pkScript;
15128
15389
  const offchainOutputScript = base.hex.encode(offchainPkScript);
15129
15390
  if (!params) {
15130
15391
  const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
15131
15392
  const estimator = new Estimator(fees.intentFee);
15132
15393
  let amount = 0;
15133
- const exitScript = chunkVVFCCNU2_cjs.CSVMultisigTapscript.decode(
15394
+ const exitScript = chunkFGKBQH5S_cjs.CSVMultisigTapscript.decode(
15134
15395
  base.hex.decode(this.boardingTapscript.exitScript)
15135
15396
  );
15136
15397
  const boardingTimelock = exitScript.params.timelock;
@@ -15162,7 +15423,7 @@ var Wallet2 = class extends ReadonlyWallet {
15162
15423
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
15163
15424
  break;
15164
15425
  }
15165
- const inputFee = estimator.evalOffchainInput(chunkVVFCCNU2_cjs.toOffchainInputFeeParams(vtxo));
15426
+ const inputFee = estimator.evalOffchainInput(chunkFGKBQH5S_cjs.toOffchainInputFeeParams(vtxo));
15166
15427
  if (inputFee.satoshis >= vtxo.value) {
15167
15428
  continue;
15168
15429
  }
@@ -15214,7 +15475,7 @@ var Wallet2 = class extends ReadonlyWallet {
15214
15475
  let script;
15215
15476
  let arkAddress;
15216
15477
  try {
15217
- arkAddress = chunkVVFCCNU2_cjs.ArkAddress.decode(output.address);
15478
+ arkAddress = chunkFGKBQH5S_cjs.ArkAddress.decode(output.address);
15218
15479
  } catch {
15219
15480
  arkAddress = void 0;
15220
15481
  }
@@ -15286,11 +15547,11 @@ var Wallet2 = class extends ReadonlyWallet {
15286
15547
  ]);
15287
15548
  let intentTxId;
15288
15549
  try {
15289
- intentTxId = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
15550
+ intentTxId = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
15290
15551
  } catch {
15291
15552
  intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
15292
15553
  }
15293
- const settleInputVtxos = params.inputs.filter(chunkVVFCCNU2_cjs.isVirtualCoin);
15554
+ const settleInputVtxos = params.inputs.filter(chunkFGKBQH5S_cjs.isVirtualCoin);
15294
15555
  const contractManager = await this.getContractManager();
15295
15556
  await contractManager.assertAnnotatable(settleInputVtxos);
15296
15557
  await contractManager.assertSpendableNow?.(
@@ -15299,7 +15560,7 @@ var Wallet2 = class extends ReadonlyWallet {
15299
15560
  );
15300
15561
  if (picked) this._assertNotHeld(params.inputs);
15301
15562
  this._addPendingSpends(params.inputs);
15302
- const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkVVFCCNU2_cjs.isVirtualCoin(i))) : [];
15563
+ const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkFGKBQH5S_cjs.isVirtualCoin(i))) : [];
15303
15564
  for (const key of boardingKeys) this._pendingSpendOutpoints.add(key);
15304
15565
  const settlingKeys = params.inputs.map((i) => `${i.txid}:${i.vout}`);
15305
15566
  for (const key of settlingKeys) this._settlingOutpoints.add(key);
@@ -15410,7 +15671,7 @@ var Wallet2 = class extends ReadonlyWallet {
15410
15671
  async maybeRotateBoardingAfterBoard(inputs) {
15411
15672
  if (!this._descriptorProvider) return;
15412
15673
  const consumedBoarding = inputs.some(
15413
- (input) => typeof input !== "string" && !chunkVVFCCNU2_cjs.isVirtualCoin(input)
15674
+ (input) => typeof input !== "string" && !chunkFGKBQH5S_cjs.isVirtualCoin(input)
15414
15675
  );
15415
15676
  if (!consumedBoarding) return;
15416
15677
  try {
@@ -15421,7 +15682,7 @@ var Wallet2 = class extends ReadonlyWallet {
15421
15682
  }
15422
15683
  async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
15423
15684
  const signedForfeits = [];
15424
- let settlementPsbt = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
15685
+ let settlementPsbt = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
15425
15686
  assertFinalCommitmentMatchesValidated(
15426
15687
  settlementPsbt,
15427
15688
  validatedCommitmentTxid,
@@ -15434,7 +15695,7 @@ var Wallet2 = class extends ReadonlyWallet {
15434
15695
  let connectorIndex = 0;
15435
15696
  const connectorsLeaves = connectorsGraph?.leaves() || [];
15436
15697
  for (const input of inputs) {
15437
- if (!chunkVVFCCNU2_cjs.isVirtualCoin(input)) {
15698
+ if (!chunkFGKBQH5S_cjs.isVirtualCoin(input)) {
15438
15699
  let matched = false;
15439
15700
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
15440
15701
  const settlementInput = settlementPsbt.getInput(i);
@@ -15472,7 +15733,7 @@ var Wallet2 = class extends ReadonlyWallet {
15472
15733
  }
15473
15734
  continue;
15474
15735
  }
15475
- if (!chunkVVFCCNU2_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
15736
+ if (!chunkFGKBQH5S_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
15476
15737
  continue;
15477
15738
  }
15478
15739
  if (connectorsLeaves.length === 0) {
@@ -15500,7 +15761,7 @@ var Wallet2 = class extends ReadonlyWallet {
15500
15761
  index: input.vout,
15501
15762
  witnessUtxo: {
15502
15763
  amount: BigInt(input.value),
15503
- script: chunkVVFCCNU2_cjs.VtxoScript.decode(input.tapTree).pkScript
15764
+ script: chunkFGKBQH5S_cjs.VtxoScript.decode(input.tapTree).pkScript
15504
15765
  },
15505
15766
  sighashType: btcSigner.SigHash.DEFAULT,
15506
15767
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -15519,7 +15780,7 @@ var Wallet2 = class extends ReadonlyWallet {
15519
15780
  forfeitTx = await this._signerRouter.sign(forfeitTx, [
15520
15781
  {
15521
15782
  index: 0,
15522
- lookupScript: chunkVVFCCNU2_cjs.VtxoScript.decode(input.tapTree).pkScript
15783
+ lookupScript: chunkFGKBQH5S_cjs.VtxoScript.decode(input.tapTree).pkScript
15523
15784
  }
15524
15785
  ]);
15525
15786
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -15577,7 +15838,7 @@ var Wallet2 = class extends ReadonlyWallet {
15577
15838
  resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
15578
15839
  );
15579
15840
  await this.arkProvider.confirmRegistration(intentId);
15580
- const sweepTapscript = chunkVVFCCNU2_cjs.CSVMultisigTapscript.encode({
15841
+ const sweepTapscript = chunkFGKBQH5S_cjs.CSVMultisigTapscript.encode({
15581
15842
  timelock,
15582
15843
  pubkeys: [this.forfeitPubkey]
15583
15844
  }).script;
@@ -15592,14 +15853,14 @@ var Wallet2 = class extends ReadonlyWallet {
15592
15853
  throw new Error("Sweep tap tree root not set");
15593
15854
  }
15594
15855
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
15595
- (k) => base.hex.encode(chunkCFOIHLON_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15856
+ (k) => base.hex.encode(chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15596
15857
  );
15597
15858
  const signerPublicKey = await session.getPublicKey();
15598
- const xonlySignerPublicKey = chunkCFOIHLON_cjs.toXOnly(signerPublicKey, "signer key");
15859
+ const xonlySignerPublicKey = chunkYFQOJTG3_cjs.toXOnly(signerPublicKey, "signer key");
15599
15860
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
15600
15861
  return { skip: true };
15601
15862
  }
15602
- const commitmentTx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(
15863
+ const commitmentTx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(
15603
15864
  base.base64.decode(event.unsignedCommitmentTx)
15604
15865
  );
15605
15866
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
@@ -15681,9 +15942,9 @@ var Wallet2 = class extends ReadonlyWallet {
15681
15942
  ...existing ?? {},
15682
15943
  intentTxId,
15683
15944
  registerProof: intent.proof,
15684
- registerProofMessage: chunkVVFCCNU2_cjs.Intent.encodeMessage(intent.message),
15945
+ registerProofMessage: chunkFGKBQH5S_cjs.Intent.encodeMessage(intent.message),
15685
15946
  deleteProof: deleteIntent.proof,
15686
- deleteProofMessage: chunkVVFCCNU2_cjs.Intent.encodeMessage(deleteIntent.message),
15947
+ deleteProofMessage: chunkFGKBQH5S_cjs.Intent.encodeMessage(deleteIntent.message),
15687
15948
  intentVtxos: inputs.map((i) => ({
15688
15949
  txid: i.txid,
15689
15950
  vout: i.vout
@@ -15716,7 +15977,7 @@ var Wallet2 = class extends ReadonlyWallet {
15716
15977
  try {
15717
15978
  return await this.arkProvider.registerIntent(intent);
15718
15979
  } catch (error) {
15719
- if (error instanceof chunkVVFCCNU2_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15980
+ if (error instanceof chunkFGKBQH5S_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15720
15981
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
15721
15982
  await this.arkProvider.deleteIntent(deleteIntent);
15722
15983
  return this.arkProvider.registerIntent(intent);
@@ -15732,7 +15993,7 @@ var Wallet2 = class extends ReadonlyWallet {
15732
15993
  expire_at: 0,
15733
15994
  cosigners_public_keys: cosignerPubKeys
15734
15995
  };
15735
- const proof = chunkVVFCCNU2_cjs.Intent.create(message, coins, outputs);
15996
+ const proof = chunkFGKBQH5S_cjs.Intent.create(message, coins, outputs);
15736
15997
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15737
15998
  return {
15738
15999
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15744,7 +16005,7 @@ var Wallet2 = class extends ReadonlyWallet {
15744
16005
  type: "delete",
15745
16006
  expire_at: 0
15746
16007
  };
15747
- const proof = chunkVVFCCNU2_cjs.Intent.create(message, coins, []);
16008
+ const proof = chunkFGKBQH5S_cjs.Intent.create(message, coins, []);
15748
16009
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15749
16010
  return {
15750
16011
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15756,7 +16017,7 @@ var Wallet2 = class extends ReadonlyWallet {
15756
16017
  type: "get-pending-tx",
15757
16018
  expire_at: 0
15758
16019
  };
15759
- const proof = chunkVVFCCNU2_cjs.Intent.create(message, coins, []);
16020
+ const proof = chunkFGKBQH5S_cjs.Intent.create(message, coins, []);
15760
16021
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15761
16022
  return {
15762
16023
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15777,7 +16038,7 @@ var Wallet2 = class extends ReadonlyWallet {
15777
16038
  if (!vtxos || vtxos.length === 0) {
15778
16039
  const scriptMap = await this.getScriptMap();
15779
16040
  const allExtended = [];
15780
- const fetchedVtxos = await chunkVVFCCNU2_cjs.getAllNormalizedVtxos(this.indexerProvider, [
16041
+ const fetchedVtxos = await chunkFGKBQH5S_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15781
16042
  ...scriptMap.keys()
15782
16043
  ]);
15783
16044
  for (const vtxo of fetchedVtxos) {
@@ -15820,8 +16081,8 @@ var Wallet2 = class extends ReadonlyWallet {
15820
16081
  batchPending.push(pendingTx.arkTxid);
15821
16082
  try {
15822
16083
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
15823
- const tx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(c));
15824
- chunkVVFCCNU2_cjs.assertAllowedSighashTypes(tx);
16084
+ const tx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(c));
16085
+ chunkFGKBQH5S_cjs.assertAllowedSighashTypes(tx);
15825
16086
  return tx;
15826
16087
  });
15827
16088
  assertCheckpointsMatchInputs(
@@ -15890,11 +16151,11 @@ var Wallet2 = class extends ReadonlyWallet {
15890
16151
  * and one per deprecated signer — else a pre-rotation tx would stay pending forever.
15891
16152
  */
15892
16153
  checkpointUnrollCandidates(info) {
15893
- const current = chunkVVFCCNU2_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
16154
+ const current = chunkFGKBQH5S_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15894
16155
  const candidates = [this._serverUnrollScript, current];
15895
16156
  for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
15896
16157
  candidates.push(
15897
- chunkVVFCCNU2_cjs.CSVMultisigTapscript.encode({
16158
+ chunkFGKBQH5S_cjs.CSVMultisigTapscript.encode({
15898
16159
  ...current.params,
15899
16160
  pubkeys: [base.hex.decode(deprecated)]
15900
16161
  })
@@ -15989,7 +16250,7 @@ var Wallet2 = class extends ReadonlyWallet {
15989
16250
  if (vtxos.length === 0) {
15990
16251
  throw new Error("No VTXOs found for this arkadeCash");
15991
16252
  }
15992
- const myPkScript = chunkVVFCCNU2_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
16253
+ const myPkScript = chunkFGKBQH5S_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
15993
16254
  let { spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos);
15994
16255
  let swept = 0;
15995
16256
  const drainable = vtxos.filter(
@@ -16115,7 +16376,7 @@ var Wallet2 = class extends ReadonlyWallet {
16115
16376
  params: {
16116
16377
  pubKey: base.hex.encode(cash.publicKey),
16117
16378
  serverPubKey: base.hex.encode(cash.serverPubKey),
16118
- csvTimelock: chunkVVFCCNU2_cjs.timelockToSequence(cash.csvTimelock).toString()
16379
+ csvTimelock: chunkFGKBQH5S_cjs.timelockToSequence(cash.csvTimelock).toString()
16119
16380
  },
16120
16381
  script: base.hex.encode(cashScript.pkScript),
16121
16382
  address: cashAddress.encode(),
@@ -16196,7 +16457,7 @@ var Wallet2 = class extends ReadonlyWallet {
16196
16457
  const recoverable = [];
16197
16458
  const unclaimed = [];
16198
16459
  for (const vtxo of vtxos) {
16199
- if (chunkVVFCCNU2_cjs.isVtxoSpent(vtxo)) {
16460
+ if (chunkFGKBQH5S_cjs.isVtxoSpent(vtxo)) {
16200
16461
  unclaimed.push(cashReport(vtxo, "already-spent"));
16201
16462
  } else if (vtxo.isUnrolled) {
16202
16463
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -16218,7 +16479,7 @@ var Wallet2 = class extends ReadonlyWallet {
16218
16479
  const all = [];
16219
16480
  const seen = /* @__PURE__ */ new Set();
16220
16481
  for (let pageIndex = 0; ; pageIndex++) {
16221
- const { vtxos, page } = await chunkVVFCCNU2_cjs.getNormalizedVtxos(this.indexerProvider, {
16482
+ const { vtxos, page } = await chunkFGKBQH5S_cjs.getNormalizedVtxos(this.indexerProvider, {
16222
16483
  scripts,
16223
16484
  pageIndex,
16224
16485
  pageSize
@@ -16256,7 +16517,7 @@ var Wallet2 = class extends ReadonlyWallet {
16256
16517
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
16257
16518
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
16258
16519
  const message = { type: "get-pending-tx", expire_at: 0 };
16259
- const proof = chunkVVFCCNU2_cjs.Intent.create(message, batch, []);
16520
+ const proof = chunkFGKBQH5S_cjs.Intent.create(message, batch, []);
16260
16521
  const signedProof = await identity.sign(
16261
16522
  proof,
16262
16523
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -16277,8 +16538,8 @@ var Wallet2 = class extends ReadonlyWallet {
16277
16538
  for (const pendingTx of pendingTxs) {
16278
16539
  try {
16279
16540
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
16280
- const tx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
16281
- chunkVVFCCNU2_cjs.assertAllowedSighashTypes(tx);
16541
+ const tx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
16542
+ chunkFGKBQH5S_cjs.assertAllowedSighashTypes(tx);
16282
16543
  return tx;
16283
16544
  });
16284
16545
  assertCheckpointsMatchInputs(
@@ -16318,7 +16579,7 @@ var Wallet2 = class extends ReadonlyWallet {
16318
16579
  }
16319
16580
  /** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
16320
16581
  arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
16321
- const arkTx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
16582
+ const arkTx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
16322
16583
  let total = 0;
16323
16584
  for (let i = 0; i < arkTx.outputsLength; i++) {
16324
16585
  const output = arkTx.getOutput(i);
@@ -16377,7 +16638,7 @@ var Wallet2 = class extends ReadonlyWallet {
16377
16638
  throw new Error("send({ maxChangeFee }): expected a non-negative safe integer");
16378
16639
  }
16379
16640
  if (selectedVtxos) {
16380
- if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo);
16641
+ if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo);
16381
16642
  if (inputExpiryFloor && selectedVtxos.some((coin) => !meetsInputExpiryFloor(coin, inputExpiryFloor))) {
16382
16643
  throw new Error("send({ selectedVtxos }): input expiry floor not met");
16383
16644
  }
@@ -16512,7 +16773,7 @@ var Wallet2 = class extends ReadonlyWallet {
16512
16773
  script: recipient.script,
16513
16774
  amount: BigInt(recipient.amount),
16514
16775
  // Already checked against the recipient address in `validateRecipients`.
16515
- ...recipient.tapTree ? { tapTree: chunkVVFCCNU2_cjs.toBIP371TapTree(recipient.tapTree) } : {}
16776
+ ...recipient.tapTree ? { tapTree: chunkFGKBQH5S_cjs.toBIP371TapTree(recipient.tapTree) } : {}
16516
16777
  }));
16517
16778
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
16518
16779
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -16704,10 +16965,10 @@ var Wallet2 = class extends ReadonlyWallet {
16704
16965
  const serverPubKey = this.arkServerPublicKey;
16705
16966
  const serverUnrollScript = this.serverUnrollScript;
16706
16967
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
16707
- const normalizedInputs = inputs.map(chunkVVFCCNU2_cjs.normalizeVtxo);
16708
- const at = now ?? await chunkVVFCCNU2_cjs.resolveTimeHeight(this.onchainProvider);
16968
+ const normalizedInputs = inputs.map(chunkFGKBQH5S_cjs.normalizeVtxo);
16969
+ const at = now ?? await chunkFGKBQH5S_cjs.resolveTimeHeight(this.onchainProvider);
16709
16970
  for (const input of normalizedInputs) {
16710
- if (!chunkVVFCCNU2_cjs.canSpendOffchain(input, at)) {
16971
+ if (!chunkFGKBQH5S_cjs.canSpendOffchain(input, at)) {
16711
16972
  throw new Error(
16712
16973
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
16713
16974
  );
@@ -16791,7 +17052,7 @@ var Wallet2 = class extends ReadonlyWallet {
16791
17052
  );
16792
17053
  const arkTxJobs = inputs.map((input, index) => ({
16793
17054
  index,
16794
- lookupScript: chunkVVFCCNU2_cjs.VtxoScript.decode(input.tapTree).pkScript
17055
+ lookupScript: chunkFGKBQH5S_cjs.VtxoScript.decode(input.tapTree).pkScript
16795
17056
  }));
16796
17057
  const identity = this.identity;
16797
17058
  const signer = {
@@ -16900,7 +17161,7 @@ var Wallet2 = class extends ReadonlyWallet {
16900
17161
  }
16901
17162
  const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
16902
17163
  for (const encoded of signedCheckpointTxs) {
16903
- const checkpoint = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
17164
+ const checkpoint = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
16904
17165
  for (let i = 0; i < checkpoint.inputsLength; i++) {
16905
17166
  const input = checkpoint.getInput(i);
16906
17167
  if (!input.txid) continue;
@@ -17016,12 +17277,12 @@ var Wallet2 = class extends ReadonlyWallet {
17016
17277
  const spentVtxos = [];
17017
17278
  const inputArkTxIds = /* @__PURE__ */ new Set();
17018
17279
  const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
17019
- const vtxoInputs = inputs.filter(chunkVVFCCNU2_cjs.isVirtualCoin);
17280
+ const vtxoInputs = inputs.filter(chunkFGKBQH5S_cjs.isVirtualCoin);
17020
17281
  const cm = await this.getContractManager();
17021
17282
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
17022
17283
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
17023
17284
  for (const input of inputs) {
17024
- if (chunkVVFCCNU2_cjs.isVirtualCoin(input)) {
17285
+ if (chunkFGKBQH5S_cjs.isVirtualCoin(input)) {
17025
17286
  const outpoint = `${input.txid}:${input.vout}`;
17026
17287
  const vtxo = annotatedByKey.get(outpoint);
17027
17288
  if (!vtxo) {
@@ -17038,7 +17299,7 @@ var Wallet2 = class extends ReadonlyWallet {
17038
17299
  } else {
17039
17300
  let sourceAddress;
17040
17301
  try {
17041
- sourceAddress = chunkVVFCCNU2_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
17302
+ sourceAddress = chunkFGKBQH5S_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
17042
17303
  this.network
17043
17304
  );
17044
17305
  } catch {
@@ -17110,7 +17371,7 @@ function bySelectionOrder(a, b) {
17110
17371
  return b.value - a.value;
17111
17372
  }
17112
17373
  function selectVirtualCoins(coins, targetAmount) {
17113
- const sortedCoins = coins.map(chunkVVFCCNU2_cjs.normalizeVtxo).sort(bySelectionOrder);
17374
+ const sortedCoins = coins.map(chunkFGKBQH5S_cjs.normalizeVtxo).sort(bySelectionOrder);
17114
17375
  const selectedCoins = [];
17115
17376
  let selectedAmount = 0;
17116
17377
  for (const coin of sortedCoins) {
@@ -17227,7 +17488,7 @@ function assertTimeoutMap(name, timeouts) {
17227
17488
  if (value === void 0) {
17228
17489
  throw new Error(`${name}.${key} must be a non-negative safe integer`);
17229
17490
  }
17230
- chunkVVFCCNU2_cjs.assertTimerMs(`${name}.${key}`, value);
17491
+ chunkFGKBQH5S_cjs.assertTimerMs(`${name}.${key}`, value);
17231
17492
  }
17232
17493
  }
17233
17494
  var MessageBus = class {
@@ -17238,15 +17499,17 @@ var MessageBus = class {
17238
17499
  messageTimeoutMs = 3e4,
17239
17500
  messageTimeoutOverrides = {},
17240
17501
  intentRepository,
17502
+ onchainProvider,
17241
17503
  debug = false,
17242
17504
  buildServices
17243
17505
  }) {
17244
17506
  this.walletRepository = walletRepository;
17245
17507
  this.contractRepository = contractRepository;
17246
- chunkVVFCCNU2_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
17247
- chunkVVFCCNU2_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
17508
+ chunkFGKBQH5S_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
17509
+ chunkFGKBQH5S_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
17248
17510
  assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
17249
17511
  this.intentRepository = intentRepository;
17512
+ this.onchainProvider = onchainProvider;
17250
17513
  this.handlers = new Map(messageHandlers.map((u) => [u.messageTag, u]));
17251
17514
  this.tickIntervalMs = tickIntervalMs;
17252
17515
  this.messageTimeoutMs = messageTimeoutMs;
@@ -17281,6 +17544,7 @@ var MessageBus = class {
17281
17544
  buildServicesFn;
17282
17545
  boundOnMessage = this.onMessage.bind(this);
17283
17546
  intentRepository;
17547
+ onchainProvider;
17284
17548
  /** Pending broadcasts, drained FIFO by a single {@link drain} loop. */
17285
17549
  broadcastQueue = [];
17286
17550
  draining = false;
@@ -17498,14 +17762,14 @@ var MessageBus = class {
17498
17762
  this.initialized = true;
17499
17763
  }
17500
17764
  async buildServices(config) {
17501
- const arkProvider = new chunkVVFCCNU2_cjs.RestArkProvider(config.arkServer.url);
17765
+ const arkProvider = new chunkFGKBQH5S_cjs.RestArkProvider(config.arkServer.url);
17502
17766
  const storage = {
17503
17767
  walletRepository: this.walletRepository,
17504
17768
  contractRepository: this.contractRepository,
17505
17769
  ...this.intentRepository && { intentRepository: this.intentRepository }
17506
17770
  };
17507
17771
  const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
17508
- const indexerProvider = new chunkFEBAG2K2_cjs.RestIndexerProvider(config.arkServer.url);
17772
+ const indexerProvider = new chunk6BJJ47JM_cjs.RestIndexerProvider(config.arkServer.url);
17509
17773
  const serialized = normalizeSerializedIdentity(config.wallet);
17510
17774
  if (isSigningSerialized(serialized)) {
17511
17775
  const identity2 = hydrateIdentity(serialized);
@@ -17514,6 +17778,7 @@ var MessageBus = class {
17514
17778
  arkProvider,
17515
17779
  arkServerPublicKey: config.arkServer.publicKey,
17516
17780
  indexerProvider,
17781
+ onchainProvider: this.onchainProvider,
17517
17782
  storage,
17518
17783
  delegateProvider,
17519
17784
  settlementConfig: config.settlementConfig,
@@ -17534,6 +17799,7 @@ var MessageBus = class {
17534
17799
  arkProvider,
17535
17800
  arkServerPublicKey: config.arkServer.publicKey,
17536
17801
  indexerProvider,
17802
+ onchainProvider: this.onchainProvider,
17537
17803
  storage,
17538
17804
  delegateProvider,
17539
17805
  watcherConfig: config.watcherConfig
@@ -17846,7 +18112,7 @@ var offboardNetworkNames = [
17846
18112
  function offboardDestinationScript(destinationAddress) {
17847
18113
  for (const networkName of offboardNetworkNames) {
17848
18114
  try {
17849
- const network = chunkVVFCCNU2_cjs.networks[networkName];
18115
+ const network = chunkFGKBQH5S_cjs.networks[networkName];
17850
18116
  const addr = btcSigner.Address(network).decode(destinationAddress);
17851
18117
  return btcSigner.OutScript.encode(addr);
17852
18118
  } catch {
@@ -17886,7 +18152,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
17886
18152
  const inputs = [];
17887
18153
  let subtotal = 0n;
17888
18154
  for (const vtxo of vtxos) {
17889
- const inputFee = estimator.evalOffchainInput(chunkVVFCCNU2_cjs.toOffchainInputFeeParams(vtxo));
18155
+ const inputFee = estimator.evalOffchainInput(chunkFGKBQH5S_cjs.toOffchainInputFeeParams(vtxo));
17890
18156
  if (inputFee.satoshis >= vtxo.value) {
17891
18157
  if (named) {
17892
18158
  throw new Error(
@@ -17983,7 +18249,7 @@ var Ramps = class {
17983
18249
  }
17984
18250
  amount = amount ?? totalAmount;
17985
18251
  const offchainAddress = await this.wallet.getAddress();
17986
- const offchainAddr = chunkVVFCCNU2_cjs.ArkAddress.decode(offchainAddress);
18252
+ const offchainAddr = chunkFGKBQH5S_cjs.ArkAddress.decode(offchainAddress);
17987
18253
  const offchainScript = base.hex.encode(offchainAddr.pkScript);
17988
18254
  const outputFee = estimator.evalOffchainOutput({
17989
18255
  amount,
@@ -18133,7 +18399,7 @@ var Ramps = class {
18133
18399
  const ordered = [...candidates].sort(bySelectionOrder);
18134
18400
  let covered = 0n;
18135
18401
  for (let i = 0; i < ordered.length && i < MAX_VTXOS_PER_SETTLEMENT; i++) {
18136
- const fee = estimator.evalOffchainInput(chunkVVFCCNU2_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
18402
+ const fee = estimator.evalOffchainInput(chunkFGKBQH5S_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
18137
18403
  covered += BigInt(ordered[i].value) - BigInt(fee);
18138
18404
  if (covered < needed) continue;
18139
18405
  try {
@@ -18167,7 +18433,7 @@ var Ramps = class {
18167
18433
  async fundChange(left, estimator) {
18168
18434
  if (left <= 0n) return { change: 0n };
18169
18435
  const changeAddress = await this.wallet.getAddress();
18170
- const changeScript = base.hex.encode(chunkVVFCCNU2_cjs.ArkAddress.decode(changeAddress).pkScript);
18436
+ const changeScript = base.hex.encode(chunkFGKBQH5S_cjs.ArkAddress.decode(changeAddress).pkScript);
18171
18437
  const { change } = changeAfterOutputFee(
18172
18438
  left,
18173
18439
  (amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
@@ -18752,6 +19018,15 @@ var WalletMessageHandler = class {
18752
19018
  payload: { paths }
18753
19019
  });
18754
19020
  }
19021
+ case "GET_UNSUPPORTED_CONTRACTS": {
19022
+ const manager = await this.readonlyWallet.getContractManager();
19023
+ const contracts = await manager.getUnsupportedContracts();
19024
+ return this.tagged({
19025
+ id,
19026
+ type: "UNSUPPORTED_CONTRACTS",
19027
+ payload: { contracts }
19028
+ });
19029
+ }
18755
19030
  case "IS_CONTRACT_MANAGER_WATCHING": {
18756
19031
  const manager = await this.readonlyWallet.getContractManager();
18757
19032
  const isWatching = await manager.isWatching();
@@ -19092,7 +19367,7 @@ var WalletMessageHandler = class {
19092
19367
  this.lazyBoardingInit = payload.lazyBoarding ?? false;
19093
19368
  this.boardingEpoch++;
19094
19369
  this.boardingLoaded = false;
19095
- this.indexerProvider = new chunkFEBAG2K2_cjs.RestIndexerProvider(arkServerUrl);
19370
+ this.indexerProvider = new chunk6BJJ47JM_cjs.RestIndexerProvider(arkServerUrl);
19096
19371
  await this.onWalletInitialized();
19097
19372
  }
19098
19373
  /** @see RequestInitWallet.payload.lazyBoarding */
@@ -19514,7 +19789,7 @@ var WalletMessageHandler = class {
19514
19789
  this.readonlyWallet.getBoardingTxs()
19515
19790
  ]);
19516
19791
  const indexerProvider = this.indexerProvider;
19517
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunkVVFCCNU2_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
19792
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunkFGKBQH5S_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
19518
19793
  return buildTransactionHistory(
19519
19794
  vtxos,
19520
19795
  boardingTxs,
@@ -19583,7 +19858,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
19583
19858
  // budget so the worker's snapshot fallback stays reachable before this
19584
19859
  // page deadline fires — lowering it below the budget would time the page
19585
19860
  // out while the worker is still seconds from answering from cache.
19586
- GET_ARKADE_INFO: chunkVVFCCNU2_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
19861
+ GET_ARKADE_INFO: chunkFGKBQH5S_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
19587
19862
  INDEXER_GET_VTXOS: 2e4,
19588
19863
  INDEXER_GET_VIRTUAL_TXS: 2e4,
19589
19864
  GET_VTXOS: 2e4,
@@ -19597,6 +19872,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
19597
19872
  ANNOTATE_VTXOS: 2e4,
19598
19873
  GET_SPENDABLE_PATHS: 2e4,
19599
19874
  GET_ALL_SPENDING_PATHS: 2e4,
19875
+ GET_UNSUPPORTED_CONTRACTS: 2e4,
19600
19876
  GET_ASSET_DETAILS: 2e4,
19601
19877
  GET_EXPIRING_VTXOS: 2e4,
19602
19878
  GET_EXPIRED_BOARDING_UTXOS: 2e4,
@@ -19667,6 +19943,7 @@ var DEDUPABLE_REQUEST_TYPES = /* @__PURE__ */ new Set([
19667
19943
  "ANNOTATE_VTXOS",
19668
19944
  "GET_SPENDABLE_PATHS",
19669
19945
  "GET_ALL_SPENDING_PATHS",
19946
+ "GET_UNSUPPORTED_CONTRACTS",
19670
19947
  "GET_ASSET_DETAILS",
19671
19948
  "GET_EXPIRING_VTXOS",
19672
19949
  "RELOAD_WALLET"
@@ -19726,7 +20003,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
19726
20003
  }
19727
20004
  };
19728
20005
  var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
19729
- chunkVVFCCNU2_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
20006
+ chunkFGKBQH5S_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
19730
20007
  const initCmd = {
19731
20008
  tag: "INITIALIZE_MESSAGE_BUS",
19732
20009
  id: getRandomId(),
@@ -19814,7 +20091,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19814
20091
  }
19815
20092
  /** Shared tail of both `create()` factories: boot the bus, INIT_WALLET, cache for reinit. */
19816
20093
  static async bootstrap(wallet, options, serializedWallet, busConfig) {
19817
- const arkServer = options.arkServer ?? { url: chunkVVFCCNU2_cjs.DEFAULT_ARKADE_SERVER_URL };
20094
+ const arkServer = options.arkServer ?? { url: chunkFGKBQH5S_cjs.DEFAULT_ARKADE_SERVER_URL };
19818
20095
  const initWalletPayload = {
19819
20096
  lazyBoarding: options.lazyBoarding,
19820
20097
  arkServerUrl: arkServer.url,
@@ -19824,7 +20101,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19824
20101
  Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
19825
20102
  );
19826
20103
  for (const [key, value] of Object.entries(overrides)) {
19827
- chunkVVFCCNU2_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
20104
+ chunkFGKBQH5S_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
19828
20105
  }
19829
20106
  const messageTimeouts = {
19830
20107
  ...DEFAULT_MESSAGE_TIMEOUTS,
@@ -20164,7 +20441,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
20164
20441
  try {
20165
20442
  const response = await this.sendMessage(message);
20166
20443
  const { vtxos, page } = response.payload;
20167
- return { vtxos: vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo), page: page && { ...page } };
20444
+ return { vtxos: vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo), page: page && { ...page } };
20168
20445
  } catch (cause) {
20169
20446
  throw new Error(`Failed to get vtxos: ${cause}`, { cause });
20170
20447
  }
@@ -20268,7 +20545,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
20268
20545
  };
20269
20546
  try {
20270
20547
  const response = await this.sendMessage(message);
20271
- return response.payload.vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo);
20548
+ return response.payload.vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo);
20272
20549
  } catch (error) {
20273
20550
  throw new Error(`Failed to get vtxos: ${error}`);
20274
20551
  }
@@ -20299,7 +20576,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
20299
20576
  "Service worker does not support the requested contract scope or freshness check"
20300
20577
  );
20301
20578
  }
20302
- return payload.vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo);
20579
+ return payload.vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo);
20303
20580
  } catch (error) {
20304
20581
  throw new Error(`Failed to get spendable vtxos: ${error}`);
20305
20582
  }
@@ -20494,7 +20771,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
20494
20771
  };
20495
20772
  try {
20496
20773
  const response = await sendContractMessage(message);
20497
- return response.payload.vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo);
20774
+ return response.payload.vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo);
20498
20775
  } catch (cause) {
20499
20776
  throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
20500
20777
  }
@@ -20585,6 +20862,19 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
20585
20862
  throw new Error(`Failed to get all spending paths: ${cause}`, { cause });
20586
20863
  }
20587
20864
  },
20865
+ async getUnsupportedContracts() {
20866
+ const message = {
20867
+ type: "GET_UNSUPPORTED_CONTRACTS",
20868
+ id: getRandomId(),
20869
+ tag: messageTag
20870
+ };
20871
+ try {
20872
+ const response = await sendContractMessage(message);
20873
+ return response.payload.contracts;
20874
+ } catch (cause) {
20875
+ throw new Error(`Failed to get unsupported contracts: ${cause}`, { cause });
20876
+ }
20877
+ },
20588
20878
  onContractEvent(callback) {
20589
20879
  const messageHandler = (event) => {
20590
20880
  const response = event.data;
@@ -21122,7 +21412,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
21122
21412
  };
21123
21413
  try {
21124
21414
  const response = await wallet.sendMessage(message);
21125
- return response.payload.vtxos.map(chunkVVFCCNU2_cjs.normalizeVtxo);
21415
+ return response.payload.vtxos.map(chunkFGKBQH5S_cjs.normalizeVtxo);
21126
21416
  } catch (e) {
21127
21417
  throw new Error(`Failed to get expiring vtxos: ${e}`);
21128
21418
  }
@@ -21239,12 +21529,12 @@ var OnchainWallet = class _OnchainWallet {
21239
21529
  * @returns Configured onchain wallet
21240
21530
  * @throws Error if the configured identity cannot produce a valid x-only public key
21241
21531
  */
21242
- static async create(identity, networkName = chunkVVFCCNU2_cjs.DEFAULT_NETWORK_NAME, provider) {
21532
+ static async create(identity, networkName = chunkFGKBQH5S_cjs.DEFAULT_NETWORK_NAME, provider) {
21243
21533
  const pubkey = await identity.xOnlyPublicKey();
21244
21534
  if (!pubkey) {
21245
21535
  throw new Error("Invalid configured public key");
21246
21536
  }
21247
- const network = chunkVVFCCNU2_cjs.getNetwork(networkName);
21537
+ const network = chunkFGKBQH5S_cjs.getNetwork(networkName);
21248
21538
  const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
21249
21539
  const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
21250
21540
  return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
@@ -21344,7 +21634,7 @@ var OnchainWallet = class _OnchainWallet {
21344
21634
  feeRate,
21345
21635
  params.address
21346
21636
  );
21347
- let tx = new chunkVVFCCNU2_cjs.Transaction();
21637
+ let tx = new chunkFGKBQH5S_cjs.Transaction();
21348
21638
  for (const input of inputs) {
21349
21639
  tx.addInput({
21350
21640
  txid: input.txid,
@@ -21402,7 +21692,7 @@ var OnchainWallet = class _OnchainWallet {
21402
21692
  * @throws If the parent has no anchor, or funding cannot be selected/signed
21403
21693
  */
21404
21694
  async bumpAnchor(parentHex, feeRate) {
21405
- const parent = chunkVVFCCNU2_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
21695
+ const parent = chunkFGKBQH5S_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
21406
21696
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
21407
21697
  const child = await this.buildBumpPackage(parent, feeRate, coins);
21408
21698
  return [parent.hex, child.hex];
@@ -22218,7 +22508,7 @@ var CachingArkProvider = class {
22218
22508
  constructor(inner, ttlMs = DEFAULT_TTL_MS) {
22219
22509
  this.inner = inner;
22220
22510
  this.ttlMs = ttlMs;
22221
- chunkVVFCCNU2_cjs.assertNonNegativeMs("ttlMs", ttlMs);
22511
+ chunkFGKBQH5S_cjs.assertNonNegativeMs("ttlMs", ttlMs);
22222
22512
  this.unsubscribe = inner.onServerInfoChanged?.((info) => {
22223
22513
  this.cached = info;
22224
22514
  this.expiresAt = Date.now() + this.ttlMs;
@@ -22310,7 +22600,7 @@ async function resolvePrevTxs(txids, source, onchain) {
22310
22600
  try {
22311
22601
  const { txs } = await source.getVirtualTxs(wanted);
22312
22602
  for (const psbt of txs) {
22313
- const tx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
22603
+ const tx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
22314
22604
  resolved.set(tx.id, tx.toBytes());
22315
22605
  }
22316
22606
  } catch (err) {
@@ -22343,7 +22633,7 @@ async function resolvePrevTxs(txids, source, onchain) {
22343
22633
  async function attachPrevArkTxs(tx, txids, source, onchain) {
22344
22634
  const pending = [];
22345
22635
  for (let i = 0; i < tx.inputsLength; i++) {
22346
- if (chunkVVFCCNU2_cjs.getArkPsbtFields(tx, i, chunkVVFCCNU2_cjs.PrevArkTxField).length === 0) pending.push(i);
22636
+ if (chunkFGKBQH5S_cjs.getArkPsbtFields(tx, i, chunkFGKBQH5S_cjs.PrevArkTxField).length === 0) pending.push(i);
22347
22637
  }
22348
22638
  if (pending.length === 0) return;
22349
22639
  const resolved = await resolvePrevTxs(
@@ -22352,13 +22642,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
22352
22642
  onchain
22353
22643
  );
22354
22644
  for (const i of pending) {
22355
- chunkVVFCCNU2_cjs.setArkPsbtField(tx, i, chunkVVFCCNU2_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
22645
+ chunkFGKBQH5S_cjs.setArkPsbtField(tx, i, chunkFGKBQH5S_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
22356
22646
  }
22357
22647
  }
22358
22648
  async function attachPrevoutTxs(tx, source) {
22359
22649
  const pending = [];
22360
22650
  for (let i = 0; i < tx.inputsLength; i++) {
22361
- if (chunkVVFCCNU2_cjs.getArkPsbtFields(tx, i, chunkVVFCCNU2_cjs.PrevoutTxField).length > 0) continue;
22651
+ if (chunkFGKBQH5S_cjs.getArkPsbtFields(tx, i, chunkFGKBQH5S_cjs.PrevoutTxField).length > 0) continue;
22362
22652
  const input = tx.getInput(i);
22363
22653
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
22364
22654
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -22369,7 +22659,7 @@ async function attachPrevoutTxs(tx, source) {
22369
22659
  resolved.set(txid, await source.getRawTransaction(txid));
22370
22660
  }
22371
22661
  for (const { index, txid } of pending) {
22372
- chunkVVFCCNU2_cjs.setArkPsbtField(tx, index, chunkVVFCCNU2_cjs.PrevoutTxField, resolved.get(txid));
22662
+ chunkFGKBQH5S_cjs.setArkPsbtField(tx, index, chunkFGKBQH5S_cjs.PrevoutTxField, resolved.get(txid));
22373
22663
  }
22374
22664
  }
22375
22665
  async function withPrevTxs(coins, source, onchain) {
@@ -22395,7 +22685,7 @@ exports.BIP322 = void 0;
22395
22685
  async function sign2(message, identity, network) {
22396
22686
  const xOnlyPubKey = await identity.xOnlyPublicKey();
22397
22687
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
22398
- const toSpend = chunkVVFCCNU2_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
22688
+ const toSpend = chunkFGKBQH5S_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
22399
22689
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
22400
22690
  const signed = await identity.sign(toSign, [0]);
22401
22691
  signed.finalizeIdx(0);
@@ -22453,7 +22743,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
22453
22743
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
22454
22744
  return false;
22455
22745
  }
22456
- const toSpend = chunkVVFCCNU2_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22746
+ const toSpend = chunkFGKBQH5S_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22457
22747
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
22458
22748
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
22459
22749
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -22474,7 +22764,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
22474
22764
  }
22475
22765
  const sighashType = sigWithHash[sigWithHash.length - 1];
22476
22766
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
22477
- const toSpend = chunkVVFCCNU2_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22767
+ const toSpend = chunkFGKBQH5S_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22478
22768
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
22479
22769
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
22480
22770
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -22527,7 +22817,7 @@ function encodeCompactSize(n) {
22527
22817
  return buf;
22528
22818
  }
22529
22819
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
22530
- const tx = new chunkVVFCCNU2_cjs.Transaction({ version: 0 });
22820
+ const tx = new chunkFGKBQH5S_cjs.Transaction({ version: 0 });
22531
22821
  tx.addInput({
22532
22822
  txid: toSpend.id,
22533
22823
  index: 0,
@@ -22541,12 +22831,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
22541
22831
  });
22542
22832
  tx.addOutput({
22543
22833
  amount: 0n,
22544
- script: chunkVVFCCNU2_cjs.OP_RETURN_EMPTY_PKSCRIPT
22834
+ script: chunkFGKBQH5S_cjs.OP_RETURN_EMPTY_PKSCRIPT
22545
22835
  });
22546
22836
  return tx;
22547
22837
  }
22548
22838
  function craftBIP322ToSignSimple(toSpend, pkScript) {
22549
- const tx = new chunkVVFCCNU2_cjs.Transaction({ version: 0 });
22839
+ const tx = new chunkFGKBQH5S_cjs.Transaction({ version: 0 });
22550
22840
  tx.addInput({
22551
22841
  txid: toSpend.id,
22552
22842
  index: 0,
@@ -22558,138 +22848,12 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
22558
22848
  });
22559
22849
  tx.addOutput({
22560
22850
  amount: 0n,
22561
- script: chunkVVFCCNU2_cjs.OP_RETURN_EMPTY_PKSCRIPT
22851
+ script: chunkFGKBQH5S_cjs.OP_RETURN_EMPTY_PKSCRIPT
22562
22852
  });
22563
22853
  return tx;
22564
22854
  }
22565
-
22566
- // src/providers/emulator.ts
22567
- var RestEmulatorProvider = class {
22568
- constructor(serverUrl) {
22569
- this.serverUrl = serverUrl;
22570
- }
22571
- serverUrl;
22572
- async getInfo() {
22573
- const url = `${this.serverUrl}/v1/info`;
22574
- const response = await chunkVVFCCNU2_cjs.baseFetch(url);
22575
- if (!response.ok) {
22576
- const errorText2 = await response.text();
22577
- throw new Error(`Failed to get emulator info: ${errorText2}`);
22578
- }
22579
- const data = await response.json();
22580
- const signerPubkey = data.signerPubkey;
22581
- if (typeof signerPubkey !== "string" || !signerPubkey) {
22582
- throw new Error("Invalid emulator info response: missing signerPubkey");
22583
- }
22584
- return { signerPubkey };
22585
- }
22586
- async submitTx(arkTx, checkpointTxs) {
22587
- const url = `${this.serverUrl}/v1/tx`;
22588
- const response = await fetch(url, {
22589
- method: "POST",
22590
- headers: { "Content-Type": "application/json" },
22591
- body: JSON.stringify({
22592
- arkTx,
22593
- checkpointTxs
22594
- })
22595
- });
22596
- if (!response.ok) {
22597
- const errorText2 = await response.text();
22598
- throw new Error(`Failed to submit tx to emulator: ${errorText2}`);
22599
- }
22600
- const data = await response.json();
22601
- if (typeof data.signedArkTx !== "string" || !data.signedArkTx) {
22602
- throw new Error("Invalid emulator submitTx response: missing signedArkTx");
22603
- }
22604
- if (!Array.isArray(data.signedCheckpointTxs) || !data.signedCheckpointTxs.every((item) => typeof item === "string")) {
22605
- throw new Error(
22606
- "Invalid emulator submitTx response: signedCheckpointTxs must be an array of strings"
22607
- );
22608
- }
22609
- return {
22610
- signedArkTx: data.signedArkTx,
22611
- signedCheckpointTxs: data.signedCheckpointTxs
22612
- };
22613
- }
22614
- async submitIntent(intent) {
22615
- const url = `${this.serverUrl}/v1/intent`;
22616
- const response = await fetch(url, {
22617
- method: "POST",
22618
- headers: { "Content-Type": "application/json" },
22619
- body: JSON.stringify({
22620
- intent: {
22621
- proof: intent.proof,
22622
- message: JSON.stringify(intent.message)
22623
- }
22624
- })
22625
- });
22626
- if (!response.ok) {
22627
- const errorText2 = await response.text();
22628
- throw new Error(`Failed to submit intent to emulator: ${errorText2}`);
22629
- }
22630
- const data = await response.json();
22631
- if (typeof data.signedProof !== "string" || !data.signedProof) {
22632
- throw new Error("Invalid emulator submitIntent response: missing signedProof");
22633
- }
22634
- return data.signedProof;
22635
- }
22636
- async submitFinalization(intent, forfeits, connectorTree, commitmentTx) {
22637
- const url = `${this.serverUrl}/v1/finalization`;
22638
- const response = await fetch(url, {
22639
- method: "POST",
22640
- headers: { "Content-Type": "application/json" },
22641
- // Uses "signedIntent" (not "intent") because the proof was already
22642
- // co-signed by the emulator via submitIntent in a prior step.
22643
- body: JSON.stringify({
22644
- signedIntent: {
22645
- proof: intent.proof,
22646
- message: JSON.stringify(intent.message)
22647
- },
22648
- forfeits,
22649
- connectorTree,
22650
- commitmentTx
22651
- })
22652
- });
22653
- if (!response.ok) {
22654
- const errorText2 = await response.text();
22655
- throw new Error(`Failed to submit finalization to emulator: ${errorText2}`);
22656
- }
22657
- const data = await response.json();
22658
- if (!Array.isArray(data.signedForfeits) || !data.signedForfeits.every((item) => typeof item === "string")) {
22659
- throw new Error(
22660
- "Invalid emulator submitFinalization response: signedForfeits must be an array of strings"
22661
- );
22662
- }
22663
- if ("signedCommitmentTx" in data && typeof data.signedCommitmentTx !== "string") {
22664
- throw new Error(
22665
- "Invalid emulator submitFinalization response: invalid signedCommitmentTx"
22666
- );
22667
- }
22668
- return {
22669
- signedForfeits: data.signedForfeits,
22670
- signedCommitmentTx: data.signedCommitmentTx
22671
- };
22672
- }
22673
- async submitOnchainTx(tx) {
22674
- const url = `${this.serverUrl}/v1/onchain-tx`;
22675
- const response = await fetch(url, {
22676
- method: "POST",
22677
- headers: { "Content-Type": "application/json" },
22678
- body: JSON.stringify({ tx })
22679
- });
22680
- if (!response.ok) {
22681
- const errorText2 = await response.text();
22682
- throw new Error(`Failed to submit onchain tx to emulator: ${errorText2}`);
22683
- }
22684
- const data = await response.json();
22685
- if (typeof data.signedTx !== "string" || !data.signedTx) {
22686
- throw new Error("Invalid emulator submitOnchainTx response: missing signedTx");
22687
- }
22688
- return { signedTx: data.signedTx };
22689
- }
22690
- };
22691
22855
  function finalizeVirtualTx(type, psbtBase64) {
22692
- const tx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
22856
+ const tx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
22693
22857
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
22694
22858
  const input = tx.getInput(0);
22695
22859
  if (!input) {
@@ -22716,14 +22880,14 @@ var ExitPathError = class extends Error {
22716
22880
  reason;
22717
22881
  };
22718
22882
  function delayWeight(sequence) {
22719
- const t = chunkVVFCCNU2_cjs.sequenceToTimelock(sequence);
22883
+ const t = chunkFGKBQH5S_cjs.sequenceToTimelock(sequence);
22720
22884
  return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
22721
22885
  }
22722
22886
  async function resolveUnilateralPath(params) {
22723
22887
  const { vtxo, scriptHex, contractRepository } = params;
22724
22888
  const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
22725
22889
  if (contract) {
22726
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
22890
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
22727
22891
  if (!handler) {
22728
22892
  throw new ExitPathError(
22729
22893
  "no-handler",
@@ -22745,12 +22909,12 @@ async function resolveUnilateralPath(params) {
22745
22909
  paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
22746
22910
  return { selection: paths[0], label: `${contract.type}:unilateral` };
22747
22911
  }
22748
- const decoded = chunkVVFCCNU2_cjs.VtxoScript.decode(vtxo.tapTree);
22912
+ const decoded = chunkFGKBQH5S_cjs.VtxoScript.decode(vtxo.tapTree);
22749
22913
  let best;
22750
22914
  for (const exit of decoded.exitPaths()) {
22751
22915
  const leaf = decoded.findLeaf(base.hex.encode(exit.script));
22752
22916
  if (!leaf) continue;
22753
- const sequence = chunkVVFCCNU2_cjs.timelockToSequence(exit.params.timelock);
22917
+ const sequence = chunkFGKBQH5S_cjs.timelockToSequence(exit.params.timelock);
22754
22918
  const weight = delayWeight(sequence);
22755
22919
  if (!best || weight < best.weight) {
22756
22920
  best = { selection: { leaf, sequence }, weight };
@@ -22957,7 +23121,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22957
23121
  const txWeightEstimator = TxWeightEstimator.create();
22958
23122
  const walletDescriptor = base.hex.encode(await wallet.identity.xOnlyPublicKey());
22959
23123
  for (const vtxo of vtxos) {
22960
- if (!chunkVVFCCNU2_cjs.canSweepOnchain(vtxo)) {
23124
+ if (!chunkFGKBQH5S_cjs.canSweepOnchain(vtxo)) {
22961
23125
  throw new Error(
22962
23126
  `Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
22963
23127
  );
@@ -22968,14 +23132,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22968
23132
  }
22969
23133
  const resolved = await resolveUnilateralPath({
22970
23134
  vtxo,
22971
- scriptHex: base.hex.encode(chunkVVFCCNU2_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
23135
+ scriptHex: base.hex.encode(chunkFGKBQH5S_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22972
23136
  contractRepository: wallet.contractRepository,
22973
23137
  walletDescriptor,
22974
23138
  currentTime: Date.now()
22975
23139
  });
22976
23140
  const spendingLeaf = resolved.selection.leaf;
22977
23141
  const sequence = resolved.selection.sequence;
22978
- const timelock = chunkVVFCCNU2_cjs.sequenceToTimelock(sequence);
23142
+ const timelock = chunkFGKBQH5S_cjs.sequenceToTimelock(sequence);
22979
23143
  const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
22980
23144
  if (!elapsed) {
22981
23145
  throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
@@ -22988,7 +23152,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22988
23152
  sequence,
22989
23153
  witnessUtxo: {
22990
23154
  amount: BigInt(vtxo.value),
22991
- script: chunkVVFCCNU2_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
23155
+ script: chunkFGKBQH5S_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22992
23156
  },
22993
23157
  sighashType: btcSigner.SigHash.DEFAULT
22994
23158
  });
@@ -22998,7 +23162,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22998
23162
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
22999
23163
  );
23000
23164
  }
23001
- const tx = new chunkVVFCCNU2_cjs.Transaction({ version: 2 });
23165
+ const tx = new chunkFGKBQH5S_cjs.Transaction({ version: 2 });
23002
23166
  for (const input of inputs) {
23003
23167
  tx.addInput(input);
23004
23168
  }
@@ -23081,7 +23245,7 @@ async function buildSignedSweep(params) {
23081
23245
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
23082
23246
  );
23083
23247
  }
23084
- const tx = new chunkVVFCCNU2_cjs.Transaction({ version: 2 });
23248
+ const tx = new chunkFGKBQH5S_cjs.Transaction({ version: 2 });
23085
23249
  tx.addInput({
23086
23250
  txid: vtxo.txid,
23087
23251
  index: vtxo.vout,
@@ -23106,7 +23270,7 @@ async function buildSignedSweep(params) {
23106
23270
  finalScriptWitness: [
23107
23271
  tapScriptSig[0][1],
23108
23272
  ...path.extraWitness,
23109
- chunkVVFCCNU2_cjs.scriptFromTapLeafScript(path.leaf),
23273
+ chunkFGKBQH5S_cjs.scriptFromTapLeafScript(path.leaf),
23110
23274
  btcSigner.TaprootControlBlock.encode(controlBlock)
23111
23275
  ]
23112
23276
  });
@@ -23136,7 +23300,7 @@ async function resolveFeeRate(opts) {
23136
23300
  }
23137
23301
  async function selectExitVtxos(opts) {
23138
23302
  if (!opts.vtxos) return opts.wallet.getVtxos();
23139
- const res = await chunkVVFCCNU2_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
23303
+ const res = await chunkFGKBQH5S_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
23140
23304
  const tapTrees = /* @__PURE__ */ new Map();
23141
23305
  const out = [];
23142
23306
  for (const vtxo of res.vtxos) {
@@ -23151,7 +23315,7 @@ async function selectExitVtxos(opts) {
23151
23315
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
23152
23316
  );
23153
23317
  }
23154
- const handler = chunkCFOIHLON_cjs.contractHandlers.get(contract.type);
23318
+ const handler = chunkYFQOJTG3_cjs.contractHandlers.get(contract.type);
23155
23319
  if (!handler) {
23156
23320
  throw new Error(`no contract handler registered for type '${contract.type}'`);
23157
23321
  }
@@ -23181,7 +23345,7 @@ async function computeExitLayout(opts, feeRate) {
23181
23345
  if (pendingNodes.length > 0) {
23182
23346
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
23183
23347
  for (const psbt of txs) {
23184
- psbts.set(chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
23348
+ psbts.set(chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
23185
23349
  }
23186
23350
  }
23187
23351
  const childVsize = Number(
@@ -23209,7 +23373,7 @@ async function computeExitLayout(opts, feeRate) {
23209
23373
  try {
23210
23374
  const resolved = await resolveUnilateralPath({
23211
23375
  vtxo,
23212
- scriptHex: base.hex.encode(chunkVVFCCNU2_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
23376
+ scriptHex: base.hex.encode(chunkFGKBQH5S_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
23213
23377
  contractRepository: wallet.contractRepository,
23214
23378
  walletDescriptor,
23215
23379
  currentTime: Date.now()
@@ -23228,7 +23392,7 @@ async function computeExitLayout(opts, feeRate) {
23228
23392
  });
23229
23393
  continue;
23230
23394
  }
23231
- const t = chunkVVFCCNU2_cjs.sequenceToTimelock(resolved.selection.sequence);
23395
+ const t = chunkFGKBQH5S_cjs.sequenceToTimelock(resolved.selection.sequence);
23232
23396
  const delay = { type: t.type, value: Number(t.value) };
23233
23397
  infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
23234
23398
  sweeps.push({ vtxo, resolved, sweepFee, delay });
@@ -23335,7 +23499,7 @@ var Executor = class {
23335
23499
  constructor(pkg, provider, opts) {
23336
23500
  this.pkg = pkg;
23337
23501
  this.provider = provider;
23338
- chunkVVFCCNU2_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
23502
+ chunkFGKBQH5S_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
23339
23503
  this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
23340
23504
  this.feeWallet = opts?.feeWallet;
23341
23505
  this.signal = opts?.signal;
@@ -23630,7 +23794,7 @@ async function prepare(opts) {
23630
23794
  txid: sweep.vtxo.txid,
23631
23795
  vout: sweep.vtxo.vout,
23632
23796
  value: sweep.vtxo.value,
23633
- pkScript: chunkVVFCCNU2_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
23797
+ pkScript: chunkFGKBQH5S_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
23634
23798
  },
23635
23799
  path: sweep.resolved.selection,
23636
23800
  outputAddress: opts.sweepAddress,
@@ -23719,7 +23883,7 @@ async function prepare(opts) {
23719
23883
  if (newFee <= splitterFee) break;
23720
23884
  splitterFee = newFee;
23721
23885
  }
23722
- const splitter = new chunkVVFCCNU2_cjs.Transaction({ version: 2 });
23886
+ const splitter = new chunkFGKBQH5S_cjs.Transaction({ version: 2 });
23723
23887
  for (const coin of selected.inputs) {
23724
23888
  splitter.addInput({
23725
23889
  txid: coin.txid,
@@ -23858,44 +24022,46 @@ var UnilateralExit = {
23858
24022
 
23859
24023
  // src/arkade/index.ts
23860
24024
  var arkade_exports = {};
23861
- chunkVVFCCNU2_cjs.__export(arkade_exports, {
23862
- ARKADE_OP: () => chunkCFOIHLON_cjs.ARKADE_OP,
23863
- ARKADE_OPCODES: () => chunkCFOIHLON_cjs.ARKADE_OPCODES,
23864
- ARKADE_OPCODE_NAMES: () => chunkCFOIHLON_cjs.ARKADE_OPCODE_NAMES,
23865
- ARKADE_OPCODE_VALUES: () => chunkCFOIHLON_cjs.ARKADE_OPCODE_VALUES,
23866
- ARKADE_OPS: () => chunkCFOIHLON_cjs.ARKADE_OPS,
24025
+ chunkFGKBQH5S_cjs.__export(arkade_exports, {
24026
+ ARKADE_OP: () => chunkYFQOJTG3_cjs.ARKADE_OP,
24027
+ ARKADE_OPCODES: () => chunkYFQOJTG3_cjs.ARKADE_OPCODES,
24028
+ ARKADE_OPCODE_NAMES: () => chunkYFQOJTG3_cjs.ARKADE_OPCODE_NAMES,
24029
+ ARKADE_OPCODE_VALUES: () => chunkYFQOJTG3_cjs.ARKADE_OPCODE_VALUES,
24030
+ ARKADE_OPS: () => chunkYFQOJTG3_cjs.ARKADE_OPS,
23867
24031
  Arkade: () => Arkade,
23868
24032
  ArkadeContract: () => ArkadeContract,
23869
- ArkadeProgramScript: () => chunkCFOIHLON_cjs.ArkadeProgramScript,
23870
- ArkadeScript: () => chunkCFOIHLON_cjs.ArkadeScript,
24033
+ ArkadeProgramScript: () => chunkYFQOJTG3_cjs.ArkadeProgramScript,
24034
+ ArkadeScript: () => chunkYFQOJTG3_cjs.ArkadeScript,
23871
24035
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
23872
- BigNum: () => chunkCFOIHLON_cjs.bignum_exports,
24036
+ BigNum: () => chunkYFQOJTG3_cjs.bignum_exports,
23873
24037
  OP: () => btcSigner.OP,
23874
- OPCODE_NAMES: () => chunkCFOIHLON_cjs.OPCODE_NAMES,
23875
- OPCODE_VALUES: () => chunkCFOIHLON_cjs.OPCODE_VALUES,
23876
- SUPPORTED_PROGRAM_VERSION: () => chunkCFOIHLON_cjs.SUPPORTED_PROGRAM_VERSION,
24038
+ OPCODE_NAMES: () => chunkYFQOJTG3_cjs.OPCODE_NAMES,
24039
+ OPCODE_VALUES: () => chunkYFQOJTG3_cjs.OPCODE_VALUES,
24040
+ SUPPORTED_PROGRAM_VERSION: () => chunkYFQOJTG3_cjs.SUPPORTED_PROGRAM_VERSION,
23877
24041
  Script: () => btcSigner.Script,
23878
- arkadeScriptHash: () => chunkCFOIHLON_cjs.arkadeScriptHash,
23879
- arkadeWitnessHash: () => chunkCFOIHLON_cjs.arkadeWitnessHash,
23880
- asmToBytes: () => chunkCFOIHLON_cjs.asmToBytes,
23881
- bytesToASM: () => chunkCFOIHLON_cjs.bytesToASM,
23882
- computeArkadeScriptPublicKey: () => chunkCFOIHLON_cjs.computeArkadeScriptPublicKey,
24042
+ UnsupportedProgramVersionError: () => chunkYFQOJTG3_cjs.UnsupportedProgramVersionError,
24043
+ arkadeScriptHash: () => chunkYFQOJTG3_cjs.arkadeScriptHash,
24044
+ arkadeWitnessHash: () => chunkYFQOJTG3_cjs.arkadeWitnessHash,
24045
+ asmToBytes: () => chunkYFQOJTG3_cjs.asmToBytes,
24046
+ bytesToASM: () => chunkYFQOJTG3_cjs.bytesToASM,
24047
+ computeArkadeScriptPublicKey: () => chunkYFQOJTG3_cjs.computeArkadeScriptPublicKey,
23883
24048
  createArkadeBatchHandler: () => createArkadeBatchHandler,
23884
- deserializeArkadeContractParams: () => chunkCFOIHLON_cjs.deserializeArkadeContractParams,
23885
- fromASM: () => chunkCFOIHLON_cjs.fromASM,
23886
- getOpcodeName: () => chunkCFOIHLON_cjs.getOpcodeName,
23887
- getOpcodeValue: () => chunkCFOIHLON_cjs.getOpcodeValue,
24049
+ deserializeArkadeContractParams: () => chunkYFQOJTG3_cjs.deserializeArkadeContractParams,
24050
+ fromASM: () => chunkYFQOJTG3_cjs.fromASM,
24051
+ getOpcodeName: () => chunkYFQOJTG3_cjs.getOpcodeName,
24052
+ getOpcodeValue: () => chunkYFQOJTG3_cjs.getOpcodeValue,
23888
24053
  isContractArtifact: () => isContractArtifact,
23889
- parseArtifact: () => chunkCFOIHLON_cjs.parseArtifact,
24054
+ parseArtifact: () => chunkYFQOJTG3_cjs.parseArtifact,
23890
24055
  programFromArtifact: () => programFromArtifact,
23891
- resolveAsm: () => chunkCFOIHLON_cjs.resolveAsm,
23892
- serializeArkadeContractParams: () => chunkCFOIHLON_cjs.serializeArkadeContractParams,
23893
- stringifyArtifact: () => chunkCFOIHLON_cjs.stringifyArtifact,
23894
- toASM: () => chunkCFOIHLON_cjs.toASM,
23895
- validateProgram: () => chunkCFOIHLON_cjs.validateProgram,
23896
- witnessRefToBytes: () => chunkCFOIHLON_cjs.witnessRefToBytes
24056
+ resolveArkadeService: () => resolveArkadeService,
24057
+ resolveAsm: () => chunkYFQOJTG3_cjs.resolveAsm,
24058
+ serializeArkadeContractParams: () => chunkYFQOJTG3_cjs.serializeArkadeContractParams,
24059
+ stringifyArtifact: () => chunkYFQOJTG3_cjs.stringifyArtifact,
24060
+ toASM: () => chunkYFQOJTG3_cjs.toASM,
24061
+ validateProgram: () => chunkYFQOJTG3_cjs.validateProgram,
24062
+ witnessRefToBytes: () => chunkYFQOJTG3_cjs.witnessRefToBytes
23897
24063
  });
23898
- var isVtxoCoin = (input) => chunkVVFCCNU2_cjs.isVirtualCoin(input);
24064
+ var isVtxoCoin = (input) => chunkFGKBQH5S_cjs.isVirtualCoin(input);
23899
24065
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
23900
24066
  let batchId;
23901
24067
  let sweepTapTreeRoot;
@@ -23916,23 +24082,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23916
24082
  );
23917
24083
  await arkProvider.confirmRegistration(intentId);
23918
24084
  batchId = event.id;
23919
- const sweepTapscript = chunkVVFCCNU2_cjs.CSVMultisigTapscript.encode({
24085
+ const sweepTapscript = chunkFGKBQH5S_cjs.CSVMultisigTapscript.encode({
23920
24086
  timelock,
23921
- pubkeys: [chunkCFOIHLON_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
24087
+ pubkeys: [chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23922
24088
  }).script;
23923
24089
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
23924
24090
  return { skip: false };
23925
24091
  },
23926
24092
  onTreeSigningStarted: async (event, vtxoTree) => {
23927
24093
  const signerPubKey = await session.getPublicKey();
23928
- const xonlySignerPubKey = chunkCFOIHLON_cjs.toXOnly(signerPubKey, "signer key");
24094
+ const xonlySignerPubKey = chunkYFQOJTG3_cjs.toXOnly(signerPubKey, "signer key");
23929
24095
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
23930
- (k) => base.hex.encode(chunkCFOIHLON_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
24096
+ (k) => base.hex.encode(chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23931
24097
  );
23932
24098
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
23933
24099
  return { skip: true };
23934
24100
  }
23935
- const commitmentTx = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
24101
+ const commitmentTx = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23936
24102
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
23937
24103
  if (recipients && recipients.length > 0) {
23938
24104
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -23970,7 +24136,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23970
24136
  if (connectorTree) {
23971
24137
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
23972
24138
  }
23973
- let commitmentPsbt = chunkVVFCCNU2_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
24139
+ let commitmentPsbt = chunkFGKBQH5S_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23974
24140
  assertFinalCommitmentMatchesValidated(
23975
24141
  commitmentPsbt,
23976
24142
  validatedCommitmentTxid,
@@ -24012,7 +24178,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
24012
24178
  boardingIndices.push(boardingIdx);
24013
24179
  continue;
24014
24180
  }
24015
- if (!chunkVVFCCNU2_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
24181
+ if (!chunkFGKBQH5S_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
24016
24182
  continue;
24017
24183
  }
24018
24184
  if (connectorIndex >= connectorLeaves.length) {
@@ -24033,7 +24199,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
24033
24199
  index: input.vout,
24034
24200
  witnessUtxo: {
24035
24201
  amount: BigInt(input.value),
24036
- script: chunkVVFCCNU2_cjs.VtxoScript.decode(input.tapTree).pkScript
24202
+ script: chunkFGKBQH5S_cjs.VtxoScript.decode(input.tapTree).pkScript
24037
24203
  },
24038
24204
  sighashType: btcSigner.SigHash.DEFAULT,
24039
24205
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -24097,6 +24263,24 @@ var NATIVE_STRUCTS = {
24097
24263
  ECPoint: [
24098
24264
  ["x", "int"],
24099
24265
  ["y", "int"]
24266
+ ],
24267
+ ScriptPubKey: [
24268
+ ["program", "bytes"],
24269
+ ["version", "int"]
24270
+ ],
24271
+ AssetEntry: [
24272
+ ["assetId", "AssetId"],
24273
+ ["amount", "int"]
24274
+ ],
24275
+ AssetLookup: [
24276
+ ["amount", "int"],
24277
+ ["found", "bool"]
24278
+ ],
24279
+ G2Point: [
24280
+ ["xC1", "int"],
24281
+ ["xC0", "int"],
24282
+ ["yC1", "int"],
24283
+ ["yC0", "int"]
24100
24284
  ]
24101
24285
  };
24102
24286
  var HASH_OPCODES = /* @__PURE__ */ new Set(["OP_SHA256", "OP_HASH160", "OP_HASH256", "OP_RIPEMD160"]);
@@ -24104,7 +24288,7 @@ function isRecord(value) {
24104
24288
  return typeof value === "object" && value !== null && !Array.isArray(value);
24105
24289
  }
24106
24290
  function isNamed(value) {
24107
- return isRecord(value) && typeof value.name === "string" && typeof value.type === "string" && value.type.length > 0;
24291
+ return isRecord(value) && typeof value.name === "string" && value.name.length > 0 && typeof value.type === "string" && value.type.length > 0;
24108
24292
  }
24109
24293
  function isContractArtifact(value) {
24110
24294
  if (!isRecord(value) || typeof value.contractName !== "string") return false;
@@ -24112,7 +24296,7 @@ function isContractArtifact(value) {
24112
24296
  if (value.structs !== void 0 && !Array.isArray(value.structs)) return false;
24113
24297
  if (!Array.isArray(value.functions) || value.functions.length === 0) return false;
24114
24298
  return value.functions.every(
24115
- (group) => isRecord(group) && typeof group.name === "string" && Array.isArray(group.leaves) && group.leaves.length > 0
24299
+ (group) => isRecord(group) && typeof group.name === "string" && group.name.length > 0 && Array.isArray(group.leaves) && group.leaves.length > 0
24116
24300
  );
24117
24301
  }
24118
24302
  function fail(detail) {
@@ -24122,33 +24306,35 @@ function claim(seen, name, kind) {
24122
24306
  if (seen.has(name)) fail(`duplicate ${kind} '${name}'`);
24123
24307
  seen.add(name);
24124
24308
  }
24125
- var SCALAR_TYPES = {
24126
- pubkey: "pubkey",
24127
- signature: "sig",
24128
- bytes: "bytes",
24129
- bytes20: "hash",
24130
- bytes32: "hash",
24131
- asset: "hash",
24132
- int: "int",
24133
- bool: "int"
24134
- };
24309
+ function inputDef(name, type) {
24310
+ return { name, type: argType(type) };
24311
+ }
24135
24312
  function argType(arkType) {
24136
- if (!Object.hasOwn(SCALAR_TYPES, arkType)) fail(`unknown type '${arkType}'`);
24137
- return SCALAR_TYPES[arkType];
24313
+ if (!Object.hasOwn(chunkYFQOJTG3_cjs.ARKADE_TYPE_ENCODINGS, arkType)) fail(`unknown type '${arkType}'`);
24314
+ return arkType;
24138
24315
  }
24139
24316
  function arrayParts(type) {
24140
24317
  const open = type.indexOf("[");
24141
24318
  if (open < 0 || !type.endsWith("]")) return [type, 0];
24142
24319
  const length = Number(type.slice(open + 1, -1));
24143
- return Number.isInteger(length) && length > 0 ? [type.slice(0, open), length] : [type, 0];
24320
+ return Number.isSafeInteger(length) && length > 0 && /^\d+$/.test(type.slice(open + 1, -1)) ? [type.slice(0, open), length] : [type, 0];
24144
24321
  }
24145
24322
  function flatten(param, structs, stack = []) {
24146
24323
  if (!isNamed(param)) fail("parameter needs a name and a type");
24324
+ const [element, length] = arrayParts(param.type);
24325
+ if (length > 0) {
24326
+ return Array.from(
24327
+ { length },
24328
+ (_, index) => flatten({ name: `${param.name}.${index}`, type: element }, structs, stack)
24329
+ ).flat();
24330
+ }
24331
+ if (param.type.includes("[") || param.type.includes("]")) {
24332
+ fail(`invalid array type '${param.type}'`);
24333
+ }
24147
24334
  if (Object.hasOwn(NATIVE_STRUCTS, param.type)) {
24148
- return NATIVE_STRUCTS[param.type].map(([field, type]) => ({
24149
- name: `${param.name}.${field}`,
24150
- type: argType(type)
24151
- }));
24335
+ return NATIVE_STRUCTS[param.type].flatMap(
24336
+ ([field, type]) => flatten({ name: `${param.name}.${field}`, type }, structs, stack)
24337
+ );
24152
24338
  }
24153
24339
  const declared = structs.find((struct) => struct?.name === param.type);
24154
24340
  if (declared) {
@@ -24160,25 +24346,12 @@ function flatten(param, structs, stack = []) {
24160
24346
  ])
24161
24347
  );
24162
24348
  }
24163
- const [element, length] = arrayParts(param.type);
24164
- if (length === 0) {
24165
- if (param.type.includes("[") || param.type.includes("]")) {
24166
- fail(`invalid array type '${param.type}'`);
24167
- }
24168
- return [{ name: param.name, type: argType(param.type) }];
24169
- }
24170
- if (Object.hasOwn(NATIVE_STRUCTS, element) || structs.some((struct) => struct.name === element)) {
24171
- fail(`arrays of structs are not supported: '${param.type}'`);
24172
- }
24173
- return Array.from({ length }, (_, index) => ({
24174
- name: `${param.name}.${index}`,
24175
- type: argType(element)
24176
- }));
24349
+ return [inputDef(param.name, param.type)];
24177
24350
  }
24178
24351
  function opcodeToken(token) {
24179
24352
  const base = token.slice(3);
24180
24353
  const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
24181
- if (!Object.hasOwn(chunkCFOIHLON_cjs.ARKADE_OPS, name)) {
24354
+ if (!Object.hasOwn(chunkYFQOJTG3_cjs.ARKADE_OPS, name)) {
24182
24355
  fail(`opcode '${token}' is not in this SDK's table`);
24183
24356
  }
24184
24357
  return name;
@@ -24220,12 +24393,21 @@ function providedWitness(witness) {
24220
24393
  if (!Array.isArray(witness)) fail("leaf witness must be an array");
24221
24394
  return witness.filter((item) => {
24222
24395
  if (!isNamed(item)) fail("witness item needs a name and a type");
24396
+ const type = argType(item.type);
24397
+ if (item.injected !== void 0 && typeof item.injected !== "boolean")
24398
+ fail(`witness '${item.name}': injected must be boolean`);
24399
+ if (item.injected && item.type !== "signature")
24400
+ fail(`witness '${item.name}': only infrastructure signatures can be injected`);
24401
+ if (item.encoding !== void 0 && item.encoding !== chunkYFQOJTG3_cjs.ARKADE_TYPE_ENCODINGS[type])
24402
+ fail(
24403
+ `witness '${item.name}': encoding '${item.encoding}' does not match type '${item.type}'`
24404
+ );
24223
24405
  return !item.injected && item.type !== "signature";
24224
24406
  });
24225
24407
  }
24226
24408
  function csvTimelock(leafName, operand) {
24227
24409
  if (typeof operand === "string") return { type: "sequence", value: operand };
24228
- const timelock = chunkVVFCCNU2_cjs.sequenceToCanonicalTimelock(operand);
24410
+ const timelock = chunkFGKBQH5S_cjs.sequenceToCanonicalTimelock(operand);
24229
24411
  if (!timelock) {
24230
24412
  fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
24231
24413
  }
@@ -24235,11 +24417,12 @@ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
24235
24417
  const asm = leaf.asm;
24236
24418
  let index = 0;
24237
24419
  let condition;
24238
- if (asm.length >= 4 && HASH_OPCODES.has(asm[0]) && asm[2] === "OP_EQUAL") {
24239
- if (asm[3] !== "OP_VERIFY")
24420
+ const hashIndex = asm[0] === "OP_SIZE" && (asm[1] === "20" || asm[1] === "32") && asm[2] === "OP_EQUALVERIFY" ? 3 : 0;
24421
+ if (HASH_OPCODES.has(asm[hashIndex]) && asm[hashIndex + 2] === "OP_EQUAL") {
24422
+ if (asm[hashIndex + 3] !== "OP_VERIFY")
24240
24423
  fail(`leaf '${leaf.name}': hash condition must end in OP_VERIFY`);
24241
- condition = asm.slice(0, 3).map((token) => asmToken(token, instantiations));
24242
- index = 4;
24424
+ condition = asm.slice(0, hashIndex + 3).map((token) => asmToken(token, instantiations));
24425
+ index = hashIndex + 4;
24243
24426
  }
24244
24427
  let csv;
24245
24428
  let cltv;
@@ -24252,10 +24435,14 @@ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
24252
24435
  }
24253
24436
  const signers = [];
24254
24437
  let emulator;
24438
+ let emulatorIndex;
24255
24439
  while (index < asm.length) {
24256
24440
  const key = asm[index];
24257
24441
  const terminator = asm[index + 1];
24258
24442
  const last = terminator === "OP_CHECKSIG";
24443
+ if (last !== (index + 2 === asm.length)) {
24444
+ fail(`leaf '${leaf.name}': only the final signer must end in OP_CHECKSIG`);
24445
+ }
24259
24446
  if (!last && terminator !== "OP_CHECKSIGVERIFY") {
24260
24447
  fail(`leaf '${leaf.name}': expected CHECKSIG after '${key}', found '${terminator}'`);
24261
24448
  }
@@ -24270,8 +24457,9 @@ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
24270
24457
  signers.push({ tweak: `$${base}`, fn });
24271
24458
  } else if (inner.startsWith("EMULATOR_KEY:")) {
24272
24459
  if (!hasCovenant) fail(`leaf '${leaf.name}': ${key} needs a covenant`);
24273
- if (!last) fail(`leaf '${leaf.name}': ${key} must be the last signer`);
24460
+ if (emulator !== void 0) fail(`leaf '${leaf.name}': duplicate emulator signer`);
24274
24461
  emulator = inner.slice("EMULATOR_KEY:".length);
24462
+ emulatorIndex = signers.length;
24275
24463
  } else signers.push(`$${inner}`);
24276
24464
  index += 2;
24277
24465
  }
@@ -24281,10 +24469,12 @@ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
24281
24469
  `leaf '${leaf.name}': covenant leaf must sign with the emulator or a tweaked constructor key`
24282
24470
  );
24283
24471
  }
24284
- if (signers.length === 0) fail(`leaf '${leaf.name}': at least one named signer is required`);
24472
+ if (signers.length === 0 && emulator === void 0)
24473
+ fail(`leaf '${leaf.name}': at least one named signer is required`);
24285
24474
  return {
24286
24475
  signers,
24287
24476
  ...emulator !== void 0 ? { emulator } : hasCovenant ? { emulator: null } : {},
24477
+ ...emulatorIndex !== void 0 ? { emulatorIndex } : {},
24288
24478
  ...condition ? { asm: condition } : {},
24289
24479
  ...csv ? { csv } : {},
24290
24480
  ...cltv !== void 0 ? { cltv } : {},
@@ -24297,21 +24487,34 @@ function programFromArtifact(artifact) {
24297
24487
  "expected a complete arkadec artifact with contractName, constructorInputs, and non-empty functions"
24298
24488
  );
24299
24489
  }
24490
+ if (artifact.formatVersion !== void 0 && artifact.formatVersion !== 1) {
24491
+ fail(`unsupported artifact format version ${artifact.formatVersion}; expected 1`);
24492
+ }
24300
24493
  const structs = artifact.structs ?? [];
24301
24494
  const structNames = /* @__PURE__ */ new Set();
24302
24495
  for (const struct of structs) {
24303
- if (!isRecord(struct) || typeof struct.name !== "string") continue;
24304
- if (Object.hasOwn(SCALAR_TYPES, struct.name) || Object.hasOwn(NATIVE_STRUCTS, struct.name)) {
24496
+ if (!isRecord(struct) || typeof struct.name !== "string" || !Array.isArray(struct.fields)) {
24497
+ fail("struct needs a name and fields array");
24498
+ }
24499
+ const fields = /* @__PURE__ */ new Set();
24500
+ for (const field of struct.fields) {
24501
+ if (!isNamed(field)) fail(`struct '${struct.name}': field needs a name and type`);
24502
+ claim(fields, field.name, "struct field");
24503
+ }
24504
+ if (Object.hasOwn(chunkYFQOJTG3_cjs.ARKADE_TYPE_ENCODINGS, struct.name) || Object.hasOwn(NATIVE_STRUCTS, struct.name)) {
24305
24505
  fail(`struct name '${struct.name}' shadows a built-in type`);
24306
24506
  }
24307
24507
  claim(structNames, struct.name, "struct");
24308
24508
  }
24309
24509
  const instantiations = /* @__PURE__ */ new Map();
24310
- const functions = {};
24510
+ const functions = /* @__PURE__ */ Object.create(null);
24311
24511
  const groups = /* @__PURE__ */ new Set();
24312
24512
  const leafNames = /* @__PURE__ */ new Set();
24313
24513
  for (const group of artifact.functions) {
24314
24514
  claim(groups, group.name, "spend group");
24515
+ if (group.arkade !== void 0 && (!isRecord(group.arkade) || !Array.isArray(group.arkade.inputs) || !Array.isArray(group.arkade.asm) || !group.arkade.asm.every((t) => typeof t === "string"))) {
24516
+ fail(`group '${group.name}': covenant needs inputs and string assembly arrays`);
24517
+ }
24315
24518
  const covenantInputs = (group.arkade?.inputs ?? []).flatMap(
24316
24519
  (input) => flatten(input, structs)
24317
24520
  );
@@ -24320,16 +24523,49 @@ function programFromArtifact(artifact) {
24320
24523
  // Covenant witness is reverse declaration order.
24321
24524
  witness: covenantInputs.map((field) => field.name).reverse()
24322
24525
  } : void 0;
24323
- for (const [index, leaf] of group.leaves.entries()) {
24324
- const name = index === 0 ? group.name : `${group.name}/${index}:${leaf.name}`;
24526
+ const covenantNames = /* @__PURE__ */ new Set();
24527
+ for (const input of covenantInputs) claim(covenantNames, input.name, "covenant input");
24528
+ for (const leaf of group.leaves) {
24529
+ if (!isRecord(leaf) || typeof leaf.name !== "string" || leaf.name.length === 0 || !Array.isArray(leaf.asm) || leaf.asm.length === 0 || !leaf.asm.every((t) => typeof t === "string")) {
24530
+ fail(`group '${group.name}': leaf needs a name and non-empty string assembly`);
24531
+ }
24532
+ const name = leaf.name;
24325
24533
  claim(leafNames, name, "function name");
24326
24534
  const extras = providedWitness(leaf.witness);
24327
- const tapscript = parseLeaf(leaf, group.arkade !== void 0, instantiations, extras);
24535
+ for (const input of extras) {
24536
+ if (leaf.asm.includes(`<${input.name}>`)) {
24537
+ fail(
24538
+ `leaf '${leaf.name}': call input '${input.name}' is a script operand; it must be a constructor binding to derive a fixed Taproot tree`
24539
+ );
24540
+ }
24541
+ }
24542
+ const witnessNames = /* @__PURE__ */ new Set();
24543
+ for (const item of leaf.witness ?? []) claim(witnessNames, item.name, "leaf witness");
24544
+ const scopedExtras = extras.map((item) => ({
24545
+ ...item,
24546
+ name: covenantNames.has(item.name) ? `tapscript:${item.name}` : item.name
24547
+ }));
24548
+ const tapscript = parseLeaf(
24549
+ leaf,
24550
+ group.arkade !== void 0,
24551
+ instantiations,
24552
+ scopedExtras
24553
+ );
24554
+ if (tapscript.emulator !== void 0 && tapscript.emulator !== null && tapscript.emulator !== group.name) {
24555
+ fail(
24556
+ `leaf '${leaf.name}': emulator covenant '${tapscript.emulator}' must match group '${group.name}'`
24557
+ );
24558
+ }
24559
+ const signatures = (leaf.witness ?? []).filter((item) => item.type === "signature" && !item.injected).map((item) => inputDef(item.name, item.type));
24560
+ if (signatures.length > 0) tapscript.signatures = signatures;
24328
24561
  const inputs = [
24329
24562
  ...covenantInputs,
24330
- ...extras.map((item) => ({ name: item.name, type: argType(item.type) }))
24563
+ ...scopedExtras.map((item) => inputDef(item.name, item.type))
24331
24564
  ];
24565
+ const inputNames = /* @__PURE__ */ new Set();
24566
+ for (const input of inputs) claim(inputNames, input.name, "function input");
24332
24567
  functions[name] = {
24568
+ group: group.name,
24333
24569
  ...inputs.length > 0 ? { inputs } : {},
24334
24570
  tapscript,
24335
24571
  ...arkadeScript ? { arkadeScript } : {}
@@ -24339,12 +24575,16 @@ function programFromArtifact(artifact) {
24339
24575
  const params = [
24340
24576
  ...artifact.constructorInputs.flatMap((input) => flatten(input, structs)),
24341
24577
  { name: "server", type: "pubkey" },
24342
- ...[...instantiations.keys()].map((name) => ({ name, type: "hash" }))
24578
+ ...Object.values(functions).some((fn) => fn.tapscript.csv?.value === "$SERVER_EXIT_DELAY") ? [{ name: "SERVER_EXIT_DELAY", type: "int" }] : [],
24579
+ ...[...instantiations.keys()].map((name) => ({
24580
+ name,
24581
+ type: "bytes32"
24582
+ }))
24343
24583
  ];
24344
24584
  const paramNames = /* @__PURE__ */ new Set();
24345
24585
  for (const param of params) claim(paramNames, param.name, "program parameter");
24346
24586
  return {
24347
- version: chunkCFOIHLON_cjs.SUPPORTED_PROGRAM_VERSION,
24587
+ version: chunkYFQOJTG3_cjs.SUPPORTED_PROGRAM_VERSION,
24348
24588
  name: artifact.contractName,
24349
24589
  params,
24350
24590
  functions
@@ -24356,6 +24596,8 @@ var Arkade = class _Arkade {
24356
24596
  emulator;
24357
24597
  network;
24358
24598
  serverKey;
24599
+ /** Bare protocol delay (blocks below 512, seconds otherwise), resolved only when needed. */
24600
+ serverExitDelay;
24359
24601
  /**
24360
24602
  * The co-signer key covenants are built against (33-byte compressed), present only when an
24361
24603
  * emulator is configured. Resolved from the network or `emulatorPubkey`, never the emulator's
@@ -24368,62 +24610,198 @@ var Arkade = class _Arkade {
24368
24610
  identity;
24369
24611
  /** The signing identity's x-only public key, resolved at connect — identifies which inputs the wallet signs. */
24370
24612
  userKey;
24371
- /** The wallet's contract manager, when contract persistence is wired up. */
24613
+ /** The contract manager, when contract persistence is wired up (passed in or owned). */
24372
24614
  contractManager;
24615
+ /** Whether {@link connect} built {@link contractManager}, so {@link dispose} must stop it. */
24616
+ ownsContractManager;
24617
+ /** {@link ArkadeContract.on} handles by contract script (hex). */
24618
+ handles = /* @__PURE__ */ new Map();
24619
+ /** The single `onContractEvent` subscription fanning out to {@link handles}. */
24620
+ unsubscribeEvents;
24621
+ disposed = false;
24373
24622
  constructor(fields) {
24374
24623
  this.arkProvider = fields.arkProvider;
24375
24624
  this.emulator = fields.emulator;
24376
24625
  this.network = fields.network;
24377
24626
  this.serverKey = fields.serverKey;
24627
+ this.serverExitDelay = fields.serverExitDelay;
24378
24628
  this.emulatorKey = fields.emulatorKey;
24379
24629
  this.checkpoint = fields.checkpoint;
24380
24630
  this.indexer = fields.indexer;
24381
24631
  this.identity = fields.identity;
24382
24632
  this.userKey = fields.userKey;
24383
24633
  this.contractManager = fields.contractManager;
24634
+ this.ownsContractManager = fields.ownsContractManager ?? false;
24384
24635
  }
24385
- /** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
24636
+ /**
24637
+ * Connect and resolve the server key, checkpoint closure and (if present) the co-signer key.
24638
+ *
24639
+ * @example
24640
+ * ```typescript
24641
+ * const arkade = await Arkade.connect({
24642
+ * service: { network: "bitcoin" },
24643
+ * identity,
24644
+ * storage: { contractRepository },
24645
+ * });
24646
+ * ```
24647
+ */
24386
24648
  static async connect(opts) {
24387
- const info = await opts.arkade.getInfo();
24388
- const serverKey = chunkCFOIHLON_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
24389
- const checkpoint = chunkVVFCCNU2_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
24390
- const network = opts.network ?? (Object.hasOwn(chunkVVFCCNU2_cjs.networks, info.network) ? chunkVVFCCNU2_cjs.getNetwork(info.network) : chunkVVFCCNU2_cjs.DEFAULT_NETWORK);
24649
+ if (opts.storage && opts.contractManager) {
24650
+ throw new Error(
24651
+ "Arkade.connect: pass either `storage` or `contractManager`, not both \u2014 `storage` builds a second manager over another repository"
24652
+ );
24653
+ }
24654
+ let arkProvider;
24655
+ let emulator;
24656
+ let indexer;
24657
+ let info;
24658
+ let resolved;
24659
+ if (opts.service) {
24660
+ resolved = await resolveArkadeService(opts.service);
24661
+ ({ arkProvider, emulator, info } = resolved);
24662
+ indexer = resolved.indexerProvider;
24663
+ } else {
24664
+ arkProvider = opts.arkade;
24665
+ emulator = opts.emulator;
24666
+ indexer = opts.indexer;
24667
+ info = await opts.arkade.getInfo();
24668
+ }
24669
+ const serverKey = chunkYFQOJTG3_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
24670
+ const checkpoint = chunkFGKBQH5S_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
24671
+ const network = opts.network ?? (Object.hasOwn(chunkFGKBQH5S_cjs.networks, info.network) ? chunkFGKBQH5S_cjs.getNetwork(info.network) : chunkFGKBQH5S_cjs.DEFAULT_NETWORK);
24391
24672
  let emulatorKey;
24392
- if (opts.emulator) {
24393
- emulatorKey = base.hex.decode(chunkVVFCCNU2_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
24673
+ if (emulator) {
24674
+ emulatorKey = base.hex.decode(chunkFGKBQH5S_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
24394
24675
  }
24395
24676
  let userKey;
24396
24677
  if (opts.identity) {
24397
- userKey = chunkCFOIHLON_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
24678
+ userKey = chunkYFQOJTG3_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
24679
+ }
24680
+ let contractManager = opts.contractManager;
24681
+ let ownsContractManager = false;
24682
+ if (resolved && opts.storage) {
24683
+ const { onchainProvider } = resolved;
24684
+ contractManager = await ContractManager.create({
24685
+ indexerProvider: resolved.indexerProvider,
24686
+ contractRepository: opts.storage.contractRepository,
24687
+ // Mandatory, and session-scoped: VTXOs are re-read from the indexer on reconnect.
24688
+ walletRepository: new InMemoryWalletRepository(),
24689
+ // Parity with the wallet-owned manager: without it every height-typed CLTV reads
24690
+ // as unsatisfied. @see ContractManagerConfig.chainTip
24691
+ chainTip: async () => {
24692
+ const { height, time } = await onchainProvider.getChainTip();
24693
+ return { height, time };
24694
+ }
24695
+ });
24696
+ ownsContractManager = true;
24398
24697
  }
24399
24698
  return new _Arkade({
24400
- arkProvider: opts.arkade,
24401
- emulator: opts.emulator,
24699
+ arkProvider,
24700
+ emulator,
24402
24701
  network,
24403
24702
  serverKey,
24703
+ serverExitDelay: info.unilateralExitDelay,
24404
24704
  emulatorKey,
24405
24705
  checkpoint,
24406
- indexer: opts.indexer,
24706
+ indexer,
24407
24707
  identity: opts.identity,
24408
24708
  userKey,
24409
- contractManager: opts.contractManager
24709
+ contractManager,
24710
+ ownsContractManager
24410
24711
  });
24411
24712
  }
24713
+ /**
24714
+ * Stop event delivery to every {@link ArkadeContract.on} handle and, when {@link connect}
24715
+ * built the contract manager (`storage`), dispose it. A caller-passed manager keeps running.
24716
+ */
24717
+ dispose() {
24718
+ this.disposed = true;
24719
+ this.unsubscribeEvents?.();
24720
+ this.unsubscribeEvents = void 0;
24721
+ this.handles.clear();
24722
+ if (this.ownsContractManager) this.contractManager?.dispose();
24723
+ }
24724
+ /**
24725
+ * @internal Add a handle for `script`, subscribing to the manager on first use; the last
24726
+ * handle's `off()` releases the subscription.
24727
+ */
24728
+ addEventHandle(manager, script, handle) {
24729
+ if (this.disposed) throw new Error("ArkadeContract.on: the Arkade client is disposed");
24730
+ let set = this.handles.get(script);
24731
+ if (!set) {
24732
+ set = /* @__PURE__ */ new Set();
24733
+ this.handles.set(script, set);
24734
+ }
24735
+ set.add(handle);
24736
+ if (!this.unsubscribeEvents) {
24737
+ this.unsubscribeEvents = manager.onContractEvent((event) => this.dispatch(event));
24738
+ }
24739
+ return () => {
24740
+ const current = this.handles.get(script);
24741
+ if (!current) return;
24742
+ current.delete(handle);
24743
+ if (current.size === 0) this.handles.delete(script);
24744
+ if (this.handles.size === 0) {
24745
+ this.unsubscribeEvents?.();
24746
+ this.unsubscribeEvents = void 0;
24747
+ }
24748
+ };
24749
+ }
24750
+ dispatch(event) {
24751
+ let targets;
24752
+ if (event.type === "connection_reset") {
24753
+ targets = [...this.handles.values()].flatMap((set) => [...set]).filter((h) => h.type === "connection_reset");
24754
+ } else if (isContractVtxoEvent(event)) {
24755
+ targets = [...this.handles.get(event.contractScript) ?? []].filter(
24756
+ (h) => h.type === event.type
24757
+ );
24758
+ } else {
24759
+ return;
24760
+ }
24761
+ const report = (error) => console.error("Error in ArkadeContract event handler:", error);
24762
+ for (const handle of targets) {
24763
+ try {
24764
+ Promise.resolve(handle.callback(event)).catch(report);
24765
+ } catch (error) {
24766
+ report(error);
24767
+ }
24768
+ }
24769
+ }
24412
24770
  /**
24413
24771
  * Instantiate a contract from a program and its constructor arguments. `const` inference keeps
24414
24772
  * the program's literal type, so `functions` is strongly typed.
24415
24773
  *
24416
- * Unbound declared `server`/`user` params default to the client's server key / identity key;
24417
- * explicit args win.
24774
+ * Declared `server`/`user` params default to the client's keys. Compiler
24775
+ * artifacts reserve the server key and exit delay to the connected server.
24418
24776
  */
24419
24777
  contract(program, args = {}) {
24420
- const declared = (program.params ?? []).map(chunkCFOIHLON_cjs.inputName);
24778
+ const declared = (program.params ?? []).map((p) => p.name);
24421
24779
  if (declared.includes("server") && args.server === void 0) {
24422
24780
  args = { ...args, server: this.serverKey };
24423
24781
  }
24424
24782
  if (declared.includes("user") && args.user === void 0 && this.userKey) {
24425
24783
  args = { ...args, user: this.userKey };
24426
24784
  }
24785
+ if (declared.includes("SERVER_EXIT_DELAY")) {
24786
+ const delay = this.serverExitDelay;
24787
+ if (delay === void 0 || delay <= 0n)
24788
+ throw new Error(
24789
+ "compiler artifact: server must provide a positive unilateral exit delay"
24790
+ );
24791
+ const typed = toTimelock(delay);
24792
+ if (typed.type === "seconds" && delay % 512n !== 0n) {
24793
+ throw new Error(
24794
+ `compiler artifact: server exit delay ${delay}s must be a multiple of 512 seconds`
24795
+ );
24796
+ }
24797
+ const sequence = BigInt(chunkFGKBQH5S_cjs.timelockToSequence(typed));
24798
+ if (args.SERVER_EXIT_DELAY !== void 0 && args.SERVER_EXIT_DELAY !== sequence && args.SERVER_EXIT_DELAY !== Number(sequence)) {
24799
+ throw new Error(
24800
+ "compiler artifact: reserved SERVER_EXIT_DELAY must match the connected server"
24801
+ );
24802
+ }
24803
+ args = { ...args, SERVER_EXIT_DELAY: sequence };
24804
+ }
24427
24805
  return new ArkadeContract(this, program, args);
24428
24806
  }
24429
24807
  };
@@ -24437,7 +24815,7 @@ var ArkadeContract = class _ArkadeContract {
24437
24815
  userKey: client.userKey,
24438
24816
  emulatorKey: client.emulatorKey
24439
24817
  };
24440
- this.vtxoScript = new chunkCFOIHLON_cjs.ArkadeProgramScript(program, args, this.keys);
24818
+ this.vtxoScript = new chunkYFQOJTG3_cjs.ArkadeProgramScript(program, args, this.keys);
24441
24819
  this.tapTree = this.vtxoScript.encode();
24442
24820
  this.compiled = this.vtxoScript.compiled;
24443
24821
  }
@@ -24462,7 +24840,7 @@ var ArkadeContract = class _ArkadeContract {
24462
24840
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
24463
24841
  );
24464
24842
  }
24465
- const typed = chunkCFOIHLON_cjs.deserializeArkadeContractParams(contract.params);
24843
+ const typed = chunkYFQOJTG3_cjs.deserializeArkadeContractParams(contract.params);
24466
24844
  return new _ArkadeContract(client, typed.program, typed.args, {
24467
24845
  serverKey: typed.serverKey,
24468
24846
  userKey: typed.userKey,
@@ -24485,7 +24863,7 @@ var ArkadeContract = class _ArkadeContract {
24485
24863
  }
24486
24864
  /** Callable spending paths: `functions.<name>(...args)` (see {@link ContractFunctions}). */
24487
24865
  get functions() {
24488
- const out = {};
24866
+ const out = /* @__PURE__ */ Object.create(null);
24489
24867
  for (const fn of this.compiled) {
24490
24868
  out[fn.name] = (...callArgs) => new ArkadeTransactionBuilder(this, fn, bindInputs(fn, callArgs));
24491
24869
  }
@@ -24498,7 +24876,7 @@ var ArkadeContract = class _ArkadeContract {
24498
24876
  toContractParams() {
24499
24877
  return {
24500
24878
  type: "arkade",
24501
- params: chunkCFOIHLON_cjs.serializeArkadeContractParams({
24879
+ params: chunkYFQOJTG3_cjs.serializeArkadeContractParams({
24502
24880
  program: this.program,
24503
24881
  args: this.args,
24504
24882
  serverKey: this.keys.serverKey,
@@ -24514,18 +24892,65 @@ var ArkadeContract = class _ArkadeContract {
24514
24892
  * counted in balances, re-derivable via the `"arkade"` handler). Idempotent per script.
24515
24893
  */
24516
24894
  async register(options) {
24517
- const manager = this.client.contractManager;
24518
- if (!manager) {
24519
- throw new Error(
24520
- "ArkadeContract.register requires a `contractManager` on the Arkade client \u2014 pass one to Arkade.connect"
24521
- );
24522
- }
24895
+ const manager = this.requireManager("register");
24523
24896
  return manager.createContract({
24524
24897
  ...this.toContractParams(),
24525
24898
  label: options?.label,
24526
24899
  metadata: options?.metadata
24527
24900
  });
24528
24901
  }
24902
+ /**
24903
+ * Report this contract's activity: `vtxo_received`/`vtxo_spent` for its script, and
24904
+ * `connection_reset` when the manager's event stream reconnects. Registers the contract
24905
+ * (idempotent) so it is persisted and watched; requires a contract manager (`storage` or
24906
+ * `contractManager` on {@link Arkade.connect}).
24907
+ *
24908
+ * Activity is reported from subscription on — coins that predate it are not replayed. After
24909
+ * subscribing, and on every `connection_reset` (the manager re-syncs silently), read stored
24910
+ * state with {@link getVtxos}.
24911
+ *
24912
+ * @example
24913
+ * ```typescript
24914
+ * const spent = await htlc.on("vtxo_spent", (e) => console.log(e.vtxos));
24915
+ * const reset = await htlc.on("connection_reset", async () => reconcile(await htlc.getVtxos()));
24916
+ * spent.off();
24917
+ * ```
24918
+ */
24919
+ async on(type, callback) {
24920
+ const manager = this.requireManager("on");
24921
+ const off = this.client.addEventHandle(manager, base.hex.encode(this.pkScript), {
24922
+ type,
24923
+ callback
24924
+ });
24925
+ try {
24926
+ await this.register();
24927
+ } catch (error) {
24928
+ off();
24929
+ throw error;
24930
+ }
24931
+ return { off };
24932
+ }
24933
+ /**
24934
+ * Every stored VTXO of this contract, spent ones included (`getUtxos` hides those), as the
24935
+ * contract manager last synced them. The recovery read for {@link on}. Empty when the
24936
+ * contract is not registered.
24937
+ */
24938
+ async getVtxos() {
24939
+ const manager = this.requireManager("getVtxos");
24940
+ const [withVtxos] = await manager.getContractsWithVtxos({
24941
+ script: base.hex.encode(this.pkScript)
24942
+ });
24943
+ return withVtxos?.vtxos ?? [];
24944
+ }
24945
+ requireManager(method) {
24946
+ const manager = this.client.contractManager;
24947
+ if (!manager) {
24948
+ throw new Error(
24949
+ `ArkadeContract.${method} requires a contract manager on the Arkade client \u2014 pass \`storage\` or \`contractManager\` to Arkade.connect`
24950
+ );
24951
+ }
24952
+ return manager;
24953
+ }
24529
24954
  /**
24530
24955
  * Spendable VTXOs locked by this contract: repository-backed when registered with a
24531
24956
  * `contractManager`, otherwise a direct indexer query. Both drop spent and unrolled outputs;
@@ -24538,17 +24963,17 @@ var ArkadeContract = class _ArkadeContract {
24538
24963
  const [registered] = await manager.getContracts({ script: scriptHex });
24539
24964
  if (registered) {
24540
24965
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
24541
- return (withVtxos?.vtxos ?? []).filter((v) => !chunkVVFCCNU2_cjs.isVtxoSpent(v) && !v.isUnrolled);
24966
+ return (withVtxos?.vtxos ?? []).filter((v) => !chunkFGKBQH5S_cjs.isVtxoSpent(v) && !v.isUnrolled);
24542
24967
  }
24543
24968
  }
24544
24969
  if (!this.client.indexer) {
24545
24970
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
24546
24971
  }
24547
- const { vtxos } = await chunkVVFCCNU2_cjs.getNormalizedVtxos(this.client.indexer, {
24972
+ const { vtxos } = await chunkFGKBQH5S_cjs.getNormalizedVtxos(this.client.indexer, {
24548
24973
  scripts: [scriptHex],
24549
24974
  spendableOnly: true
24550
24975
  });
24551
- return vtxos.filter((v) => !chunkVVFCCNU2_cjs.isVtxoSpent(v) && !v.isUnrolled);
24976
+ return vtxos.filter((v) => !chunkFGKBQH5S_cjs.isVtxoSpent(v) && !v.isUnrolled);
24552
24977
  }
24553
24978
  /** Total spendable balance (requires an indexer). */
24554
24979
  async getBalance() {
@@ -24615,6 +25040,11 @@ var ArkadeTransactionBuilder = class {
24615
25040
  }
24616
25041
  /** Assemble the unsigned ark transaction and its checkpoints. */
24617
25042
  async build() {
25043
+ if (this.fn.def.tapscript.csv) {
25044
+ throw new Error(
25045
+ `${this.fn.name}: CSV leaves require an aged onchain output; the offchain builder creates fresh checkpoints \u2014 use the wallet's unilateral exit flow`
25046
+ );
25047
+ }
24618
25048
  if (this.outputs.length === 0) {
24619
25049
  throw new Error("ArkadeTransactionBuilder: at least one output is required");
24620
25050
  }
@@ -24652,7 +25082,7 @@ var ArkadeTransactionBuilder = class {
24652
25082
  this.contract.client.checkpoint
24653
25083
  );
24654
25084
  if (coin.sourceTx) {
24655
- chunkVVFCCNU2_cjs.setArkPsbtField(arkTx, 0, chunkVVFCCNU2_cjs.PrevArkTxField, coin.sourceTx);
25085
+ chunkFGKBQH5S_cjs.setArkPsbtField(arkTx, 0, chunkFGKBQH5S_cjs.PrevArkTxField, coin.sourceTx);
24656
25086
  }
24657
25087
  if (this.fn.arkadeScript) {
24658
25088
  const indexer = this.contract.client.indexer;
@@ -24669,8 +25099,8 @@ var ArkadeTransactionBuilder = class {
24669
25099
  }
24670
25100
  const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
24671
25101
  if (condition.length > 0) {
24672
- chunkVVFCCNU2_cjs.setArkPsbtField(arkTx, 0, chunkVVFCCNU2_cjs.ConditionWitness, condition);
24673
- chunkVVFCCNU2_cjs.setArkPsbtField(checkpoints[0], 0, chunkVVFCCNU2_cjs.ConditionWitness, condition);
25102
+ chunkFGKBQH5S_cjs.setArkPsbtField(arkTx, 0, chunkFGKBQH5S_cjs.ConditionWitness, condition);
25103
+ chunkFGKBQH5S_cjs.setArkPsbtField(checkpoints[0], 0, chunkFGKBQH5S_cjs.ConditionWitness, condition);
24674
25104
  }
24675
25105
  const packets = [];
24676
25106
  if (this.assetSpecs.length > 0) {
@@ -24693,6 +25123,22 @@ var ArkadeTransactionBuilder = class {
24693
25123
  }
24694
25124
  /** Build, submit and return the finalized transaction. */
24695
25125
  async send() {
25126
+ if (this.fn.def.tapscript.signers.some(
25127
+ (signer) => typeof signer === "object" && "tweak" in signer
25128
+ )) {
25129
+ throw new Error(
25130
+ `${this.fn.name}: covenant-tweaked leaf signing is not supported by Identity; use a signer that supports the covenant tweak with build()`
25131
+ );
25132
+ }
25133
+ const { serverKey } = this.contract.keys;
25134
+ const userKey = this.contract.client.userKey;
25135
+ if (this.fn.signerKeys.some(
25136
+ (key) => !utils_js.equalBytes(key, serverKey) && (!userKey || !utils_js.equalBytes(key, userKey))
25137
+ )) {
25138
+ throw new Error(
25139
+ `${this.fn.name}: external leaf signatures are required; use build() and sign the PSBT with all required signers`
25140
+ );
25141
+ }
24696
25142
  const { arkTx, checkpoints } = await this.build();
24697
25143
  const client = this.contract.client;
24698
25144
  const userInputs = this.userInputIndexes();
@@ -24744,7 +25190,7 @@ var ArkadeTransactionBuilder = class {
24744
25190
  /** Indexes of inputs the client owns and must sign (contract input + funded inputs). */
24745
25191
  userInputIndexes() {
24746
25192
  const idxs = [];
24747
- const userKey = this.contract.keys.userKey;
25193
+ const userKey = this.contract.client.userKey;
24748
25194
  if (userKey && this.fn.signerKeys.some((k) => utils_js.equalBytes(k, userKey))) {
24749
25195
  idxs.push(0);
24750
25196
  }
@@ -24762,28 +25208,35 @@ var ArkadeTransactionBuilder = class {
24762
25208
  }
24763
25209
  buildAssetPacket() {
24764
25210
  const groups = this.assetSpecs.map((s) => {
24765
- const id = typeof s.assetId === "string" ? chunkFEBAG2K2_cjs.AssetId.fromString(s.assetId) : chunkFEBAG2K2_cjs.AssetId.fromBytes(s.assetId);
24766
- return chunkFEBAG2K2_cjs.AssetGroup.create(
25211
+ const id = typeof s.assetId === "string" ? chunk6BJJ47JM_cjs.AssetId.fromString(s.assetId) : chunk6BJJ47JM_cjs.AssetId.fromBytes(s.assetId);
25212
+ return chunk6BJJ47JM_cjs.AssetGroup.create(
24767
25213
  id,
24768
25214
  null,
24769
- s.inputs.map((i) => chunkFEBAG2K2_cjs.AssetInput.create(i.vin, i.amount)),
24770
- s.outputs.map((o) => chunkFEBAG2K2_cjs.AssetOutput.create(o.vout, o.amount)),
24771
- (s.metadata ?? []).map((m) => chunkFEBAG2K2_cjs.Metadata.create(m.key, m.value))
25215
+ s.inputs.map((i) => chunk6BJJ47JM_cjs.AssetInput.create(i.vin, i.amount)),
25216
+ s.outputs.map((o) => chunk6BJJ47JM_cjs.AssetOutput.create(o.vout, o.amount)),
25217
+ (s.metadata ?? []).map((m) => chunk6BJJ47JM_cjs.Metadata.create(m.key, m.value))
24772
25218
  );
24773
25219
  });
24774
- return chunkFEBAG2K2_cjs.Packet.create(groups);
25220
+ return chunk6BJJ47JM_cjs.Packet.create(groups);
24775
25221
  }
24776
25222
  witnessBytes(ref) {
24777
- return chunkCFOIHLON_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
25223
+ return chunkYFQOJTG3_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
24778
25224
  }
24779
25225
  };
24780
25226
  function bindInputs(fn, callArgs) {
24781
- const names = (fn.def.inputs ?? []).map(chunkCFOIHLON_cjs.inputName);
24782
- if (callArgs.length !== names.length) {
24783
- throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
25227
+ const inputs = fn.def.inputs ?? [];
25228
+ if (callArgs.length !== inputs.length) {
25229
+ throw new Error(
25230
+ `${fn.name}: expected ${inputs.length} argument(s), got ${callArgs.length}`
25231
+ );
24784
25232
  }
24785
- const bound = {};
24786
- names.forEach((n, i) => bound[n] = callArgs[i]);
25233
+ const bound = /* @__PURE__ */ Object.create(null);
25234
+ inputs.forEach((def, i) => {
25235
+ if (Object.hasOwn(bound, def.name))
25236
+ throw new Error(`${fn.name}: duplicate input '${def.name}'`);
25237
+ chunkYFQOJTG3_cjs.validateParamValue(def, callArgs[i]);
25238
+ bound[def.name] = callArgs[i];
25239
+ });
24787
25240
  return bound;
24788
25241
  }
24789
25242
  function attachExtension(tx, newPackets) {
@@ -25192,17 +25645,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
25192
25645
  function offchainInputFees(vtxos, fees) {
25193
25646
  const estimator = new Estimator(fees?.intentFee ?? {});
25194
25647
  return vtxos.reduce(
25195
- (total, vtxo) => total + estimator.evalOffchainInput(chunkVVFCCNU2_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
25648
+ (total, vtxo) => total + estimator.evalOffchainInput(chunkFGKBQH5S_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
25196
25649
  0
25197
25650
  );
25198
25651
  }
25199
25652
  async function changeOutputFee(wallet, inputs, needed, fees) {
25200
25653
  const estimator = new Estimator(fees?.intentFee ?? {});
25201
25654
  const net = inputs.reduce(
25202
- (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkVVFCCNU2_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
25655
+ (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkFGKBQH5S_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
25203
25656
  0n
25204
25657
  );
25205
- const script = base.hex.encode(chunkVVFCCNU2_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
25658
+ const script = base.hex.encode(chunkFGKBQH5S_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
25206
25659
  return changeAfterOutputFee(
25207
25660
  net - needed,
25208
25661
  (amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
@@ -25276,6 +25729,7 @@ exports.AbortError = AbortError;
25276
25729
  exports.ActivityRegistry = ActivityRegistry;
25277
25730
  exports.AmbiguousRouteError = AmbiguousRouteError;
25278
25731
  exports.ArkNote = ArkNote;
25732
+ exports.Arkade = Arkade;
25279
25733
  exports.ArkadeCash = ArkadeCash;
25280
25734
  exports.ArkadeCashCreateError = ArkadeCashCreateError;
25281
25735
  exports.ArkadeCashOperatorMismatchError = ArkadeCashOperatorMismatchError;
@@ -25510,5 +25964,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
25510
25964
  exports.walletFeeSource = walletFeeSource;
25511
25965
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
25512
25966
  exports.withPrevTxs = withPrevTxs;
25513
- //# sourceMappingURL=chunk-B2YMUJD5.cjs.map
25514
- //# sourceMappingURL=chunk-B2YMUJD5.cjs.map
25967
+ //# sourceMappingURL=chunk-4BT6HBZQ.cjs.map
25968
+ //# sourceMappingURL=chunk-4BT6HBZQ.cjs.map