@arkade-os/sdk 0.5.0-rc.4 → 0.5.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/adapters/expo.cjs +5 -5
  2. package/dist/adapters/expo.d.cts +2 -2
  3. package/dist/adapters/expo.d.ts +2 -2
  4. package/dist/adapters/expo.js +3 -3
  5. package/dist/{asyncStorageTaskQueue-CTIwKrt5.d.cts → asyncStorageTaskQueue-BHOhjFiF.d.cts} +2 -2
  6. package/dist/{asyncStorageTaskQueue-BCiOgs5x.d.ts → asyncStorageTaskQueue-BedBOEpT.d.ts} +2 -2
  7. package/dist/{chunk-GLZNJFAT.js → chunk-2P75JIT5.js} +30 -5
  8. package/dist/chunk-2P75JIT5.js.map +1 -0
  9. package/dist/{chunk-5NLJUXXQ.cjs → chunk-3LGOKP52.cjs} +10 -10
  10. package/dist/{chunk-5NLJUXXQ.cjs.map → chunk-3LGOKP52.cjs.map} +1 -1
  11. package/dist/{chunk-ZHLYFRYY.cjs → chunk-4I6KPFCB.cjs} +811 -495
  12. package/dist/chunk-4I6KPFCB.cjs.map +1 -0
  13. package/dist/{chunk-CIBGIZUW.js → chunk-7PW4GV2Q.js} +4 -4
  14. package/dist/{chunk-CIBGIZUW.js.map → chunk-7PW4GV2Q.js.map} +1 -1
  15. package/dist/{chunk-GPJSGLWM.cjs → chunk-BMYEJA3W.cjs} +21 -17
  16. package/dist/chunk-BMYEJA3W.cjs.map +1 -0
  17. package/dist/{chunk-MOWSLXGO.js → chunk-BWHKCHJN.js} +8 -4
  18. package/dist/chunk-BWHKCHJN.js.map +1 -0
  19. package/dist/{chunk-XHASFSDU.js → chunk-IRXEWL2A.js} +37 -11
  20. package/dist/chunk-IRXEWL2A.js.map +1 -0
  21. package/dist/{chunk-PYTAH2NY.js → chunk-ISA3HWFN.js} +388 -73
  22. package/dist/chunk-ISA3HWFN.js.map +1 -0
  23. package/dist/{chunk-4EZOMPAO.js → chunk-QKHXUTXM.js} +3 -3
  24. package/dist/{chunk-4EZOMPAO.js.map → chunk-QKHXUTXM.js.map} +1 -1
  25. package/dist/{chunk-SYRQJS5N.cjs → chunk-TVG3GDEO.cjs} +52 -26
  26. package/dist/chunk-TVG3GDEO.cjs.map +1 -0
  27. package/dist/{chunk-C5Y2R63Z.cjs → chunk-XR23C6TF.cjs} +30 -4
  28. package/dist/chunk-XR23C6TF.cjs.map +1 -0
  29. package/dist/{chunk-F7HJO5GT.cjs → chunk-ZF52B7BV.cjs} +50 -50
  30. package/dist/{chunk-F7HJO5GT.cjs.map → chunk-ZF52B7BV.cjs.map} +1 -1
  31. package/dist/contracts/handlers/index.cjs +9 -9
  32. package/dist/contracts/handlers/index.d.cts +3 -3
  33. package/dist/contracts/handlers/index.d.ts +3 -3
  34. package/dist/contracts/handlers/index.js +2 -2
  35. package/dist/{delegate-CpQIgTs7.d.cts → delegate-Dv8aEvSp.d.cts} +1 -1
  36. package/dist/{delegate-Dv-us16c.d.ts → delegate-Hl92NVgS.d.ts} +1 -1
  37. package/dist/{hdWalletCapable-BC4Fmmht.d.ts → hdWalletCapable-Bqcb-XtC.d.ts} +2 -2
  38. package/dist/{hdWalletCapable-DotEa5rZ.d.cts → hdWalletCapable-QiCK1B9d.d.cts} +2 -2
  39. package/dist/{index-DUkvXxpt.d.ts → index-BwEO0Yb-.d.ts} +2 -2
  40. package/dist/{index-DdJt5fRc.d.cts → index-CeC9FiJt.d.cts} +2 -2
  41. package/dist/{index-Czz9HSqE.d.cts → index-F-X4BWxi.d.cts} +136 -5
  42. package/dist/{index-Czz9HSqE.d.ts → index-F-X4BWxi.d.ts} +136 -5
  43. package/dist/index.cjs +296 -288
  44. package/dist/index.d.cts +83 -12
  45. package/dist/index.d.ts +83 -12
  46. package/dist/index.js +4 -4
  47. package/dist/repositories/realm/index.cjs +20 -20
  48. package/dist/repositories/realm/index.d.cts +2 -2
  49. package/dist/repositories/realm/index.d.ts +2 -2
  50. package/dist/repositories/realm/index.js +5 -5
  51. package/dist/repositories/sqlite/index.cjs +19 -19
  52. package/dist/repositories/sqlite/index.d.cts +2 -2
  53. package/dist/repositories/sqlite/index.d.ts +2 -2
  54. package/dist/repositories/sqlite/index.js +5 -5
  55. package/dist/{taskRunner-DUId1UJ8.d.ts → taskRunner-BdU_d__J.d.ts} +2 -2
  56. package/dist/{taskRunner-7E_Rx8bD.d.cts → taskRunner-CDCz7MTW.d.cts} +2 -2
  57. package/dist/wallet/expo/background.cjs +14 -14
  58. package/dist/wallet/expo/background.d.cts +3 -3
  59. package/dist/wallet/expo/background.d.ts +3 -3
  60. package/dist/wallet/expo/background.js +6 -6
  61. package/dist/wallet/expo/index.cjs +14 -14
  62. package/dist/wallet/expo/index.d.cts +4 -4
  63. package/dist/wallet/expo/index.d.ts +4 -4
  64. package/dist/wallet/expo/index.js +5 -5
  65. package/dist/worker/expo/index.cjs +9 -9
  66. package/dist/worker/expo/index.d.cts +4 -4
  67. package/dist/worker/expo/index.d.ts +4 -4
  68. package/dist/worker/expo/index.js +5 -5
  69. package/package.json +1 -1
  70. package/dist/chunk-C5Y2R63Z.cjs.map +0 -1
  71. package/dist/chunk-GLZNJFAT.js.map +0 -1
  72. package/dist/chunk-GPJSGLWM.cjs.map +0 -1
  73. package/dist/chunk-MOWSLXGO.js.map +0 -1
  74. package/dist/chunk-PYTAH2NY.js.map +0 -1
  75. package/dist/chunk-SYRQJS5N.cjs.map +0 -1
  76. package/dist/chunk-XHASFSDU.js.map +0 -1
  77. package/dist/chunk-ZHLYFRYY.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkSYRQJS5N_cjs = require('./chunk-SYRQJS5N.cjs');
4
- var chunkF7HJO5GT_cjs = require('./chunk-F7HJO5GT.cjs');
5
- var chunkC5Y2R63Z_cjs = require('./chunk-C5Y2R63Z.cjs');
3
+ var chunkTVG3GDEO_cjs = require('./chunk-TVG3GDEO.cjs');
4
+ var chunkZF52B7BV_cjs = require('./chunk-ZF52B7BV.cjs');
5
+ var chunkXR23C6TF_cjs = require('./chunk-XR23C6TF.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 = chunkC5Y2R63Z_cjs.getArkPsbtFields(tx.root, 0, chunkC5Y2R63Z_cjs.CosignerPublicKey).map(
190
+ const cosigners = chunkXR23C6TF_cjs.getArkPsbtFields(tx.root, 0, chunkXR23C6TF_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 = chunkC5Y2R63Z_cjs.getArkPsbtFields(g.root, 0, chunkC5Y2R63Z_cjs.CosignerPublicKey).map((c) => c.key);
242
+ const cosigners = chunkXR23C6TF_cjs.getArkPsbtFields(g.root, 0, chunkXR23C6TF_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
- chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
325
+ chunkXR23C6TF_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");
@@ -431,7 +431,7 @@ var SeedIdentity = class _SeedIdentity {
431
431
  let network;
432
432
  if ("descriptor" in opts && typeof opts.descriptor === "string") {
433
433
  descriptor = opts.descriptor;
434
- network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
434
+ network = chunkZF52B7BV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
435
435
  } else {
436
436
  network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
437
437
  descriptor = descriptorsScure.scriptExpressions.trBIP32({
@@ -521,7 +521,7 @@ var SeedIdentity = class _SeedIdentity {
521
521
  }
522
522
  /** Returns true when `descriptor` is derived from this identity's seed. */
523
523
  ownsDescriptor(descriptor) {
524
- return chunkF7HJO5GT_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
524
+ return chunkZF52B7BV_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
525
525
  }
526
526
  /**
527
527
  * Signs each request with the key derived from its descriptor.
@@ -560,7 +560,7 @@ var SeedIdentity = class _SeedIdentity {
560
560
  }
561
561
  // ── internal helpers ─────────────────────────────────────────────
562
562
  derivePrivateKeyForDescriptor(descriptor) {
563
- const network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
563
+ const network = chunkZF52B7BV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
564
564
  const expansion = descriptorsScure.expand({ descriptor, network });
565
565
  if (expansion.isRanged) {
566
566
  throw new Error(
@@ -585,7 +585,7 @@ var SeedIdentity = class _SeedIdentity {
585
585
  signTxWithKey(tx, key, inputIndexes) {
586
586
  const txCpy = tx.clone();
587
587
  if (!inputIndexes) {
588
- chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
588
+ chunkXR23C6TF_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
589
589
  try {
590
590
  if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
591
591
  throw new Error("Failed to sign transaction");
@@ -647,7 +647,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
647
647
  */
648
648
  descriptor;
649
649
  constructor(descriptor) {
650
- const network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
650
+ const network = chunkZF52B7BV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
651
651
  let expansion;
652
652
  try {
653
653
  expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
@@ -688,7 +688,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
688
688
  }
689
689
  /** Returns true when `descriptor` derives from this identity's xpub. */
690
690
  ownsDescriptor(descriptor) {
691
- return chunkF7HJO5GT_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
691
+ return chunkZF52B7BV_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
692
692
  }
693
693
  };
694
694
  function serializeSeedOwnedSigningIdentity(identity) {
@@ -834,10 +834,10 @@ var DescriptorIdentity = class {
834
834
  this.base = base;
835
835
  }
836
836
  async xOnlyPublicKey() {
837
- return chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(this.descriptor);
837
+ return chunkZF52B7BV_cjs.deriveDescriptorLeafPubKey(this.descriptor);
838
838
  }
839
839
  async compressedPublicKey() {
840
- return chunkF7HJO5GT_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
840
+ return chunkZF52B7BV_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
841
841
  }
842
842
  async sign(tx, inputIndexes) {
843
843
  const [signed] = await this.signer.signWithDescriptor([
@@ -910,12 +910,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
910
910
  signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
911
911
  } : void 0;
912
912
  const owner = providerOwner ?? identityOwner;
913
- if (owner && chunkF7HJO5GT_cjs.parseHDDescriptor(descriptor)) {
913
+ if (owner && chunkZF52B7BV_cjs.parseHDDescriptor(descriptor)) {
914
914
  return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
915
915
  }
916
916
  let key;
917
917
  try {
918
- key = chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor);
918
+ key = chunkZF52B7BV_cjs.deriveDescriptorLeafPubKey(descriptor);
919
919
  } catch {
920
920
  throw new ForeignDescriptorError(descriptor);
921
921
  }
@@ -1290,14 +1290,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
1290
1290
  }
1291
1291
  var PREIMAGE_INDEX = 0;
1292
1292
  function isPerArtifactDescriptor(descriptor) {
1293
- return chunkF7HJO5GT_cjs.parseHDDescriptor(descriptor) !== null;
1293
+ return chunkZF52B7BV_cjs.parseHDDescriptor(descriptor) !== null;
1294
1294
  }
1295
1295
  async function provisionDescriptor(wallet) {
1296
1296
  const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
1297
- return allocated ?? await chunkF7HJO5GT_cjs.identityDescriptor(wallet.identity);
1297
+ return allocated ?? await chunkZF52B7BV_cjs.identityDescriptor(wallet.identity);
1298
1298
  }
1299
1299
  async function provisionRefundKey(wallet) {
1300
- const descriptor = await chunkF7HJO5GT_cjs.identityDescriptor(wallet.identity);
1300
+ const descriptor = await chunkZF52B7BV_cjs.identityDescriptor(wallet.identity);
1301
1301
  const signer = await contractSigner(wallet, descriptor);
1302
1302
  const pubkey = await signer.xOnlyPublicKey();
1303
1303
  const identityPubkey = await wallet.identity.xOnlyPublicKey();
@@ -1307,7 +1307,7 @@ async function provisionRefundKey(wallet) {
1307
1307
  );
1308
1308
  }
1309
1309
  const address = await wallet.getAddress();
1310
- const { pkScript } = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
1310
+ const { pkScript } = chunkXR23C6TF_cjs.ArkAddress.decode(address);
1311
1311
  return { descriptor, pubkey, pkScript, address };
1312
1312
  }
1313
1313
  async function provisionClaimSecret(wallet, opts = {}) {
@@ -1353,7 +1353,7 @@ async function contractSigner(wallet, descriptor) {
1353
1353
  const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
1354
1354
  let expected;
1355
1355
  try {
1356
- expected = chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor);
1356
+ expected = chunkZF52B7BV_cjs.deriveDescriptorLeafPubKey(descriptor);
1357
1357
  } catch (cause) {
1358
1358
  throw new ForeignDescriptorError(descriptor, { cause });
1359
1359
  }
@@ -1572,14 +1572,14 @@ var RestDelegateProvider = class {
1572
1572
  */
1573
1573
  async delegate(intent, forfeitTxs, options) {
1574
1574
  const url = `${this.url}/v1/delegate`;
1575
- const response = await chunkC5Y2R63Z_cjs.baseFetch(url, {
1575
+ const response = await chunkXR23C6TF_cjs.baseFetch(url, {
1576
1576
  method: "POST",
1577
1577
  headers: {
1578
1578
  "Content-Type": "application/json"
1579
1579
  },
1580
1580
  body: JSON.stringify({
1581
1581
  intent: {
1582
- message: chunkC5Y2R63Z_cjs.Intent.encodeMessage(intent.message),
1582
+ message: chunkXR23C6TF_cjs.Intent.encodeMessage(intent.message),
1583
1583
  proof: intent.proof
1584
1584
  },
1585
1585
  forfeit_txs: forfeitTxs,
@@ -1599,7 +1599,7 @@ var RestDelegateProvider = class {
1599
1599
  */
1600
1600
  async getDelegateInfo() {
1601
1601
  const url = `${this.url}/v1/delegator/info`;
1602
- const response = await chunkC5Y2R63Z_cjs.rateGate.runHttp(url, () => chunkC5Y2R63Z_cjs.baseFetch(url));
1602
+ const response = await chunkXR23C6TF_cjs.rateGate.runHttp(url, () => chunkXR23C6TF_cjs.baseFetch(url));
1603
1603
  if (!response.ok) {
1604
1604
  const errorText2 = await response.text();
1605
1605
  throw new Error(`Failed to get delegate info: ${errorText2}`);
@@ -1622,7 +1622,7 @@ var ESPLORA_URL = {
1622
1622
  regtest: "http://localhost:3000/api"
1623
1623
  };
1624
1624
  var EsploraProvider = class {
1625
- constructor(baseUrl = ESPLORA_URL[chunkC5Y2R63Z_cjs.DEFAULT_NETWORK_NAME], opts) {
1625
+ constructor(baseUrl = ESPLORA_URL[chunkXR23C6TF_cjs.DEFAULT_NETWORK_NAME], opts) {
1626
1626
  this.baseUrl = baseUrl;
1627
1627
  this.pollingInterval = opts?.pollingInterval ?? 15e3;
1628
1628
  this.forcePolling = opts?.forcePolling ?? false;
@@ -1641,14 +1641,14 @@ var EsploraProvider = class {
1641
1641
  */
1642
1642
  addressWatches = /* @__PURE__ */ new Map();
1643
1643
  async getCoins(address) {
1644
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1644
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1645
1645
  if (!response.ok) {
1646
1646
  throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
1647
1647
  }
1648
1648
  return response.json();
1649
1649
  }
1650
1650
  async getFeeRate() {
1651
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1651
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1652
1652
  if (response.status === 404) {
1653
1653
  return void 0;
1654
1654
  }
@@ -1669,7 +1669,7 @@ var EsploraProvider = class {
1669
1669
  }
1670
1670
  }
1671
1671
  async getTxOutspends(txid) {
1672
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1672
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1673
1673
  if (!response.ok) {
1674
1674
  const error = await response.text();
1675
1675
  throw new Error(`Failed to get transaction outspends: ${error}`);
@@ -1677,7 +1677,7 @@ var EsploraProvider = class {
1677
1677
  return response.json();
1678
1678
  }
1679
1679
  async getTransactions(address) {
1680
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1680
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1681
1681
  if (!response.ok) {
1682
1682
  const error = await response.text();
1683
1683
  throw new Error(`Failed to get transactions: ${error}`);
@@ -1690,14 +1690,14 @@ var EsploraProvider = class {
1690
1690
  * usable as a change probe for the polling fallback.
1691
1691
  */
1692
1692
  async getAddressStats(address) {
1693
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1693
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1694
1694
  if (!response.ok) {
1695
1695
  throw new Error(`Failed to get address stats: ${response.statusText}`);
1696
1696
  }
1697
1697
  return response.json();
1698
1698
  }
1699
1699
  async getRawTransaction(txid) {
1700
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1700
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1701
1701
  if (!response.ok) {
1702
1702
  const error = await response.text();
1703
1703
  throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
@@ -1705,7 +1705,7 @@ var EsploraProvider = class {
1705
1705
  return base.hex.decode((await response.text()).trim());
1706
1706
  }
1707
1707
  async getTxStatus(txid) {
1708
- const txresponse = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1708
+ const txresponse = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1709
1709
  if (!txresponse.ok) {
1710
1710
  throw new Error(txresponse.statusText);
1711
1711
  }
@@ -1713,7 +1713,7 @@ var EsploraProvider = class {
1713
1713
  if (!tx.status.confirmed) {
1714
1714
  return { confirmed: false };
1715
1715
  }
1716
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1716
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1717
1717
  if (!response.ok) {
1718
1718
  throw new Error(`Failed to get transaction status: ${response.statusText}`);
1719
1719
  }
@@ -1997,9 +1997,9 @@ var EsploraProvider = class {
1997
1997
  return { subscribers, teardown, started };
1998
1998
  }
1999
1999
  async getChainTip() {
2000
- let tipBlocks = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/blocks`);
2000
+ let tipBlocks = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/blocks`);
2001
2001
  if (tipBlocks.status === 404) {
2002
- tipBlocks = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2002
+ tipBlocks = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2003
2003
  }
2004
2004
  if (!tipBlocks.ok) {
2005
2005
  throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
@@ -2021,7 +2021,7 @@ var EsploraProvider = class {
2021
2021
  };
2022
2022
  }
2023
2023
  async broadcastPackage(parent, child) {
2024
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2024
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2025
2025
  method: "POST",
2026
2026
  headers: {
2027
2027
  "Content-Type": "application/json"
@@ -2037,7 +2037,7 @@ var EsploraProvider = class {
2037
2037
  return result;
2038
2038
  }
2039
2039
  async broadcastTx(tx) {
2040
- const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx`, {
2040
+ const response = await chunkXR23C6TF_cjs.baseFetch(`${this.baseUrl}/tx`, {
2041
2041
  method: "POST",
2042
2042
  headers: {
2043
2043
  "Content-Type": "text/plain"
@@ -2220,7 +2220,7 @@ function findP2AOutput(tx) {
2220
2220
  var CHILD_DUST_AMOUNT = 546;
2221
2221
  function buildAnchorChild(params) {
2222
2222
  const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
2223
- const child = new chunkC5Y2R63Z_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2223
+ const child = new chunkXR23C6TF_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2224
2224
  child.addInput(findP2AOutput(parent));
2225
2225
  const estimator = TxWeightEstimator.create().addP2AInput();
2226
2226
  for (const _ of fundingCoins) {
@@ -2268,7 +2268,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
2268
2268
  );
2269
2269
  }
2270
2270
  function buildForfeitTxWithOutput(inputs, output, txLocktime) {
2271
- const tx = new chunkC5Y2R63Z_cjs.Transaction({
2271
+ const tx = new chunkXR23C6TF_cjs.Transaction({
2272
2272
  version: 3,
2273
2273
  lockTime: txLocktime
2274
2274
  });
@@ -2344,7 +2344,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2344
2344
  if (previousScriptKey.length !== 32) {
2345
2345
  throw new Error(`parent output ${childIndex} has invalid script`);
2346
2346
  }
2347
- const cosigners = chunkC5Y2R63Z_cjs.getArkPsbtFields(child.root, 0, chunkC5Y2R63Z_cjs.CosignerPublicKey);
2347
+ const cosigners = chunkXR23C6TF_cjs.getArkPsbtFields(child.root, 0, chunkXR23C6TF_cjs.CosignerPublicKey);
2348
2348
  if (cosigners.length === 0) {
2349
2349
  throw ErrMissingCosignersPublicKeys;
2350
2350
  }
@@ -2402,7 +2402,7 @@ var EmulatorPacket = class _EmulatorPacket {
2402
2402
  return new _EmulatorPacket(entries);
2403
2403
  }
2404
2404
  static fromBytes(data) {
2405
- const reader = new chunkSYRQJS5N_cjs.BufferReader(data);
2405
+ const reader = new chunkTVG3GDEO_cjs.BufferReader(data);
2406
2406
  const entryCount = reader.readCompactSize();
2407
2407
  const entries = [];
2408
2408
  for (let i = 0; i < entryCount; i++) {
@@ -2420,7 +2420,7 @@ var EmulatorPacket = class _EmulatorPacket {
2420
2420
  return _EmulatorPacket.PACKET_TYPE;
2421
2421
  }
2422
2422
  serialize() {
2423
- const writer = new chunkSYRQJS5N_cjs.BufferWriter();
2423
+ const writer = new chunkTVG3GDEO_cjs.BufferWriter();
2424
2424
  writer.writeCompactSize(this.entries.length);
2425
2425
  for (const entry of this.entries) {
2426
2426
  writer.writeUint16LE(entry.vin);
@@ -2507,7 +2507,7 @@ var Extension = class _Extension {
2507
2507
  `expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
2508
2508
  );
2509
2509
  }
2510
- const reader = new chunkSYRQJS5N_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2510
+ const reader = new chunkTVG3GDEO_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2511
2511
  const packets = [];
2512
2512
  while (reader.remaining() > 0) {
2513
2513
  const packetType = reader.readByte();
@@ -2581,7 +2581,7 @@ var Extension = class _Extension {
2581
2581
  */
2582
2582
  getAssetPacket() {
2583
2583
  for (const p of this.packets) {
2584
- if (p instanceof chunkSYRQJS5N_cjs.Packet) {
2584
+ if (p instanceof chunkTVG3GDEO_cjs.Packet) {
2585
2585
  return p;
2586
2586
  }
2587
2587
  }
@@ -2619,8 +2619,8 @@ var Extension = class _Extension {
2619
2619
  };
2620
2620
  function parsePacket(packetType, data) {
2621
2621
  switch (packetType) {
2622
- case chunkSYRQJS5N_cjs.Packet.PACKET_TYPE:
2623
- return chunkSYRQJS5N_cjs.Packet.fromBytes(data);
2622
+ case chunkTVG3GDEO_cjs.Packet.PACKET_TYPE:
2623
+ return chunkTVG3GDEO_cjs.Packet.fromBytes(data);
2624
2624
  case EmulatorPacket.PACKET_TYPE:
2625
2625
  return EmulatorPacket.fromBytes(data);
2626
2626
  default:
@@ -2667,16 +2667,16 @@ function buildOpReturnScript(data) {
2667
2667
  }
2668
2668
  return script;
2669
2669
  }
2670
- var ErrOffchainOutputNotFound = (address) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2671
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
2670
+ var ErrOffchainOutputNotFound = (address) => new chunkXR23C6TF_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2671
+ var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkXR23C6TF_cjs.ServerResponseMismatchError(
2672
2672
  `invalid asset output amount for ${assetId}: got ${got}, want ${want}`
2673
2673
  );
2674
- var ErrAssetGroupNotFound = (assetId) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2675
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
2674
+ var ErrAssetGroupNotFound = (assetId) => new chunkXR23C6TF_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2675
+ var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkXR23C6TF_cjs.ServerResponseMismatchError(
2676
2676
  `asset output not found in asset group ${assetId} at index ${outputIndex}`
2677
2677
  );
2678
- var ErrOnchainOutputNotFound = (address) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2679
- var ErrUnvalidatedOffchainOutput = (address) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
2678
+ var ErrOnchainOutputNotFound = (address) => new chunkXR23C6TF_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2679
+ var ErrUnvalidatedOffchainOutput = (address) => new chunkXR23C6TF_cjs.ServerResponseMismatchError(
2680
2680
  `offchain output ${address} cannot be validated: virtual output tree signing did not run`
2681
2681
  );
2682
2682
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
@@ -2685,7 +2685,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
2685
2685
  function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
2686
2686
  if (!validatedCommitmentTxid) return;
2687
2687
  if (finalCommitmentTx.id === validatedCommitmentTxid) return;
2688
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
2688
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
2689
2689
  `${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
2690
2690
  );
2691
2691
  }
@@ -2695,7 +2695,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
2695
2695
  for (const recipient of recipients) {
2696
2696
  let arkAddress;
2697
2697
  try {
2698
- arkAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(recipient.address);
2698
+ arkAddress = chunkXR23C6TF_cjs.ArkAddress.decode(recipient.address);
2699
2699
  } catch {
2700
2700
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2701
2701
  continue;
@@ -2707,7 +2707,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2707
2707
  const usedOnchainOutputs = /* @__PURE__ */ new Set();
2708
2708
  for (const recipient of recipients) {
2709
2709
  try {
2710
- chunkC5Y2R63Z_cjs.ArkAddress.decode(recipient.address);
2710
+ chunkXR23C6TF_cjs.ArkAddress.decode(recipient.address);
2711
2711
  } catch {
2712
2712
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2713
2713
  continue;
@@ -2940,7 +2940,7 @@ function assetMintResolver() {
2940
2940
  if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
2941
2941
  const minted = tx.assets.filter((a) => {
2942
2942
  try {
2943
- return base.hex.encode(chunkSYRQJS5N_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
2943
+ return base.hex.encode(chunkTVG3GDEO_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
2944
2944
  } catch {
2945
2945
  return false;
2946
2946
  }
@@ -2983,7 +2983,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
2983
2983
  const existing = inputsByAssetId.get(asset.assetId);
2984
2984
  inputsByAssetId.set(asset.assetId, [
2985
2985
  ...existing ?? [],
2986
- chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount)
2986
+ chunkTVG3GDEO_cjs.AssetInput.create(inputIndex, asset.amount)
2987
2987
  ]);
2988
2988
  }
2989
2989
  }
@@ -2995,7 +2995,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
2995
2995
  const existing = outputsByAssetId.get(asset.assetId);
2996
2996
  outputsByAssetId.set(asset.assetId, [
2997
2997
  ...existing ?? [],
2998
- chunkSYRQJS5N_cjs.AssetOutput.create(outputIndex, asset.amount)
2998
+ chunkTVG3GDEO_cjs.AssetOutput.create(outputIndex, asset.amount)
2999
2999
  ]);
3000
3000
  }
3001
3001
  }
@@ -3006,7 +3006,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3006
3006
  const existing = outputsByAssetId.get(asset.assetId);
3007
3007
  outputsByAssetId.set(asset.assetId, [
3008
3008
  ...existing ?? [],
3009
- chunkSYRQJS5N_cjs.AssetOutput.create(outputIndex, asset.amount)
3009
+ chunkTVG3GDEO_cjs.AssetOutput.create(outputIndex, asset.amount)
3010
3010
  ]);
3011
3011
  }
3012
3012
  }
@@ -3015,11 +3015,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3015
3015
  for (const assetIdStr of allAssetIds) {
3016
3016
  const inputs = inputsByAssetId.get(assetIdStr);
3017
3017
  const outputs = outputsByAssetId.get(assetIdStr);
3018
- const assetId = chunkSYRQJS5N_cjs.AssetId.fromString(assetIdStr);
3019
- const group = chunkSYRQJS5N_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3018
+ const assetId = chunkTVG3GDEO_cjs.AssetId.fromString(assetIdStr);
3019
+ const group = chunkTVG3GDEO_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3020
3020
  groups.push(group);
3021
3021
  }
3022
- return chunkSYRQJS5N_cjs.Packet.create(groups);
3022
+ return chunkTVG3GDEO_cjs.Packet.create(groups);
3023
3023
  }
3024
3024
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
3025
3025
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -3056,7 +3056,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
3056
3056
  }
3057
3057
  function toXOnlySignerHex(pubkeyHex) {
3058
3058
  const bytes = base.hex.decode(pubkeyHex);
3059
- if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(bytes, "signer key"));
3059
+ if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkZF52B7BV_cjs.toXOnly(bytes, "signer key"));
3060
3060
  throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
3061
3061
  }
3062
3062
  function signerSetFromInfo(info) {
@@ -3103,13 +3103,13 @@ var toTimelock = (value) => ({
3103
3103
  var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
3104
3104
  function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
3105
3105
  if (policy.requireSeconds && timelock.type === "blocks") {
3106
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3106
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3107
3107
  `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
3108
3108
  );
3109
3109
  }
3110
3110
  const seconds = toSeconds(timelock);
3111
3111
  if (seconds < policy.minSeconds) {
3112
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3112
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3113
3113
  `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
3114
3114
  );
3115
3115
  }
@@ -3130,7 +3130,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
3130
3130
  }
3131
3131
  function assertValidBatchExpiry(batchExpiry, policy) {
3132
3132
  if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
3133
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3133
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3134
3134
  `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
3135
3135
  );
3136
3136
  }
@@ -3160,21 +3160,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
3160
3160
  function assertValidServerUnrollScript(checkpointTapscript, policy) {
3161
3161
  let script;
3162
3162
  try {
3163
- script = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3163
+ script = chunkXR23C6TF_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3164
3164
  } catch (e) {
3165
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3165
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3166
3166
  `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
3167
3167
  );
3168
3168
  }
3169
3169
  if (policy.advertisedForfeitPubkey !== void 0) {
3170
3170
  const { pubkeys } = script.params;
3171
3171
  if (pubkeys.length !== 1) {
3172
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3172
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3173
3173
  `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
3174
3174
  );
3175
3175
  }
3176
3176
  if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
3177
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3177
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3178
3178
  `checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
3179
3179
  );
3180
3180
  }
@@ -3218,8 +3218,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
3218
3218
  function buildVirtualTx(inputs, outputs) {
3219
3219
  let lockTime = 0n;
3220
3220
  for (const input of inputs) {
3221
- const tapscript = chunkC5Y2R63Z_cjs.decodeTapscript(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3222
- if (chunkC5Y2R63Z_cjs.CLTVMultisigTapscript.is(tapscript)) {
3221
+ const tapscript = chunkXR23C6TF_cjs.decodeTapscript(chunkXR23C6TF_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3222
+ if (chunkXR23C6TF_cjs.CLTVMultisigTapscript.is(tapscript)) {
3223
3223
  if (lockTime !== 0n) {
3224
3224
  if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
3225
3225
  throw new Error("cannot mix seconds and blocks locktime");
@@ -3230,7 +3230,7 @@ function buildVirtualTx(inputs, outputs) {
3230
3230
  }
3231
3231
  }
3232
3232
  }
3233
- const tx = new chunkC5Y2R63Z_cjs.Transaction({
3233
+ const tx = new chunkXR23C6TF_cjs.Transaction({
3234
3234
  version: 3,
3235
3235
  lockTime: Number(lockTime)
3236
3236
  });
@@ -3240,12 +3240,12 @@ function buildVirtualTx(inputs, outputs) {
3240
3240
  index: input.vout,
3241
3241
  sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
3242
3242
  witnessUtxo: {
3243
- script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript,
3243
+ script: chunkXR23C6TF_cjs.VtxoScript.decode(input.tapTree).pkScript,
3244
3244
  amount: BigInt(input.value)
3245
3245
  },
3246
3246
  tapLeafScript: [input.tapLeafScript]
3247
3247
  });
3248
- chunkC5Y2R63Z_cjs.setArkPsbtField(tx, i, chunkC5Y2R63Z_cjs.VtxoTaprootTree, input.tapTree);
3248
+ chunkXR23C6TF_cjs.setArkPsbtField(tx, i, chunkXR23C6TF_cjs.VtxoTaprootTree, input.tapTree);
3249
3249
  }
3250
3250
  for (const output of outputs) {
3251
3251
  tx.addOutput(output);
@@ -3254,8 +3254,8 @@ function buildVirtualTx(inputs, outputs) {
3254
3254
  return tx;
3255
3255
  }
3256
3256
  function buildCheckpointTx(vtxo, serverUnrollScript) {
3257
- const collaborativeClosure = chunkC5Y2R63Z_cjs.decodeTapscript(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3258
- const checkpointVtxoScript = new chunkC5Y2R63Z_cjs.VtxoScript([
3257
+ const collaborativeClosure = chunkXR23C6TF_cjs.decodeTapscript(chunkXR23C6TF_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3258
+ const checkpointVtxoScript = new chunkXR23C6TF_cjs.VtxoScript([
3259
3259
  serverUnrollScript.script,
3260
3260
  collaborativeClosure.script
3261
3261
  ]);
@@ -3331,7 +3331,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
3331
3331
  const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
3332
3332
  const sig = signature.subarray(0, 64);
3333
3333
  if (!allowedSighashTypes.includes(sighashType)) {
3334
- const sighashName = chunkC5Y2R63Z_cjs.formatSighash(sighashType);
3334
+ const sighashName = chunkXR23C6TF_cjs.formatSighash(sighashType);
3335
3335
  throw new Error(
3336
3336
  `Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
3337
3337
  );
@@ -3405,7 +3405,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
3405
3405
  }
3406
3406
  function isValidArkAddress(address) {
3407
3407
  try {
3408
- chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
3408
+ chunkXR23C6TF_cjs.ArkAddress.decode(address);
3409
3409
  return true;
3410
3410
  } catch (e) {
3411
3411
  return false;
@@ -3413,16 +3413,16 @@ function isValidArkAddress(address) {
3413
3413
  }
3414
3414
  function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
3415
3415
  if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
3416
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3416
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3417
3417
  `${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
3418
3418
  );
3419
3419
  }
3420
3420
  const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
3421
3421
  return serverCheckpointTxs.map((encoded, index) => {
3422
- const server = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3422
+ const server = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3423
3423
  const local = byTxid.get(server.id);
3424
3424
  if (!local) {
3425
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3425
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3426
3426
  `${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
3427
3427
  );
3428
3428
  }
@@ -3432,14 +3432,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
3432
3432
  }
3433
3433
  function assertSubmittedArkTxid(response, signedArkTx, context) {
3434
3434
  if (response.arkTxid !== signedArkTx.id) {
3435
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3435
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3436
3436
  `${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
3437
3437
  );
3438
3438
  }
3439
3439
  if (response.finalArkTx === void 0) return;
3440
- const finalTxid = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3440
+ const finalTxid = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3441
3441
  if (finalTxid !== signedArkTx.id) {
3442
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3442
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3443
3443
  `${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
3444
3444
  );
3445
3445
  }
@@ -3458,10 +3458,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
3458
3458
  [serverPubkeyHex],
3459
3459
  void 0,
3460
3460
  void 0,
3461
- payment_js.tapLeafHash(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(leaf))
3461
+ payment_js.tapLeafHash(chunkXR23C6TF_cjs.scriptFromTapLeafScript(leaf))
3462
3462
  );
3463
3463
  } catch (error) {
3464
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3464
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3465
3465
  `${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
3466
3466
  );
3467
3467
  }
@@ -3470,20 +3470,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3470
3470
  const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
3471
3471
  for (const [index, checkpoint] of checkpoints.entries()) {
3472
3472
  if (checkpoint.inputsLength !== 1) {
3473
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3473
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3474
3474
  `${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
3475
3475
  );
3476
3476
  }
3477
3477
  const spent = checkpoint.getInput(0);
3478
3478
  if (!spent.txid || spent.index === void 0) {
3479
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3479
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3480
3480
  `${context}: checkpoint ${index} has no input outpoint`
3481
3481
  );
3482
3482
  }
3483
3483
  const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
3484
3484
  const input = byOutpoint.get(outpoint);
3485
3485
  if (!input) {
3486
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3486
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3487
3487
  `${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
3488
3488
  );
3489
3489
  }
@@ -3491,7 +3491,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3491
3491
  (unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
3492
3492
  );
3493
3493
  if (!rebuilt) {
3494
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3494
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3495
3495
  `${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
3496
3496
  );
3497
3497
  }
@@ -3517,9 +3517,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3517
3517
  const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
3518
3518
  matched.forEach(({ server }, index) => {
3519
3519
  try {
3520
- chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(server);
3520
+ chunkXR23C6TF_cjs.assertAllowedSighashTypes(server);
3521
3521
  } catch (error) {
3522
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3522
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3523
3523
  `submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
3524
3524
  );
3525
3525
  }
@@ -3527,12 +3527,12 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3527
3527
  const verify = options?.verifyServerSignatures;
3528
3528
  if (verify) {
3529
3529
  if (response.finalArkTx === void 0) {
3530
- throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
3530
+ throw new chunkXR23C6TF_cjs.ServerResponseMismatchError(
3531
3531
  "submitTx: server returned no final ark tx to verify its signatures against"
3532
3532
  );
3533
3533
  }
3534
- const finalArkTx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3535
- const serverPubkeyHex = base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(verify.serverPubkey, "server key"));
3534
+ const finalArkTx = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3535
+ const serverPubkeyHex = base.hex.encode(chunkZF52B7BV_cjs.toXOnly(verify.serverPubkey, "server key"));
3536
3536
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
3537
3537
  assertServerSignedLeaf(
3538
3538
  finalArkTx,
@@ -3588,17 +3588,37 @@ function claimWithPreimageIdentity(identity, preimage) {
3588
3588
  return {
3589
3589
  ...identity,
3590
3590
  sign: async (tx, inputIndexes) => {
3591
- const signed = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(
3591
+ const signed = chunkXR23C6TF_cjs.Transaction.fromPSBT(
3592
3592
  (await identity.sign(tx.clone(), inputIndexes)).toPSBT()
3593
3593
  );
3594
3594
  const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
3595
3595
  for (const index of indexes) {
3596
- chunkC5Y2R63Z_cjs.setArkPsbtField(signed, index, chunkC5Y2R63Z_cjs.ConditionWitness, [preimage]);
3596
+ chunkXR23C6TF_cjs.setArkPsbtField(signed, index, chunkXR23C6TF_cjs.ConditionWitness, [preimage]);
3597
3597
  }
3598
3598
  return signed;
3599
3599
  }
3600
3600
  };
3601
3601
  }
3602
+
3603
+ // src/contracts/types.ts
3604
+ function watchStateOf(contract) {
3605
+ return contract.watch ?? "watched";
3606
+ }
3607
+ function isWatchedContract(contract) {
3608
+ return watchStateOf(contract) !== "retained";
3609
+ }
3610
+ function hasCandidates(handler) {
3611
+ return !!handler && typeof handler.candidatesAt === "function";
3612
+ }
3613
+ function isDiscoverable(handler) {
3614
+ return !!handler && typeof handler.discoverAt === "function";
3615
+ }
3616
+ function isTapscriptDeriving(handler) {
3617
+ return !!handler && typeof handler.deriveTapscripts === "function";
3618
+ }
3619
+ function isContractVtxoEvent(event) {
3620
+ return "contract" in event && event.contract !== void 0;
3621
+ }
3602
3622
  var AmountVariableName = "amount";
3603
3623
  var ExpiryVariableName = "expiry";
3604
3624
  var BirthVariableName = "birth";
@@ -3754,23 +3774,6 @@ function parseProgram(text, env) {
3754
3774
  }
3755
3775
  return { program, text };
3756
3776
  }
3757
-
3758
- // src/contracts/types.ts
3759
- function watchStateOf(contract) {
3760
- return contract.watch ?? "watched";
3761
- }
3762
- function isWatchedContract(contract) {
3763
- return watchStateOf(contract) !== "retained";
3764
- }
3765
- function hasCandidates(handler) {
3766
- return !!handler && typeof handler.candidatesAt === "function";
3767
- }
3768
- function isDiscoverable(handler) {
3769
- return !!handler && typeof handler.discoverAt === "function";
3770
- }
3771
- function isTapscriptDeriving(handler) {
3772
- return !!handler && typeof handler.deriveTapscripts === "function";
3773
- }
3774
3777
  var DUST_AMOUNT = 546;
3775
3778
  var FALLBACK_WALLET_DUST_AMOUNT = 330n;
3776
3779
  function getDustAmount(wallet) {
@@ -3785,7 +3788,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
3785
3788
  };
3786
3789
  }
3787
3790
  function deriveContractTapscripts(contract) {
3788
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
3791
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(contract.type);
3789
3792
  if (!handler) {
3790
3793
  throw new Error(`No handler for contract type '${contract.type}'`);
3791
3794
  }
@@ -3856,7 +3859,7 @@ function getRandomId() {
3856
3859
  }
3857
3860
  function isValidArkAddress2(address) {
3858
3861
  try {
3859
- chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
3862
+ chunkXR23C6TF_cjs.ArkAddress.decode(address);
3860
3863
  return true;
3861
3864
  } catch (e) {
3862
3865
  return false;
@@ -3884,7 +3887,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
3884
3887
  function assertTapTreeDerivesAddress(encoded, tapTree, address) {
3885
3888
  let derived;
3886
3889
  try {
3887
- derived = chunkC5Y2R63Z_cjs.VtxoScript.decode(tapTree).pkScript;
3890
+ derived = chunkXR23C6TF_cjs.VtxoScript.decode(tapTree).pkScript;
3888
3891
  } catch (e) {
3889
3892
  throw new Error(
3890
3893
  `Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
@@ -3901,7 +3904,7 @@ function validateRecipients(recipients, dustAmount, context) {
3901
3904
  for (const recipient of recipients) {
3902
3905
  let address;
3903
3906
  try {
3904
- address = chunkC5Y2R63Z_cjs.ArkAddress.decode(recipient.address);
3907
+ address = chunkXR23C6TF_cjs.ArkAddress.decode(recipient.address);
3905
3908
  } catch (e) {
3906
3909
  throw new Error(`Invalid Arkade address: ${recipient.address}`);
3907
3910
  }
@@ -3926,7 +3929,7 @@ function validateRecipients(recipients, dustAmount, context) {
3926
3929
 
3927
3930
  // src/contracts/spendability.ts
3928
3931
  function isContractGenericallySpendable(contract) {
3929
- return chunkF7HJO5GT_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
3932
+ return chunkZF52B7BV_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
3930
3933
  }
3931
3934
  function gatedContracts(contracts) {
3932
3935
  const gated = /* @__PURE__ */ new Map();
@@ -3935,11 +3938,20 @@ function gatedContracts(contracts) {
3935
3938
  }
3936
3939
  return gated;
3937
3940
  }
3941
+ function gatedFrom(snapshot) {
3942
+ return gatedContracts(snapshot.map((entry) => entry.contract));
3943
+ }
3944
+ function gatedTypeOf(vtxo, gated) {
3945
+ return vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
3946
+ }
3947
+ function isGatedVtxo(vtxo, gated) {
3948
+ return gatedTypeOf(vtxo, gated) !== void 0;
3949
+ }
3938
3950
  function gateExclusion(gated) {
3939
3951
  return (vtxo) => {
3940
- const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
3952
+ const type = gatedTypeOf(vtxo, gated);
3941
3953
  if (type === void 0) return void 0;
3942
- if (!chunkF7HJO5GT_cjs.contractHandlers.has(type)) {
3954
+ if (!chunkZF52B7BV_cjs.contractHandlers.has(type)) {
3943
3955
  return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
3944
3956
  }
3945
3957
  return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
@@ -3975,7 +3987,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
3975
3987
  continue;
3976
3988
  }
3977
3989
  for (const v of vtxos) {
3978
- if (!chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
3990
+ if (!chunkXR23C6TF_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
3979
3991
  out.add(`${v.txid}:${v.vout}`);
3980
3992
  }
3981
3993
  }
@@ -4010,10 +4022,10 @@ function byValueDescending(vtxos) {
4010
4022
  return [...vtxos].sort((a, b) => b.value - a.value);
4011
4023
  }
4012
4024
  async function fetchTimeHeight(wallet) {
4013
- return chunkC5Y2R63Z_cjs.resolveTimeHeight(wallet.onchainProvider);
4025
+ return chunkXR23C6TF_cjs.resolveTimeHeight(wallet.onchainProvider);
4014
4026
  }
4015
4027
  function canMigrateBySend(vtxo, now) {
4016
- if (!chunkC5Y2R63Z_cjs.canSpendOffchain(vtxo, now)) return false;
4028
+ if (!chunkXR23C6TF_cjs.canSpendOffchain(vtxo, now)) return false;
4017
4029
  return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
4018
4030
  }
4019
4031
  function byExpiryAscending(vtxos, now) {
@@ -4021,7 +4033,7 @@ function byExpiryAscending(vtxos, now) {
4021
4033
  if (vtxo.isSwept) return -Infinity;
4022
4034
  if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
4023
4035
  if (vtxo.expiresAtHeight !== void 0) {
4024
- return chunkC5Y2R63Z_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4036
+ return chunkXR23C6TF_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4025
4037
  }
4026
4038
  return Infinity;
4027
4039
  };
@@ -4048,7 +4060,7 @@ function priceSettlementInputs(vtxos, estimator) {
4048
4060
  const payable = [];
4049
4061
  const net = /* @__PURE__ */ new Map();
4050
4062
  for (const vtxo of vtxos) {
4051
- const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(vtxo));
4063
+ const inputFee = estimator.evalOffchainInput(chunkXR23C6TF_cjs.toOffchainInputFeeParams(vtxo));
4052
4064
  if (inputFee.satoshis >= vtxo.value) {
4053
4065
  continue;
4054
4066
  }
@@ -4074,7 +4086,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
4074
4086
  }
4075
4087
  const outputFee = estimator.evalOffchainOutput({
4076
4088
  amount: subtotal,
4077
- script: base.hex.encode(chunkC5Y2R63Z_cjs.ArkAddress.decode(arkAddress).pkScript)
4089
+ script: base.hex.encode(chunkXR23C6TF_cjs.ArkAddress.decode(arkAddress).pkScript)
4078
4090
  });
4079
4091
  return subtotal - BigInt(outputFee.satoshis);
4080
4092
  }
@@ -4088,10 +4100,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
4088
4100
  };
4089
4101
  function getRecoverableVtxos(vtxos, dustAmount, now) {
4090
4102
  return vtxos.filter((vtxo) => {
4091
- if (chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
4103
+ if (chunkXR23C6TF_cjs.canRecoverOnchain(vtxo, now)) {
4092
4104
  return true;
4093
4105
  }
4094
- if (chunkC5Y2R63Z_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4106
+ if (chunkXR23C6TF_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4095
4107
  return true;
4096
4108
  }
4097
4109
  return false;
@@ -4123,7 +4135,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
4123
4135
  function isVtxoExpiringSoon(vtxo, thresholdMs) {
4124
4136
  if (vtxo.isUnrolled) return false;
4125
4137
  const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
4126
- const expiresAt = chunkC5Y2R63Z_cjs.normalizeVtxo(vtxo).expiresAt;
4138
+ const expiresAt = chunkXR23C6TF_cjs.normalizeVtxo(vtxo).expiresAt;
4127
4139
  if (expiresAt === void 0) return false;
4128
4140
  const now = Date.now();
4129
4141
  const batchExpiry = expiresAt.getTime();
@@ -4134,7 +4146,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
4134
4146
  return vtxos.filter(
4135
4147
  // The leading exclusion covers the `isSubdust` arm too, which is a value
4136
4148
  // property and would otherwise re-admit an exited coin on its own.
4137
- (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4149
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkXR23C6TF_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4138
4150
  );
4139
4151
  }
4140
4152
  function isMigrationCapable(wallet) {
@@ -4721,11 +4733,11 @@ var VtxoManager = class _VtxoManager {
4721
4733
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
4722
4734
  );
4723
4735
  }
4724
- const tx = new chunkC5Y2R63Z_cjs.Transaction();
4736
+ const tx = new chunkXR23C6TF_cjs.Transaction();
4725
4737
  for (const utxo of expiredUtxos) {
4726
- const utxoScript = chunkC5Y2R63Z_cjs.VtxoScript.decode(utxo.tapTree);
4738
+ const utxoScript = chunkXR23C6TF_cjs.VtxoScript.decode(utxo.tapTree);
4727
4739
  const utxoExitLeaf = utxoScript.leaves.find(
4728
- (leaf) => chunkC5Y2R63Z_cjs.CSVMultisigTapscript.isScriptValid(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(leaf)) === true
4740
+ (leaf) => chunkXR23C6TF_cjs.CSVMultisigTapscript.isScriptValid(chunkXR23C6TF_cjs.scriptFromTapLeafScript(leaf)) === true
4729
4741
  );
4730
4742
  if (!utxoExitLeaf) {
4731
4743
  throw new Error(
@@ -4740,7 +4752,7 @@ var VtxoManager = class _VtxoManager {
4740
4752
  amount: BigInt(utxo.value)
4741
4753
  },
4742
4754
  tapLeafScript: [utxoExitLeaf],
4743
- sequence: chunkC5Y2R63Z_cjs.getSequence(utxoExitLeaf)
4755
+ sequence: chunkXR23C6TF_cjs.getSequence(utxoExitLeaf)
4744
4756
  });
4745
4757
  }
4746
4758
  tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
@@ -4983,8 +4995,8 @@ var VtxoManager = class _VtxoManager {
4983
4995
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
4984
4996
  if (cls.status === "CURRENT") continue;
4985
4997
  const live = vtxos.filter((v) => !v.isUnrolled);
4986
- const recoverable = live.filter((v) => v.isSwept && !chunkC5Y2R63Z_cjs.hasTerminalSpend(v));
4987
- const spendable = live.filter((v) => !chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isSwept);
4998
+ const recoverable = live.filter((v) => v.isSwept && !chunkXR23C6TF_cjs.hasTerminalSpend(v));
4999
+ const spendable = live.filter((v) => !chunkXR23C6TF_cjs.hasTerminalSpend(v) && !v.isSwept);
4988
5000
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
4989
5001
  let recoverableCount = 0;
4990
5002
  let recoverableValue = 0;
@@ -5258,7 +5270,7 @@ var VtxoManager = class _VtxoManager {
5258
5270
  /** Decodes the boarding tapscript exit path to extract the CSV timelock. */
5259
5271
  getBoardingTimelock() {
5260
5272
  const wallet = this.getSweepWallet();
5261
- const exitScript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(
5273
+ const exitScript = chunkXR23C6TF_cjs.CSVMultisigTapscript.decode(
5262
5274
  base.hex.decode(wallet.boardingTapscript.exitScript)
5263
5275
  );
5264
5276
  return exitScript.params.timelock;
@@ -5304,7 +5316,7 @@ var VtxoManager = class _VtxoManager {
5304
5316
  this.wallet.getAddress()
5305
5317
  ]);
5306
5318
  const stopWatching = contractManager.onContractEvent((event) => {
5307
- if (event.type !== "vtxo_received") {
5319
+ if (event.type !== "vtxo_received" || !isContractVtxoEvent(event)) {
5308
5320
  return;
5309
5321
  }
5310
5322
  const msSinceLastRenewal = Date.now() - this.lastRenewalTimestamp;
@@ -5389,8 +5401,8 @@ var VtxoManager = class _VtxoManager {
5389
5401
  * or doesn't carry the metadata.
5390
5402
  */
5391
5403
  extractSpentOutpoint(error) {
5392
- const ark = chunkC5Y2R63Z_cjs.maybeArkError(error);
5393
- if (!chunkC5Y2R63Z_cjs.isArkError(ark, chunkC5Y2R63Z_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5404
+ const ark = chunkXR23C6TF_cjs.maybeArkError(error);
5405
+ if (!chunkXR23C6TF_cjs.isArkError(ark, chunkXR23C6TF_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5394
5406
  const raw = ark.metadata?.vtxo_outpoint;
5395
5407
  if (typeof raw !== "string") return void 0;
5396
5408
  const [txid, voutStr] = raw.split(":");
@@ -5580,7 +5592,7 @@ var VtxoManager = class _VtxoManager {
5580
5592
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
5581
5593
  break;
5582
5594
  }
5583
- const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(v));
5595
+ const inputFee = estimator.evalOffchainInput(chunkXR23C6TF_cjs.toOffchainInputFeeParams(v));
5584
5596
  if (inputFee.satoshis >= v.value) {
5585
5597
  continue;
5586
5598
  }
@@ -5600,7 +5612,7 @@ var VtxoManager = class _VtxoManager {
5600
5612
  const arkAddress = await this.wallet.getAddress();
5601
5613
  const outputFee = estimator.evalOffchainOutput({
5602
5614
  amount: totalAmount,
5603
- script: base.hex.encode(chunkC5Y2R63Z_cjs.ArkAddress.decode(arkAddress).pkScript)
5615
+ script: base.hex.encode(chunkXR23C6TF_cjs.ArkAddress.decode(arkAddress).pkScript)
5604
5616
  });
5605
5617
  totalAmount -= BigInt(outputFee.satoshis);
5606
5618
  if (totalAmount < dustAmount) return;
@@ -5680,7 +5692,7 @@ var ArkNote = class _ArkNote {
5680
5692
  this.value = value;
5681
5693
  this.HRP = HRP;
5682
5694
  const preimageHash = utils_js.sha256(this.preimage);
5683
- this.vtxoScript = new chunkC5Y2R63Z_cjs.VtxoScript([noteTapscript(preimageHash)]);
5695
+ this.vtxoScript = new chunkXR23C6TF_cjs.VtxoScript([noteTapscript(preimageHash)]);
5684
5696
  const leaf = this.vtxoScript.leaves[0];
5685
5697
  this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
5686
5698
  this.tapTree = this.vtxoScript.encode();
@@ -5847,7 +5859,7 @@ var ArkadeCash = class _ArkadeCash {
5847
5859
  const privateKey = data.slice(1, 33);
5848
5860
  const serverPubKey = data.slice(33, 65);
5849
5861
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
5850
- const csvTimelock = chunkC5Y2R63Z_cjs.sequenceToTimelock(sequence);
5862
+ const csvTimelock = chunkXR23C6TF_cjs.sequenceToTimelock(sequence);
5851
5863
  return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
5852
5864
  }
5853
5865
  toString() {
@@ -5855,7 +5867,7 @@ var ArkadeCash = class _ArkadeCash {
5855
5867
  data[0] = _ArkadeCash.Version;
5856
5868
  data.set(this._privateKey, 1);
5857
5869
  data.set(this._serverPubKey, 33);
5858
- const sequence = chunkC5Y2R63Z_cjs.timelockToSequence(this.csvTimelock);
5870
+ const sequence = chunkXR23C6TF_cjs.timelockToSequence(this.csvTimelock);
5859
5871
  new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
5860
5872
  const words = base.bech32m.toWords(data);
5861
5873
  return base.bech32m.encode(this.hrp, words, 1023);
@@ -5864,7 +5876,7 @@ var ArkadeCash = class _ArkadeCash {
5864
5876
  return SingleKey.fromPrivateKey(this._privateKey);
5865
5877
  }
5866
5878
  get vtxoScript() {
5867
- return new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
5879
+ return new chunkZF52B7BV_cjs.DefaultVtxo.Script({
5868
5880
  pubKey: this._publicKey,
5869
5881
  serverPubKey: this._serverPubKey,
5870
5882
  csvTimelock: this.csvTimelock
@@ -6125,7 +6137,7 @@ async function captureExitBranch(params) {
6125
6137
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
6126
6138
  if (nonCommitment.length > 0) {
6127
6139
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
6128
- psbtByTxid.set(chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6140
+ psbtByTxid.set(chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6129
6141
  }
6130
6142
  }
6131
6143
  }
@@ -6168,10 +6180,10 @@ var IndexerExitDataSource = class {
6168
6180
  while (hasMore) {
6169
6181
  const { chain: page, page: meta } = await this.indexer.getVtxoChain(
6170
6182
  { txid: vtxo.txid, vout: vtxo.vout },
6171
- { pageIndex, pageSize: chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE }
6183
+ { pageIndex, pageSize: chunkXR23C6TF_cjs.DEFAULT_PAGE_SIZE }
6172
6184
  );
6173
6185
  chain.push(...page);
6174
- hasMore = meta ? page.length === chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE : false;
6186
+ hasMore = meta ? page.length === chunkXR23C6TF_cjs.DEFAULT_PAGE_SIZE : false;
6175
6187
  pageIndex++;
6176
6188
  }
6177
6189
  return chain;
@@ -6183,12 +6195,12 @@ var IndexerExitDataSource = class {
6183
6195
  while (hasMore) {
6184
6196
  const { txs, page } = await this.indexer.getVirtualTxs(txids, {
6185
6197
  pageIndex,
6186
- pageSize: chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE
6198
+ pageSize: chunkXR23C6TF_cjs.DEFAULT_PAGE_SIZE
6187
6199
  });
6188
6200
  for (const psbt of txs) {
6189
- out.set(chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6201
+ out.set(chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6190
6202
  }
6191
- hasMore = page ? txs.length === chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE : false;
6203
+ hasMore = page ? txs.length === chunkXR23C6TF_cjs.DEFAULT_PAGE_SIZE : false;
6192
6204
  pageIndex++;
6193
6205
  }
6194
6206
  return out;
@@ -6209,7 +6221,7 @@ function chainedTxTypeToChainTxType(t) {
6209
6221
  }
6210
6222
  }
6211
6223
  function psbtInputTxids(psbtBase64) {
6212
- const tx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6224
+ const tx = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6213
6225
  const ids = [];
6214
6226
  for (let i = 0; i < tx.inputsLength; i++) {
6215
6227
  const txid = tx.getInput(i).txid;
@@ -6568,10 +6580,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
6568
6580
  try {
6569
6581
  info = await arkProvider.getInfo();
6570
6582
  } catch (err) {
6571
- if (opts?.requireLive || !chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
6583
+ if (opts?.requireLive || !chunkXR23C6TF_cjs.isRetryableProviderError(err)) throw err;
6572
6584
  const snapshot = await loadArkInfoSnapshot(walletRepository);
6573
6585
  if (!snapshot) {
6574
- throw new chunkC5Y2R63Z_cjs.ProviderUnavailableError(
6586
+ throw new chunkXR23C6TF_cjs.ProviderUnavailableError(
6575
6587
  "Arkade server info is unavailable and no cached snapshot exists",
6576
6588
  { cause: err }
6577
6589
  );
@@ -6899,6 +6911,24 @@ exports.Batch = void 0;
6899
6911
  })(exports.Batch || (exports.Batch = {}));
6900
6912
 
6901
6913
  // src/utils/transactionHistory.ts
6914
+ function localCreatedAtByTxid(vtxos) {
6915
+ const createdAt = /* @__PURE__ */ new Map();
6916
+ for (const vtxo of vtxos) {
6917
+ if (vtxo.txid && !createdAt.has(vtxo.txid)) {
6918
+ createdAt.set(vtxo.txid, vtxo.createdAt.getTime());
6919
+ }
6920
+ }
6921
+ return createdAt;
6922
+ }
6923
+ function gatedTouchpoints(gated) {
6924
+ const paidIn = /* @__PURE__ */ new Set();
6925
+ const paidOut = /* @__PURE__ */ new Set();
6926
+ for (const vtxo of gated) {
6927
+ if (vtxo.txid) paidIn.add(vtxo.txid);
6928
+ if (vtxo.isSpent && vtxo.arkTxId) paidOut.add(vtxo.arkTxId);
6929
+ }
6930
+ return { paidIn, paidOut };
6931
+ }
6902
6932
  var txKey = {
6903
6933
  commitmentTxid: "",
6904
6934
  boardingTxid: "",
@@ -6950,24 +6980,27 @@ function subtractAssets(spent, change) {
6950
6980
  if (map.size === 0) return void 0;
6951
6981
  return Array.from(map, ([assetId, amount]) => ({ assetId, amount }));
6952
6982
  }
6953
- function collectArkTxidsNeedingCreatedAt(vtxos) {
6954
- const ownTxids = new Set(vtxos.map((v) => v.txid));
6983
+ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
6955
6984
  const txids = /* @__PURE__ */ new Set();
6956
6985
  for (const vtxo of vtxos) {
6957
- if (vtxo.isSpent && vtxo.arkTxId && !ownTxids.has(vtxo.arkTxId)) {
6986
+ if (vtxo.isSpent && vtxo.arkTxId && !localCreatedAt.has(vtxo.arkTxId)) {
6958
6987
  txids.add(vtxo.arkTxId);
6959
6988
  }
6960
6989
  }
6961
6990
  return [...txids];
6962
6991
  }
6963
- async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
6964
- const fromOldestVtxo = vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
6965
- const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
6992
+ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
6993
+ const normalized = vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
6994
+ const localCreatedAt = localCreatedAtByTxid(normalized);
6995
+ const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
6996
+ const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
6997
+ const { paidIn: paidIntoGated, paidOut: paidOutOfGated } = gatedTouchpoints(gatedVtxos);
6998
+ const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(ownVtxos, localCreatedAt) : [];
6966
6999
  const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
6967
7000
  const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
6968
7001
  const sent = [];
6969
7002
  let received = [];
6970
- for (const vtxo of fromOldestVtxo) {
7003
+ for (const vtxo of ownVtxos) {
6971
7004
  if (vtxo.status.isLeaf) {
6972
7005
  const commitmentTxid = vtxo.commitmentTxIds[0];
6973
7006
  const vtxoCreatedAt = vtxo.createdAt.getTime();
@@ -6977,7 +7010,7 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
6977
7010
  unmatchedSettledBoardingTxs,
6978
7011
  (tx) => tx.createdAt <= vtxoCreatedAt && (tx.key.commitmentTxid === commitmentTxid || tx.key.commitmentTxid === vtxo.settledBy)
6979
7012
  );
6980
- } else if (fromOldestVtxo.filter((v) => v.settledBy === vtxo.commitmentTxIds[0]).length === 0) {
7013
+ } else if (ownVtxos.filter((v) => v.settledBy === vtxo.commitmentTxIds[0]).length === 0) {
6981
7014
  const duplicateBoardingReceive = consumeBoardingReceive(
6982
7015
  unmatchedSettledBoardingTxs,
6983
7016
  (tx) => tx.amount === vtxo.value && tx.createdAt <= vtxoCreatedAt
@@ -6998,11 +7031,14 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
6998
7031
  });
6999
7032
  }
7000
7033
  }
7001
- } else if (fromOldestVtxo.filter((v) => v.arkTxId === vtxo.txid).length === 0) {
7034
+ } else if (ownVtxos.filter((v) => v.arkTxId === vtxo.txid).length === 0) {
7002
7035
  const assets = collectAssets([vtxo]);
7003
7036
  received.push({
7004
7037
  key: { ...txKey, arkTxid: vtxo.txid },
7005
- tag: "offchain",
7038
+ // The escrow paying out: a swap fill or a cancel spends the
7039
+ // gated coin and lands the proceeds here. Nothing else about
7040
+ // the row changes — the tag only names the counterparty.
7041
+ tag: paidOutOfGated.has(vtxo.txid) ? "gated" : "offchain",
7006
7042
  type: "RECEIVED" /* TxReceived */,
7007
7043
  amount: vtxo.value,
7008
7044
  settled: vtxo.status.isLeaf || vtxo.isSpent,
@@ -7012,8 +7048,8 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
7012
7048
  }
7013
7049
  if (vtxo.isSpent) {
7014
7050
  if (vtxo.arkTxId && !sent.some((s) => s.key.arkTxid === vtxo.arkTxId)) {
7015
- const changes = fromOldestVtxo.filter((_) => _.txid === vtxo.arkTxId);
7016
- const allSpent = fromOldestVtxo.filter((v) => v.arkTxId === vtxo.arkTxId);
7051
+ const changes = ownVtxos.filter((_) => _.txid === vtxo.arkTxId);
7052
+ const allSpent = ownVtxos.filter((v) => v.arkTxId === vtxo.arkTxId);
7017
7053
  const spentAmount = allSpent.reduce((acc, v) => acc + v.value, 0);
7018
7054
  let txAmount = 0;
7019
7055
  let txTime = 0;
@@ -7023,13 +7059,16 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
7023
7059
  txTime = changes[0].createdAt.getTime();
7024
7060
  } else {
7025
7061
  txAmount = spentAmount;
7026
- txTime = resolvedCreatedAt.get(vtxo.arkTxId) ?? vtxo.createdAt.getTime() + 1;
7062
+ txTime = localCreatedAt.get(vtxo.arkTxId) ?? resolvedCreatedAt.get(vtxo.arkTxId) ?? vtxo.createdAt.getTime() + 1;
7027
7063
  }
7028
7064
  const assets = subtractAssets(allSpent, changes);
7029
7065
  if (txAmount !== 0 || assets) {
7030
7066
  sent.push({
7031
7067
  key: { ...txKey, arkTxid: vtxo.arkTxId },
7032
- tag: "offchain",
7068
+ // Funding the escrow: an output of this tx landed on a
7069
+ // gated contract of the wallet's, so the send is to the
7070
+ // user's own covenant rather than to a stranger.
7071
+ tag: paidIntoGated.has(vtxo.arkTxId) ? "gated" : "offchain",
7033
7072
  type: "SENT" /* TxSent */,
7034
7073
  amount: txAmount,
7035
7074
  settled: true,
@@ -7039,10 +7078,10 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
7039
7078
  }
7040
7079
  }
7041
7080
  if (vtxo.settledBy && !commitmentsToIgnore.has(vtxo.settledBy) && !sent.some((s) => s.key.commitmentTxid === vtxo.settledBy)) {
7042
- const changes = fromOldestVtxo.filter(
7081
+ const changes = ownVtxos.filter(
7043
7082
  (v) => v.status.isLeaf && v.commitmentTxIds.length > 0 && v.commitmentTxIds.every((_) => vtxo.settledBy === _)
7044
7083
  );
7045
- const forfeitVtxos = fromOldestVtxo.filter((v) => v.settledBy === vtxo.settledBy);
7084
+ const forfeitVtxos = ownVtxos.filter((v) => v.settledBy === vtxo.settledBy);
7046
7085
  const forfeitAmount = forfeitVtxos.reduce((acc, v) => acc + v.value, 0);
7047
7086
  if (changes.length > 0) {
7048
7087
  const settledAmount = changes.reduce((acc, v) => acc + v.value, 0);
@@ -7125,7 +7164,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7125
7164
  const virtualCoins = await this.wallet.getSpendableVtxos({
7126
7165
  withRecoverable: false
7127
7166
  });
7128
- const controlAssetRef = params.controlAssetId ? chunkSYRQJS5N_cjs.AssetRef.fromId(chunkSYRQJS5N_cjs.AssetId.fromString(params.controlAssetId)) : null;
7167
+ const controlAssetRef = params.controlAssetId ? chunkTVG3GDEO_cjs.AssetRef.fromId(chunkTVG3GDEO_cjs.AssetId.fromString(params.controlAssetId)) : null;
7129
7168
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
7130
7169
  let totalBtcSelected = 0n;
7131
7170
  const assetChanges = /* @__PURE__ */ new Map();
@@ -7138,8 +7177,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7138
7177
  }
7139
7178
  }
7140
7179
  const groups = [];
7141
- const issuedAssetOutput = chunkSYRQJS5N_cjs.AssetOutput.create(0, params.amount);
7142
- const issuedAssetGroup = chunkSYRQJS5N_cjs.AssetGroup.create(
7180
+ const issuedAssetOutput = chunkTVG3GDEO_cjs.AssetOutput.create(0, params.amount);
7181
+ const issuedAssetGroup = chunkTVG3GDEO_cjs.AssetGroup.create(
7143
7182
  null,
7144
7183
  controlAssetRef,
7145
7184
  [],
@@ -7154,28 +7193,28 @@ var AssetManager = class extends ReadonlyAssetManager {
7154
7193
  for (const [inputIndex, assets] of assetInputs) {
7155
7194
  for (const asset of assets) {
7156
7195
  if (asset.assetId !== assetId) continue;
7157
- changeInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
7196
+ changeInputs.push(chunkTVG3GDEO_cjs.AssetInput.create(inputIndex, asset.amount));
7158
7197
  }
7159
7198
  }
7160
7199
  groups.push(
7161
- chunkSYRQJS5N_cjs.AssetGroup.create(
7162
- chunkSYRQJS5N_cjs.AssetId.fromString(assetId),
7200
+ chunkTVG3GDEO_cjs.AssetGroup.create(
7201
+ chunkTVG3GDEO_cjs.AssetId.fromString(assetId),
7163
7202
  null,
7164
7203
  changeInputs,
7165
- [chunkSYRQJS5N_cjs.AssetOutput.create(0, amount)],
7204
+ [chunkTVG3GDEO_cjs.AssetOutput.create(0, amount)],
7166
7205
  []
7167
7206
  )
7168
7207
  );
7169
7208
  }
7170
7209
  }
7171
7210
  const address = await this.wallet.getAddress();
7172
- const outputAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
7211
+ const outputAddress = chunkXR23C6TF_cjs.ArkAddress.decode(address);
7173
7212
  const outputs = [
7174
7213
  {
7175
7214
  script: outputAddress.pkScript,
7176
7215
  amount: BigInt(totalBtcSelected)
7177
7216
  },
7178
- Extension.create([chunkSYRQJS5N_cjs.Packet.create(groups)]).txOut()
7217
+ Extension.create([chunkTVG3GDEO_cjs.Packet.create(groups)]).txOut()
7179
7218
  ];
7180
7219
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
7181
7220
  coinSelection.inputs,
@@ -7183,7 +7222,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7183
7222
  );
7184
7223
  return {
7185
7224
  arkTxId: arkTxid,
7186
- assetId: chunkSYRQJS5N_cjs.AssetId.create(arkTxid, 0).toString()
7225
+ assetId: chunkTVG3GDEO_cjs.AssetId.create(arkTxid, 0).toString()
7187
7226
  };
7188
7227
  }
7189
7228
  /**
@@ -7255,16 +7294,16 @@ var AssetManager = class extends ReadonlyAssetManager {
7255
7294
  for (const [inputIndex, assets] of assetInputs) {
7256
7295
  for (const asset of assets) {
7257
7296
  if (asset.assetId !== params.assetId) continue;
7258
- reissueInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
7297
+ reissueInputs.push(chunkTVG3GDEO_cjs.AssetInput.create(inputIndex, asset.amount));
7259
7298
  }
7260
7299
  }
7261
7300
  const totalAssetAmount = assetToReissueAmount + params.amount;
7262
- const reissueAssetIdObj = chunkSYRQJS5N_cjs.AssetId.fromString(params.assetId);
7263
- const reissueAssetGroup = chunkSYRQJS5N_cjs.AssetGroup.create(
7301
+ const reissueAssetIdObj = chunkTVG3GDEO_cjs.AssetId.fromString(params.assetId);
7302
+ const reissueAssetGroup = chunkTVG3GDEO_cjs.AssetGroup.create(
7264
7303
  reissueAssetIdObj,
7265
7304
  null,
7266
7305
  reissueInputs,
7267
- [chunkSYRQJS5N_cjs.AssetOutput.create(0, totalAssetAmount)],
7306
+ [chunkTVG3GDEO_cjs.AssetOutput.create(0, totalAssetAmount)],
7268
7307
  []
7269
7308
  );
7270
7309
  const groups = [reissueAssetGroup];
@@ -7273,27 +7312,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7273
7312
  for (const [inputIndex, assets] of assetInputs) {
7274
7313
  for (const asset of assets) {
7275
7314
  if (asset.assetId !== assetId) continue;
7276
- changeInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
7315
+ changeInputs.push(chunkTVG3GDEO_cjs.AssetInput.create(inputIndex, asset.amount));
7277
7316
  }
7278
7317
  }
7279
7318
  groups.push(
7280
- chunkSYRQJS5N_cjs.AssetGroup.create(
7281
- chunkSYRQJS5N_cjs.AssetId.fromString(assetId),
7319
+ chunkTVG3GDEO_cjs.AssetGroup.create(
7320
+ chunkTVG3GDEO_cjs.AssetId.fromString(assetId),
7282
7321
  null,
7283
7322
  changeInputs,
7284
- [chunkSYRQJS5N_cjs.AssetOutput.create(0, amount)],
7323
+ [chunkTVG3GDEO_cjs.AssetOutput.create(0, amount)],
7285
7324
  []
7286
7325
  )
7287
7326
  );
7288
7327
  }
7289
7328
  const address = await this.wallet.getAddress();
7290
- const outputAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
7329
+ const outputAddress = chunkXR23C6TF_cjs.ArkAddress.decode(address);
7291
7330
  const outputs = [
7292
7331
  {
7293
7332
  script: outputAddress.pkScript,
7294
7333
  amount: BigInt(totalBtcSelected)
7295
7334
  },
7296
- Extension.create([chunkSYRQJS5N_cjs.Packet.create(groups)]).txOut()
7335
+ Extension.create([chunkTVG3GDEO_cjs.Packet.create(groups)]).txOut()
7297
7336
  ];
7298
7337
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7299
7338
  return arkTxid;
@@ -7360,27 +7399,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7360
7399
  for (const [inputIndex, assets] of assetInputs) {
7361
7400
  for (const asset of assets) {
7362
7401
  if (asset.assetId !== assetId) continue;
7363
- changeInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
7402
+ changeInputs.push(chunkTVG3GDEO_cjs.AssetInput.create(inputIndex, asset.amount));
7364
7403
  }
7365
7404
  }
7366
7405
  groups.push(
7367
- chunkSYRQJS5N_cjs.AssetGroup.create(
7368
- chunkSYRQJS5N_cjs.AssetId.fromString(assetId),
7406
+ chunkTVG3GDEO_cjs.AssetGroup.create(
7407
+ chunkTVG3GDEO_cjs.AssetId.fromString(assetId),
7369
7408
  null,
7370
7409
  changeInputs,
7371
- amount > 0n ? [chunkSYRQJS5N_cjs.AssetOutput.create(0, amount)] : [],
7410
+ amount > 0n ? [chunkTVG3GDEO_cjs.AssetOutput.create(0, amount)] : [],
7372
7411
  []
7373
7412
  )
7374
7413
  );
7375
7414
  }
7376
7415
  const address = await this.wallet.getAddress();
7377
- const outputAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
7416
+ const outputAddress = chunkXR23C6TF_cjs.ArkAddress.decode(address);
7378
7417
  const outputs = [
7379
7418
  {
7380
7419
  script: outputAddress.pkScript,
7381
7420
  amount: BigInt(totalBtcSelected)
7382
7421
  },
7383
- Extension.create([chunkSYRQJS5N_cjs.Packet.create(groups)]).txOut()
7422
+ Extension.create([chunkTVG3GDEO_cjs.Packet.create(groups)]).txOut()
7384
7423
  ];
7385
7424
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7386
7425
  return arkTxid;
@@ -7405,7 +7444,7 @@ function castMetadata(metadata) {
7405
7444
  } else {
7406
7445
  throw new Error("Invalid metadata value type");
7407
7446
  }
7408
- md.push(chunkSYRQJS5N_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7447
+ md.push(chunkTVG3GDEO_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7409
7448
  }
7410
7449
  return md;
7411
7450
  }
@@ -7426,10 +7465,10 @@ var DelegateManagerImpl = class {
7426
7465
  if (vtxos.length === 0) {
7427
7466
  return { delegated: [], failed: [] };
7428
7467
  }
7429
- const destinationScript = chunkC5Y2R63Z_cjs.ArkAddress.decode(destination).pkScript;
7468
+ const destinationScript = chunkXR23C6TF_cjs.ArkAddress.decode(destination).pkScript;
7430
7469
  const arkInfo = await this.arkInfoProvider.getInfo();
7431
7470
  const delegateInfo = await this.delegateProvider.getDelegateInfo();
7432
- const eligible = vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo).filter(
7471
+ const eligible = vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo).filter(
7433
7472
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
7434
7473
  );
7435
7474
  if (eligible.length === 0) {
@@ -7458,7 +7497,7 @@ var DelegateManagerImpl = class {
7458
7497
  const groupByExpiry = /* @__PURE__ */ new Map();
7459
7498
  let recoverableVtxos = [];
7460
7499
  for (const vtxo of eligible) {
7461
- if (chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
7500
+ if (chunkXR23C6TF_cjs.canRecoverOnchain(vtxo, now)) {
7462
7501
  recoverableVtxos.push(vtxo);
7463
7502
  continue;
7464
7503
  }
@@ -7526,7 +7565,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7526
7565
  }
7527
7566
  if (!delegateAt) {
7528
7567
  const now = { timestamp: /* @__PURE__ */ new Date() };
7529
- const expiryTimestamp = vtxos.filter((coin) => !chunkC5Y2R63Z_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
7568
+ const expiryTimestamp = vtxos.filter((coin) => !chunkXR23C6TF_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
7530
7569
  (min, coin) => Math.min(min, coin.expiresAt.getTime()),
7531
7570
  Number.MAX_SAFE_INTEGER
7532
7571
  );
@@ -7558,7 +7597,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7558
7597
  let amount = 0n;
7559
7598
  for (const coin of vtxos) {
7560
7599
  const inputFee = estimator.evalOffchainInput({
7561
- ...chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(coin),
7600
+ ...chunkXR23C6TF_cjs.toOffchainInputFeeParams(coin),
7562
7601
  type: "vtxo"
7563
7602
  });
7564
7603
  if (inputFee.value >= coin.value) {
@@ -7572,7 +7611,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7572
7611
  const delegateFee = BigInt(Number(fee));
7573
7612
  if (delegateFee > 0n) {
7574
7613
  outputs.push({
7575
- script: chunkC5Y2R63Z_cjs.ArkAddress.decode(delegateAddress).pkScript,
7614
+ script: chunkXR23C6TF_cjs.ArkAddress.decode(delegateAddress).pkScript,
7576
7615
  amount: delegateFee
7577
7616
  });
7578
7617
  }
@@ -7605,10 +7644,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7605
7644
  destinationScript
7606
7645
  );
7607
7646
  const forfeitOutputScript = btcSigner.OutScript.encode(
7608
- btcSigner.Address(chunkC5Y2R63Z_cjs.getNetwork(network)).decode(forfeitAddress)
7647
+ btcSigner.Address(chunkXR23C6TF_cjs.getNetwork(network)).decode(forfeitAddress)
7609
7648
  );
7610
7649
  const forfeits = await Promise.all(
7611
- vtxos.filter((v) => !chunkC5Y2R63Z_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7650
+ vtxos.filter((v) => !chunkXR23C6TF_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7612
7651
  const forfeit = await makeDelegateForfeitTx(
7613
7652
  coin,
7614
7653
  dust,
@@ -7633,7 +7672,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
7633
7672
  index: input.vout,
7634
7673
  witnessUtxo: {
7635
7674
  amount: BigInt(input.value),
7636
- script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
7675
+ script: chunkXR23C6TF_cjs.VtxoScript.decode(input.tapTree).pkScript
7637
7676
  },
7638
7677
  sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
7639
7678
  tapLeafScript: [delegateTapLeaf]
@@ -7691,7 +7730,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
7691
7730
  expire_at: 0,
7692
7731
  cosigners_public_keys: cosignerPubKeys
7693
7732
  };
7694
- const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, outputs);
7733
+ const proof = chunkXR23C6TF_cjs.Intent.create(message, coins, outputs);
7695
7734
  const signedProof = await identity.sign(proof);
7696
7735
  return {
7697
7736
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -7709,10 +7748,10 @@ function getDayTimestamp(timestamp) {
7709
7748
  function findDelegateTapLeaf(vtxo, delegatePubkey) {
7710
7749
  if (!vtxo.tapTree) return void 0;
7711
7750
  const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
7712
- const vtxoScript = chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree);
7751
+ const vtxoScript = chunkXR23C6TF_cjs.VtxoScript.decode(vtxo.tapTree);
7713
7752
  return vtxoScript.leaves.find((tapLeaf) => {
7714
- const arkTapscript = chunkC5Y2R63Z_cjs.decodeTapscript(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(tapLeaf));
7715
- if (!chunkC5Y2R63Z_cjs.MultisigTapscript.is(arkTapscript)) return false;
7753
+ const arkTapscript = chunkXR23C6TF_cjs.decodeTapscript(chunkXR23C6TF_cjs.scriptFromTapLeafScript(tapLeaf));
7754
+ if (!chunkXR23C6TF_cjs.MultisigTapscript.is(arkTapscript)) return false;
7716
7755
  return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
7717
7756
  });
7718
7757
  }
@@ -7993,7 +8032,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
7993
8032
  };
7994
8033
  }
7995
8034
  function scriptFromArkAddress(address) {
7996
- return base.hex.encode(chunkC5Y2R63Z_cjs.ArkAddress.decode(address).pkScript);
8035
+ return base.hex.encode(chunkXR23C6TF_cjs.ArkAddress.decode(address).pkScript);
7997
8036
  }
7998
8037
 
7999
8038
  // src/repositories/indexedDB/schema.ts
@@ -8477,7 +8516,7 @@ function validateVtxosForScript(vtxos, script, context) {
8477
8516
  }
8478
8517
  async function getVtxosForContract(repo, contract) {
8479
8518
  const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8480
- return vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
8519
+ return vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo);
8481
8520
  }
8482
8521
  async function saveVtxosForContract(repo, contract, vtxos) {
8483
8522
  if (repo.saveVtxosForScript) {
@@ -8619,7 +8658,7 @@ function decodeArkContract(encoded) {
8619
8658
  }
8620
8659
  function contractFromArkContract(encoded, options = {}) {
8621
8660
  const parsed = decodeArkContract(encoded);
8622
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(parsed.type);
8661
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(parsed.type);
8623
8662
  if (!handler) {
8624
8663
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
8625
8664
  }
@@ -8633,9 +8672,9 @@ function contractFromArkContract(encoded, options = {}) {
8633
8672
  metadata: options.metadata
8634
8673
  };
8635
8674
  }
8636
- function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkC5Y2R63Z_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8675
+ function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkXR23C6TF_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8637
8676
  const parsed = decodeArkContract(encoded);
8638
- const handler = chunkF7HJO5GT_cjs.contractHandlers.getOrThrow(parsed.type);
8677
+ const handler = chunkZF52B7BV_cjs.contractHandlers.getOrThrow(parsed.type);
8639
8678
  const params = parsed.data;
8640
8679
  const vtxoScript = handler.createScript(params);
8641
8680
  return {
@@ -8667,6 +8706,8 @@ var DEFAULT_CONTRACT_WATCHER_CONFIG = {
8667
8706
  var ContractWatcher = class {
8668
8707
  config;
8669
8708
  contracts = /* @__PURE__ */ new Map();
8709
+ /** In-memory and process-lifetime; never persisted. */
8710
+ watchedScripts = /* @__PURE__ */ new Map();
8670
8711
  subscriptionId;
8671
8712
  abortController;
8672
8713
  isWatching = false;
@@ -8787,6 +8828,47 @@ var ContractWatcher = class {
8787
8828
  getWatchedContracts() {
8788
8829
  return this.getAllContracts().filter(isWatchedContract);
8789
8830
  }
8831
+ /**
8832
+ * Every script the subscription must carry. Wider than
8833
+ * {@link getWatchedContracts}, which stays the sync scope.
8834
+ */
8835
+ getSubscribedScripts() {
8836
+ const scripts = new Set(this.getWatchedContracts().map((c) => c.script));
8837
+ for (const script of this.watchedScripts.keys()) {
8838
+ scripts.add(script);
8839
+ }
8840
+ return Array.from(scripts);
8841
+ }
8842
+ /** @see IContractManager.watchScript for the delivery and filter contract. */
8843
+ async addWatchedScript(script, options) {
8844
+ const existing = this.watchedScripts.get(script);
8845
+ if (existing) {
8846
+ if (options?.label !== void 0) existing.label = options.label;
8847
+ return;
8848
+ }
8849
+ this.watchedScripts.set(script, {
8850
+ label: options?.label,
8851
+ lastKnownVtxos: /* @__PURE__ */ new Map()
8852
+ });
8853
+ if (this.isWatching) {
8854
+ await this.pollWatchedScripts([script]);
8855
+ await this.tryUpdateSubscription();
8856
+ }
8857
+ }
8858
+ /** Stop watching a script added by {@link addWatchedScript}. */
8859
+ async removeWatchedScript(script) {
8860
+ if (!this.watchedScripts.delete(script)) return;
8861
+ if (this.isWatching) {
8862
+ await this.tryUpdateSubscription();
8863
+ }
8864
+ }
8865
+ /** Every script registered via {@link addWatchedScript}. */
8866
+ getWatchedScripts() {
8867
+ return Array.from(this.watchedScripts.entries()).map(([script, state]) => ({
8868
+ script,
8869
+ label: state.label
8870
+ }));
8871
+ }
8790
8872
  /**
8791
8873
  * Get virtual outputs for contracts, grouped by contract script.
8792
8874
  * @see WalletRepository for `repo`
@@ -8889,9 +8971,9 @@ var ContractWatcher = class {
8889
8971
  this.connectionState = "connected";
8890
8972
  this.reconnectAttempts = 0;
8891
8973
  this.listenLoop().catch((e) => {
8892
- if (chunkC5Y2R63Z_cjs.isEventSourceError(e)) {
8974
+ if (chunkXR23C6TF_cjs.isEventSourceError(e)) {
8893
8975
  console.debug("ContractWatcher subscription disconnected; reconnecting");
8894
- } else if (!chunkC5Y2R63Z_cjs.isEventSourceUnavailableError(e)) {
8976
+ } else if (!chunkXR23C6TF_cjs.isEventSourceUnavailableError(e)) {
8895
8977
  console.error(e);
8896
8978
  }
8897
8979
  this.connectionState = "disconnected";
@@ -8903,7 +8985,7 @@ var ContractWatcher = class {
8903
8985
  this.scheduleReconnect();
8904
8986
  });
8905
8987
  } catch (error) {
8906
- if (!chunkC5Y2R63Z_cjs.isEventSourceUnavailableError(error)) {
8988
+ if (!chunkXR23C6TF_cjs.isEventSourceUnavailableError(error)) {
8907
8989
  console.error("ContractWatcher connection failed:", error);
8908
8990
  }
8909
8991
  this.connectionState = "disconnected";
@@ -8929,7 +9011,7 @@ var ContractWatcher = class {
8929
9011
  * slower; what it loses is push latency.
8930
9012
  */
8931
9013
  reportEventSourceUnavailable(error) {
8932
- if (!chunkC5Y2R63Z_cjs.isEventSourceUnavailableError(error)) return false;
9014
+ if (!chunkXR23C6TF_cjs.isEventSourceUnavailableError(error)) return false;
8933
9015
  if (!this.eventSourceReported) {
8934
9016
  this.eventSourceReported = true;
8935
9017
  console.warn(
@@ -8978,8 +9060,72 @@ var ContractWatcher = class {
8978
9060
  }
8979
9061
  async pollAllContracts() {
8980
9062
  const scripts = this.getWatchedContracts().map((c) => c.script);
9063
+ if (scripts.length > 0) {
9064
+ await this.pollContracts(scripts);
9065
+ }
9066
+ await this.pollWatchedScripts(Array.from(this.watchedScripts.keys()));
9067
+ }
9068
+ /**
9069
+ * Poll watch-only scripts against the indexer and emit the delta.
9070
+ *
9071
+ * Separate from {@link pollContracts} because that one diffs the wallet
9072
+ * repository, which is permanently empty for a script this wallet does not
9073
+ * own — reusing it would report every live output as spent on every tick.
9074
+ * Not a second poll loop: same timer and callers, different source.
9075
+ */
9076
+ async pollWatchedScripts(candidates) {
9077
+ if (!this.eventCallback) return;
9078
+ const scripts = candidates.filter((s) => {
9079
+ const state = this.contracts.get(s);
9080
+ return this.watchedScripts.has(s) && (state === void 0 || !isWatchedContract(state.contract));
9081
+ });
8981
9082
  if (scripts.length === 0) return;
8982
- await this.pollContracts(scripts);
9083
+ const now = Date.now();
9084
+ let current;
9085
+ try {
9086
+ current = await chunkXR23C6TF_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9087
+ spendableOnly: true
9088
+ });
9089
+ } catch (error) {
9090
+ console.error("ContractWatcher watch-only poll failed:", error);
9091
+ return;
9092
+ }
9093
+ const byScript = /* @__PURE__ */ new Map();
9094
+ for (const vtxo of current) {
9095
+ let bucket = byScript.get(vtxo.script);
9096
+ if (!bucket) {
9097
+ bucket = [];
9098
+ byScript.set(vtxo.script, bucket);
9099
+ }
9100
+ bucket.push(vtxo);
9101
+ }
9102
+ for (const script of scripts) {
9103
+ const state = this.watchedScripts.get(script);
9104
+ if (!state) continue;
9105
+ const currentVtxos = byScript.get(script) || [];
9106
+ const currentKeys = new Set(currentVtxos.map((v) => `${v.txid}:${v.vout}`));
9107
+ const newVtxos = [];
9108
+ for (const vtxo of currentVtxos) {
9109
+ const key = `${vtxo.txid}:${vtxo.vout}`;
9110
+ if (!state.lastKnownVtxos.has(key)) {
9111
+ newVtxos.push(vtxo);
9112
+ state.lastKnownVtxos.set(key, vtxo);
9113
+ }
9114
+ }
9115
+ const spentVtxos = [];
9116
+ for (const [key, vtxo] of state.lastKnownVtxos) {
9117
+ if (!currentKeys.has(key)) {
9118
+ spentVtxos.push(vtxo);
9119
+ state.lastKnownVtxos.delete(key);
9120
+ }
9121
+ }
9122
+ if (newVtxos.length > 0) {
9123
+ this.emitWatchedScriptEvent(script, newVtxos, "vtxo_received", now);
9124
+ }
9125
+ if (spentVtxos.length > 0) {
9126
+ this.emitWatchedScriptEvent(script, spentVtxos, "vtxo_spent", now);
9127
+ }
9128
+ }
8983
9129
  }
8984
9130
  /**
8985
9131
  * Poll specific contracts and emit events for changes.
@@ -9080,10 +9226,10 @@ var ContractWatcher = class {
9080
9226
  /**
9081
9227
  * Update the subscription with scripts that should be watched.
9082
9228
  *
9083
- * @see getWatchedContracts
9229
+ * @see getSubscribedScripts
9084
9230
  */
9085
9231
  async updateSubscription() {
9086
- const scriptsToWatch = this.getWatchedContracts().map((c) => c.script);
9232
+ const scriptsToWatch = this.getSubscribedScripts();
9087
9233
  if (scriptsToWatch.length === 0) {
9088
9234
  if (this.subscriptionId) {
9089
9235
  try {
@@ -9145,14 +9291,14 @@ var ContractWatcher = class {
9145
9291
  const timestamp = Date.now();
9146
9292
  if (update.newVtxos?.length) {
9147
9293
  this.processSubscriptionVtxos(
9148
- update.newVtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo),
9294
+ update.newVtxos.map(chunkXR23C6TF_cjs.normalizeVtxo),
9149
9295
  "vtxo_received",
9150
9296
  timestamp
9151
9297
  );
9152
9298
  }
9153
9299
  if (update.spentVtxos?.length) {
9154
9300
  this.processSubscriptionVtxos(
9155
- update.spentVtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo),
9301
+ update.spentVtxos.map(chunkXR23C6TF_cjs.normalizeVtxo),
9156
9302
  "vtxo_spent",
9157
9303
  timestamp
9158
9304
  );
@@ -9167,16 +9313,26 @@ var ContractWatcher = class {
9167
9313
  */
9168
9314
  processSubscriptionVtxos(vtxos, eventType, timestamp) {
9169
9315
  const byContract = /* @__PURE__ */ new Map();
9316
+ const byWatchedScript = /* @__PURE__ */ new Map();
9170
9317
  let unknownScript = 0;
9318
+ const now = { timestamp: /* @__PURE__ */ new Date() };
9171
9319
  for (const vtxo of vtxos) {
9172
- if (!this.contracts.has(vtxo.script)) {
9320
+ const state = this.contracts.get(vtxo.script);
9321
+ const watchOnly = this.watchedScripts.has(vtxo.script);
9322
+ const preferContract = state !== void 0 && (!watchOnly || isWatchedContract(state.contract));
9323
+ const target = preferContract ? byContract : watchOnly ? byWatchedScript : void 0;
9324
+ if (!target) {
9173
9325
  unknownScript++;
9174
9326
  continue;
9175
9327
  }
9176
- let bucket = byContract.get(vtxo.script);
9328
+ if (target === byWatchedScript && eventType === "vtxo_received") {
9329
+ const n = chunkXR23C6TF_cjs.normalizeVtxo(vtxo);
9330
+ if (chunkXR23C6TF_cjs.hasTerminalSpend(n) || n.isSwept || chunkXR23C6TF_cjs.isPastExpiry(n, now)) continue;
9331
+ }
9332
+ let bucket = target.get(vtxo.script);
9177
9333
  if (!bucket) {
9178
9334
  bucket = [];
9179
- byContract.set(vtxo.script, bucket);
9335
+ target.set(vtxo.script, bucket);
9180
9336
  }
9181
9337
  bucket.push(vtxo);
9182
9338
  }
@@ -9199,6 +9355,29 @@ var ContractWatcher = class {
9199
9355
  }
9200
9356
  this.emitVtxoEvent(contractScript, bucketVtxos, eventType, timestamp);
9201
9357
  }
9358
+ for (const [script, bucketVtxos] of byWatchedScript) {
9359
+ const state = this.watchedScripts.get(script);
9360
+ if (state) {
9361
+ for (const vtxo of bucketVtxos) {
9362
+ const key = `${vtxo.txid}:${vtxo.vout}`;
9363
+ if (eventType === "vtxo_received") {
9364
+ state.lastKnownVtxos.set(key, vtxo);
9365
+ } else {
9366
+ state.lastKnownVtxos.delete(key);
9367
+ }
9368
+ }
9369
+ }
9370
+ this.emitWatchedScriptEvent(script, bucketVtxos, eventType, timestamp);
9371
+ }
9372
+ }
9373
+ /** As {@link emitVtxoEvent}, less the `contract` and the annotation. */
9374
+ emitWatchedScriptEvent(script, vtxos, eventType, timestamp) {
9375
+ if (!this.eventCallback) return;
9376
+ if (eventType === "vtxo_received") {
9377
+ this.eventCallback({ type: "vtxo_received", contractScript: script, vtxos, timestamp });
9378
+ return;
9379
+ }
9380
+ this.eventCallback({ type: "vtxo_spent", contractScript: script, vtxos, timestamp });
9202
9381
  }
9203
9382
  /**
9204
9383
  * Emit a virtual output event for a contract.
@@ -9247,7 +9426,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
9247
9426
  (s) => !isTerminalIntentState(s)
9248
9427
  );
9249
9428
  function isConsumed(vtxo) {
9250
- return vtxo !== void 0 && chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo);
9429
+ return vtxo !== void 0 && chunkXR23C6TF_cjs.hasTerminalSpend(vtxo);
9251
9430
  }
9252
9431
  async function classifyIntent(intent, vtxosByOutpoint, now) {
9253
9432
  if (isTerminalIntentState(intent.state)) return void 0;
@@ -9290,7 +9469,7 @@ async function reconcileIntents(deps) {
9290
9469
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
9291
9470
  if (outpoints.length > 0) {
9292
9471
  try {
9293
- const { vtxos } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9472
+ const { vtxos } = await chunkXR23C6TF_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9294
9473
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
9295
9474
  } catch (e) {
9296
9475
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -9370,6 +9549,7 @@ var ContractManager = class _ContractManager {
9370
9549
  syncDegradedReason;
9371
9550
  /** Epoch-ms of the last successful provider sync, if any. */
9372
9551
  lastSyncedAt;
9552
+ syncedAtByScript = /* @__PURE__ */ new Map();
9373
9553
  /** Last chain tip read, with the epoch-ms it was read at. @see currentChainTip */
9374
9554
  chainTipCache;
9375
9555
  /** In-flight chain tip read, so concurrent cache misses share one. */
@@ -9423,6 +9603,10 @@ var ContractManager = class _ContractManager {
9423
9603
  lastSyncedAt: this.lastSyncedAt
9424
9604
  };
9425
9605
  }
9606
+ /** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
9607
+ setVtxoSyncMaxAge(maxAgeMs) {
9608
+ this.config.vtxoSyncMaxAgeMs = maxAgeMs;
9609
+ }
9426
9610
  markSyncOnline() {
9427
9611
  this.lastSyncedAt = Date.now();
9428
9612
  this.syncDegradedReason = this.annotationDegradedReason();
@@ -9464,7 +9648,7 @@ var ContractManager = class _ContractManager {
9464
9648
  await this.reconcileWatched();
9465
9649
  this.markSyncOnline();
9466
9650
  } catch (err) {
9467
- if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
9651
+ if (!chunkXR23C6TF_cjs.isRetryableProviderError(err)) throw err;
9468
9652
  this.markSyncDegraded(err);
9469
9653
  }
9470
9654
  this.initialized = true;
@@ -9596,7 +9780,7 @@ var ContractManager = class _ContractManager {
9596
9780
  const from = Math.max(0, watermark - lookAhead.size);
9597
9781
  const to = watermark + lookAhead.size;
9598
9782
  const deps = lookAhead.candidateDeps();
9599
- const handlers = chunkF7HJO5GT_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkF7HJO5GT_cjs.contractHandlers.get(t)).filter(hasCandidates);
9783
+ const handlers = chunkZF52B7BV_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkZF52B7BV_cjs.contractHandlers.get(t)).filter(hasCandidates);
9600
9784
  const band = /* @__PURE__ */ new Map();
9601
9785
  for (let index = from; index <= to; index++) {
9602
9786
  const descriptor = lookAhead.materialize(index);
@@ -9607,7 +9791,7 @@ var ContractManager = class _ContractManager {
9607
9791
  index,
9608
9792
  params: {
9609
9793
  ...candidate,
9610
- ...chunkF7HJO5GT_cjs.speculativeReceiveMetadata(descriptor)
9794
+ ...chunkZF52B7BV_cjs.speculativeReceiveMetadata(descriptor)
9611
9795
  }
9612
9796
  });
9613
9797
  }
@@ -9669,7 +9853,7 @@ var ContractManager = class _ContractManager {
9669
9853
  });
9670
9854
  for (const entry of pending) entry.catchUpPending = false;
9671
9855
  } catch (err) {
9672
- if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
9856
+ if (!chunkXR23C6TF_cjs.isRetryableProviderError(err)) throw err;
9673
9857
  this.markSyncDegraded(err);
9674
9858
  }
9675
9859
  }
@@ -9718,7 +9902,7 @@ var ContractManager = class _ContractManager {
9718
9902
  await this.fetchContractVxosFromIndexer([contract]);
9719
9903
  this.markSyncOnline();
9720
9904
  } catch (err) {
9721
- if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
9905
+ if (!chunkXR23C6TF_cjs.isRetryableProviderError(err)) throw err;
9722
9906
  this.markSyncDegraded(err);
9723
9907
  }
9724
9908
  await this.watcher.addContract(contract);
@@ -9755,7 +9939,7 @@ var ContractManager = class _ContractManager {
9755
9939
  return result;
9756
9940
  }
9757
9941
  async upsertContractRow(params) {
9758
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(params.type);
9942
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(params.type);
9759
9943
  if (!handler) {
9760
9944
  throw new Error(`No handler registered for contract type '${params.type}'`);
9761
9945
  }
@@ -9855,7 +10039,7 @@ var ContractManager = class _ContractManager {
9855
10039
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
9856
10040
  );
9857
10041
  }
9858
- const registered = chunkF7HJO5GT_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkF7HJO5GT_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10042
+ const registered = chunkZF52B7BV_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkZF52B7BV_cjs.contractHandlers.get(t)).filter(isDiscoverable);
9859
10043
  const discoverables = [
9860
10044
  ...registered.filter((h) => h.type === "boarding"),
9861
10045
  ...registered.filter((h) => h.type !== "boarding")
@@ -9985,12 +10169,16 @@ var ContractManager = class _ContractManager {
9985
10169
  }
9986
10170
  async getContractsWithVtxos(filter, pageSize) {
9987
10171
  const contracts = await this.getContracts(filter);
9988
- try {
9989
- await this.syncContracts({ contracts, pageSize });
9990
- this.markSyncOnline();
9991
- } catch (err) {
9992
- if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
9993
- this.markSyncDegraded(err);
10172
+ if (this.syncedWithin(contracts, this.config.vtxoSyncMaxAgeMs ?? 0)) {
10173
+ await this.demoteFundedAwaitingContracts(contracts);
10174
+ } else {
10175
+ try {
10176
+ await this.syncContracts({ contracts, pageSize });
10177
+ this.markSyncOnline();
10178
+ } catch (err) {
10179
+ if (!chunkXR23C6TF_cjs.isRetryableProviderError(err)) throw err;
10180
+ this.markSyncDegraded(err);
10181
+ }
9994
10182
  }
9995
10183
  const vtxos = await this.getVtxosForContracts(contracts);
9996
10184
  return contracts.map((contract) => ({
@@ -10010,7 +10198,7 @@ var ContractManager = class _ContractManager {
10010
10198
  }
10011
10199
  const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
10012
10200
  return vtxos.map(
10013
- (vtxo) => extendVirtualCoinForContract(chunkC5Y2R63Z_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10201
+ (vtxo) => extendVirtualCoinForContract(chunkXR23C6TF_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10014
10202
  );
10015
10203
  }
10016
10204
  /** @inheritdoc */
@@ -10054,14 +10242,14 @@ var ContractManager = class _ContractManager {
10054
10242
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
10055
10243
  const asking = vtxos.filter((vtxo) => {
10056
10244
  const contract = byScript.get(vtxo.script);
10057
- return contract !== void 0 && chunkF7HJO5GT_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10245
+ return contract !== void 0 && chunkZF52B7BV_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10058
10246
  });
10059
10247
  if (asking.length === 0) return refused;
10060
10248
  const tip = await this.currentChainTip();
10061
10249
  const walletDescriptorValue = await walletDescriptor?.();
10062
10250
  for (const vtxo of asking) {
10063
10251
  const contract = byScript.get(vtxo.script);
10064
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
10252
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(contract.type);
10065
10253
  if (!handler?.assertSpendableNow) continue;
10066
10254
  const context = {
10067
10255
  collaborative: true,
@@ -10076,7 +10264,7 @@ var ContractManager = class _ContractManager {
10076
10264
  // the next handler to answer a CSV question would meet a
10077
10265
  // TypeError instead of a `false`. Carry the coin only when it
10078
10266
  // really is one.
10079
- vtxo: chunkC5Y2R63Z_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10267
+ vtxo: chunkXR23C6TF_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10080
10268
  };
10081
10269
  try {
10082
10270
  await handler.assertSpendableNow(
@@ -10232,7 +10420,7 @@ var ContractManager = class _ContractManager {
10232
10420
  const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
10233
10421
  const [contract] = await this.getContracts({ script: contractScript });
10234
10422
  if (!contract) return [];
10235
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
10423
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(contract.type);
10236
10424
  if (!handler) return [];
10237
10425
  const script = handler.createScript(contract.params);
10238
10426
  const tip = await this.currentChainTip();
@@ -10260,7 +10448,7 @@ var ContractManager = class _ContractManager {
10260
10448
  const { contractScript, collaborative = true, walletDescriptor } = options;
10261
10449
  const [contract] = await this.getContracts({ script: contractScript });
10262
10450
  if (!contract) return [];
10263
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
10451
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(contract.type);
10264
10452
  if (!handler) return [];
10265
10453
  const script = handler.createScript(contract.params);
10266
10454
  const context = {
@@ -10316,7 +10504,7 @@ var ContractManager = class _ContractManager {
10316
10504
  }
10317
10505
  async refreshOutpoints(outpoints) {
10318
10506
  if (outpoints.length === 0) return;
10319
- const { vtxos } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10507
+ const { vtxos } = await chunkXR23C6TF_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10320
10508
  outpoints
10321
10509
  });
10322
10510
  if (vtxos.length === 0) return;
@@ -10352,6 +10540,18 @@ var ContractManager = class _ContractManager {
10352
10540
  async isWatching() {
10353
10541
  return this.watcher.isCurrentlyWatching();
10354
10542
  }
10543
+ /** @see IContractManager.watchScript */
10544
+ async watchScript(script, options) {
10545
+ await this.watcher.addWatchedScript(script, options);
10546
+ }
10547
+ /** @see IContractManager.unwatchScript */
10548
+ async unwatchScript(script) {
10549
+ await this.watcher.removeWatchedScript(script);
10550
+ }
10551
+ /** @see IContractManager.getWatchedScripts */
10552
+ async getWatchedScripts() {
10553
+ return this.watcher.getWatchedScripts();
10554
+ }
10355
10555
  /**
10356
10556
  * Emit an event to all registered callbacks.
10357
10557
  */
@@ -10372,11 +10572,15 @@ var ContractManager = class _ContractManager {
10372
10572
  try {
10373
10573
  switch (event.type) {
10374
10574
  // Delta-sync only the changed virtual outputs for this contract.
10575
+ // The guard below is the ownership boundary: a watch-only script
10576
+ // reports these same types, so it must precede `syncContracts`.
10375
10577
  case "vtxo_received":
10578
+ if (!isContractVtxoEvent(event)) break;
10376
10579
  await this.syncContracts({ contracts: [event.contract] });
10377
10580
  this.markSyncOnline();
10378
10581
  break;
10379
10582
  case "vtxo_spent":
10583
+ if (!isContractVtxoEvent(event)) break;
10380
10584
  await this.syncContracts({ contracts: [event.contract] });
10381
10585
  this.markSyncOnline();
10382
10586
  if (this.config.onVtxosSpent) {
@@ -10389,13 +10593,14 @@ var ContractManager = class _ContractManager {
10389
10593
  }
10390
10594
  break;
10391
10595
  case "connection_reset":
10596
+ this.syncedAtByScript.clear();
10392
10597
  await this.scheduleLookAheadDrain();
10393
10598
  await this.reconcileWatched();
10394
10599
  this.markSyncOnline();
10395
10600
  break;
10396
10601
  }
10397
10602
  } catch (err) {
10398
- if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
10603
+ if (!chunkXR23C6TF_cjs.isRetryableProviderError(err)) throw err;
10399
10604
  this.markSyncDegraded(err);
10400
10605
  }
10401
10606
  this.emitEvent(event);
@@ -10435,9 +10640,21 @@ var ContractManager = class _ContractManager {
10435
10640
  const cutoff = cursorCutoff(requestStartedAt);
10436
10641
  await advanceSyncCursor(this.config.walletRepository, cutoff);
10437
10642
  }
10643
+ if (options.window === void 0) {
10644
+ for (const contract of contracts) {
10645
+ this.syncedAtByScript.set(contract.script, requestStartedAt);
10646
+ }
10647
+ }
10438
10648
  await this.demoteFundedAwaitingContracts(contracts);
10439
10649
  return result;
10440
10650
  }
10651
+ syncedWithin(contracts, maxAgeMs) {
10652
+ if (maxAgeMs <= 0) return false;
10653
+ const floor = Date.now() - maxAgeMs;
10654
+ return contracts.every(
10655
+ (contract) => (this.syncedAtByScript.get(contract.script) ?? 0) >= floor
10656
+ );
10657
+ }
10441
10658
  /**
10442
10659
  * Demote every `awaiting-funds` contract in `contracts` that has been
10443
10660
  * funded — the automatic half of {@link ContractWatchState}.
@@ -10474,7 +10691,7 @@ var ContractManager = class _ContractManager {
10474
10691
  */
10475
10692
  async reconcilePendingFrontier(contracts) {
10476
10693
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
10477
- const vtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(
10694
+ const vtxos = await chunkXR23C6TF_cjs.getAllNormalizedVtxos(
10478
10695
  this.config.indexerProvider,
10479
10696
  contracts.map((c) => c.script),
10480
10697
  { pendingOnly: true }
@@ -10557,7 +10774,7 @@ var ContractManager = class _ContractManager {
10557
10774
  }
10558
10775
  return result;
10559
10776
  }
10560
- async fetchContractVtxosBulk(contracts, pageSize = chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
10777
+ async fetchContractVtxosBulk(contracts, pageSize = chunkXR23C6TF_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
10561
10778
  if (contracts.length === 0) {
10562
10779
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
10563
10780
  }
@@ -10573,7 +10790,7 @@ var ContractManager = class _ContractManager {
10573
10790
  before: syncWindow.before
10574
10791
  }
10575
10792
  } : {};
10576
- const vtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(
10793
+ const vtxos = await chunkXR23C6TF_cjs.getAllNormalizedVtxos(
10577
10794
  this.config.indexerProvider,
10578
10795
  contracts.map((c) => c.script),
10579
10796
  { ...windowOpts, pageSize }
@@ -10714,7 +10931,7 @@ var deserializeTapLeaf = (t) => {
10714
10931
  const s = base.hex.decode(t.s);
10715
10932
  return [cb, s];
10716
10933
  };
10717
- var deserializeVtxo = (o) => chunkC5Y2R63Z_cjs.normalizeVtxo({
10934
+ var deserializeVtxo = (o) => chunkXR23C6TF_cjs.normalizeVtxo({
10718
10935
  ...o,
10719
10936
  createdAt: new Date(o.createdAt),
10720
10937
  tapTree: base.hex.decode(o.tapTree),
@@ -10849,7 +11066,7 @@ function parseLegacyExpiry(batchExpiry) {
10849
11066
  if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
10850
11067
  return {};
10851
11068
  }
10852
- if (batchExpiry >= chunkC5Y2R63Z_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
11069
+ if (batchExpiry >= chunkXR23C6TF_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
10853
11070
  return { expiresAtHeight: batchExpiry / 1e3 };
10854
11071
  }
10855
11072
  function legacyVtxoFacts(status) {
@@ -11261,7 +11478,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
11261
11478
  */
11262
11479
  materializeDescriptorAt(index) {
11263
11480
  const descriptor = this.identity.descriptor;
11264
- const network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11481
+ const network = chunkZF52B7BV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11265
11482
  const expansion = descriptorsScure.expand({ descriptor, network, index });
11266
11483
  const keyInfo = expansion.expansionMap?.["@0"];
11267
11484
  if (!keyInfo?.keyExpression) {
@@ -11409,7 +11626,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
11409
11626
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
11410
11627
  if (!provider) return void 0;
11411
11628
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
11412
- const expectedContractType = setup.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? "delegate" : "default";
11629
+ const expectedContractType = setup.offchainTapscript instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script ? "delegate" : "default";
11413
11630
  const factoryOpts = {
11414
11631
  walletRepository: setup.walletRepository,
11415
11632
  contractRepository: setup.contractRepository,
@@ -11610,7 +11827,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
11610
11827
  };
11611
11828
  function deriveLeafPubkey(descriptor) {
11612
11829
  try {
11613
- return chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor);
11830
+ return chunkZF52B7BV_cjs.deriveDescriptorLeafPubKey(descriptor);
11614
11831
  } catch (e) {
11615
11832
  throw new NonRangeableDescriptorError(
11616
11833
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -11622,7 +11839,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
11622
11839
  const pubKey = deriveLeafPubkey(descriptor);
11623
11840
  const tapscript = rebuildTapscript(current, pubKey);
11624
11841
  const serverPubKey = tapscript.options.serverPubKey;
11625
- const csvTimelock = chunkC5Y2R63Z_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
11842
+ const csvTimelock = chunkXR23C6TF_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
11626
11843
  const base$1 = {
11627
11844
  script: base.hex.encode(tapscript.pkScript),
11628
11845
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -11633,11 +11850,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
11633
11850
  // index-0 key. Without it, spends produce unsigned PSBTs that the
11634
11851
  // server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
11635
11852
  metadata: {
11636
- ...tagSource && { source: chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE },
11853
+ ...tagSource && { source: chunkZF52B7BV_cjs.WALLET_RECEIVE_SOURCE },
11637
11854
  signingDescriptor: descriptor
11638
11855
  }
11639
11856
  };
11640
- const params = tapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? {
11857
+ const params = tapscript instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script ? {
11641
11858
  ...base$1,
11642
11859
  type: "delegate",
11643
11860
  params: {
@@ -11658,10 +11875,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
11658
11875
  return { tapscript, params };
11659
11876
  }
11660
11877
  function rebuildTapscript(current, pubKey) {
11661
- if (current instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script) {
11662
- return new chunkF7HJO5GT_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
11878
+ if (current instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script) {
11879
+ return new chunkZF52B7BV_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
11663
11880
  }
11664
- return new chunkF7HJO5GT_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
11881
+ return new chunkZF52B7BV_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
11665
11882
  }
11666
11883
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
11667
11884
  const candidates = await contractRepository.getContracts({
@@ -11670,7 +11887,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
11670
11887
  });
11671
11888
  const serverPubKeyHex = base.hex.encode(serverPubKey);
11672
11889
  const matching = candidates.filter(
11673
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE
11890
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkZF52B7BV_cjs.WALLET_RECEIVE_SOURCE
11674
11891
  ).sort((a, b) => {
11675
11892
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
11676
11893
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -11726,7 +11943,7 @@ function computeOffchainBalance(vtxos, caps) {
11726
11943
  }
11727
11944
  };
11728
11945
  for (const vtxo of vtxos) {
11729
- if (chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)) continue;
11946
+ if (chunkXR23C6TF_cjs.hasTerminalSpend(vtxo)) continue;
11730
11947
  addAssets(owned, vtxo);
11731
11948
  if (vtxo.isUnrolled) {
11732
11949
  unrolled += vtxo.value;
@@ -11736,11 +11953,11 @@ function computeOffchainBalance(vtxos, caps) {
11736
11953
  pendingRecovery += vtxo.value;
11737
11954
  continue;
11738
11955
  }
11739
- if (chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
11956
+ if (chunkXR23C6TF_cjs.canRecoverOnchain(vtxo, now)) {
11740
11957
  recoverable += vtxo.value;
11741
11958
  continue;
11742
11959
  }
11743
- if (!chunkC5Y2R63Z_cjs.canSpendOffchain(vtxo, now)) continue;
11960
+ if (!chunkXR23C6TF_cjs.canSpendOffchain(vtxo, now)) continue;
11744
11961
  if (vtxo.isPreconfirmed) {
11745
11962
  preconfirmed += vtxo.value;
11746
11963
  } else {
@@ -11914,7 +12131,7 @@ function intentProofJobs(coins) {
11914
12131
  if (coins.length === 0) return [];
11915
12132
  const coinJobs = coins.map((coin, i) => ({
11916
12133
  index: i + 1,
11917
- lookupScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(coin.tapTree).pkScript
12134
+ lookupScript: chunkXR23C6TF_cjs.VtxoScript.decode(coin.tapTree).pkScript
11918
12135
  }));
11919
12136
  return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
11920
12137
  }
@@ -11946,7 +12163,7 @@ function dedupeTimelocks(timelocks) {
11946
12163
  const seen = /* @__PURE__ */ new Set();
11947
12164
  const deduped = [];
11948
12165
  for (const timelock of timelocks) {
11949
- const sequence = chunkC5Y2R63Z_cjs.timelockToSequence(timelock).toString();
12166
+ const sequence = chunkXR23C6TF_cjs.timelockToSequence(timelock).toString();
11950
12167
  if (seen.has(sequence)) continue;
11951
12168
  seen.add(sequence);
11952
12169
  deduped.push(timelock);
@@ -11963,7 +12180,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
11963
12180
  state: "active"
11964
12181
  });
11965
12182
  const newest = candidates.filter(
11966
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE
12183
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkZF52B7BV_cjs.WALLET_RECEIVE_SOURCE
11967
12184
  ).sort((a, b) => {
11968
12185
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
11969
12186
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -11971,7 +12188,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
11971
12188
  if (!newest?.params.pubKey) return baseline;
11972
12189
  try {
11973
12190
  const pubKey = base.hex.decode(newest.params.pubKey);
11974
- return new chunkF7HJO5GT_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12191
+ return new chunkZF52B7BV_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
11975
12192
  } catch (e) {
11976
12193
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
11977
12194
  return baseline;
@@ -11990,10 +12207,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
11990
12207
  if (vtxo.isUnrolled) {
11991
12208
  return !!f.withUnrolled;
11992
12209
  }
11993
- if (chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)) {
12210
+ if (chunkXR23C6TF_cjs.hasTerminalSpend(vtxo)) {
11994
12211
  return false;
11995
12212
  }
11996
- if (!f.withRecoverable && chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
12213
+ if (!f.withRecoverable && chunkXR23C6TF_cjs.canRecoverOnchain(vtxo, now)) {
11997
12214
  return false;
11998
12215
  }
11999
12216
  return true;
@@ -12344,7 +12561,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12344
12561
  async getArkadeReader() {
12345
12562
  const indexer = this.indexerProvider;
12346
12563
  return {
12347
- getVtxos: (opts) => chunkC5Y2R63Z_cjs.getNormalizedVtxos(indexer, opts),
12564
+ getVtxos: (opts) => chunkXR23C6TF_cjs.getNormalizedVtxos(indexer, opts),
12348
12565
  getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
12349
12566
  };
12350
12567
  }
@@ -12399,7 +12616,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12399
12616
  * Extracts common logic used by both ReadonlyWallet.create() and Wallet.create().
12400
12617
  */
12401
12618
  static async setupWalletConfig(config, pubKey) {
12402
- const arkProvider = config.arkProvider || new chunkC5Y2R63Z_cjs.RestArkProvider();
12619
+ const arkProvider = config.arkProvider || new chunkXR23C6TF_cjs.RestArkProvider();
12403
12620
  let indexerProvider = config.indexerProvider;
12404
12621
  if (!indexerProvider) {
12405
12622
  const derived = extractArkProviderUrl(arkProvider);
@@ -12408,7 +12625,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12408
12625
  "indexerProvider is required when arkProvider is provided without a discoverable serverUrl"
12409
12626
  );
12410
12627
  }
12411
- indexerProvider = new chunkSYRQJS5N_cjs.RestIndexerProvider(derived ?? chunkC5Y2R63Z_cjs.DEFAULT_ARKADE_SERVER_URL);
12628
+ indexerProvider = new chunkTVG3GDEO_cjs.RestIndexerProvider(derived ?? chunkXR23C6TF_cjs.DEFAULT_ARKADE_SERVER_URL);
12412
12629
  }
12413
12630
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
12414
12631
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
@@ -12417,7 +12634,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12417
12634
  source: serverInfoSource,
12418
12635
  lastOnlineAt: serverInfoLastOnlineAt
12419
12636
  } = await resolveArkInfo(arkProvider, walletRepository);
12420
- const network = chunkC5Y2R63Z_cjs.networkFromArkadeInfo(info);
12637
+ const network = chunkXR23C6TF_cjs.networkFromArkadeInfo(info);
12421
12638
  if ("descriptor" in config.identity) {
12422
12639
  const descriptor = config.identity.descriptor;
12423
12640
  const identityIsMainnet = !descriptor.includes("tpub");
@@ -12456,18 +12673,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
12456
12673
  value: info.boardingExitDelay,
12457
12674
  type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
12458
12675
  };
12459
- const serverPubKey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
12460
- const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
12676
+ const serverPubKey = chunkZF52B7BV_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
12677
+ const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkZF52B7BV_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
12461
12678
  const offchainOptions = {
12462
12679
  pubKey,
12463
12680
  serverPubKey,
12464
12681
  csvTimelock: exitTimelock
12465
12682
  };
12466
- const offchainTapscript = !delegatePubKey ? new chunkF7HJO5GT_cjs.DefaultVtxo.Script(offchainOptions) : new chunkF7HJO5GT_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
12467
- const boardingTapscript = chunkF7HJO5GT_cjs.BoardingContractHandler.createScript({
12683
+ const offchainTapscript = !delegatePubKey ? new chunkZF52B7BV_cjs.DefaultVtxo.Script(offchainOptions) : new chunkZF52B7BV_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
12684
+ const boardingTapscript = chunkZF52B7BV_cjs.BoardingContractHandler.createScript({
12468
12685
  pubKey: base.hex.encode(pubKey),
12469
12686
  serverPubKey: base.hex.encode(serverPubKey),
12470
- csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(boardingTimelock).toString()
12687
+ csvTimelock: chunkXR23C6TF_cjs.timelockToSequence(boardingTimelock).toString()
12471
12688
  });
12472
12689
  return {
12473
12690
  arkProvider,
@@ -12618,7 +12835,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12618
12835
  const vtxos = filterSnapshotVtxos(snapshot, filter, this._pendingSpendOutpoints);
12619
12836
  const { gated, pendingRecovery } = this.spendabilityView(snapshot);
12620
12837
  const selectable = vtxos.filter(
12621
- (vtxo) => !gated.has(vtxo.script) && !pendingRecovery.has(`${vtxo.txid}:${vtxo.vout}`)
12838
+ (vtxo) => !isGatedVtxo(vtxo, gated) && !pendingRecovery.has(`${vtxo.txid}:${vtxo.vout}`)
12622
12839
  );
12623
12840
  const unlocked = await spendableVtxosExcludingLocked(selectable, this.intentRepository);
12624
12841
  logExcludedVtxos("getSpendableVtxos", vtxos, [
@@ -12632,7 +12849,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12632
12849
  if (!filter?.withUnrolled) {
12633
12850
  logExcludedVtxos(
12634
12851
  "getSpendableVtxos",
12635
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)),
12852
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkXR23C6TF_cjs.hasTerminalSpend(vtxo)),
12636
12853
  [() => UNROLLED_REASON]
12637
12854
  );
12638
12855
  }
@@ -12716,7 +12933,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12716
12933
  */
12717
12934
  spendabilityView(snapshot) {
12718
12935
  return {
12719
- gated: gatedContracts(snapshot.map((_) => _.contract)),
12936
+ gated: gatedFrom(snapshot),
12720
12937
  pendingRecovery: this.selectPendingRecovery(snapshot)
12721
12938
  };
12722
12939
  }
@@ -12731,7 +12948,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12731
12948
  return {
12732
12949
  now: { timestamp: /* @__PURE__ */ new Date() },
12733
12950
  isPendingRecovery: (vtxo) => pendingRecovery.has(`${vtxo.txid}:${vtxo.vout}`),
12734
- isGenericallySpendable: (vtxo) => !gated.has(vtxo.script),
12951
+ isGenericallySpendable: (vtxo) => !isGatedVtxo(vtxo, gated),
12735
12952
  isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`)
12736
12953
  };
12737
12954
  }
@@ -12771,16 +12988,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
12771
12988
  * Return wallet transaction history derived from Arkade state and boarding transactions.
12772
12989
  */
12773
12990
  async getTransactionHistory() {
12774
- const contractManager = await this.getContractManager();
12775
- const response = await contractManager.getContractsWithVtxos();
12776
- const allVtxos = response.flatMap((_) => _.vtxos);
12777
- const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
12778
- const resolveTxCreatedAt = (txids) => chunkC5Y2R63Z_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
12991
+ const [snapshot, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
12992
+ this.contractSnapshot(),
12993
+ this.getBoardingTxs()
12994
+ ]);
12995
+ const allVtxos = snapshot.flatMap((_) => _.vtxos);
12996
+ const resolveTxCreatedAt = (txids) => chunkXR23C6TF_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
12779
12997
  return buildTransactionHistory(
12780
12998
  allVtxos,
12781
12999
  boardingTxs,
12782
13000
  commitmentsToIgnore,
12783
- resolveTxCreatedAt
13001
+ resolveTxCreatedAt,
13002
+ gatedFrom(snapshot)
12784
13003
  );
12785
13004
  }
12786
13005
  /**
@@ -12924,9 +13143,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
12924
13143
  async getBoardingTapscripts(allowedSigners) {
12925
13144
  const byScript = /* @__PURE__ */ new Map();
12926
13145
  const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
12927
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13146
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkZF52B7BV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
12928
13147
  add(
12929
- new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
13148
+ new chunkZF52B7BV_cjs.DefaultVtxo.Script({
12930
13149
  pubKey: await this.identity.xOnlyPublicKey(),
12931
13150
  serverPubKey: this.boardingTapscript.options.serverPubKey,
12932
13151
  csvTimelock: boardingCsv
@@ -12941,7 +13160,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12941
13160
  for (const c of boardingContracts) {
12942
13161
  if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
12943
13162
  try {
12944
- add(chunkF7HJO5GT_cjs.BoardingContractHandler.createScript(c.params));
13163
+ add(chunkZF52B7BV_cjs.BoardingContractHandler.createScript(c.params));
12945
13164
  } catch (e) {
12946
13165
  console.warn("Skipping malformed boarding contract", c.script, e);
12947
13166
  }
@@ -12979,7 +13198,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12979
13198
  // Per-row CSV delay decoded from THIS tapscript's exit leaf —
12980
13199
  // not the wallet's current boarding timelock, which a signer
12981
13200
  // rotation may have changed.
12982
- csvTimelock: chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13201
+ csvTimelock: chunkXR23C6TF_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
12983
13202
  coins: utxos
12984
13203
  });
12985
13204
  }
@@ -13077,7 +13296,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13077
13296
  const cm = await this.getContractManager();
13078
13297
  let annotationQueue = Promise.resolve();
13079
13298
  indexerStopFunc = cm.onContractEvent((event) => {
13080
- if (event.type !== "vtxo_received" && event.type !== "vtxo_spent") {
13299
+ if (!isContractVtxoEvent(event)) {
13081
13300
  return;
13082
13301
  }
13083
13302
  if (event.contract.type !== "default" && event.contract.type !== "delegate") {
@@ -13112,7 +13331,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13112
13331
  /** Fetch Arkade transaction ids that are still pending final settlement. */
13113
13332
  async fetchPendingTxs() {
13114
13333
  const scripts = await this.getWalletScripts();
13115
- const vtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13334
+ const vtxos = await chunkXR23C6TF_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13116
13335
  return vtxos.filter(
13117
13336
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
13118
13337
  ).map((_) => _.arkTxId);
@@ -13143,7 +13362,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13143
13362
  });
13144
13363
  for (const contract of contracts) {
13145
13364
  if (map.has(contract.script)) continue;
13146
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
13365
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(contract.type);
13147
13366
  if (handler) {
13148
13367
  const script = handler.createScript(contract.params);
13149
13368
  map.set(contract.script, script);
@@ -13255,7 +13474,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13255
13474
  }
13256
13475
  });
13257
13476
  const baselinePubkey = await this.identity.xOnlyPublicKey();
13258
- const delegatePubKey = this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
13477
+ const delegatePubKey = this.offchainTapscript instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
13259
13478
  const baselineSigners = [
13260
13479
  this.offchainTapscript.options.serverPubKey,
13261
13480
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
@@ -13263,8 +13482,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
13263
13482
  const seenBaselineScripts = /* @__PURE__ */ new Set();
13264
13483
  for (const serverPubKey of baselineSigners) {
13265
13484
  for (const csvTimelock of this.walletContractTimelocks) {
13266
- const csvTimelockStr = chunkC5Y2R63Z_cjs.timelockToSequence(csvTimelock).toString();
13267
- const defaultScript = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
13485
+ const csvTimelockStr = chunkXR23C6TF_cjs.timelockToSequence(csvTimelock).toString();
13486
+ const defaultScript = new chunkZF52B7BV_cjs.DefaultVtxo.Script({
13268
13487
  pubKey: baselinePubkey,
13269
13488
  serverPubKey,
13270
13489
  csvTimelock
@@ -13285,7 +13504,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13285
13504
  });
13286
13505
  }
13287
13506
  if (delegatePubKey) {
13288
- const delegateScript = new chunkF7HJO5GT_cjs.DelegateVtxo.Script({
13507
+ const delegateScript = new chunkZF52B7BV_cjs.DelegateVtxo.Script({
13289
13508
  pubKey: baselinePubkey,
13290
13509
  serverPubKey,
13291
13510
  delegatePubKey,
@@ -13309,9 +13528,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13309
13528
  }
13310
13529
  }
13311
13530
  }
13312
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13531
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkZF52B7BV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13313
13532
  for (const serverPubKey of baselineSigners) {
13314
- const baselineBoarding = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
13533
+ const baselineBoarding = new chunkZF52B7BV_cjs.DefaultVtxo.Script({
13315
13534
  pubKey: baselinePubkey,
13316
13535
  serverPubKey,
13317
13536
  csvTimelock: boardingCsvTimelock
@@ -13324,7 +13543,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13324
13543
  params: {
13325
13544
  pubKey: base.hex.encode(baselineBoarding.options.pubKey),
13326
13545
  serverPubKey: base.hex.encode(serverPubKey),
13327
- csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(boardingCsvTimelock).toString()
13546
+ csvTimelock: chunkXR23C6TF_cjs.timelockToSequence(boardingCsvTimelock).toString()
13328
13547
  },
13329
13548
  script: boardingScriptHex,
13330
13549
  address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
@@ -13508,7 +13727,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13508
13727
  serverPubKey: this.offchainTapscript.options.serverPubKey,
13509
13728
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
13510
13729
  csvTimelocks: this.walletContractTimelocks,
13511
- delegatePubKey: this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
13730
+ delegatePubKey: this.offchainTapscript instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
13512
13731
  };
13513
13732
  }
13514
13733
  _signerRouter;
@@ -13753,7 +13972,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13753
13972
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
13754
13973
  const persisted = row?.metadata?.signingDescriptor;
13755
13974
  if (typeof persisted === "string") return persisted;
13756
- return chunkF7HJO5GT_cjs.identityDescriptor(this.identity);
13975
+ return chunkZF52B7BV_cjs.identityDescriptor(this.identity);
13757
13976
  }
13758
13977
  /**
13759
13978
  * Build, persist and shape one address of `type` owned by `descriptor` —
@@ -13769,7 +13988,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13769
13988
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
13770
13989
  if (type === "boarding") {
13771
13990
  const built2 = this.buildBoardingContract(
13772
- chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor),
13991
+ chunkZF52B7BV_cjs.deriveDescriptorLeafPubKey(descriptor),
13773
13992
  descriptor,
13774
13993
  tagSource
13775
13994
  );
@@ -13814,11 +14033,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13814
14033
  * {@link buildReceiveContract}.
13815
14034
  */
13816
14035
  buildBoardingContract(pubKey, descriptor, tagSource) {
13817
- const tapscript = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
14036
+ const tapscript = new chunkZF52B7BV_cjs.DefaultVtxo.Script({
13818
14037
  ...this._boardingTapscript.options,
13819
14038
  pubKey
13820
14039
  });
13821
- const csvTimelock = tapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14040
+ const csvTimelock = tapscript.options.csvTimelock ?? chunkZF52B7BV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13822
14041
  return {
13823
14042
  tapscript,
13824
14043
  params: {
@@ -13826,13 +14045,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13826
14045
  params: {
13827
14046
  pubKey: base.hex.encode(pubKey),
13828
14047
  serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
13829
- csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(csvTimelock).toString()
14048
+ csvTimelock: chunkXR23C6TF_cjs.timelockToSequence(csvTimelock).toString()
13830
14049
  },
13831
14050
  script: base.hex.encode(tapscript.pkScript),
13832
14051
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
13833
14052
  state: "active",
13834
14053
  metadata: {
13835
- ...tagSource && { source: chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE },
14054
+ ...tagSource && { source: chunkZF52B7BV_cjs.WALLET_RECEIVE_SOURCE },
13836
14055
  signingDescriptor: descriptor
13837
14056
  }
13838
14057
  }
@@ -13861,7 +14080,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13861
14080
  if (this._descriptorProvider instanceof HDDescriptorProvider) {
13862
14081
  return (await this.getContractManager()).getNextSigningDescriptor();
13863
14082
  }
13864
- return chunkF7HJO5GT_cjs.identityDescriptor(this.identity);
14083
+ return chunkZF52B7BV_cjs.identityDescriptor(this.identity);
13865
14084
  }
13866
14085
  /**
13867
14086
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -13957,7 +14176,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13957
14176
  * the stable public API.
13958
14177
  */
13959
14178
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
13960
- const xonly = chunkF7HJO5GT_cjs.toXOnly(newServerPubKey, "ark signer key");
14179
+ const xonly = chunkZF52B7BV_cjs.toXOnly(newServerPubKey, "ark signer key");
13961
14180
  const newServerUnrollScript = assertValidServerUnrollScript(
13962
14181
  checkpointTapscript,
13963
14182
  resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
@@ -13986,21 +14205,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13986
14205
  const [currentBoardingRow] = await manager.getContracts({
13987
14206
  script: currentBoardingScript
13988
14207
  });
13989
- const newOffchain = this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? new chunkF7HJO5GT_cjs.DelegateVtxo.Script({
14208
+ const newOffchain = this.offchainTapscript instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script ? new chunkZF52B7BV_cjs.DelegateVtxo.Script({
13990
14209
  ...this.offchainTapscript.options,
13991
14210
  serverPubKey: xonly
13992
- }) : new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
14211
+ }) : new chunkZF52B7BV_cjs.DefaultVtxo.Script({
13993
14212
  ...this.offchainTapscript.options,
13994
14213
  serverPubKey: xonly
13995
14214
  });
13996
- const newBoarding = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
14215
+ const newBoarding = new chunkZF52B7BV_cjs.DefaultVtxo.Script({
13997
14216
  ...this._boardingTapscript.options,
13998
14217
  serverPubKey: xonly
13999
14218
  });
14000
- const offchainCsv = chunkC5Y2R63Z_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14219
+ const offchainCsv = chunkXR23C6TF_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14001
14220
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
14002
14221
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
14003
- if (newOffchain instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script) {
14222
+ if (newOffchain instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script) {
14004
14223
  await manager.createContract({
14005
14224
  type: "delegate",
14006
14225
  params: {
@@ -14028,13 +14247,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14028
14247
  metadata: currentOffchainRow?.metadata
14029
14248
  });
14030
14249
  }
14031
- const boardingCsv = newBoarding.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14250
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkZF52B7BV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14032
14251
  await manager.createContract({
14033
14252
  type: "boarding",
14034
14253
  params: {
14035
14254
  pubKey: base.hex.encode(newBoarding.options.pubKey),
14036
14255
  serverPubKey: base.hex.encode(xonly),
14037
- csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(boardingCsv).toString()
14256
+ csvTimelock: chunkXR23C6TF_cjs.timelockToSequence(boardingCsv).toString()
14038
14257
  },
14039
14258
  script: base.hex.encode(newBoarding.pkScript),
14040
14259
  address: newBoarding.address(this.network.hrp, xonly).encode(),
@@ -14067,14 +14286,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14067
14286
  _restoreInFlight;
14068
14287
  _addPendingSpends(inputs) {
14069
14288
  for (const input of inputs) {
14070
- if (chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
14289
+ if (chunkXR23C6TF_cjs.isVirtualCoin(input)) {
14071
14290
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
14072
14291
  }
14073
14292
  }
14074
14293
  }
14075
14294
  _removePendingSpends(inputs) {
14076
14295
  for (const input of inputs) {
14077
- if (chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
14296
+ if (chunkXR23C6TF_cjs.isVirtualCoin(input)) {
14078
14297
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
14079
14298
  }
14080
14299
  }
@@ -14132,13 +14351,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14132
14351
  const manager = await this.getContractManager();
14133
14352
  const provider = this._descriptorProvider;
14134
14353
  const hd = provider instanceof HDDescriptorProvider;
14135
- const staticDescriptor = hd ? void 0 : await chunkF7HJO5GT_cjs.identityDescriptor(this.identity);
14354
+ const staticDescriptor = hd ? void 0 : await chunkZF52B7BV_cjs.identityDescriptor(this.identity);
14136
14355
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
14137
- const delegatePubKey = this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14356
+ const delegatePubKey = this.offchainTapscript instanceof chunkZF52B7BV_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14138
14357
  const arkInfo = await this.arkProvider.getInfo();
14139
- const currentSignerPubKey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14358
+ const currentSignerPubKey = chunkZF52B7BV_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14140
14359
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
14141
- (s) => chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14360
+ (s) => chunkZF52B7BV_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14142
14361
  );
14143
14362
  const deps = {
14144
14363
  indexerProvider: this.indexerProvider,
@@ -14153,7 +14372,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14153
14372
  csvTimelocks: this.walletContractTimelocks,
14154
14373
  // Boarding-exit CSV so the boarding handler can build its
14155
14374
  // candidate script (distinct from the unilateral-exit matrix).
14156
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14375
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkZF52B7BV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14157
14376
  delegatePubKey
14158
14377
  };
14159
14378
  const result = await manager.scanContracts({
@@ -14280,7 +14499,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14280
14499
  throw new Error("Invalid configured public key");
14281
14500
  }
14282
14501
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
14283
- const forfeitPubkey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14502
+ const forfeitPubkey = chunkZF52B7BV_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14284
14503
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
14285
14504
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
14286
14505
  const checkpointExitDelayOverrides = {
@@ -14427,13 +14646,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14427
14646
  void this.logUngatedInputs("settle({ inputs })", params.inputs);
14428
14647
  }
14429
14648
  const offchainAddress = await this.getAddress();
14430
- const offchainPkScript = chunkC5Y2R63Z_cjs.ArkAddress.decode(offchainAddress).pkScript;
14649
+ const offchainPkScript = chunkXR23C6TF_cjs.ArkAddress.decode(offchainAddress).pkScript;
14431
14650
  const offchainOutputScript = base.hex.encode(offchainPkScript);
14432
14651
  if (!params) {
14433
14652
  const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
14434
14653
  const estimator = new Estimator(fees.intentFee);
14435
14654
  let amount = 0;
14436
- const exitScript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(
14655
+ const exitScript = chunkXR23C6TF_cjs.CSVMultisigTapscript.decode(
14437
14656
  base.hex.decode(this.boardingTapscript.exitScript)
14438
14657
  );
14439
14658
  const boardingTimelock = exitScript.params.timelock;
@@ -14462,7 +14681,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14462
14681
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
14463
14682
  break;
14464
14683
  }
14465
- const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(vtxo));
14684
+ const inputFee = estimator.evalOffchainInput(chunkXR23C6TF_cjs.toOffchainInputFeeParams(vtxo));
14466
14685
  if (inputFee.satoshis >= vtxo.value) {
14467
14686
  continue;
14468
14687
  }
@@ -14509,7 +14728,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14509
14728
  let script;
14510
14729
  let arkAddress;
14511
14730
  try {
14512
- arkAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(output.address);
14731
+ arkAddress = chunkXR23C6TF_cjs.ArkAddress.decode(output.address);
14513
14732
  } catch {
14514
14733
  arkAddress = void 0;
14515
14734
  }
@@ -14599,7 +14818,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14599
14818
  const abortController = new AbortController();
14600
14819
  let stream;
14601
14820
  let committedTxid;
14602
- const settleInputVtxos = params.inputs.filter(chunkC5Y2R63Z_cjs.isVirtualCoin);
14821
+ const settleInputVtxos = params.inputs.filter(chunkXR23C6TF_cjs.isVirtualCoin);
14603
14822
  const contractManager = await this.getContractManager();
14604
14823
  await contractManager.assertAnnotatable(settleInputVtxos);
14605
14824
  await contractManager.assertSpendableNow?.(
@@ -14711,7 +14930,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14711
14930
  async maybeRotateBoardingAfterBoard(inputs) {
14712
14931
  if (!this._descriptorProvider) return;
14713
14932
  const consumedBoarding = inputs.some(
14714
- (input) => typeof input !== "string" && !chunkC5Y2R63Z_cjs.isVirtualCoin(input)
14933
+ (input) => typeof input !== "string" && !chunkXR23C6TF_cjs.isVirtualCoin(input)
14715
14934
  );
14716
14935
  if (!consumedBoarding) return;
14717
14936
  try {
@@ -14735,7 +14954,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14735
14954
  let connectorIndex = 0;
14736
14955
  const connectorsLeaves = connectorsGraph?.leaves() || [];
14737
14956
  for (const input of inputs) {
14738
- if (!chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
14957
+ if (!chunkXR23C6TF_cjs.isVirtualCoin(input)) {
14739
14958
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
14740
14959
  const settlementInput = settlementPsbt.getInput(i);
14741
14960
  if (!settlementInput.txid || settlementInput.index === void 0) {
@@ -14766,7 +14985,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14766
14985
  }
14767
14986
  continue;
14768
14987
  }
14769
- if (chunkC5Y2R63Z_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
14988
+ if (chunkXR23C6TF_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
14770
14989
  continue;
14771
14990
  }
14772
14991
  if (connectorsLeaves.length === 0) {
@@ -14794,7 +15013,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14794
15013
  index: input.vout,
14795
15014
  witnessUtxo: {
14796
15015
  amount: BigInt(input.value),
14797
- script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
15016
+ script: chunkXR23C6TF_cjs.VtxoScript.decode(input.tapTree).pkScript
14798
15017
  },
14799
15018
  sighashType: btcSigner.SigHash.DEFAULT,
14800
15019
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -14813,7 +15032,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14813
15032
  forfeitTx = await this._signerRouter.sign(forfeitTx, [
14814
15033
  {
14815
15034
  index: 0,
14816
- lookupScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
15035
+ lookupScript: chunkXR23C6TF_cjs.VtxoScript.decode(input.tapTree).pkScript
14817
15036
  }
14818
15037
  ]);
14819
15038
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -14871,7 +15090,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14871
15090
  resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
14872
15091
  );
14873
15092
  await this.arkProvider.confirmRegistration(intentId);
14874
- const sweepTapscript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.encode({
15093
+ const sweepTapscript = chunkXR23C6TF_cjs.CSVMultisigTapscript.encode({
14875
15094
  timelock,
14876
15095
  pubkeys: [this.forfeitPubkey]
14877
15096
  }).script;
@@ -14886,10 +15105,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14886
15105
  throw new Error("Sweep tap tree root not set");
14887
15106
  }
14888
15107
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
14889
- (k) => base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15108
+ (k) => base.hex.encode(chunkZF52B7BV_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
14890
15109
  );
14891
15110
  const signerPublicKey = await session.getPublicKey();
14892
- const xonlySignerPublicKey = chunkF7HJO5GT_cjs.toXOnly(signerPublicKey, "signer key");
15111
+ const xonlySignerPublicKey = chunkZF52B7BV_cjs.toXOnly(signerPublicKey, "signer key");
14893
15112
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
14894
15113
  return { skip: true };
14895
15114
  }
@@ -14979,9 +15198,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14979
15198
  ...existing ?? {},
14980
15199
  intentTxId,
14981
15200
  registerProof: intent.proof,
14982
- registerProofMessage: chunkC5Y2R63Z_cjs.Intent.encodeMessage(intent.message),
15201
+ registerProofMessage: chunkXR23C6TF_cjs.Intent.encodeMessage(intent.message),
14983
15202
  deleteProof: deleteIntent.proof,
14984
- deleteProofMessage: chunkC5Y2R63Z_cjs.Intent.encodeMessage(deleteIntent.message),
15203
+ deleteProofMessage: chunkXR23C6TF_cjs.Intent.encodeMessage(deleteIntent.message),
14985
15204
  intentVtxos: inputs.map((i) => ({
14986
15205
  txid: i.txid,
14987
15206
  vout: i.vout
@@ -15013,7 +15232,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15013
15232
  try {
15014
15233
  return await this.arkProvider.registerIntent(intent);
15015
15234
  } catch (error) {
15016
- if (error instanceof chunkC5Y2R63Z_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15235
+ if (error instanceof chunkXR23C6TF_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15017
15236
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
15018
15237
  await this.arkProvider.deleteIntent(deleteIntent);
15019
15238
  return this.arkProvider.registerIntent(intent);
@@ -15029,7 +15248,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15029
15248
  expire_at: 0,
15030
15249
  cosigners_public_keys: cosignerPubKeys
15031
15250
  };
15032
- const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, outputs);
15251
+ const proof = chunkXR23C6TF_cjs.Intent.create(message, coins, outputs);
15033
15252
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15034
15253
  return {
15035
15254
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15041,7 +15260,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15041
15260
  type: "delete",
15042
15261
  expire_at: 0
15043
15262
  };
15044
- const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, []);
15263
+ const proof = chunkXR23C6TF_cjs.Intent.create(message, coins, []);
15045
15264
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15046
15265
  return {
15047
15266
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15053,7 +15272,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15053
15272
  type: "get-pending-tx",
15054
15273
  expire_at: 0
15055
15274
  };
15056
- const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, []);
15275
+ const proof = chunkXR23C6TF_cjs.Intent.create(message, coins, []);
15057
15276
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15058
15277
  return {
15059
15278
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15074,7 +15293,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15074
15293
  if (!vtxos || vtxos.length === 0) {
15075
15294
  const scriptMap = await this.getScriptMap();
15076
15295
  const allExtended = [];
15077
- const fetchedVtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15296
+ const fetchedVtxos = await chunkXR23C6TF_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15078
15297
  ...scriptMap.keys()
15079
15298
  ]);
15080
15299
  for (const vtxo of fetchedVtxos) {
@@ -15118,7 +15337,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15118
15337
  try {
15119
15338
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
15120
15339
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
15121
- chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(tx);
15340
+ chunkXR23C6TF_cjs.assertAllowedSighashTypes(tx);
15122
15341
  return tx;
15123
15342
  });
15124
15343
  assertCheckpointsMatchInputs(
@@ -15190,11 +15409,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15190
15409
  * against the current key alone would leave it pending forever.
15191
15410
  */
15192
15411
  checkpointUnrollCandidates(info) {
15193
- const current = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15412
+ const current = chunkXR23C6TF_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15194
15413
  const candidates = [this._serverUnrollScript, current];
15195
15414
  for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
15196
15415
  candidates.push(
15197
- chunkC5Y2R63Z_cjs.CSVMultisigTapscript.encode({
15416
+ chunkXR23C6TF_cjs.CSVMultisigTapscript.encode({
15198
15417
  ...current.params,
15199
15418
  pubkeys: [base.hex.decode(deprecated)]
15200
15419
  })
@@ -15285,7 +15504,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15285
15504
  if (vtxos.length === 0) {
15286
15505
  throw new Error("No VTXOs found for this arkadeCash");
15287
15506
  }
15288
- const myPkScript = chunkC5Y2R63Z_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
15507
+ const myPkScript = chunkXR23C6TF_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
15289
15508
  let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
15290
15509
  let swept = 0;
15291
15510
  const drainable = vtxos.filter(
@@ -15361,7 +15580,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15361
15580
  const spendable = [];
15362
15581
  const unclaimed = [];
15363
15582
  for (const vtxo of vtxos) {
15364
- if (chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)) {
15583
+ if (chunkXR23C6TF_cjs.hasTerminalSpend(vtxo)) {
15365
15584
  unclaimed.push(cashReport(vtxo, "already-spent"));
15366
15585
  } else if (vtxo.isUnrolled) {
15367
15586
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -15383,7 +15602,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15383
15602
  const all = [];
15384
15603
  const seen = /* @__PURE__ */ new Set();
15385
15604
  for (let pageIndex = 0; ; pageIndex++) {
15386
- const { vtxos, page } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(this.indexerProvider, {
15605
+ const { vtxos, page } = await chunkXR23C6TF_cjs.getNormalizedVtxos(this.indexerProvider, {
15387
15606
  scripts,
15388
15607
  pageIndex,
15389
15608
  pageSize
@@ -15430,7 +15649,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15430
15649
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
15431
15650
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
15432
15651
  const message = { type: "get-pending-tx", expire_at: 0 };
15433
- const proof = chunkC5Y2R63Z_cjs.Intent.create(message, batch, []);
15652
+ const proof = chunkXR23C6TF_cjs.Intent.create(message, batch, []);
15434
15653
  const signedProof = await identity.sign(
15435
15654
  proof,
15436
15655
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -15452,7 +15671,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15452
15671
  try {
15453
15672
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
15454
15673
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
15455
- chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(tx);
15674
+ chunkXR23C6TF_cjs.assertAllowedSighashTypes(tx);
15456
15675
  return tx;
15457
15676
  });
15458
15677
  assertCheckpointsMatchInputs(
@@ -15651,7 +15870,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15651
15870
  script: recipient.script,
15652
15871
  amount: BigInt(recipient.amount),
15653
15872
  // Already checked against the recipient address in `validateRecipients`.
15654
- ...recipient.tapTree ? { tapTree: chunkC5Y2R63Z_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
15873
+ ...recipient.tapTree ? { tapTree: chunkXR23C6TF_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
15655
15874
  }));
15656
15875
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
15657
15876
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -15795,10 +16014,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15795
16014
  const serverPubKey = this.arkServerPublicKey;
15796
16015
  const serverUnrollScript = this.serverUnrollScript;
15797
16016
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
15798
- const normalizedInputs = inputs.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
15799
- const at = now ?? await chunkC5Y2R63Z_cjs.resolveTimeHeight(this.onchainProvider);
16017
+ const normalizedInputs = inputs.map(chunkXR23C6TF_cjs.normalizeVtxo);
16018
+ const at = now ?? await chunkXR23C6TF_cjs.resolveTimeHeight(this.onchainProvider);
15800
16019
  for (const input of normalizedInputs) {
15801
- if (!chunkC5Y2R63Z_cjs.canSpendOffchain(input, at)) {
16020
+ if (!chunkXR23C6TF_cjs.canSpendOffchain(input, at)) {
15802
16021
  throw new Error(
15803
16022
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
15804
16023
  );
@@ -15868,7 +16087,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15868
16087
  );
15869
16088
  const arkTxJobs = inputs.map((input, index) => ({
15870
16089
  index,
15871
- lookupScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
16090
+ lookupScript: chunkXR23C6TF_cjs.VtxoScript.decode(input.tapTree).pkScript
15872
16091
  }));
15873
16092
  const identity = this.identity;
15874
16093
  const signer = {
@@ -16053,12 +16272,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16053
16272
  const spentVtxos = [];
16054
16273
  const inputArkTxIds = /* @__PURE__ */ new Set();
16055
16274
  const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
16056
- const vtxoInputs = inputs.filter(chunkC5Y2R63Z_cjs.isVirtualCoin);
16275
+ const vtxoInputs = inputs.filter(chunkXR23C6TF_cjs.isVirtualCoin);
16057
16276
  const cm = await this.getContractManager();
16058
16277
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
16059
16278
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
16060
16279
  for (const input of inputs) {
16061
- if (chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
16280
+ if (chunkXR23C6TF_cjs.isVirtualCoin(input)) {
16062
16281
  const outpoint = `${input.txid}:${input.vout}`;
16063
16282
  const vtxo = annotatedByKey.get(outpoint);
16064
16283
  if (!vtxo) {
@@ -16075,7 +16294,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16075
16294
  } else {
16076
16295
  let sourceAddress;
16077
16296
  try {
16078
- sourceAddress = chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16297
+ sourceAddress = chunkXR23C6TF_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16079
16298
  this.network
16080
16299
  );
16081
16300
  } catch {
@@ -16133,7 +16352,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16133
16352
  }
16134
16353
  };
16135
16354
  function selectVirtualCoins(coins, targetAmount) {
16136
- const sortedCoins = coins.map(chunkC5Y2R63Z_cjs.normalizeVtxo).sort((a, b) => {
16355
+ const sortedCoins = coins.map(chunkXR23C6TF_cjs.normalizeVtxo).sort((a, b) => {
16137
16356
  const expiryA = a.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
16138
16357
  const expiryB = b.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
16139
16358
  if (expiryA !== expiryB) {
@@ -16504,14 +16723,14 @@ var MessageBus = class {
16504
16723
  this.initialized = true;
16505
16724
  }
16506
16725
  async buildServices(config) {
16507
- const arkProvider = new chunkC5Y2R63Z_cjs.RestArkProvider(config.arkServer.url);
16726
+ const arkProvider = new chunkXR23C6TF_cjs.RestArkProvider(config.arkServer.url);
16508
16727
  const storage = {
16509
16728
  walletRepository: this.walletRepository,
16510
16729
  contractRepository: this.contractRepository,
16511
16730
  ...this.intentRepository && { intentRepository: this.intentRepository }
16512
16731
  };
16513
16732
  const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
16514
- const indexerProvider = new chunkSYRQJS5N_cjs.RestIndexerProvider(config.arkServer.url);
16733
+ const indexerProvider = new chunkTVG3GDEO_cjs.RestIndexerProvider(config.arkServer.url);
16515
16734
  const serialized = normalizeSerializedIdentity(config.wallet);
16516
16735
  if (isSigningSerialized(serialized)) {
16517
16736
  const identity2 = hydrateIdentity(serialized);
@@ -16848,7 +17067,7 @@ var offboardNetworkNames = [
16848
17067
  function offboardDestinationScript(destinationAddress) {
16849
17068
  for (const networkName of offboardNetworkNames) {
16850
17069
  try {
16851
- const network = chunkC5Y2R63Z_cjs.networks[networkName];
17070
+ const network = chunkXR23C6TF_cjs.networks[networkName];
16852
17071
  const addr = btcSigner.Address(network).decode(destinationAddress);
16853
17072
  return btcSigner.OutScript.encode(addr);
16854
17073
  } catch {
@@ -16912,7 +17131,7 @@ var Ramps = class {
16912
17131
  }
16913
17132
  amount = amount ?? totalAmount;
16914
17133
  const offchainAddress = await this.wallet.getAddress();
16915
- const offchainAddr = chunkC5Y2R63Z_cjs.ArkAddress.decode(offchainAddress);
17134
+ const offchainAddr = chunkXR23C6TF_cjs.ArkAddress.decode(offchainAddress);
16916
17135
  const offchainScript = base.hex.encode(offchainAddr.pkScript);
16917
17136
  const outputFee = estimator.evalOffchainOutput({
16918
17137
  amount,
@@ -16972,7 +17191,7 @@ var Ramps = class {
16972
17191
  const filteredVtxos = [];
16973
17192
  let totalAmount = 0n;
16974
17193
  for (const vtxo of vtxos) {
16975
- const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(vtxo));
17194
+ const inputFee = estimator.evalOffchainInput(chunkXR23C6TF_cjs.toOffchainInputFeeParams(vtxo));
16976
17195
  if (inputFee.satoshis >= vtxo.value) {
16977
17196
  continue;
16978
17197
  }
@@ -17076,6 +17295,9 @@ var DelegateNotConfiguredError = class extends Error {
17076
17295
  }
17077
17296
  };
17078
17297
  var DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
17298
+ function unsupportedByManager(method) {
17299
+ return new Error(`Contract manager does not support ${method}`);
17300
+ }
17079
17301
  var serializeMigrationVtxoRef = (ref) => ({
17080
17302
  txid: ref.txid,
17081
17303
  vout: ref.vout,
@@ -17419,8 +17641,7 @@ var WalletMessageHandler = class {
17419
17641
  });
17420
17642
  }
17421
17643
  case "GET_TRANSACTION_HISTORY": {
17422
- const allVtxos = await this.getVtxosFromRepo();
17423
- const transactions = await this.buildTransactionHistoryFromCache(allVtxos) ?? [];
17644
+ const transactions = await this.buildTransactionHistoryFromCache() ?? [];
17424
17645
  return this.tagged({
17425
17646
  id,
17426
17647
  type: "TRANSACTION_HISTORY",
@@ -17496,6 +17717,39 @@ var WalletMessageHandler = class {
17496
17717
  payload: { contracts }
17497
17718
  });
17498
17719
  }
17720
+ case "WATCH_SCRIPT": {
17721
+ const manager = await this.readonlyWallet.getContractManager();
17722
+ if (!manager.watchScript) throw unsupportedByManager("watchScript");
17723
+ await manager.watchScript(message.payload.script, {
17724
+ label: message.payload.label
17725
+ });
17726
+ return this.tagged({
17727
+ id,
17728
+ type: "SCRIPT_WATCHED",
17729
+ payload: { script: message.payload.script }
17730
+ });
17731
+ }
17732
+ case "UNWATCH_SCRIPT": {
17733
+ const manager = await this.readonlyWallet.getContractManager();
17734
+ if (!manager.unwatchScript) throw unsupportedByManager("unwatchScript");
17735
+ await manager.unwatchScript(message.payload.script);
17736
+ return this.tagged({
17737
+ id,
17738
+ type: "SCRIPT_UNWATCHED",
17739
+ payload: { script: message.payload.script }
17740
+ });
17741
+ }
17742
+ case "GET_WATCHED_SCRIPTS": {
17743
+ const manager = await this.readonlyWallet.getContractManager();
17744
+ if (!manager.getWatchedScripts) {
17745
+ throw unsupportedByManager("getWatchedScripts");
17746
+ }
17747
+ return this.tagged({
17748
+ id,
17749
+ type: "WATCHED_SCRIPTS",
17750
+ payload: { scripts: await manager.getWatchedScripts() }
17751
+ });
17752
+ }
17499
17753
  case "ANNOTATE_VTXOS": {
17500
17754
  const manager = await this.readonlyWallet.getContractManager();
17501
17755
  const annotated = await manager.annotateVtxos(message.payload.vtxos);
@@ -17844,7 +18098,7 @@ var WalletMessageHandler = class {
17844
18098
  // Wallet methods
17845
18099
  async handleInitWallet({ payload }) {
17846
18100
  const { arkServerUrl } = payload;
17847
- this.indexerProvider = new chunkSYRQJS5N_cjs.RestIndexerProvider(arkServerUrl);
18101
+ this.indexerProvider = new chunkTVG3GDEO_cjs.RestIndexerProvider(arkServerUrl);
17848
18102
  await this.onWalletInitialized();
17849
18103
  }
17850
18104
  /**
@@ -17870,7 +18124,7 @@ var WalletMessageHandler = class {
17870
18124
  unconfirmed += utxo.value;
17871
18125
  }
17872
18126
  }
17873
- const gated = gatedContracts(snapshot.map((_) => _.contract));
18127
+ const gated = gatedFrom(snapshot);
17874
18128
  const unlocked = new Set(
17875
18129
  (await spendableVtxosExcludingLocked(allVtxos, this.readonlyWallet?.intentRepository)).map((vtxo) => `${vtxo.txid}:${vtxo.vout}`)
17876
18130
  );
@@ -17878,7 +18132,7 @@ var WalletMessageHandler = class {
17878
18132
  const offchain = computeOffchainBalance(allVtxos, {
17879
18133
  now: { timestamp: /* @__PURE__ */ new Date() },
17880
18134
  isPendingRecovery: (vtxo) => pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`),
17881
- isGenericallySpendable: (vtxo) => !gated.has(vtxo.script),
18135
+ isGenericallySpendable: (vtxo) => !isGatedVtxo(vtxo, gated),
17882
18136
  isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`)
17883
18137
  });
17884
18138
  return {
@@ -18018,7 +18272,6 @@ var WalletMessageHandler = class {
18018
18272
  if (!this.readonlyWallet || !this.walletRepository) {
18019
18273
  return;
18020
18274
  }
18021
- const vtxos = await this.getVtxosFromRepo();
18022
18275
  const boardingAddresses = await this.readonlyWallet.getBoardingAddresses();
18023
18276
  const fresh = await this.readonlyWallet.getBoardingUtxos();
18024
18277
  const freshKeys = new Set(fresh.map((u) => `${u.txid}:${u.vout}`));
@@ -18030,7 +18283,7 @@ var WalletMessageHandler = class {
18030
18283
  if (kept.length > 0) await this.walletRepository.saveUtxos(addr, kept);
18031
18284
  }
18032
18285
  const address = await this.readonlyWallet.getAddress();
18033
- const txs = await this.buildTransactionHistoryFromCache(vtxos);
18286
+ const txs = await this.buildTransactionHistoryFromCache();
18034
18287
  if (txs) await this.walletRepository.saveTransactions(address, txs);
18035
18288
  }
18036
18289
  /**
@@ -18122,7 +18375,7 @@ var WalletMessageHandler = class {
18122
18375
  if (v.isUnrolled) {
18123
18376
  return withUnrolled;
18124
18377
  }
18125
- if (chunkC5Y2R63Z_cjs.hasTerminalSpend(v)) {
18378
+ if (chunkXR23C6TF_cjs.hasTerminalSpend(v)) {
18126
18379
  return false;
18127
18380
  }
18128
18381
  if (includeRecoverable) {
@@ -18131,7 +18384,7 @@ var WalletMessageHandler = class {
18131
18384
  if (dustAmount != null && isSubdust(v, dustAmount)) {
18132
18385
  return false;
18133
18386
  }
18134
- return chunkC5Y2R63Z_cjs.canSpendOffchain(v, { timestamp: /* @__PURE__ */ new Date() });
18387
+ return chunkXR23C6TF_cjs.canSpendOffchain(v, { timestamp: /* @__PURE__ */ new Date() });
18135
18388
  });
18136
18389
  }
18137
18390
  /** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
@@ -18221,13 +18474,29 @@ var WalletMessageHandler = class {
18221
18474
  /**
18222
18475
  * Build transaction history from cached virtual outputs, hitting the indexer only for
18223
18476
  * uncached timestamps. Best-effort, like the plain Wallet path.
18224
- */
18225
- async buildTransactionHistoryFromCache(vtxos) {
18477
+ *
18478
+ * Takes its own {@link repoSnapshot} rather than a caller-supplied VTXO
18479
+ * list: the coins and the gate that judges them have to come off one read
18480
+ * or they answer about different instants, and being the worker's only
18481
+ * history builder means neither caller can supply one without the other.
18482
+ * The snapshot and the boarding read are independent, so they run together
18483
+ * — the same pairing `handleGetBalance` makes.
18484
+ */
18485
+ async buildTransactionHistoryFromCache() {
18226
18486
  if (!this.readonlyWallet) return null;
18227
- const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
18487
+ const [{ snapshot, vtxos }, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
18488
+ this.repoSnapshot(),
18489
+ this.readonlyWallet.getBoardingTxs()
18490
+ ]);
18228
18491
  const indexerProvider = this.indexerProvider;
18229
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunkC5Y2R63Z_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
18230
- return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
18492
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunkXR23C6TF_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
18493
+ return buildTransactionHistory(
18494
+ vtxos,
18495
+ boardingTxs,
18496
+ commitmentsToIgnore,
18497
+ resolveTxCreatedAt,
18498
+ gatedFrom(snapshot)
18499
+ );
18231
18500
  }
18232
18501
  async ensureContractEventBroadcasting() {
18233
18502
  const wallet = this.readonlyWallet;
@@ -18289,7 +18558,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
18289
18558
  // budget so the worker's snapshot fallback stays reachable before this
18290
18559
  // page deadline fires — lowering it below the budget would time the page
18291
18560
  // out while the worker is still seconds from answering from cache.
18292
- GET_ARKADE_INFO: chunkC5Y2R63Z_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
18561
+ GET_ARKADE_INFO: chunkXR23C6TF_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
18293
18562
  INDEXER_GET_VTXOS: 2e4,
18294
18563
  INDEXER_GET_VIRTUAL_TXS: 2e4,
18295
18564
  GET_VTXOS: 2e4,
@@ -18298,6 +18567,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
18298
18567
  GET_TRANSACTION_HISTORY: 2e4,
18299
18568
  GET_CONTRACTS: 2e4,
18300
18569
  GET_CONTRACTS_WITH_VTXOS: 2e4,
18570
+ GET_WATCHED_SCRIPTS: 1e4,
18301
18571
  ANNOTATE_VTXOS: 2e4,
18302
18572
  GET_SPENDABLE_PATHS: 2e4,
18303
18573
  GET_ALL_SPENDING_PATHS: 2e4,
@@ -18337,6 +18607,10 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
18337
18607
  SIGN_TRANSACTION: 3e4,
18338
18608
  CREATE_CONTRACT: 3e4,
18339
18609
  UPDATE_CONTRACT: 3e4,
18610
+ // Registering a watch is an in-memory map write plus one subscription
18611
+ // update — no indexer round trip on the request path.
18612
+ WATCH_SCRIPT: 1e4,
18613
+ UNWATCH_SCRIPT: 1e4,
18340
18614
  DELETE_CONTRACT: 1e4,
18341
18615
  REFRESH_VTXOS: 3e4,
18342
18616
  REFRESH_OUTPOINTS: 3e4
@@ -18360,6 +18634,7 @@ var DEDUPABLE_REQUEST_TYPES = /* @__PURE__ */ new Set([
18360
18634
  "GET_SPENDABLE_VTXOS",
18361
18635
  "GET_CONTRACTS",
18362
18636
  "GET_CONTRACTS_WITH_VTXOS",
18637
+ "GET_WATCHED_SCRIPTS",
18363
18638
  "ANNOTATE_VTXOS",
18364
18639
  "GET_SPENDABLE_PATHS",
18365
18640
  "GET_ALL_SPENDING_PATHS",
@@ -18870,7 +19145,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
18870
19145
  try {
18871
19146
  const response = await this.sendMessage(message);
18872
19147
  const { vtxos, page } = response.payload;
18873
- return { vtxos: vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo), page: page && { ...page } };
19148
+ return { vtxos: vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo), page: page && { ...page } };
18874
19149
  } catch (error) {
18875
19150
  throw new Error(`Failed to get vtxos: ${error}`, { cause: error });
18876
19151
  }
@@ -18974,7 +19249,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
18974
19249
  };
18975
19250
  try {
18976
19251
  const response = await this.sendMessage(message);
18977
- return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
19252
+ return response.payload.vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo);
18978
19253
  } catch (error) {
18979
19254
  throw new Error(`Failed to get vtxos: ${error}`);
18980
19255
  }
@@ -18999,7 +19274,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
18999
19274
  };
19000
19275
  try {
19001
19276
  const response = await this.sendMessage(message);
19002
- return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
19277
+ return response.payload.vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo);
19003
19278
  } catch (error) {
19004
19279
  throw new Error(`Failed to get spendable vtxos: ${error}`);
19005
19280
  }
@@ -19099,6 +19374,46 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19099
19374
  throw new Error("Failed to get contracts with vtxos");
19100
19375
  }
19101
19376
  },
19377
+ async watchScript(script, options) {
19378
+ const message = {
19379
+ type: "WATCH_SCRIPT",
19380
+ id: getRandomId(),
19381
+ tag: messageTag,
19382
+ payload: { script, label: options?.label }
19383
+ };
19384
+ try {
19385
+ await sendContractMessage(message);
19386
+ } catch (e) {
19387
+ throw new Error("Failed to watch script");
19388
+ }
19389
+ },
19390
+ async unwatchScript(script) {
19391
+ const message = {
19392
+ type: "UNWATCH_SCRIPT",
19393
+ id: getRandomId(),
19394
+ tag: messageTag,
19395
+ payload: { script }
19396
+ };
19397
+ try {
19398
+ await sendContractMessage(message);
19399
+ } catch (e) {
19400
+ throw new Error("Failed to unwatch script");
19401
+ }
19402
+ },
19403
+ async getWatchedScripts() {
19404
+ const message = {
19405
+ type: "GET_WATCHED_SCRIPTS",
19406
+ id: getRandomId(),
19407
+ tag: messageTag,
19408
+ payload: {}
19409
+ };
19410
+ try {
19411
+ const response = await sendContractMessage(message);
19412
+ return response.payload.scripts;
19413
+ } catch (e) {
19414
+ throw new Error("Failed to get watched scripts");
19415
+ }
19416
+ },
19102
19417
  getSyncState() {
19103
19418
  return syncState;
19104
19419
  },
@@ -19130,7 +19445,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19130
19445
  };
19131
19446
  try {
19132
19447
  const response = await sendContractMessage(message);
19133
- return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
19448
+ return response.payload.vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo);
19134
19449
  } catch (e) {
19135
19450
  throw new Error("Failed to annotate vtxos");
19136
19451
  }
@@ -19735,7 +20050,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
19735
20050
  };
19736
20051
  try {
19737
20052
  const response = await wallet.sendMessage(message);
19738
- return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
20053
+ return response.payload.vtxos.map(chunkXR23C6TF_cjs.normalizeVtxo);
19739
20054
  } catch (e) {
19740
20055
  throw new Error(`Failed to get expiring vtxos: ${e}`);
19741
20056
  }
@@ -19847,12 +20162,12 @@ var OnchainWallet = class _OnchainWallet {
19847
20162
  * @returns Configured onchain wallet
19848
20163
  * @throws Error if the configured identity cannot produce a valid x-only public key
19849
20164
  */
19850
- static async create(identity, networkName = chunkC5Y2R63Z_cjs.DEFAULT_NETWORK_NAME, provider) {
20165
+ static async create(identity, networkName = chunkXR23C6TF_cjs.DEFAULT_NETWORK_NAME, provider) {
19851
20166
  const pubkey = await identity.xOnlyPublicKey();
19852
20167
  if (!pubkey) {
19853
20168
  throw new Error("Invalid configured public key");
19854
20169
  }
19855
- const network = chunkC5Y2R63Z_cjs.getNetwork(networkName);
20170
+ const network = chunkXR23C6TF_cjs.getNetwork(networkName);
19856
20171
  const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
19857
20172
  const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
19858
20173
  return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
@@ -19958,7 +20273,7 @@ var OnchainWallet = class _OnchainWallet {
19958
20273
  if (!inputs) {
19959
20274
  throw new Error("Fee estimation failed");
19960
20275
  }
19961
- let tx = new chunkC5Y2R63Z_cjs.Transaction();
20276
+ let tx = new chunkXR23C6TF_cjs.Transaction();
19962
20277
  for (const input of inputs) {
19963
20278
  tx.addInput({
19964
20279
  txid: input.txid,
@@ -20016,7 +20331,7 @@ var OnchainWallet = class _OnchainWallet {
20016
20331
  * @throws If the parent has no anchor, or funding cannot be selected/signed
20017
20332
  */
20018
20333
  async bumpAnchor(parentHex, feeRate) {
20019
- const parent = chunkC5Y2R63Z_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20334
+ const parent = chunkXR23C6TF_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20020
20335
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
20021
20336
  const child = await this.buildBumpPackage(parent, feeRate, coins);
20022
20337
  return [parent.hex, child.hex];
@@ -20923,7 +21238,7 @@ async function resolvePrevTxs(txids, source, onchain) {
20923
21238
  try {
20924
21239
  const { txs } = await source.getVirtualTxs(wanted);
20925
21240
  for (const psbt of txs) {
20926
- const tx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21241
+ const tx = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
20927
21242
  resolved.set(tx.id, tx.toBytes());
20928
21243
  }
20929
21244
  } catch (err) {
@@ -20956,7 +21271,7 @@ async function resolvePrevTxs(txids, source, onchain) {
20956
21271
  async function attachPrevArkTxs(tx, txids, source, onchain) {
20957
21272
  const pending = [];
20958
21273
  for (let i = 0; i < tx.inputsLength; i++) {
20959
- if (chunkC5Y2R63Z_cjs.getArkPsbtFields(tx, i, chunkC5Y2R63Z_cjs.PrevArkTxField).length === 0) pending.push(i);
21274
+ if (chunkXR23C6TF_cjs.getArkPsbtFields(tx, i, chunkXR23C6TF_cjs.PrevArkTxField).length === 0) pending.push(i);
20960
21275
  }
20961
21276
  if (pending.length === 0) return;
20962
21277
  const resolved = await resolvePrevTxs(
@@ -20965,13 +21280,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
20965
21280
  onchain
20966
21281
  );
20967
21282
  for (const i of pending) {
20968
- chunkC5Y2R63Z_cjs.setArkPsbtField(tx, i, chunkC5Y2R63Z_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
21283
+ chunkXR23C6TF_cjs.setArkPsbtField(tx, i, chunkXR23C6TF_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
20969
21284
  }
20970
21285
  }
20971
21286
  async function attachPrevoutTxs(tx, source) {
20972
21287
  const pending = [];
20973
21288
  for (let i = 0; i < tx.inputsLength; i++) {
20974
- if (chunkC5Y2R63Z_cjs.getArkPsbtFields(tx, i, chunkC5Y2R63Z_cjs.PrevoutTxField).length > 0) continue;
21289
+ if (chunkXR23C6TF_cjs.getArkPsbtFields(tx, i, chunkXR23C6TF_cjs.PrevoutTxField).length > 0) continue;
20975
21290
  const input = tx.getInput(i);
20976
21291
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
20977
21292
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -20982,7 +21297,7 @@ async function attachPrevoutTxs(tx, source) {
20982
21297
  resolved.set(txid, await source.getRawTransaction(txid));
20983
21298
  }
20984
21299
  for (const { index, txid } of pending) {
20985
- chunkC5Y2R63Z_cjs.setArkPsbtField(tx, index, chunkC5Y2R63Z_cjs.PrevoutTxField, resolved.get(txid));
21300
+ chunkXR23C6TF_cjs.setArkPsbtField(tx, index, chunkXR23C6TF_cjs.PrevoutTxField, resolved.get(txid));
20986
21301
  }
20987
21302
  }
20988
21303
  async function withPrevTxs(coins, source, onchain) {
@@ -21008,7 +21323,7 @@ exports.BIP322 = void 0;
21008
21323
  async function sign2(message, identity, network) {
21009
21324
  const xOnlyPubKey = await identity.xOnlyPublicKey();
21010
21325
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
21011
- const toSpend = chunkC5Y2R63Z_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21326
+ const toSpend = chunkXR23C6TF_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21012
21327
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
21013
21328
  const signed = await identity.sign(toSign, [0]);
21014
21329
  signed.finalizeIdx(0);
@@ -21066,7 +21381,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
21066
21381
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
21067
21382
  return false;
21068
21383
  }
21069
- const toSpend = chunkC5Y2R63Z_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21384
+ const toSpend = chunkXR23C6TF_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21070
21385
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
21071
21386
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
21072
21387
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -21087,7 +21402,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
21087
21402
  }
21088
21403
  const sighashType = sigWithHash[sigWithHash.length - 1];
21089
21404
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
21090
- const toSpend = chunkC5Y2R63Z_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21405
+ const toSpend = chunkXR23C6TF_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21091
21406
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
21092
21407
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
21093
21408
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -21140,7 +21455,7 @@ function encodeCompactSize(n) {
21140
21455
  return buf;
21141
21456
  }
21142
21457
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21143
- const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 0 });
21458
+ const tx = new chunkXR23C6TF_cjs.Transaction({ version: 0 });
21144
21459
  tx.addInput({
21145
21460
  txid: toSpend.id,
21146
21461
  index: 0,
@@ -21154,12 +21469,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21154
21469
  });
21155
21470
  tx.addOutput({
21156
21471
  amount: 0n,
21157
- script: chunkC5Y2R63Z_cjs.OP_RETURN_EMPTY_PKSCRIPT
21472
+ script: chunkXR23C6TF_cjs.OP_RETURN_EMPTY_PKSCRIPT
21158
21473
  });
21159
21474
  return tx;
21160
21475
  }
21161
21476
  function craftBIP322ToSignSimple(toSpend, pkScript) {
21162
- const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 0 });
21477
+ const tx = new chunkXR23C6TF_cjs.Transaction({ version: 0 });
21163
21478
  tx.addInput({
21164
21479
  txid: toSpend.id,
21165
21480
  index: 0,
@@ -21171,7 +21486,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
21171
21486
  });
21172
21487
  tx.addOutput({
21173
21488
  amount: 0n,
21174
- script: chunkC5Y2R63Z_cjs.OP_RETURN_EMPTY_PKSCRIPT
21489
+ script: chunkXR23C6TF_cjs.OP_RETURN_EMPTY_PKSCRIPT
21175
21490
  });
21176
21491
  return tx;
21177
21492
  }
@@ -21184,7 +21499,7 @@ var RestEmulatorProvider = class {
21184
21499
  serverUrl;
21185
21500
  async getInfo() {
21186
21501
  const url = `${this.serverUrl}/v1/info`;
21187
- const response = await fetch(url);
21502
+ const response = await chunkXR23C6TF_cjs.baseFetch(url);
21188
21503
  if (!response.ok) {
21189
21504
  const errorText2 = await response.text();
21190
21505
  throw new Error(`Failed to get emulator info: ${errorText2}`);
@@ -21302,7 +21617,7 @@ var RestEmulatorProvider = class {
21302
21617
  }
21303
21618
  };
21304
21619
  function finalizeVirtualTx(type, psbtBase64) {
21305
- const tx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
21620
+ const tx = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
21306
21621
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
21307
21622
  const input = tx.getInput(0);
21308
21623
  if (!input) {
@@ -21329,14 +21644,14 @@ var ExitPathError = class extends Error {
21329
21644
  reason;
21330
21645
  };
21331
21646
  function delayWeight(sequence) {
21332
- const t = chunkC5Y2R63Z_cjs.sequenceToTimelock(sequence);
21647
+ const t = chunkXR23C6TF_cjs.sequenceToTimelock(sequence);
21333
21648
  return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
21334
21649
  }
21335
21650
  async function resolveUnilateralPath(params) {
21336
21651
  const { vtxo, scriptHex, contractRepository } = params;
21337
21652
  const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
21338
21653
  if (contract) {
21339
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
21654
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(contract.type);
21340
21655
  if (!handler) {
21341
21656
  throw new ExitPathError(
21342
21657
  "no-handler",
@@ -21358,12 +21673,12 @@ async function resolveUnilateralPath(params) {
21358
21673
  paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
21359
21674
  return { selection: paths[0], label: `${contract.type}:unilateral` };
21360
21675
  }
21361
- const decoded = chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree);
21676
+ const decoded = chunkXR23C6TF_cjs.VtxoScript.decode(vtxo.tapTree);
21362
21677
  let best;
21363
21678
  for (const exit of decoded.exitPaths()) {
21364
21679
  const leaf = decoded.findLeaf(base.hex.encode(exit.script));
21365
21680
  if (!leaf) continue;
21366
- const sequence = chunkC5Y2R63Z_cjs.timelockToSequence(exit.params.timelock);
21681
+ const sequence = chunkXR23C6TF_cjs.timelockToSequence(exit.params.timelock);
21367
21682
  const weight = delayWeight(sequence);
21368
21683
  if (!best || weight < best.weight) {
21369
21684
  best = { selection: { leaf, sequence }, weight };
@@ -21583,7 +21898,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21583
21898
  let totalAmount = 0n;
21584
21899
  const txWeightEstimator = TxWeightEstimator.create();
21585
21900
  for (const vtxo of vtxos) {
21586
- if (!chunkC5Y2R63Z_cjs.canSweepOnchain(vtxo)) {
21901
+ if (!chunkXR23C6TF_cjs.canSweepOnchain(vtxo)) {
21587
21902
  throw new Error(
21588
21903
  `Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
21589
21904
  );
@@ -21594,13 +21909,13 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21594
21909
  }
21595
21910
  const resolved = await resolveUnilateralPath({
21596
21911
  vtxo,
21597
- scriptHex: base.hex.encode(chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
21912
+ scriptHex: base.hex.encode(chunkXR23C6TF_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
21598
21913
  contractRepository: wallet.contractRepository,
21599
21914
  currentTime: Date.now()
21600
21915
  });
21601
21916
  const spendingLeaf = resolved.selection.leaf;
21602
21917
  const sequence = resolved.selection.sequence;
21603
- const timelock = chunkC5Y2R63Z_cjs.sequenceToTimelock(sequence);
21918
+ const timelock = chunkXR23C6TF_cjs.sequenceToTimelock(sequence);
21604
21919
  const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
21605
21920
  if (!elapsed) {
21606
21921
  throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
@@ -21613,7 +21928,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21613
21928
  sequence,
21614
21929
  witnessUtxo: {
21615
21930
  amount: BigInt(vtxo.value),
21616
- script: chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
21931
+ script: chunkXR23C6TF_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
21617
21932
  },
21618
21933
  sighashType: btcSigner.SigHash.DEFAULT
21619
21934
  });
@@ -21623,7 +21938,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21623
21938
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
21624
21939
  );
21625
21940
  }
21626
- const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 2 });
21941
+ const tx = new chunkXR23C6TF_cjs.Transaction({ version: 2 });
21627
21942
  for (const input of inputs) {
21628
21943
  tx.addInput(input);
21629
21944
  }
@@ -21706,7 +22021,7 @@ async function buildSignedSweep(params) {
21706
22021
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
21707
22022
  );
21708
22023
  }
21709
- const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 2 });
22024
+ const tx = new chunkXR23C6TF_cjs.Transaction({ version: 2 });
21710
22025
  tx.addInput({
21711
22026
  txid: vtxo.txid,
21712
22027
  index: vtxo.vout,
@@ -21731,7 +22046,7 @@ async function buildSignedSweep(params) {
21731
22046
  finalScriptWitness: [
21732
22047
  tapScriptSig[0][1],
21733
22048
  ...path.extraWitness,
21734
- chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(path.leaf),
22049
+ chunkXR23C6TF_cjs.scriptFromTapLeafScript(path.leaf),
21735
22050
  btcSigner.TaprootControlBlock.encode(controlBlock)
21736
22051
  ]
21737
22052
  });
@@ -21761,7 +22076,7 @@ async function resolveFeeRate(opts) {
21761
22076
  }
21762
22077
  async function selectExitVtxos(opts) {
21763
22078
  if (!opts.vtxos) return opts.wallet.getVtxos();
21764
- const res = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22079
+ const res = await chunkXR23C6TF_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
21765
22080
  const tapTrees = /* @__PURE__ */ new Map();
21766
22081
  const out = [];
21767
22082
  for (const vtxo of res.vtxos) {
@@ -21776,7 +22091,7 @@ async function selectExitVtxos(opts) {
21776
22091
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
21777
22092
  );
21778
22093
  }
21779
- const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
22094
+ const handler = chunkZF52B7BV_cjs.contractHandlers.get(contract.type);
21780
22095
  if (!handler) {
21781
22096
  throw new Error(`no contract handler registered for type '${contract.type}'`);
21782
22097
  }
@@ -21806,7 +22121,7 @@ async function computeExitLayout(opts, feeRate) {
21806
22121
  if (pendingNodes.length > 0) {
21807
22122
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
21808
22123
  for (const psbt of txs) {
21809
- psbts.set(chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22124
+ psbts.set(chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
21810
22125
  }
21811
22126
  }
21812
22127
  const childVsize = Number(
@@ -21842,7 +22157,7 @@ async function computeExitLayout(opts, feeRate) {
21842
22157
  try {
21843
22158
  const resolved = await resolveUnilateralPath({
21844
22159
  vtxo,
21845
- scriptHex: base.hex.encode(chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22160
+ scriptHex: base.hex.encode(chunkXR23C6TF_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
21846
22161
  contractRepository: wallet.contractRepository,
21847
22162
  walletDescriptor,
21848
22163
  currentTime: Date.now()
@@ -21861,7 +22176,7 @@ async function computeExitLayout(opts, feeRate) {
21861
22176
  });
21862
22177
  continue;
21863
22178
  }
21864
- const t = chunkC5Y2R63Z_cjs.sequenceToTimelock(resolved.selection.sequence);
22179
+ const t = chunkXR23C6TF_cjs.sequenceToTimelock(resolved.selection.sequence);
21865
22180
  const delay = { type: t.type, value: Number(t.value) };
21866
22181
  infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
21867
22182
  sweeps.push({ vtxo, resolved, sweepFee, delay });
@@ -22262,7 +22577,7 @@ async function prepare(opts) {
22262
22577
  txid: sweep.vtxo.txid,
22263
22578
  vout: sweep.vtxo.vout,
22264
22579
  value: sweep.vtxo.value,
22265
- pkScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
22580
+ pkScript: chunkXR23C6TF_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
22266
22581
  },
22267
22582
  path: sweep.resolved.selection,
22268
22583
  outputAddress: opts.sweepAddress,
@@ -22350,7 +22665,7 @@ async function prepare(opts) {
22350
22665
  if (newFee <= splitterFee) break;
22351
22666
  splitterFee = newFee;
22352
22667
  }
22353
- const splitter = new chunkC5Y2R63Z_cjs.Transaction({ version: 2 });
22668
+ const splitter = new chunkXR23C6TF_cjs.Transaction({ version: 2 });
22354
22669
  for (const coin of selected.inputs) {
22355
22670
  splitter.addInput({
22356
22671
  txid: coin.txid,
@@ -22493,42 +22808,42 @@ var UnilateralExit = {
22493
22808
 
22494
22809
  // src/arkade/index.ts
22495
22810
  var arkade_exports = {};
22496
- chunkC5Y2R63Z_cjs.__export(arkade_exports, {
22497
- ARKADE_OP: () => chunkF7HJO5GT_cjs.ARKADE_OP,
22498
- ARKADE_OPCODES: () => chunkF7HJO5GT_cjs.ARKADE_OPCODES,
22499
- ARKADE_OPCODE_NAMES: () => chunkF7HJO5GT_cjs.ARKADE_OPCODE_NAMES,
22500
- ARKADE_OPCODE_VALUES: () => chunkF7HJO5GT_cjs.ARKADE_OPCODE_VALUES,
22501
- ARKADE_OPS: () => chunkF7HJO5GT_cjs.ARKADE_OPS,
22811
+ chunkXR23C6TF_cjs.__export(arkade_exports, {
22812
+ ARKADE_OP: () => chunkZF52B7BV_cjs.ARKADE_OP,
22813
+ ARKADE_OPCODES: () => chunkZF52B7BV_cjs.ARKADE_OPCODES,
22814
+ ARKADE_OPCODE_NAMES: () => chunkZF52B7BV_cjs.ARKADE_OPCODE_NAMES,
22815
+ ARKADE_OPCODE_VALUES: () => chunkZF52B7BV_cjs.ARKADE_OPCODE_VALUES,
22816
+ ARKADE_OPS: () => chunkZF52B7BV_cjs.ARKADE_OPS,
22502
22817
  Arkade: () => Arkade,
22503
22818
  ArkadeContract: () => ArkadeContract,
22504
- ArkadeProgramScript: () => chunkF7HJO5GT_cjs.ArkadeProgramScript,
22505
- ArkadeScript: () => chunkF7HJO5GT_cjs.ArkadeScript,
22819
+ ArkadeProgramScript: () => chunkZF52B7BV_cjs.ArkadeProgramScript,
22820
+ ArkadeScript: () => chunkZF52B7BV_cjs.ArkadeScript,
22506
22821
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
22507
- BigNum: () => chunkF7HJO5GT_cjs.bignum_exports,
22822
+ BigNum: () => chunkZF52B7BV_cjs.bignum_exports,
22508
22823
  OP: () => btcSigner.OP,
22509
- OPCODE_NAMES: () => chunkF7HJO5GT_cjs.OPCODE_NAMES,
22510
- OPCODE_VALUES: () => chunkF7HJO5GT_cjs.OPCODE_VALUES,
22511
- SUPPORTED_PROGRAM_VERSION: () => chunkF7HJO5GT_cjs.SUPPORTED_PROGRAM_VERSION,
22824
+ OPCODE_NAMES: () => chunkZF52B7BV_cjs.OPCODE_NAMES,
22825
+ OPCODE_VALUES: () => chunkZF52B7BV_cjs.OPCODE_VALUES,
22826
+ SUPPORTED_PROGRAM_VERSION: () => chunkZF52B7BV_cjs.SUPPORTED_PROGRAM_VERSION,
22512
22827
  Script: () => btcSigner.Script,
22513
- arkadeScriptHash: () => chunkF7HJO5GT_cjs.arkadeScriptHash,
22514
- arkadeWitnessHash: () => chunkF7HJO5GT_cjs.arkadeWitnessHash,
22515
- asmToBytes: () => chunkF7HJO5GT_cjs.asmToBytes,
22516
- bytesToASM: () => chunkF7HJO5GT_cjs.bytesToASM,
22517
- computeArkadeScriptPublicKey: () => chunkF7HJO5GT_cjs.computeArkadeScriptPublicKey,
22828
+ arkadeScriptHash: () => chunkZF52B7BV_cjs.arkadeScriptHash,
22829
+ arkadeWitnessHash: () => chunkZF52B7BV_cjs.arkadeWitnessHash,
22830
+ asmToBytes: () => chunkZF52B7BV_cjs.asmToBytes,
22831
+ bytesToASM: () => chunkZF52B7BV_cjs.bytesToASM,
22832
+ computeArkadeScriptPublicKey: () => chunkZF52B7BV_cjs.computeArkadeScriptPublicKey,
22518
22833
  createArkadeBatchHandler: () => createArkadeBatchHandler,
22519
- deserializeArkadeContractParams: () => chunkF7HJO5GT_cjs.deserializeArkadeContractParams,
22520
- fromASM: () => chunkF7HJO5GT_cjs.fromASM,
22521
- getOpcodeName: () => chunkF7HJO5GT_cjs.getOpcodeName,
22522
- getOpcodeValue: () => chunkF7HJO5GT_cjs.getOpcodeValue,
22523
- parseArtifact: () => chunkF7HJO5GT_cjs.parseArtifact,
22524
- resolveAsm: () => chunkF7HJO5GT_cjs.resolveAsm,
22525
- serializeArkadeContractParams: () => chunkF7HJO5GT_cjs.serializeArkadeContractParams,
22526
- stringifyArtifact: () => chunkF7HJO5GT_cjs.stringifyArtifact,
22527
- toASM: () => chunkF7HJO5GT_cjs.toASM,
22528
- validateProgram: () => chunkF7HJO5GT_cjs.validateProgram,
22529
- witnessRefToBytes: () => chunkF7HJO5GT_cjs.witnessRefToBytes
22834
+ deserializeArkadeContractParams: () => chunkZF52B7BV_cjs.deserializeArkadeContractParams,
22835
+ fromASM: () => chunkZF52B7BV_cjs.fromASM,
22836
+ getOpcodeName: () => chunkZF52B7BV_cjs.getOpcodeName,
22837
+ getOpcodeValue: () => chunkZF52B7BV_cjs.getOpcodeValue,
22838
+ parseArtifact: () => chunkZF52B7BV_cjs.parseArtifact,
22839
+ resolveAsm: () => chunkZF52B7BV_cjs.resolveAsm,
22840
+ serializeArkadeContractParams: () => chunkZF52B7BV_cjs.serializeArkadeContractParams,
22841
+ stringifyArtifact: () => chunkZF52B7BV_cjs.stringifyArtifact,
22842
+ toASM: () => chunkZF52B7BV_cjs.toASM,
22843
+ validateProgram: () => chunkZF52B7BV_cjs.validateProgram,
22844
+ witnessRefToBytes: () => chunkZF52B7BV_cjs.witnessRefToBytes
22530
22845
  });
22531
- var isVtxoCoin = (input) => chunkC5Y2R63Z_cjs.isVirtualCoin(input);
22846
+ var isVtxoCoin = (input) => chunkXR23C6TF_cjs.isVirtualCoin(input);
22532
22847
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
22533
22848
  let batchId;
22534
22849
  let sweepTapTreeRoot;
@@ -22549,23 +22864,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22549
22864
  );
22550
22865
  await arkProvider.confirmRegistration(intentId);
22551
22866
  batchId = event.id;
22552
- const sweepTapscript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.encode({
22867
+ const sweepTapscript = chunkXR23C6TF_cjs.CSVMultisigTapscript.encode({
22553
22868
  timelock,
22554
- pubkeys: [chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
22869
+ pubkeys: [chunkZF52B7BV_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
22555
22870
  }).script;
22556
22871
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
22557
22872
  return { skip: false };
22558
22873
  },
22559
22874
  onTreeSigningStarted: async (event, vtxoTree) => {
22560
22875
  const signerPubKey = await session.getPublicKey();
22561
- const xonlySignerPubKey = chunkF7HJO5GT_cjs.toXOnly(signerPubKey, "signer key");
22876
+ const xonlySignerPubKey = chunkZF52B7BV_cjs.toXOnly(signerPubKey, "signer key");
22562
22877
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
22563
- (k) => base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
22878
+ (k) => base.hex.encode(chunkZF52B7BV_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
22564
22879
  );
22565
22880
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
22566
22881
  return { skip: true };
22567
22882
  }
22568
- const commitmentTx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
22883
+ const commitmentTx = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
22569
22884
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
22570
22885
  if (recipients && recipients.length > 0) {
22571
22886
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -22597,7 +22912,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22597
22912
  if (connectorTree) {
22598
22913
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
22599
22914
  }
22600
- let commitmentPsbt = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
22915
+ let commitmentPsbt = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
22601
22916
  assertFinalCommitmentMatchesValidated(
22602
22917
  commitmentPsbt,
22603
22918
  validatedCommitmentTxid,
@@ -22632,7 +22947,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22632
22947
  boardingIndices.push(boardingIdx);
22633
22948
  continue;
22634
22949
  }
22635
- if (chunkC5Y2R63Z_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust(input, info.dust)) {
22950
+ if (chunkXR23C6TF_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust(input, info.dust)) {
22636
22951
  continue;
22637
22952
  }
22638
22953
  if (connectorIndex >= connectorLeaves.length) {
@@ -22653,7 +22968,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22653
22968
  index: input.vout,
22654
22969
  witnessUtxo: {
22655
22970
  amount: BigInt(input.value),
22656
- script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
22971
+ script: chunkXR23C6TF_cjs.VtxoScript.decode(input.tapTree).pkScript
22657
22972
  },
22658
22973
  sighashType: btcSigner.SigHash.DEFAULT,
22659
22974
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -22744,16 +23059,16 @@ var Arkade = class _Arkade {
22744
23059
  /** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
22745
23060
  static async connect(opts) {
22746
23061
  const info = await opts.arkade.getInfo();
22747
- const serverKey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
22748
- const checkpoint = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
22749
- const network = opts.network ?? chunkC5Y2R63Z_cjs.DEFAULT_NETWORK;
23062
+ const serverKey = chunkZF52B7BV_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
23063
+ const checkpoint = chunkXR23C6TF_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
23064
+ const network = opts.network ?? chunkXR23C6TF_cjs.DEFAULT_NETWORK;
22750
23065
  let emulatorKey;
22751
23066
  if (opts.emulator) {
22752
- emulatorKey = base.hex.decode(chunkC5Y2R63Z_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23067
+ emulatorKey = base.hex.decode(chunkXR23C6TF_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
22753
23068
  }
22754
23069
  let userKey;
22755
23070
  if (opts.identity) {
22756
- userKey = chunkF7HJO5GT_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23071
+ userKey = chunkZF52B7BV_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
22757
23072
  }
22758
23073
  return new _Arkade({
22759
23074
  arkProvider: opts.arkade,
@@ -22779,7 +23094,7 @@ var Arkade = class _Arkade {
22779
23094
  * key respectively; explicit args always win.
22780
23095
  */
22781
23096
  contract(program, args = {}) {
22782
- const declared = (program.params ?? []).map(chunkF7HJO5GT_cjs.inputName);
23097
+ const declared = (program.params ?? []).map(chunkZF52B7BV_cjs.inputName);
22783
23098
  if (declared.includes("server") && args.server === void 0) {
22784
23099
  args = { ...args, server: this.serverKey };
22785
23100
  }
@@ -22799,7 +23114,7 @@ var ArkadeContract = class _ArkadeContract {
22799
23114
  userKey: client.userKey,
22800
23115
  emulatorKey: client.emulatorKey
22801
23116
  };
22802
- this.vtxoScript = new chunkF7HJO5GT_cjs.ArkadeProgramScript(program, args, this.keys);
23117
+ this.vtxoScript = new chunkZF52B7BV_cjs.ArkadeProgramScript(program, args, this.keys);
22803
23118
  this.tapTree = this.vtxoScript.encode();
22804
23119
  this.compiled = this.vtxoScript.compiled;
22805
23120
  }
@@ -22827,7 +23142,7 @@ var ArkadeContract = class _ArkadeContract {
22827
23142
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
22828
23143
  );
22829
23144
  }
22830
- const typed = chunkF7HJO5GT_cjs.deserializeArkadeContractParams(contract.params);
23145
+ const typed = chunkZF52B7BV_cjs.deserializeArkadeContractParams(contract.params);
22831
23146
  return new _ArkadeContract(client, typed.program, typed.args, {
22832
23147
  serverKey: typed.serverKey,
22833
23148
  userKey: typed.userKey,
@@ -22868,7 +23183,7 @@ var ArkadeContract = class _ArkadeContract {
22868
23183
  toContractParams() {
22869
23184
  return {
22870
23185
  type: "arkade",
22871
- params: chunkF7HJO5GT_cjs.serializeArkadeContractParams({
23186
+ params: chunkZF52B7BV_cjs.serializeArkadeContractParams({
22872
23187
  program: this.program,
22873
23188
  args: this.args,
22874
23189
  serverKey: this.keys.serverKey,
@@ -22918,18 +23233,18 @@ var ArkadeContract = class _ArkadeContract {
22918
23233
  if (registered) {
22919
23234
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
22920
23235
  return (withVtxos?.vtxos ?? []).filter(
22921
- (v) => !chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isUnrolled
23236
+ (v) => !chunkXR23C6TF_cjs.hasTerminalSpend(v) && !v.isUnrolled
22922
23237
  );
22923
23238
  }
22924
23239
  }
22925
23240
  if (!this.client.indexer) {
22926
23241
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
22927
23242
  }
22928
- const { vtxos } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(this.client.indexer, {
23243
+ const { vtxos } = await chunkXR23C6TF_cjs.getNormalizedVtxos(this.client.indexer, {
22929
23244
  scripts: [scriptHex],
22930
23245
  spendableOnly: true
22931
23246
  });
22932
- return vtxos.filter((v) => !chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isUnrolled);
23247
+ return vtxos.filter((v) => !chunkXR23C6TF_cjs.hasTerminalSpend(v) && !v.isUnrolled);
22933
23248
  }
22934
23249
  /** Total spendable balance (requires an indexer). */
22935
23250
  async getBalance() {
@@ -23027,7 +23342,7 @@ var ArkadeTransactionBuilder = class {
23027
23342
  this.contract.client.checkpoint
23028
23343
  );
23029
23344
  if (coin.sourceTx) {
23030
- chunkC5Y2R63Z_cjs.setArkPsbtField(arkTx, 0, chunkC5Y2R63Z_cjs.PrevArkTxField, coin.sourceTx);
23345
+ chunkXR23C6TF_cjs.setArkPsbtField(arkTx, 0, chunkXR23C6TF_cjs.PrevArkTxField, coin.sourceTx);
23031
23346
  }
23032
23347
  if (this.fn.arkadeScript) {
23033
23348
  const indexer = this.contract.client.indexer;
@@ -23044,8 +23359,8 @@ var ArkadeTransactionBuilder = class {
23044
23359
  }
23045
23360
  const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
23046
23361
  if (condition.length > 0) {
23047
- chunkC5Y2R63Z_cjs.setArkPsbtField(arkTx, 0, chunkC5Y2R63Z_cjs.ConditionWitness, condition);
23048
- chunkC5Y2R63Z_cjs.setArkPsbtField(checkpoints[0], 0, chunkC5Y2R63Z_cjs.ConditionWitness, condition);
23362
+ chunkXR23C6TF_cjs.setArkPsbtField(arkTx, 0, chunkXR23C6TF_cjs.ConditionWitness, condition);
23363
+ chunkXR23C6TF_cjs.setArkPsbtField(checkpoints[0], 0, chunkXR23C6TF_cjs.ConditionWitness, condition);
23049
23364
  }
23050
23365
  const packets = [];
23051
23366
  if (this.assetSpecs.length > 0) {
@@ -23084,7 +23399,7 @@ var ArkadeTransactionBuilder = class {
23084
23399
  base.base64.encode(signedArk2.toPSBT()),
23085
23400
  signedCps.map((c) => base.base64.encode(c.toPSBT()))
23086
23401
  );
23087
- const txid = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23402
+ const txid = chunkXR23C6TF_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23088
23403
  return {
23089
23404
  txid,
23090
23405
  signedArkTx: res2.signedArkTx,
@@ -23149,23 +23464,23 @@ var ArkadeTransactionBuilder = class {
23149
23464
  }
23150
23465
  buildAssetPacket() {
23151
23466
  const groups = this.assetSpecs.map((s) => {
23152
- const id = typeof s.assetId === "string" ? chunkSYRQJS5N_cjs.AssetId.fromString(s.assetId) : chunkSYRQJS5N_cjs.AssetId.fromBytes(s.assetId);
23153
- return chunkSYRQJS5N_cjs.AssetGroup.create(
23467
+ const id = typeof s.assetId === "string" ? chunkTVG3GDEO_cjs.AssetId.fromString(s.assetId) : chunkTVG3GDEO_cjs.AssetId.fromBytes(s.assetId);
23468
+ return chunkTVG3GDEO_cjs.AssetGroup.create(
23154
23469
  id,
23155
23470
  null,
23156
- s.inputs.map((i) => chunkSYRQJS5N_cjs.AssetInput.create(i.vin, i.amount)),
23157
- s.outputs.map((o) => chunkSYRQJS5N_cjs.AssetOutput.create(o.vout, o.amount)),
23158
- (s.metadata ?? []).map((m) => chunkSYRQJS5N_cjs.Metadata.create(m.key, m.value))
23471
+ s.inputs.map((i) => chunkTVG3GDEO_cjs.AssetInput.create(i.vin, i.amount)),
23472
+ s.outputs.map((o) => chunkTVG3GDEO_cjs.AssetOutput.create(o.vout, o.amount)),
23473
+ (s.metadata ?? []).map((m) => chunkTVG3GDEO_cjs.Metadata.create(m.key, m.value))
23159
23474
  );
23160
23475
  });
23161
- return chunkSYRQJS5N_cjs.Packet.create(groups);
23476
+ return chunkTVG3GDEO_cjs.Packet.create(groups);
23162
23477
  }
23163
23478
  witnessBytes(ref) {
23164
- return chunkF7HJO5GT_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
23479
+ return chunkZF52B7BV_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
23165
23480
  }
23166
23481
  };
23167
23482
  function bindInputs(fn, callArgs) {
23168
- const names = (fn.def.inputs ?? []).map(chunkF7HJO5GT_cjs.inputName);
23483
+ const names = (fn.def.inputs ?? []).map(chunkZF52B7BV_cjs.inputName);
23169
23484
  if (callArgs.length !== names.length) {
23170
23485
  throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
23171
23486
  }
@@ -23779,6 +24094,7 @@ exports.isArkContract = isArkContract;
23779
24094
  exports.isBatchSignable = isBatchSignable;
23780
24095
  exports.isBtcAddress = isBtcAddress;
23781
24096
  exports.isContractGenericallySpendable = isContractGenericallySpendable;
24097
+ exports.isContractVtxoEvent = isContractVtxoEvent;
23782
24098
  exports.isCooperativelyMigratable = isCooperativelyMigratable;
23783
24099
  exports.isDeterministicSigner = isDeterministicSigner;
23784
24100
  exports.isDiscoverable = isDiscoverable;
@@ -23839,5 +24155,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
23839
24155
  exports.walletFeeSource = walletFeeSource;
23840
24156
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
23841
24157
  exports.withPrevTxs = withPrevTxs;
23842
- //# sourceMappingURL=chunk-ZHLYFRYY.cjs.map
23843
- //# sourceMappingURL=chunk-ZHLYFRYY.cjs.map
24158
+ //# sourceMappingURL=chunk-4I6KPFCB.cjs.map
24159
+ //# sourceMappingURL=chunk-4I6KPFCB.cjs.map