@arkade-os/sdk 0.4.69 → 0.4.71

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 (73) 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/adapters/indexedDB.cjs +5 -5
  6. package/dist/adapters/indexedDB.js +4 -4
  7. package/dist/{asyncStorageTaskQueue-BgUJN-3X.d.ts → asyncStorageTaskQueue-CjKAUiuj.d.ts} +2 -2
  8. package/dist/{asyncStorageTaskQueue-Cstx6hS7.d.cts → asyncStorageTaskQueue-DgXf4iuU.d.cts} +2 -2
  9. package/dist/{chunk-L5SCQYHF.js → chunk-2ZX4Z2IP.js} +3 -3
  10. package/dist/{chunk-L5SCQYHF.js.map → chunk-2ZX4Z2IP.js.map} +1 -1
  11. package/dist/{chunk-5MLC2HU3.cjs → chunk-5J5PDZRR.cjs} +3 -3
  12. package/dist/{chunk-5MLC2HU3.cjs.map → chunk-5J5PDZRR.cjs.map} +1 -1
  13. package/dist/{chunk-HQ4DMGA4.cjs → chunk-7PHMT3T4.cjs} +10 -10
  14. package/dist/{chunk-HQ4DMGA4.cjs.map → chunk-7PHMT3T4.cjs.map} +1 -1
  15. package/dist/{chunk-2PPL3O7Z.js → chunk-ALZ2CZ3T.js} +3 -3
  16. package/dist/{chunk-2PPL3O7Z.js.map → chunk-ALZ2CZ3T.js.map} +1 -1
  17. package/dist/{chunk-TA7XLEP2.js → chunk-E5JNYFOF.js} +350 -36
  18. package/dist/chunk-E5JNYFOF.js.map +1 -0
  19. package/dist/{chunk-GVHUHTRH.cjs → chunk-FM263GKH.cjs} +17 -17
  20. package/dist/{chunk-GVHUHTRH.cjs.map → chunk-FM263GKH.cjs.map} +1 -1
  21. package/dist/{chunk-XQPN5YP2.cjs → chunk-I7ZNWBBU.cjs} +17 -17
  22. package/dist/{chunk-XQPN5YP2.cjs.map → chunk-I7ZNWBBU.cjs.map} +1 -1
  23. package/dist/{chunk-EBYCTLET.cjs → chunk-MK5EPTTB.cjs} +786 -465
  24. package/dist/chunk-MK5EPTTB.cjs.map +1 -0
  25. package/dist/{chunk-XLWDX7QZ.js → chunk-NOWVA5CM.js} +4 -4
  26. package/dist/{chunk-XLWDX7QZ.js.map → chunk-NOWVA5CM.js.map} +1 -1
  27. package/dist/{chunk-WIFL5QYZ.cjs → chunk-P6EXRY5L.cjs} +49 -49
  28. package/dist/{chunk-WIFL5QYZ.cjs.map → chunk-P6EXRY5L.cjs.map} +1 -1
  29. package/dist/{chunk-MNMPGEK2.js → chunk-SCSLCU66.js} +4 -4
  30. package/dist/{chunk-MNMPGEK2.js.map → chunk-SCSLCU66.js.map} +1 -1
  31. package/dist/{chunk-YG7T6LI3.js → chunk-ZT3EM4CE.js} +3 -3
  32. package/dist/{chunk-YG7T6LI3.js.map → chunk-ZT3EM4CE.js.map} +1 -1
  33. package/dist/contracts/handlers/index.cjs +9 -9
  34. package/dist/contracts/handlers/index.d.cts +3 -3
  35. package/dist/contracts/handlers/index.d.ts +3 -3
  36. package/dist/contracts/handlers/index.js +2 -2
  37. package/dist/{delegate-BPdzTbwN.d.ts → delegate-CKJdsC99.d.ts} +1 -1
  38. package/dist/{delegate-DrwIar11.d.cts → delegate-D-gEEqrP.d.cts} +1 -1
  39. package/dist/{hdWalletCapable-DyxCiNVE.d.ts → hdWalletCapable-BJ4pvkai.d.ts} +2 -2
  40. package/dist/{hdWalletCapable-D4WH35z0.d.cts → hdWalletCapable-CwLPmWct.d.cts} +2 -2
  41. package/dist/{index-BqhpAqqj.d.cts → index-BE1uFXrV.d.cts} +2 -2
  42. package/dist/{index-TZJvbIaA.d.ts → index-Boppyqav.d.ts} +2 -2
  43. package/dist/{index-dWRqYSdS.d.ts → index-CyGnhCSS.d.cts} +98 -2
  44. package/dist/{index-dWRqYSdS.d.cts → index-CyGnhCSS.d.ts} +98 -2
  45. package/dist/index.cjs +319 -291
  46. package/dist/index.d.cts +117 -23
  47. package/dist/index.d.ts +117 -23
  48. package/dist/index.js +4 -4
  49. package/dist/repositories/realm/index.cjs +19 -19
  50. package/dist/repositories/realm/index.d.cts +2 -2
  51. package/dist/repositories/realm/index.d.ts +2 -2
  52. package/dist/repositories/realm/index.js +5 -5
  53. package/dist/repositories/sqlite/index.cjs +18 -18
  54. package/dist/repositories/sqlite/index.d.cts +2 -2
  55. package/dist/repositories/sqlite/index.d.ts +2 -2
  56. package/dist/repositories/sqlite/index.js +5 -5
  57. package/dist/{taskRunner-CzYKyJ9c.d.cts → taskRunner-CjmMH_rW.d.cts} +2 -2
  58. package/dist/{taskRunner-D2fnbqYw.d.ts → taskRunner-l3zyfW_Q.d.ts} +2 -2
  59. package/dist/wallet/expo/background.cjs +14 -14
  60. package/dist/wallet/expo/background.d.cts +3 -3
  61. package/dist/wallet/expo/background.d.ts +3 -3
  62. package/dist/wallet/expo/background.js +6 -6
  63. package/dist/wallet/expo/index.cjs +14 -14
  64. package/dist/wallet/expo/index.d.cts +4 -4
  65. package/dist/wallet/expo/index.d.ts +4 -4
  66. package/dist/wallet/expo/index.js +5 -5
  67. package/dist/worker/expo/index.cjs +9 -9
  68. package/dist/worker/expo/index.d.cts +4 -4
  69. package/dist/worker/expo/index.d.ts +4 -4
  70. package/dist/worker/expo/index.js +5 -5
  71. package/package.json +2 -1
  72. package/dist/chunk-EBYCTLET.cjs.map +0 -1
  73. package/dist/chunk-TA7XLEP2.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkGVHUHTRH_cjs = require('./chunk-GVHUHTRH.cjs');
4
- var chunkWIFL5QYZ_cjs = require('./chunk-WIFL5QYZ.cjs');
5
- var chunk5MLC2HU3_cjs = require('./chunk-5MLC2HU3.cjs');
3
+ var chunkFM263GKH_cjs = require('./chunk-FM263GKH.cjs');
4
+ var chunkP6EXRY5L_cjs = require('./chunk-P6EXRY5L.cjs');
5
+ var chunk5J5PDZRR_cjs = require('./chunk-5J5PDZRR.cjs');
6
6
  var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
7
7
  var utils_js = require('@scure/btc-signer/utils.js');
8
8
  var btcSigner = require('@scure/btc-signer');
@@ -188,7 +188,7 @@ var TreeSignerSession = class _TreeSignerSession {
188
188
  noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
189
189
  const tx = this.graph.find(txid);
190
190
  if (!tx) throw new Error(`missing tx for txid ${txid}`);
191
- const cosigners = chunk5MLC2HU3_cjs.getArkPsbtFields(tx.root, 0, chunk5MLC2HU3_cjs.CosignerPublicKey).map(
191
+ const cosigners = chunk5J5PDZRR_cjs.getArkPsbtFields(tx.root, 0, chunk5J5PDZRR_cjs.CosignerPublicKey).map(
192
192
  (c) => base.hex.encode(c.key.subarray(1))
193
193
  // xonly pubkey
194
194
  );
@@ -240,7 +240,7 @@ var TreeSignerSession = class _TreeSignerSession {
240
240
  if (!aggNonce) throw new Error("missing aggregate nonce");
241
241
  const prevoutAmounts = [];
242
242
  const prevoutScripts = [];
243
- const cosigners = chunk5MLC2HU3_cjs.getArkPsbtFields(g.root, 0, chunk5MLC2HU3_cjs.CosignerPublicKey).map((c) => c.key);
243
+ const cosigners = chunk5J5PDZRR_cjs.getArkPsbtFields(g.root, 0, chunk5J5PDZRR_cjs.CosignerPublicKey).map((c) => c.key);
244
244
  const { finalKey } = aggregateKeys(cosigners, true, {
245
245
  taprootTweak: this.scriptRoot
246
246
  });
@@ -323,7 +323,7 @@ var SingleKey = class _SingleKey {
323
323
  async sign(tx, inputIndexes) {
324
324
  const txCpy = tx.clone();
325
325
  if (!inputIndexes) {
326
- chunk5MLC2HU3_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
326
+ chunk5J5PDZRR_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
327
327
  try {
328
328
  if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
329
329
  throw new Error("Failed to sign transaction");
@@ -432,7 +432,7 @@ var SeedIdentity = class _SeedIdentity {
432
432
  let network;
433
433
  if ("descriptor" in opts && typeof opts.descriptor === "string") {
434
434
  descriptor = opts.descriptor;
435
- network = chunkWIFL5QYZ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
435
+ network = chunkP6EXRY5L_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
436
436
  } else {
437
437
  network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
438
438
  descriptor = descriptorsScure.scriptExpressions.trBIP32({
@@ -530,7 +530,7 @@ var SeedIdentity = class _SeedIdentity {
530
530
  * `StaticDescriptorProvider` for legacy single-key wallets.
531
531
  */
532
532
  isOurs(descriptor) {
533
- return chunkWIFL5QYZ_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
533
+ return chunkP6EXRY5L_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
534
534
  }
535
535
  /**
536
536
  * Signs each request with the key derived from its descriptor.
@@ -579,7 +579,7 @@ var SeedIdentity = class _SeedIdentity {
579
579
  }
580
580
  // ── internal helpers ─────────────────────────────────────────────
581
581
  derivePrivateKeyForDescriptor(descriptor) {
582
- const network = chunkWIFL5QYZ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
582
+ const network = chunkP6EXRY5L_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
583
583
  const expansion = descriptorsScure.expand({ descriptor, network });
584
584
  if (expansion.isRanged) {
585
585
  throw new Error(
@@ -604,7 +604,7 @@ var SeedIdentity = class _SeedIdentity {
604
604
  signTxWithKey(tx, key, inputIndexes) {
605
605
  const txCpy = tx.clone();
606
606
  if (!inputIndexes) {
607
- chunk5MLC2HU3_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
607
+ chunk5J5PDZRR_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
608
608
  try {
609
609
  if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
610
610
  throw new Error("Failed to sign transaction");
@@ -666,7 +666,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
666
666
  */
667
667
  descriptor;
668
668
  constructor(descriptor) {
669
- const network = chunkWIFL5QYZ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
669
+ const network = chunkP6EXRY5L_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
670
670
  let expansion;
671
671
  try {
672
672
  expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
@@ -716,7 +716,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
716
716
  * `StaticDescriptorProvider` for legacy single-key wallets.
717
717
  */
718
718
  isOurs(descriptor) {
719
- return chunkWIFL5QYZ_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
719
+ return chunkP6EXRY5L_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
720
720
  }
721
721
  };
722
722
  function serializeSeedOwnedSigningIdentity(identity) {
@@ -878,10 +878,10 @@ var DescriptorIdentity = class {
878
878
  this.base = base;
879
879
  }
880
880
  async xOnlyPublicKey() {
881
- return chunkWIFL5QYZ_cjs.deriveDescriptorLeafPubKey(this.descriptor);
881
+ return chunkP6EXRY5L_cjs.deriveDescriptorLeafPubKey(this.descriptor);
882
882
  }
883
883
  async compressedPublicKey() {
884
- return chunkWIFL5QYZ_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
884
+ return chunkP6EXRY5L_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
885
885
  }
886
886
  async sign(tx, inputIndexes) {
887
887
  const [signed] = await this.signer.signWithDescriptor([
@@ -949,12 +949,12 @@ var WalletCannotAllocateAddressError = class extends Error {
949
949
  };
950
950
  async function resolveDescriptorSigner(descriptor, identity, provider) {
951
951
  const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
952
- if (owner && chunkWIFL5QYZ_cjs.parseHDDescriptor(descriptor)) {
952
+ if (owner && chunkP6EXRY5L_cjs.parseHDDescriptor(descriptor)) {
953
953
  return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
954
954
  }
955
955
  let key;
956
956
  try {
957
- key = chunkWIFL5QYZ_cjs.deriveDescriptorLeafPubKey(descriptor);
957
+ key = chunkP6EXRY5L_cjs.deriveDescriptorLeafPubKey(descriptor);
958
958
  } catch {
959
959
  throw new ForeignDescriptorError(descriptor);
960
960
  }
@@ -1329,14 +1329,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
1329
1329
  }
1330
1330
  var PREIMAGE_INDEX = 0;
1331
1331
  function isPerArtifactDescriptor(descriptor) {
1332
- return chunkWIFL5QYZ_cjs.parseHDDescriptor(descriptor) !== null;
1332
+ return chunkP6EXRY5L_cjs.parseHDDescriptor(descriptor) !== null;
1333
1333
  }
1334
1334
  async function provisionDescriptor(wallet) {
1335
1335
  const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
1336
- return allocated ?? await chunkWIFL5QYZ_cjs.identityDescriptor(wallet.identity);
1336
+ return allocated ?? await chunkP6EXRY5L_cjs.identityDescriptor(wallet.identity);
1337
1337
  }
1338
1338
  async function provisionRefundKey(wallet) {
1339
- const descriptor = await chunkWIFL5QYZ_cjs.identityDescriptor(wallet.identity);
1339
+ const descriptor = await chunkP6EXRY5L_cjs.identityDescriptor(wallet.identity);
1340
1340
  const signer = await contractSigner(wallet, descriptor);
1341
1341
  const pubkey = await signer.xOnlyPublicKey();
1342
1342
  const identityPubkey = await wallet.identity.xOnlyPublicKey();
@@ -1346,7 +1346,7 @@ async function provisionRefundKey(wallet) {
1346
1346
  );
1347
1347
  }
1348
1348
  const address = await wallet.getAddress();
1349
- const { pkScript } = chunk5MLC2HU3_cjs.ArkAddress.decode(address);
1349
+ const { pkScript } = chunk5J5PDZRR_cjs.ArkAddress.decode(address);
1350
1350
  return { descriptor, pubkey, pkScript, address };
1351
1351
  }
1352
1352
  async function provisionClaimSecret(wallet, opts = {}) {
@@ -1392,7 +1392,7 @@ async function contractSigner(wallet, descriptor) {
1392
1392
  const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
1393
1393
  let expected;
1394
1394
  try {
1395
- expected = chunkWIFL5QYZ_cjs.deriveDescriptorLeafPubKey(descriptor);
1395
+ expected = chunkP6EXRY5L_cjs.deriveDescriptorLeafPubKey(descriptor);
1396
1396
  } catch (cause) {
1397
1397
  throw new ForeignDescriptorError(descriptor, { cause });
1398
1398
  }
@@ -1611,14 +1611,14 @@ var RestDelegateProvider = class {
1611
1611
  */
1612
1612
  async delegate(intent, forfeitTxs, options) {
1613
1613
  const url = `${this.url}/v1/delegate`;
1614
- const response = await chunk5MLC2HU3_cjs.baseFetch(url, {
1614
+ const response = await chunk5J5PDZRR_cjs.baseFetch(url, {
1615
1615
  method: "POST",
1616
1616
  headers: {
1617
1617
  "Content-Type": "application/json"
1618
1618
  },
1619
1619
  body: JSON.stringify({
1620
1620
  intent: {
1621
- message: chunk5MLC2HU3_cjs.Intent.encodeMessage(intent.message),
1621
+ message: chunk5J5PDZRR_cjs.Intent.encodeMessage(intent.message),
1622
1622
  proof: intent.proof
1623
1623
  },
1624
1624
  forfeit_txs: forfeitTxs,
@@ -1638,7 +1638,7 @@ var RestDelegateProvider = class {
1638
1638
  */
1639
1639
  async getDelegateInfo() {
1640
1640
  const url = `${this.url}/v1/delegator/info`;
1641
- const response = await chunk5MLC2HU3_cjs.rateGate.runHttp(url, () => chunk5MLC2HU3_cjs.baseFetch(url));
1641
+ const response = await chunk5J5PDZRR_cjs.rateGate.runHttp(url, () => chunk5J5PDZRR_cjs.baseFetch(url));
1642
1642
  if (!response.ok) {
1643
1643
  const errorText2 = await response.text();
1644
1644
  throw new Error(`Failed to get delegate info: ${errorText2}`);
@@ -1663,7 +1663,7 @@ var ESPLORA_URL = {
1663
1663
  regtest: "http://localhost:3000/api"
1664
1664
  };
1665
1665
  var EsploraProvider = class {
1666
- constructor(baseUrl = ESPLORA_URL[chunk5MLC2HU3_cjs.DEFAULT_NETWORK_NAME], opts) {
1666
+ constructor(baseUrl = ESPLORA_URL[chunk5J5PDZRR_cjs.DEFAULT_NETWORK_NAME], opts) {
1667
1667
  this.baseUrl = baseUrl;
1668
1668
  this.pollingInterval = opts?.pollingInterval ?? 15e3;
1669
1669
  this.forcePolling = opts?.forcePolling ?? false;
@@ -1682,14 +1682,14 @@ var EsploraProvider = class {
1682
1682
  */
1683
1683
  addressWatches = /* @__PURE__ */ new Map();
1684
1684
  async getCoins(address) {
1685
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1685
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1686
1686
  if (!response.ok) {
1687
1687
  throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
1688
1688
  }
1689
1689
  return response.json();
1690
1690
  }
1691
1691
  async getFeeRate() {
1692
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1692
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1693
1693
  if (response.status === 404) {
1694
1694
  return void 0;
1695
1695
  }
@@ -1710,7 +1710,7 @@ var EsploraProvider = class {
1710
1710
  }
1711
1711
  }
1712
1712
  async getTxOutspends(txid) {
1713
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1713
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1714
1714
  if (!response.ok) {
1715
1715
  const error = await response.text();
1716
1716
  throw new Error(`Failed to get transaction outspends: ${error}`);
@@ -1718,7 +1718,7 @@ var EsploraProvider = class {
1718
1718
  return response.json();
1719
1719
  }
1720
1720
  async getTransactions(address) {
1721
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1721
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1722
1722
  if (!response.ok) {
1723
1723
  const error = await response.text();
1724
1724
  throw new Error(`Failed to get transactions: ${error}`);
@@ -1731,14 +1731,14 @@ var EsploraProvider = class {
1731
1731
  * usable as a change probe for the polling fallback.
1732
1732
  */
1733
1733
  async getAddressStats(address) {
1734
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1734
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1735
1735
  if (!response.ok) {
1736
1736
  throw new Error(`Failed to get address stats: ${response.statusText}`);
1737
1737
  }
1738
1738
  return response.json();
1739
1739
  }
1740
1740
  async getRawTransaction(txid) {
1741
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1741
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1742
1742
  if (!response.ok) {
1743
1743
  const error = await response.text();
1744
1744
  throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
@@ -1746,7 +1746,7 @@ var EsploraProvider = class {
1746
1746
  return base.hex.decode((await response.text()).trim());
1747
1747
  }
1748
1748
  async getTxStatus(txid) {
1749
- const txresponse = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1749
+ const txresponse = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1750
1750
  if (!txresponse.ok) {
1751
1751
  throw new Error(txresponse.statusText);
1752
1752
  }
@@ -1754,7 +1754,7 @@ var EsploraProvider = class {
1754
1754
  if (!tx.status.confirmed) {
1755
1755
  return { confirmed: false };
1756
1756
  }
1757
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1757
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1758
1758
  if (!response.ok) {
1759
1759
  throw new Error(`Failed to get transaction status: ${response.statusText}`);
1760
1760
  }
@@ -2038,7 +2038,10 @@ var EsploraProvider = class {
2038
2038
  return { subscribers, teardown, started };
2039
2039
  }
2040
2040
  async getChainTip() {
2041
- const tipBlocks = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/blocks`);
2041
+ let tipBlocks = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/blocks`);
2042
+ if (tipBlocks.status === 404) {
2043
+ tipBlocks = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2044
+ }
2042
2045
  if (!tipBlocks.ok) {
2043
2046
  throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
2044
2047
  }
@@ -2059,7 +2062,7 @@ var EsploraProvider = class {
2059
2062
  };
2060
2063
  }
2061
2064
  async broadcastPackage(parent, child) {
2062
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2065
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2063
2066
  method: "POST",
2064
2067
  headers: {
2065
2068
  "Content-Type": "application/json"
@@ -2075,7 +2078,7 @@ var EsploraProvider = class {
2075
2078
  return result;
2076
2079
  }
2077
2080
  async broadcastTx(tx) {
2078
- const response = await chunk5MLC2HU3_cjs.baseFetch(`${this.baseUrl}/tx`, {
2081
+ const response = await chunk5J5PDZRR_cjs.baseFetch(`${this.baseUrl}/tx`, {
2079
2082
  method: "POST",
2080
2083
  headers: {
2081
2084
  "Content-Type": "text/plain"
@@ -2258,7 +2261,7 @@ function findP2AOutput(tx) {
2258
2261
  var CHILD_DUST_AMOUNT = 546;
2259
2262
  function buildAnchorChild(params) {
2260
2263
  const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
2261
- const child = new chunk5MLC2HU3_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2264
+ const child = new chunk5J5PDZRR_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2262
2265
  child.addInput(findP2AOutput(parent));
2263
2266
  const estimator = TxWeightEstimator.create().addP2AInput();
2264
2267
  for (const _ of fundingCoins) {
@@ -2306,7 +2309,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
2306
2309
  );
2307
2310
  }
2308
2311
  function buildForfeitTxWithOutput(inputs, output, txLocktime) {
2309
- const tx = new chunk5MLC2HU3_cjs.Transaction({
2312
+ const tx = new chunk5J5PDZRR_cjs.Transaction({
2310
2313
  version: 3,
2311
2314
  lockTime: txLocktime
2312
2315
  });
@@ -2382,7 +2385,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2382
2385
  if (previousScriptKey.length !== 32) {
2383
2386
  throw new Error(`parent output ${childIndex} has invalid script`);
2384
2387
  }
2385
- const cosigners = chunk5MLC2HU3_cjs.getArkPsbtFields(child.root, 0, chunk5MLC2HU3_cjs.CosignerPublicKey);
2388
+ const cosigners = chunk5J5PDZRR_cjs.getArkPsbtFields(child.root, 0, chunk5J5PDZRR_cjs.CosignerPublicKey);
2386
2389
  if (cosigners.length === 0) {
2387
2390
  throw ErrMissingCosignersPublicKeys;
2388
2391
  }
@@ -2440,7 +2443,7 @@ var EmulatorPacket = class _EmulatorPacket {
2440
2443
  return new _EmulatorPacket(entries);
2441
2444
  }
2442
2445
  static fromBytes(data) {
2443
- const reader = new chunkGVHUHTRH_cjs.BufferReader(data);
2446
+ const reader = new chunkFM263GKH_cjs.BufferReader(data);
2444
2447
  const entryCount = reader.readCompactSize();
2445
2448
  const entries = [];
2446
2449
  for (let i = 0; i < entryCount; i++) {
@@ -2458,7 +2461,7 @@ var EmulatorPacket = class _EmulatorPacket {
2458
2461
  return _EmulatorPacket.PACKET_TYPE;
2459
2462
  }
2460
2463
  serialize() {
2461
- const writer = new chunkGVHUHTRH_cjs.BufferWriter();
2464
+ const writer = new chunkFM263GKH_cjs.BufferWriter();
2462
2465
  writer.writeCompactSize(this.entries.length);
2463
2466
  for (const entry of this.entries) {
2464
2467
  writer.writeUint16LE(entry.vin);
@@ -2545,7 +2548,7 @@ var Extension = class _Extension {
2545
2548
  `expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
2546
2549
  );
2547
2550
  }
2548
- const reader = new chunkGVHUHTRH_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2551
+ const reader = new chunkFM263GKH_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2549
2552
  const packets = [];
2550
2553
  while (reader.remaining() > 0) {
2551
2554
  const packetType = reader.readByte();
@@ -2619,7 +2622,7 @@ var Extension = class _Extension {
2619
2622
  */
2620
2623
  getAssetPacket() {
2621
2624
  for (const p of this.packets) {
2622
- if (p instanceof chunkGVHUHTRH_cjs.Packet) {
2625
+ if (p instanceof chunkFM263GKH_cjs.Packet) {
2623
2626
  return p;
2624
2627
  }
2625
2628
  }
@@ -2657,8 +2660,8 @@ var Extension = class _Extension {
2657
2660
  };
2658
2661
  function parsePacket(packetType, data) {
2659
2662
  switch (packetType) {
2660
- case chunkGVHUHTRH_cjs.Packet.PACKET_TYPE:
2661
- return chunkGVHUHTRH_cjs.Packet.fromBytes(data);
2663
+ case chunkFM263GKH_cjs.Packet.PACKET_TYPE:
2664
+ return chunkFM263GKH_cjs.Packet.fromBytes(data);
2662
2665
  case EmulatorPacket.PACKET_TYPE:
2663
2666
  return EmulatorPacket.fromBytes(data);
2664
2667
  default:
@@ -2705,16 +2708,16 @@ function buildOpReturnScript(data) {
2705
2708
  }
2706
2709
  return script;
2707
2710
  }
2708
- var ErrOffchainOutputNotFound = (address) => new chunk5MLC2HU3_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2709
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
2711
+ var ErrOffchainOutputNotFound = (address) => new chunk5J5PDZRR_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2712
+ var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
2710
2713
  `invalid asset output amount for ${assetId}: got ${got}, want ${want}`
2711
2714
  );
2712
- var ErrAssetGroupNotFound = (assetId) => new chunk5MLC2HU3_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2713
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
2715
+ var ErrAssetGroupNotFound = (assetId) => new chunk5J5PDZRR_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2716
+ var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
2714
2717
  `asset output not found in asset group ${assetId} at index ${outputIndex}`
2715
2718
  );
2716
- var ErrOnchainOutputNotFound = (address) => new chunk5MLC2HU3_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2717
- var ErrUnvalidatedOffchainOutput = (address) => new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
2719
+ var ErrOnchainOutputNotFound = (address) => new chunk5J5PDZRR_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2720
+ var ErrUnvalidatedOffchainOutput = (address) => new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
2718
2721
  `offchain output ${address} cannot be validated: virtual output tree signing did not run`
2719
2722
  );
2720
2723
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
@@ -2723,7 +2726,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
2723
2726
  function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
2724
2727
  if (!validatedCommitmentTxid) return;
2725
2728
  if (finalCommitmentTx.id === validatedCommitmentTxid) return;
2726
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
2729
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
2727
2730
  `${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
2728
2731
  );
2729
2732
  }
@@ -2733,7 +2736,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
2733
2736
  for (const recipient of recipients) {
2734
2737
  let arkAddress;
2735
2738
  try {
2736
- arkAddress = chunk5MLC2HU3_cjs.ArkAddress.decode(recipient.address);
2739
+ arkAddress = chunk5J5PDZRR_cjs.ArkAddress.decode(recipient.address);
2737
2740
  } catch {
2738
2741
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2739
2742
  continue;
@@ -2745,7 +2748,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2745
2748
  const usedOnchainOutputs = /* @__PURE__ */ new Set();
2746
2749
  for (const recipient of recipients) {
2747
2750
  try {
2748
- chunk5MLC2HU3_cjs.ArkAddress.decode(recipient.address);
2751
+ chunk5J5PDZRR_cjs.ArkAddress.decode(recipient.address);
2749
2752
  } catch {
2750
2753
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2751
2754
  continue;
@@ -2978,7 +2981,7 @@ function assetMintResolver() {
2978
2981
  if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
2979
2982
  const minted = tx.assets.filter((a) => {
2980
2983
  try {
2981
- return base.hex.encode(chunkGVHUHTRH_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
2984
+ return base.hex.encode(chunkFM263GKH_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
2982
2985
  } catch {
2983
2986
  return false;
2984
2987
  }
@@ -3021,7 +3024,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3021
3024
  const existing = inputsByAssetId.get(asset.assetId);
3022
3025
  inputsByAssetId.set(asset.assetId, [
3023
3026
  ...existing ?? [],
3024
- chunkGVHUHTRH_cjs.AssetInput.create(inputIndex, asset.amount)
3027
+ chunkFM263GKH_cjs.AssetInput.create(inputIndex, asset.amount)
3025
3028
  ]);
3026
3029
  }
3027
3030
  }
@@ -3033,7 +3036,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3033
3036
  const existing = outputsByAssetId.get(asset.assetId);
3034
3037
  outputsByAssetId.set(asset.assetId, [
3035
3038
  ...existing ?? [],
3036
- chunkGVHUHTRH_cjs.AssetOutput.create(outputIndex, asset.amount)
3039
+ chunkFM263GKH_cjs.AssetOutput.create(outputIndex, asset.amount)
3037
3040
  ]);
3038
3041
  }
3039
3042
  }
@@ -3044,7 +3047,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3044
3047
  const existing = outputsByAssetId.get(asset.assetId);
3045
3048
  outputsByAssetId.set(asset.assetId, [
3046
3049
  ...existing ?? [],
3047
- chunkGVHUHTRH_cjs.AssetOutput.create(outputIndex, asset.amount)
3050
+ chunkFM263GKH_cjs.AssetOutput.create(outputIndex, asset.amount)
3048
3051
  ]);
3049
3052
  }
3050
3053
  }
@@ -3053,11 +3056,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3053
3056
  for (const assetIdStr of allAssetIds) {
3054
3057
  const inputs = inputsByAssetId.get(assetIdStr);
3055
3058
  const outputs = outputsByAssetId.get(assetIdStr);
3056
- const assetId = chunkGVHUHTRH_cjs.AssetId.fromString(assetIdStr);
3057
- const group = chunkGVHUHTRH_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3059
+ const assetId = chunkFM263GKH_cjs.AssetId.fromString(assetIdStr);
3060
+ const group = chunkFM263GKH_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3058
3061
  groups.push(group);
3059
3062
  }
3060
- return chunkGVHUHTRH_cjs.Packet.create(groups);
3063
+ return chunkFM263GKH_cjs.Packet.create(groups);
3061
3064
  }
3062
3065
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
3063
3066
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -3094,7 +3097,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
3094
3097
  }
3095
3098
  function toXOnlySignerHex(pubkeyHex) {
3096
3099
  const bytes = base.hex.decode(pubkeyHex);
3097
- if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkWIFL5QYZ_cjs.toXOnly(bytes, "signer key"));
3100
+ if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkP6EXRY5L_cjs.toXOnly(bytes, "signer key"));
3098
3101
  throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
3099
3102
  }
3100
3103
  function signerSetFromInfo(info) {
@@ -3141,13 +3144,13 @@ var toTimelock = (value) => ({
3141
3144
  var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
3142
3145
  function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
3143
3146
  if (policy.requireSeconds && timelock.type === "blocks") {
3144
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3147
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3145
3148
  `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
3146
3149
  );
3147
3150
  }
3148
3151
  const seconds = toSeconds(timelock);
3149
3152
  if (seconds < policy.minSeconds) {
3150
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3153
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3151
3154
  `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
3152
3155
  );
3153
3156
  }
@@ -3168,7 +3171,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
3168
3171
  }
3169
3172
  function assertValidBatchExpiry(batchExpiry, policy) {
3170
3173
  if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
3171
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3174
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3172
3175
  `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
3173
3176
  );
3174
3177
  }
@@ -3198,21 +3201,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
3198
3201
  function assertValidServerUnrollScript(checkpointTapscript, policy) {
3199
3202
  let script;
3200
3203
  try {
3201
- script = chunk5MLC2HU3_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3204
+ script = chunk5J5PDZRR_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3202
3205
  } catch (e) {
3203
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3206
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3204
3207
  `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
3205
3208
  );
3206
3209
  }
3207
3210
  if (policy.advertisedForfeitPubkey !== void 0) {
3208
3211
  const { pubkeys } = script.params;
3209
3212
  if (pubkeys.length !== 1) {
3210
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3213
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3211
3214
  `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
3212
3215
  );
3213
3216
  }
3214
3217
  if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
3215
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3218
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3216
3219
  `checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
3217
3220
  );
3218
3221
  }
@@ -3256,8 +3259,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
3256
3259
  function buildVirtualTx(inputs, outputs) {
3257
3260
  let lockTime = 0n;
3258
3261
  for (const input of inputs) {
3259
- const tapscript = chunk5MLC2HU3_cjs.decodeTapscript(chunk5MLC2HU3_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3260
- if (chunk5MLC2HU3_cjs.CLTVMultisigTapscript.is(tapscript)) {
3262
+ const tapscript = chunk5J5PDZRR_cjs.decodeTapscript(chunk5J5PDZRR_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3263
+ if (chunk5J5PDZRR_cjs.CLTVMultisigTapscript.is(tapscript)) {
3261
3264
  if (lockTime !== 0n) {
3262
3265
  if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
3263
3266
  throw new Error("cannot mix seconds and blocks locktime");
@@ -3268,7 +3271,7 @@ function buildVirtualTx(inputs, outputs) {
3268
3271
  }
3269
3272
  }
3270
3273
  }
3271
- const tx = new chunk5MLC2HU3_cjs.Transaction({
3274
+ const tx = new chunk5J5PDZRR_cjs.Transaction({
3272
3275
  version: 3,
3273
3276
  lockTime: Number(lockTime)
3274
3277
  });
@@ -3278,12 +3281,12 @@ function buildVirtualTx(inputs, outputs) {
3278
3281
  index: input.vout,
3279
3282
  sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
3280
3283
  witnessUtxo: {
3281
- script: chunk5MLC2HU3_cjs.VtxoScript.decode(input.tapTree).pkScript,
3284
+ script: chunk5J5PDZRR_cjs.VtxoScript.decode(input.tapTree).pkScript,
3282
3285
  amount: BigInt(input.value)
3283
3286
  },
3284
3287
  tapLeafScript: [input.tapLeafScript]
3285
3288
  });
3286
- chunk5MLC2HU3_cjs.setArkPsbtField(tx, i, chunk5MLC2HU3_cjs.VtxoTaprootTree, input.tapTree);
3289
+ chunk5J5PDZRR_cjs.setArkPsbtField(tx, i, chunk5J5PDZRR_cjs.VtxoTaprootTree, input.tapTree);
3287
3290
  }
3288
3291
  for (const output of outputs) {
3289
3292
  tx.addOutput(output);
@@ -3292,8 +3295,8 @@ function buildVirtualTx(inputs, outputs) {
3292
3295
  return tx;
3293
3296
  }
3294
3297
  function buildCheckpointTx(vtxo, serverUnrollScript) {
3295
- const collaborativeClosure = chunk5MLC2HU3_cjs.decodeTapscript(chunk5MLC2HU3_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3296
- const checkpointVtxoScript = new chunk5MLC2HU3_cjs.VtxoScript([
3298
+ const collaborativeClosure = chunk5J5PDZRR_cjs.decodeTapscript(chunk5J5PDZRR_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3299
+ const checkpointVtxoScript = new chunk5J5PDZRR_cjs.VtxoScript([
3297
3300
  serverUnrollScript.script,
3298
3301
  collaborativeClosure.script
3299
3302
  ]);
@@ -3369,7 +3372,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
3369
3372
  const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
3370
3373
  const sig = signature.subarray(0, 64);
3371
3374
  if (!allowedSighashTypes.includes(sighashType)) {
3372
- const sighashName = chunk5MLC2HU3_cjs.formatSighash(sighashType);
3375
+ const sighashName = chunk5J5PDZRR_cjs.formatSighash(sighashType);
3373
3376
  throw new Error(
3374
3377
  `Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
3375
3378
  );
@@ -3443,7 +3446,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
3443
3446
  }
3444
3447
  function isValidArkAddress(address) {
3445
3448
  try {
3446
- chunk5MLC2HU3_cjs.ArkAddress.decode(address);
3449
+ chunk5J5PDZRR_cjs.ArkAddress.decode(address);
3447
3450
  return true;
3448
3451
  } catch (e) {
3449
3452
  return false;
@@ -3451,16 +3454,16 @@ function isValidArkAddress(address) {
3451
3454
  }
3452
3455
  function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
3453
3456
  if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
3454
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3457
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3455
3458
  `${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
3456
3459
  );
3457
3460
  }
3458
3461
  const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
3459
3462
  return serverCheckpointTxs.map((encoded, index) => {
3460
- const server = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3463
+ const server = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3461
3464
  const local = byTxid.get(server.id);
3462
3465
  if (!local) {
3463
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3466
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3464
3467
  `${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
3465
3468
  );
3466
3469
  }
@@ -3470,14 +3473,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
3470
3473
  }
3471
3474
  function assertSubmittedArkTxid(response, signedArkTx, context) {
3472
3475
  if (response.arkTxid !== signedArkTx.id) {
3473
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3476
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3474
3477
  `${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
3475
3478
  );
3476
3479
  }
3477
3480
  if (response.finalArkTx === void 0) return;
3478
- const finalTxid = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3481
+ const finalTxid = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3479
3482
  if (finalTxid !== signedArkTx.id) {
3480
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3483
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3481
3484
  `${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
3482
3485
  );
3483
3486
  }
@@ -3496,10 +3499,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
3496
3499
  [serverPubkeyHex],
3497
3500
  void 0,
3498
3501
  void 0,
3499
- payment_js.tapLeafHash(chunk5MLC2HU3_cjs.scriptFromTapLeafScript(leaf))
3502
+ payment_js.tapLeafHash(chunk5J5PDZRR_cjs.scriptFromTapLeafScript(leaf))
3500
3503
  );
3501
3504
  } catch (error) {
3502
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3505
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3503
3506
  `${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
3504
3507
  );
3505
3508
  }
@@ -3508,20 +3511,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3508
3511
  const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
3509
3512
  for (const [index, checkpoint] of checkpoints.entries()) {
3510
3513
  if (checkpoint.inputsLength !== 1) {
3511
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3514
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3512
3515
  `${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
3513
3516
  );
3514
3517
  }
3515
3518
  const spent = checkpoint.getInput(0);
3516
3519
  if (!spent.txid || spent.index === void 0) {
3517
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3520
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3518
3521
  `${context}: checkpoint ${index} has no input outpoint`
3519
3522
  );
3520
3523
  }
3521
3524
  const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
3522
3525
  const input = byOutpoint.get(outpoint);
3523
3526
  if (!input) {
3524
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3527
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3525
3528
  `${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
3526
3529
  );
3527
3530
  }
@@ -3529,7 +3532,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3529
3532
  (unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
3530
3533
  );
3531
3534
  if (!rebuilt) {
3532
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3535
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3533
3536
  `${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
3534
3537
  );
3535
3538
  }
@@ -3555,9 +3558,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3555
3558
  const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
3556
3559
  matched.forEach(({ server }, index) => {
3557
3560
  try {
3558
- chunk5MLC2HU3_cjs.assertAllowedSighashTypes(server);
3561
+ chunk5J5PDZRR_cjs.assertAllowedSighashTypes(server);
3559
3562
  } catch (error) {
3560
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3563
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3561
3564
  `submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
3562
3565
  );
3563
3566
  }
@@ -3565,12 +3568,12 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3565
3568
  const verify = options?.verifyServerSignatures;
3566
3569
  if (verify) {
3567
3570
  if (response.finalArkTx === void 0) {
3568
- throw new chunk5MLC2HU3_cjs.ServerResponseMismatchError(
3571
+ throw new chunk5J5PDZRR_cjs.ServerResponseMismatchError(
3569
3572
  "submitTx: server returned no final ark tx to verify its signatures against"
3570
3573
  );
3571
3574
  }
3572
- const finalArkTx = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3573
- const serverPubkeyHex = base.hex.encode(chunkWIFL5QYZ_cjs.toXOnly(verify.serverPubkey, "server key"));
3575
+ const finalArkTx = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3576
+ const serverPubkeyHex = base.hex.encode(chunkP6EXRY5L_cjs.toXOnly(verify.serverPubkey, "server key"));
3574
3577
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
3575
3578
  assertServerSignedLeaf(
3576
3579
  finalArkTx,
@@ -3626,17 +3629,37 @@ function claimWithPreimageIdentity(identity, preimage) {
3626
3629
  return {
3627
3630
  ...identity,
3628
3631
  sign: async (tx, inputIndexes) => {
3629
- const signed = chunk5MLC2HU3_cjs.Transaction.fromPSBT(
3632
+ const signed = chunk5J5PDZRR_cjs.Transaction.fromPSBT(
3630
3633
  (await identity.sign(tx.clone(), inputIndexes)).toPSBT()
3631
3634
  );
3632
3635
  const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
3633
3636
  for (const index of indexes) {
3634
- chunk5MLC2HU3_cjs.setArkPsbtField(signed, index, chunk5MLC2HU3_cjs.ConditionWitness, [preimage]);
3637
+ chunk5J5PDZRR_cjs.setArkPsbtField(signed, index, chunk5J5PDZRR_cjs.ConditionWitness, [preimage]);
3635
3638
  }
3636
3639
  return signed;
3637
3640
  }
3638
3641
  };
3639
3642
  }
3643
+
3644
+ // src/contracts/types.ts
3645
+ function watchStateOf(contract) {
3646
+ return contract.watch ?? "watched";
3647
+ }
3648
+ function isWatchedContract(contract) {
3649
+ return watchStateOf(contract) !== "retained";
3650
+ }
3651
+ function hasCandidates(handler) {
3652
+ return !!handler && typeof handler.candidatesAt === "function";
3653
+ }
3654
+ function isDiscoverable(handler) {
3655
+ return !!handler && typeof handler.discoverAt === "function";
3656
+ }
3657
+ function isTapscriptDeriving(handler) {
3658
+ return !!handler && typeof handler.deriveTapscripts === "function";
3659
+ }
3660
+ function isContractVtxoEvent(event) {
3661
+ return "contract" in event && event.contract !== void 0;
3662
+ }
3640
3663
  var AmountVariableName = "amount";
3641
3664
  var ExpiryVariableName = "expiry";
3642
3665
  var BirthVariableName = "birth";
@@ -3792,23 +3815,6 @@ function parseProgram(text, env) {
3792
3815
  }
3793
3816
  return { program, text };
3794
3817
  }
3795
-
3796
- // src/contracts/types.ts
3797
- function watchStateOf(contract) {
3798
- return contract.watch ?? "watched";
3799
- }
3800
- function isWatchedContract(contract) {
3801
- return watchStateOf(contract) !== "retained";
3802
- }
3803
- function hasCandidates(handler) {
3804
- return !!handler && typeof handler.candidatesAt === "function";
3805
- }
3806
- function isDiscoverable(handler) {
3807
- return !!handler && typeof handler.discoverAt === "function";
3808
- }
3809
- function isTapscriptDeriving(handler) {
3810
- return !!handler && typeof handler.deriveTapscripts === "function";
3811
- }
3812
3818
  var DUST_AMOUNT = 546;
3813
3819
  var FALLBACK_WALLET_DUST_AMOUNT = 330n;
3814
3820
  function getDustAmount(wallet) {
@@ -3823,7 +3829,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
3823
3829
  };
3824
3830
  }
3825
3831
  function deriveContractTapscripts(contract) {
3826
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type);
3832
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(contract.type);
3827
3833
  if (!handler) {
3828
3834
  throw new Error(`No handler for contract type '${contract.type}'`);
3829
3835
  }
@@ -3894,7 +3900,7 @@ function getRandomId() {
3894
3900
  }
3895
3901
  function isValidArkAddress2(address) {
3896
3902
  try {
3897
- chunk5MLC2HU3_cjs.ArkAddress.decode(address);
3903
+ chunk5J5PDZRR_cjs.ArkAddress.decode(address);
3898
3904
  return true;
3899
3905
  } catch (e) {
3900
3906
  return false;
@@ -3922,7 +3928,7 @@ function assertRecipientArkAddress(encoded, address, context) {
3922
3928
  function assertTapTreeDerivesAddress(encoded, tapTree, address) {
3923
3929
  let derived;
3924
3930
  try {
3925
- derived = chunk5MLC2HU3_cjs.VtxoScript.decode(tapTree).pkScript;
3931
+ derived = chunk5J5PDZRR_cjs.VtxoScript.decode(tapTree).pkScript;
3926
3932
  } catch (e) {
3927
3933
  throw new Error(
3928
3934
  `Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
@@ -3939,7 +3945,7 @@ function validateRecipients(recipients, dustAmount, context) {
3939
3945
  for (const recipient of recipients) {
3940
3946
  let address;
3941
3947
  try {
3942
- address = chunk5MLC2HU3_cjs.ArkAddress.decode(recipient.address);
3948
+ address = chunk5J5PDZRR_cjs.ArkAddress.decode(recipient.address);
3943
3949
  } catch (e) {
3944
3950
  throw new Error(`Invalid Arkade address: ${recipient.address}`);
3945
3951
  }
@@ -3964,7 +3970,7 @@ function validateRecipients(recipients, dustAmount, context) {
3964
3970
 
3965
3971
  // src/contracts/spendability.ts
3966
3972
  function isContractGenericallySpendable(contract) {
3967
- return chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
3973
+ return chunkP6EXRY5L_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
3968
3974
  }
3969
3975
  function gatedContracts(contracts) {
3970
3976
  const gated = /* @__PURE__ */ new Map();
@@ -3977,7 +3983,7 @@ function gateExclusion(gated) {
3977
3983
  return (vtxo) => {
3978
3984
  const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
3979
3985
  if (type === void 0) return void 0;
3980
- if (!chunkWIFL5QYZ_cjs.contractHandlers.has(type)) {
3986
+ if (!chunkP6EXRY5L_cjs.contractHandlers.has(type)) {
3981
3987
  return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
3982
3988
  }
3983
3989
  return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
@@ -4013,7 +4019,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
4013
4019
  continue;
4014
4020
  }
4015
4021
  for (const v of vtxos) {
4016
- if (!chunk5MLC2HU3_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
4022
+ if (!chunk5J5PDZRR_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
4017
4023
  out.add(`${v.txid}:${v.vout}`);
4018
4024
  }
4019
4025
  }
@@ -4048,10 +4054,10 @@ function byValueDescending(vtxos) {
4048
4054
  return [...vtxos].sort((a, b) => b.value - a.value);
4049
4055
  }
4050
4056
  async function fetchTimeHeight(wallet) {
4051
- return chunk5MLC2HU3_cjs.resolveTimeHeight(wallet.onchainProvider);
4057
+ return chunk5J5PDZRR_cjs.resolveTimeHeight(wallet.onchainProvider);
4052
4058
  }
4053
4059
  function canMigrateBySend(vtxo, now) {
4054
- if (!chunk5MLC2HU3_cjs.canSpendOffchain(vtxo, now)) return false;
4060
+ if (!chunk5J5PDZRR_cjs.canSpendOffchain(vtxo, now)) return false;
4055
4061
  return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
4056
4062
  }
4057
4063
  function byExpiryAscending(vtxos, now) {
@@ -4059,7 +4065,7 @@ function byExpiryAscending(vtxos, now) {
4059
4065
  if (vtxo.isSwept) return -Infinity;
4060
4066
  if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
4061
4067
  if (vtxo.expiresAtHeight !== void 0) {
4062
- return chunk5MLC2HU3_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4068
+ return chunk5J5PDZRR_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4063
4069
  }
4064
4070
  return Infinity;
4065
4071
  };
@@ -4086,7 +4092,7 @@ function priceSettlementInputs(vtxos, estimator) {
4086
4092
  const payable = [];
4087
4093
  const net = /* @__PURE__ */ new Map();
4088
4094
  for (const vtxo of vtxos) {
4089
- const inputFee = estimator.evalOffchainInput(chunk5MLC2HU3_cjs.toOffchainInputFeeParams(vtxo));
4095
+ const inputFee = estimator.evalOffchainInput(chunk5J5PDZRR_cjs.toOffchainInputFeeParams(vtxo));
4090
4096
  if (inputFee.satoshis >= vtxo.value) {
4091
4097
  continue;
4092
4098
  }
@@ -4112,7 +4118,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
4112
4118
  }
4113
4119
  const outputFee = estimator.evalOffchainOutput({
4114
4120
  amount: subtotal,
4115
- script: base.hex.encode(chunk5MLC2HU3_cjs.ArkAddress.decode(arkAddress).pkScript)
4121
+ script: base.hex.encode(chunk5J5PDZRR_cjs.ArkAddress.decode(arkAddress).pkScript)
4116
4122
  });
4117
4123
  return subtotal - BigInt(outputFee.satoshis);
4118
4124
  }
@@ -4130,10 +4136,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
4130
4136
  };
4131
4137
  function getRecoverableVtxos(vtxos, dustAmount, now) {
4132
4138
  return vtxos.filter((vtxo) => {
4133
- if (chunk5MLC2HU3_cjs.canRecoverOnchain(vtxo, now)) {
4139
+ if (chunk5J5PDZRR_cjs.canRecoverOnchain(vtxo, now)) {
4134
4140
  return true;
4135
4141
  }
4136
- if (chunk5MLC2HU3_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4142
+ if (chunk5J5PDZRR_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4137
4143
  return true;
4138
4144
  }
4139
4145
  return false;
@@ -4165,7 +4171,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
4165
4171
  function isVtxoExpiringSoon(vtxo, thresholdMs) {
4166
4172
  if (vtxo.isUnrolled) return false;
4167
4173
  const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
4168
- const expiresAt = chunk5MLC2HU3_cjs.normalizeVtxo(vtxo).expiresAt;
4174
+ const expiresAt = chunk5J5PDZRR_cjs.normalizeVtxo(vtxo).expiresAt;
4169
4175
  if (expiresAt === void 0) return false;
4170
4176
  const now = Date.now();
4171
4177
  const batchExpiry = expiresAt.getTime();
@@ -4176,7 +4182,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
4176
4182
  return vtxos.filter(
4177
4183
  // The leading exclusion covers the `isSubdust` arm too, which is a value
4178
4184
  // property and would otherwise re-admit an exited coin on its own.
4179
- (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunk5MLC2HU3_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4185
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunk5J5PDZRR_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4180
4186
  );
4181
4187
  }
4182
4188
  function isMigrationCapable(wallet) {
@@ -4775,11 +4781,11 @@ var VtxoManager = class _VtxoManager {
4775
4781
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
4776
4782
  );
4777
4783
  }
4778
- const tx = new chunk5MLC2HU3_cjs.Transaction();
4784
+ const tx = new chunk5J5PDZRR_cjs.Transaction();
4779
4785
  for (const utxo of expiredUtxos) {
4780
- const utxoScript = chunk5MLC2HU3_cjs.VtxoScript.decode(utxo.tapTree);
4786
+ const utxoScript = chunk5J5PDZRR_cjs.VtxoScript.decode(utxo.tapTree);
4781
4787
  const utxoExitLeaf = utxoScript.leaves.find(
4782
- (leaf) => chunk5MLC2HU3_cjs.CSVMultisigTapscript.isScriptValid(chunk5MLC2HU3_cjs.scriptFromTapLeafScript(leaf)) === true
4788
+ (leaf) => chunk5J5PDZRR_cjs.CSVMultisigTapscript.isScriptValid(chunk5J5PDZRR_cjs.scriptFromTapLeafScript(leaf)) === true
4783
4789
  );
4784
4790
  if (!utxoExitLeaf) {
4785
4791
  throw new Error(
@@ -4794,7 +4800,7 @@ var VtxoManager = class _VtxoManager {
4794
4800
  amount: BigInt(utxo.value)
4795
4801
  },
4796
4802
  tapLeafScript: [utxoExitLeaf],
4797
- sequence: chunk5MLC2HU3_cjs.getSequence(utxoExitLeaf)
4803
+ sequence: chunk5J5PDZRR_cjs.getSequence(utxoExitLeaf)
4798
4804
  });
4799
4805
  }
4800
4806
  tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
@@ -5037,8 +5043,8 @@ var VtxoManager = class _VtxoManager {
5037
5043
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
5038
5044
  if (cls.status === "CURRENT") continue;
5039
5045
  const live = vtxos.filter((v) => !v.isUnrolled);
5040
- const recoverable = live.filter((v) => v.isSwept && !chunk5MLC2HU3_cjs.hasTerminalSpend(v));
5041
- const spendable = live.filter((v) => !chunk5MLC2HU3_cjs.hasTerminalSpend(v) && !v.isSwept);
5046
+ const recoverable = live.filter((v) => v.isSwept && !chunk5J5PDZRR_cjs.hasTerminalSpend(v));
5047
+ const spendable = live.filter((v) => !chunk5J5PDZRR_cjs.hasTerminalSpend(v) && !v.isSwept);
5042
5048
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
5043
5049
  let recoverableCount = 0;
5044
5050
  let recoverableValue = 0;
@@ -5051,7 +5057,7 @@ var VtxoManager = class _VtxoManager {
5051
5057
  awaitingSweepCount = spendable.length;
5052
5058
  awaitingSweepValue = value;
5053
5059
  for (const v of spendable) {
5054
- const exp = chunk5MLC2HU3_cjs.toBatchExpiry(v);
5060
+ const exp = chunk5J5PDZRR_cjs.toBatchExpiry(v);
5055
5061
  if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
5056
5062
  nextSweepEta = exp;
5057
5063
  }
@@ -5312,7 +5318,7 @@ var VtxoManager = class _VtxoManager {
5312
5318
  /** Decodes the boarding tapscript exit path to extract the CSV timelock. */
5313
5319
  getBoardingTimelock() {
5314
5320
  const wallet = this.getSweepWallet();
5315
- const exitScript = chunk5MLC2HU3_cjs.CSVMultisigTapscript.decode(
5321
+ const exitScript = chunk5J5PDZRR_cjs.CSVMultisigTapscript.decode(
5316
5322
  base.hex.decode(wallet.boardingTapscript.exitScript)
5317
5323
  );
5318
5324
  return exitScript.params.timelock;
@@ -5358,7 +5364,7 @@ var VtxoManager = class _VtxoManager {
5358
5364
  this.wallet.getAddress()
5359
5365
  ]);
5360
5366
  const stopWatching = contractManager.onContractEvent((event) => {
5361
- if (event.type !== "vtxo_received") {
5367
+ if (event.type !== "vtxo_received" || !isContractVtxoEvent(event)) {
5362
5368
  return;
5363
5369
  }
5364
5370
  const msSinceLastRenewal = Date.now() - this.lastRenewalTimestamp;
@@ -5443,8 +5449,8 @@ var VtxoManager = class _VtxoManager {
5443
5449
  * or doesn't carry the metadata.
5444
5450
  */
5445
5451
  extractSpentOutpoint(error) {
5446
- const ark = chunk5MLC2HU3_cjs.maybeArkError(error);
5447
- if (!chunk5MLC2HU3_cjs.isArkError(ark, chunk5MLC2HU3_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5452
+ const ark = chunk5J5PDZRR_cjs.maybeArkError(error);
5453
+ if (!chunk5J5PDZRR_cjs.isArkError(ark, chunk5J5PDZRR_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5448
5454
  const raw = ark.metadata?.vtxo_outpoint;
5449
5455
  if (typeof raw !== "string") return void 0;
5450
5456
  const [txid, voutStr] = raw.split(":");
@@ -5634,7 +5640,7 @@ var VtxoManager = class _VtxoManager {
5634
5640
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
5635
5641
  break;
5636
5642
  }
5637
- const inputFee = estimator.evalOffchainInput(chunk5MLC2HU3_cjs.toOffchainInputFeeParams(v));
5643
+ const inputFee = estimator.evalOffchainInput(chunk5J5PDZRR_cjs.toOffchainInputFeeParams(v));
5638
5644
  if (inputFee.satoshis >= v.value) {
5639
5645
  continue;
5640
5646
  }
@@ -5654,7 +5660,7 @@ var VtxoManager = class _VtxoManager {
5654
5660
  const arkAddress = await this.wallet.getAddress();
5655
5661
  const outputFee = estimator.evalOffchainOutput({
5656
5662
  amount: totalAmount,
5657
- script: base.hex.encode(chunk5MLC2HU3_cjs.ArkAddress.decode(arkAddress).pkScript)
5663
+ script: base.hex.encode(chunk5J5PDZRR_cjs.ArkAddress.decode(arkAddress).pkScript)
5658
5664
  });
5659
5665
  totalAmount -= BigInt(outputFee.satoshis);
5660
5666
  if (totalAmount < dustAmount) return;
@@ -5734,7 +5740,7 @@ var ArkNote = class _ArkNote {
5734
5740
  this.value = value;
5735
5741
  this.HRP = HRP;
5736
5742
  const preimageHash = utils_js.sha256(this.preimage);
5737
- this.vtxoScript = new chunk5MLC2HU3_cjs.VtxoScript([noteTapscript(preimageHash)]);
5743
+ this.vtxoScript = new chunk5J5PDZRR_cjs.VtxoScript([noteTapscript(preimageHash)]);
5738
5744
  const leaf = this.vtxoScript.leaves[0];
5739
5745
  this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
5740
5746
  this.tapTree = this.vtxoScript.encode();
@@ -5901,7 +5907,7 @@ var ArkadeCash = class _ArkadeCash {
5901
5907
  const privateKey = data.slice(1, 33);
5902
5908
  const serverPubKey = data.slice(33, 65);
5903
5909
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
5904
- const csvTimelock = chunk5MLC2HU3_cjs.sequenceToTimelock(sequence);
5910
+ const csvTimelock = chunk5J5PDZRR_cjs.sequenceToTimelock(sequence);
5905
5911
  return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
5906
5912
  }
5907
5913
  toString() {
@@ -5909,7 +5915,7 @@ var ArkadeCash = class _ArkadeCash {
5909
5915
  data[0] = _ArkadeCash.Version;
5910
5916
  data.set(this._privateKey, 1);
5911
5917
  data.set(this._serverPubKey, 33);
5912
- const sequence = chunk5MLC2HU3_cjs.timelockToSequence(this.csvTimelock);
5918
+ const sequence = chunk5J5PDZRR_cjs.timelockToSequence(this.csvTimelock);
5913
5919
  new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
5914
5920
  const words = base.bech32m.toWords(data);
5915
5921
  return base.bech32m.encode(this.hrp, words, 1023);
@@ -5918,7 +5924,7 @@ var ArkadeCash = class _ArkadeCash {
5918
5924
  return SingleKey.fromPrivateKey(this._privateKey);
5919
5925
  }
5920
5926
  get vtxoScript() {
5921
- return new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({
5927
+ return new chunkP6EXRY5L_cjs.DefaultVtxo.Script({
5922
5928
  pubKey: this._publicKey,
5923
5929
  serverPubKey: this._serverPubKey,
5924
5930
  csvTimelock: this.csvTimelock
@@ -6179,7 +6185,7 @@ async function captureExitBranch(params) {
6179
6185
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
6180
6186
  if (nonCommitment.length > 0) {
6181
6187
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
6182
- psbtByTxid.set(chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6188
+ psbtByTxid.set(chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6183
6189
  }
6184
6190
  }
6185
6191
  }
@@ -6222,10 +6228,10 @@ var IndexerExitDataSource = class {
6222
6228
  while (hasMore) {
6223
6229
  const { chain: page, page: meta } = await this.indexer.getVtxoChain(
6224
6230
  { txid: vtxo.txid, vout: vtxo.vout },
6225
- { pageIndex, pageSize: chunk5MLC2HU3_cjs.DEFAULT_PAGE_SIZE }
6231
+ { pageIndex, pageSize: chunk5J5PDZRR_cjs.DEFAULT_PAGE_SIZE }
6226
6232
  );
6227
6233
  chain.push(...page);
6228
- hasMore = meta ? page.length === chunk5MLC2HU3_cjs.DEFAULT_PAGE_SIZE : false;
6234
+ hasMore = meta ? page.length === chunk5J5PDZRR_cjs.DEFAULT_PAGE_SIZE : false;
6229
6235
  pageIndex++;
6230
6236
  }
6231
6237
  return chain;
@@ -6237,12 +6243,12 @@ var IndexerExitDataSource = class {
6237
6243
  while (hasMore) {
6238
6244
  const { txs, page } = await this.indexer.getVirtualTxs(txids, {
6239
6245
  pageIndex,
6240
- pageSize: chunk5MLC2HU3_cjs.DEFAULT_PAGE_SIZE
6246
+ pageSize: chunk5J5PDZRR_cjs.DEFAULT_PAGE_SIZE
6241
6247
  });
6242
6248
  for (const psbt of txs) {
6243
- out.set(chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6249
+ out.set(chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6244
6250
  }
6245
- hasMore = page ? txs.length === chunk5MLC2HU3_cjs.DEFAULT_PAGE_SIZE : false;
6251
+ hasMore = page ? txs.length === chunk5J5PDZRR_cjs.DEFAULT_PAGE_SIZE : false;
6246
6252
  pageIndex++;
6247
6253
  }
6248
6254
  return out;
@@ -6263,7 +6269,7 @@ function chainedTxTypeToChainTxType(t) {
6263
6269
  }
6264
6270
  }
6265
6271
  function psbtInputTxids(psbtBase64) {
6266
- const tx = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6272
+ const tx = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6267
6273
  const ids = [];
6268
6274
  for (let i = 0; i < tx.inputsLength; i++) {
6269
6275
  const txid = tx.getInput(i).txid;
@@ -6622,10 +6628,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
6622
6628
  try {
6623
6629
  info = await arkProvider.getInfo();
6624
6630
  } catch (err) {
6625
- if (!chunk5MLC2HU3_cjs.isRetryableProviderError(err)) throw err;
6631
+ if (!chunk5J5PDZRR_cjs.isRetryableProviderError(err)) throw err;
6626
6632
  const snapshot = await loadArkInfoSnapshot(walletRepository);
6627
6633
  if (!snapshot) {
6628
- throw new chunk5MLC2HU3_cjs.ProviderUnavailableError(
6634
+ throw new chunk5J5PDZRR_cjs.ProviderUnavailableError(
6629
6635
  "Arkade server info is unavailable and no cached snapshot exists",
6630
6636
  { cause: err }
6631
6637
  );
@@ -7015,7 +7021,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
7015
7021
  return [...txids];
7016
7022
  }
7017
7023
  async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
7018
- const fromOldestVtxo = vtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7024
+ const fromOldestVtxo = vtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7019
7025
  const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
7020
7026
  const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
7021
7027
  const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
@@ -7179,7 +7185,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7179
7185
  const virtualCoins = await this.wallet.getSpendableVtxos({
7180
7186
  withRecoverable: false
7181
7187
  });
7182
- const controlAssetRef = params.controlAssetId ? chunkGVHUHTRH_cjs.AssetRef.fromId(chunkGVHUHTRH_cjs.AssetId.fromString(params.controlAssetId)) : null;
7188
+ const controlAssetRef = params.controlAssetId ? chunkFM263GKH_cjs.AssetRef.fromId(chunkFM263GKH_cjs.AssetId.fromString(params.controlAssetId)) : null;
7183
7189
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
7184
7190
  let totalBtcSelected = 0n;
7185
7191
  const assetChanges = /* @__PURE__ */ new Map();
@@ -7192,8 +7198,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7192
7198
  }
7193
7199
  }
7194
7200
  const groups = [];
7195
- const issuedAssetOutput = chunkGVHUHTRH_cjs.AssetOutput.create(0, params.amount);
7196
- const issuedAssetGroup = chunkGVHUHTRH_cjs.AssetGroup.create(
7201
+ const issuedAssetOutput = chunkFM263GKH_cjs.AssetOutput.create(0, params.amount);
7202
+ const issuedAssetGroup = chunkFM263GKH_cjs.AssetGroup.create(
7197
7203
  null,
7198
7204
  controlAssetRef,
7199
7205
  [],
@@ -7208,28 +7214,28 @@ var AssetManager = class extends ReadonlyAssetManager {
7208
7214
  for (const [inputIndex, assets] of assetInputs) {
7209
7215
  for (const asset of assets) {
7210
7216
  if (asset.assetId !== assetId) continue;
7211
- changeInputs.push(chunkGVHUHTRH_cjs.AssetInput.create(inputIndex, asset.amount));
7217
+ changeInputs.push(chunkFM263GKH_cjs.AssetInput.create(inputIndex, asset.amount));
7212
7218
  }
7213
7219
  }
7214
7220
  groups.push(
7215
- chunkGVHUHTRH_cjs.AssetGroup.create(
7216
- chunkGVHUHTRH_cjs.AssetId.fromString(assetId),
7221
+ chunkFM263GKH_cjs.AssetGroup.create(
7222
+ chunkFM263GKH_cjs.AssetId.fromString(assetId),
7217
7223
  null,
7218
7224
  changeInputs,
7219
- [chunkGVHUHTRH_cjs.AssetOutput.create(0, amount)],
7225
+ [chunkFM263GKH_cjs.AssetOutput.create(0, amount)],
7220
7226
  []
7221
7227
  )
7222
7228
  );
7223
7229
  }
7224
7230
  }
7225
7231
  const address = await this.wallet.getAddress();
7226
- const outputAddress = chunk5MLC2HU3_cjs.ArkAddress.decode(address);
7232
+ const outputAddress = chunk5J5PDZRR_cjs.ArkAddress.decode(address);
7227
7233
  const outputs = [
7228
7234
  {
7229
7235
  script: outputAddress.pkScript,
7230
7236
  amount: BigInt(totalBtcSelected)
7231
7237
  },
7232
- Extension.create([chunkGVHUHTRH_cjs.Packet.create(groups)]).txOut()
7238
+ Extension.create([chunkFM263GKH_cjs.Packet.create(groups)]).txOut()
7233
7239
  ];
7234
7240
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
7235
7241
  coinSelection.inputs,
@@ -7237,7 +7243,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7237
7243
  );
7238
7244
  return {
7239
7245
  arkTxId: arkTxid,
7240
- assetId: chunkGVHUHTRH_cjs.AssetId.create(arkTxid, 0).toString()
7246
+ assetId: chunkFM263GKH_cjs.AssetId.create(arkTxid, 0).toString()
7241
7247
  };
7242
7248
  }
7243
7249
  /**
@@ -7309,16 +7315,16 @@ var AssetManager = class extends ReadonlyAssetManager {
7309
7315
  for (const [inputIndex, assets] of assetInputs) {
7310
7316
  for (const asset of assets) {
7311
7317
  if (asset.assetId !== params.assetId) continue;
7312
- reissueInputs.push(chunkGVHUHTRH_cjs.AssetInput.create(inputIndex, asset.amount));
7318
+ reissueInputs.push(chunkFM263GKH_cjs.AssetInput.create(inputIndex, asset.amount));
7313
7319
  }
7314
7320
  }
7315
7321
  const totalAssetAmount = assetToReissueAmount + params.amount;
7316
- const reissueAssetIdObj = chunkGVHUHTRH_cjs.AssetId.fromString(params.assetId);
7317
- const reissueAssetGroup = chunkGVHUHTRH_cjs.AssetGroup.create(
7322
+ const reissueAssetIdObj = chunkFM263GKH_cjs.AssetId.fromString(params.assetId);
7323
+ const reissueAssetGroup = chunkFM263GKH_cjs.AssetGroup.create(
7318
7324
  reissueAssetIdObj,
7319
7325
  null,
7320
7326
  reissueInputs,
7321
- [chunkGVHUHTRH_cjs.AssetOutput.create(0, totalAssetAmount)],
7327
+ [chunkFM263GKH_cjs.AssetOutput.create(0, totalAssetAmount)],
7322
7328
  []
7323
7329
  );
7324
7330
  const groups = [reissueAssetGroup];
@@ -7327,27 +7333,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7327
7333
  for (const [inputIndex, assets] of assetInputs) {
7328
7334
  for (const asset of assets) {
7329
7335
  if (asset.assetId !== assetId) continue;
7330
- changeInputs.push(chunkGVHUHTRH_cjs.AssetInput.create(inputIndex, asset.amount));
7336
+ changeInputs.push(chunkFM263GKH_cjs.AssetInput.create(inputIndex, asset.amount));
7331
7337
  }
7332
7338
  }
7333
7339
  groups.push(
7334
- chunkGVHUHTRH_cjs.AssetGroup.create(
7335
- chunkGVHUHTRH_cjs.AssetId.fromString(assetId),
7340
+ chunkFM263GKH_cjs.AssetGroup.create(
7341
+ chunkFM263GKH_cjs.AssetId.fromString(assetId),
7336
7342
  null,
7337
7343
  changeInputs,
7338
- [chunkGVHUHTRH_cjs.AssetOutput.create(0, amount)],
7344
+ [chunkFM263GKH_cjs.AssetOutput.create(0, amount)],
7339
7345
  []
7340
7346
  )
7341
7347
  );
7342
7348
  }
7343
7349
  const address = await this.wallet.getAddress();
7344
- const outputAddress = chunk5MLC2HU3_cjs.ArkAddress.decode(address);
7350
+ const outputAddress = chunk5J5PDZRR_cjs.ArkAddress.decode(address);
7345
7351
  const outputs = [
7346
7352
  {
7347
7353
  script: outputAddress.pkScript,
7348
7354
  amount: BigInt(totalBtcSelected)
7349
7355
  },
7350
- Extension.create([chunkGVHUHTRH_cjs.Packet.create(groups)]).txOut()
7356
+ Extension.create([chunkFM263GKH_cjs.Packet.create(groups)]).txOut()
7351
7357
  ];
7352
7358
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7353
7359
  return arkTxid;
@@ -7414,27 +7420,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7414
7420
  for (const [inputIndex, assets] of assetInputs) {
7415
7421
  for (const asset of assets) {
7416
7422
  if (asset.assetId !== assetId) continue;
7417
- changeInputs.push(chunkGVHUHTRH_cjs.AssetInput.create(inputIndex, asset.amount));
7423
+ changeInputs.push(chunkFM263GKH_cjs.AssetInput.create(inputIndex, asset.amount));
7418
7424
  }
7419
7425
  }
7420
7426
  groups.push(
7421
- chunkGVHUHTRH_cjs.AssetGroup.create(
7422
- chunkGVHUHTRH_cjs.AssetId.fromString(assetId),
7427
+ chunkFM263GKH_cjs.AssetGroup.create(
7428
+ chunkFM263GKH_cjs.AssetId.fromString(assetId),
7423
7429
  null,
7424
7430
  changeInputs,
7425
- amount > 0n ? [chunkGVHUHTRH_cjs.AssetOutput.create(0, amount)] : [],
7431
+ amount > 0n ? [chunkFM263GKH_cjs.AssetOutput.create(0, amount)] : [],
7426
7432
  []
7427
7433
  )
7428
7434
  );
7429
7435
  }
7430
7436
  const address = await this.wallet.getAddress();
7431
- const outputAddress = chunk5MLC2HU3_cjs.ArkAddress.decode(address);
7437
+ const outputAddress = chunk5J5PDZRR_cjs.ArkAddress.decode(address);
7432
7438
  const outputs = [
7433
7439
  {
7434
7440
  script: outputAddress.pkScript,
7435
7441
  amount: BigInt(totalBtcSelected)
7436
7442
  },
7437
- Extension.create([chunkGVHUHTRH_cjs.Packet.create(groups)]).txOut()
7443
+ Extension.create([chunkFM263GKH_cjs.Packet.create(groups)]).txOut()
7438
7444
  ];
7439
7445
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7440
7446
  return arkTxid;
@@ -7459,7 +7465,7 @@ function castMetadata(metadata) {
7459
7465
  } else {
7460
7466
  throw new Error("Invalid metadata value type");
7461
7467
  }
7462
- md.push(chunkGVHUHTRH_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7468
+ md.push(chunkFM263GKH_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7463
7469
  }
7464
7470
  return md;
7465
7471
  }
@@ -7480,10 +7486,10 @@ var DelegateManagerImpl = class {
7480
7486
  if (vtxos.length === 0) {
7481
7487
  return { delegated: [], failed: [] };
7482
7488
  }
7483
- const destinationScript = chunk5MLC2HU3_cjs.ArkAddress.decode(destination).pkScript;
7489
+ const destinationScript = chunk5J5PDZRR_cjs.ArkAddress.decode(destination).pkScript;
7484
7490
  const arkInfo = await this.arkInfoProvider.getInfo();
7485
7491
  const delegateInfo = await this.delegateProvider.getDelegateInfo();
7486
- const eligible = vtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo).filter(
7492
+ const eligible = vtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo).filter(
7487
7493
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
7488
7494
  );
7489
7495
  if (eligible.length === 0) {
@@ -7512,11 +7518,11 @@ var DelegateManagerImpl = class {
7512
7518
  const groupByExpiry = /* @__PURE__ */ new Map();
7513
7519
  let recoverableVtxos = [];
7514
7520
  for (const vtxo of eligible) {
7515
- if (chunk5MLC2HU3_cjs.canRecoverOnchain(vtxo, now)) {
7521
+ if (chunk5J5PDZRR_cjs.canRecoverOnchain(vtxo, now)) {
7516
7522
  recoverableVtxos.push(vtxo);
7517
7523
  continue;
7518
7524
  }
7519
- const expiry = chunk5MLC2HU3_cjs.toBatchExpiry(vtxo);
7525
+ const expiry = chunk5J5PDZRR_cjs.toBatchExpiry(vtxo);
7520
7526
  if (!expiry) continue;
7521
7527
  const dayKey = getDayTimestamp(expiry);
7522
7528
  groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
@@ -7581,7 +7587,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7581
7587
  }
7582
7588
  if (!delegateAt) {
7583
7589
  const now = { timestamp: /* @__PURE__ */ new Date() };
7584
- const expiryTimestamp = vtxos.filter((coin) => !chunk5MLC2HU3_cjs.canRecoverOnchain(coin, now) && chunk5MLC2HU3_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunk5MLC2HU3_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
7590
+ const expiryTimestamp = vtxos.filter((coin) => !chunk5J5PDZRR_cjs.canRecoverOnchain(coin, now) && chunk5J5PDZRR_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunk5J5PDZRR_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
7585
7591
  if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
7586
7592
  delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
7587
7593
  } else {
@@ -7610,7 +7616,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7610
7616
  let amount = 0n;
7611
7617
  for (const coin of vtxos) {
7612
7618
  const inputFee = estimator.evalOffchainInput({
7613
- ...chunk5MLC2HU3_cjs.toOffchainInputFeeParams(coin),
7619
+ ...chunk5J5PDZRR_cjs.toOffchainInputFeeParams(coin),
7614
7620
  type: "vtxo"
7615
7621
  });
7616
7622
  if (inputFee.value >= coin.value) {
@@ -7624,7 +7630,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7624
7630
  const delegateFee = BigInt(Number(fee));
7625
7631
  if (delegateFee > 0n) {
7626
7632
  outputs.push({
7627
- script: chunk5MLC2HU3_cjs.ArkAddress.decode(delegateAddress).pkScript,
7633
+ script: chunk5J5PDZRR_cjs.ArkAddress.decode(delegateAddress).pkScript,
7628
7634
  amount: delegateFee
7629
7635
  });
7630
7636
  }
@@ -7657,10 +7663,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7657
7663
  destinationScript
7658
7664
  );
7659
7665
  const forfeitOutputScript = btcSigner.OutScript.encode(
7660
- btcSigner.Address(chunk5MLC2HU3_cjs.getNetwork(network)).decode(forfeitAddress)
7666
+ btcSigner.Address(chunk5J5PDZRR_cjs.getNetwork(network)).decode(forfeitAddress)
7661
7667
  );
7662
7668
  const forfeits = await Promise.all(
7663
- vtxos.filter((v) => !chunk5MLC2HU3_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7669
+ vtxos.filter((v) => !chunk5J5PDZRR_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7664
7670
  const forfeit = await makeDelegateForfeitTx(
7665
7671
  coin,
7666
7672
  dust,
@@ -7685,7 +7691,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
7685
7691
  index: input.vout,
7686
7692
  witnessUtxo: {
7687
7693
  amount: BigInt(input.value),
7688
- script: chunk5MLC2HU3_cjs.VtxoScript.decode(input.tapTree).pkScript
7694
+ script: chunk5J5PDZRR_cjs.VtxoScript.decode(input.tapTree).pkScript
7689
7695
  },
7690
7696
  sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
7691
7697
  tapLeafScript: [delegateTapLeaf]
@@ -7743,7 +7749,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
7743
7749
  expire_at: 0,
7744
7750
  cosigners_public_keys: cosignerPubKeys
7745
7751
  };
7746
- const proof = chunk5MLC2HU3_cjs.Intent.create(message, coins, outputs);
7752
+ const proof = chunk5J5PDZRR_cjs.Intent.create(message, coins, outputs);
7747
7753
  const signedProof = await identity.sign(proof);
7748
7754
  return {
7749
7755
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -7761,10 +7767,10 @@ function getDayTimestamp(timestamp) {
7761
7767
  function findDelegateTapLeaf(vtxo, delegatePubkey) {
7762
7768
  if (!vtxo.tapTree) return void 0;
7763
7769
  const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
7764
- const vtxoScript = chunk5MLC2HU3_cjs.VtxoScript.decode(vtxo.tapTree);
7770
+ const vtxoScript = chunk5J5PDZRR_cjs.VtxoScript.decode(vtxo.tapTree);
7765
7771
  return vtxoScript.leaves.find((tapLeaf) => {
7766
- const arkTapscript = chunk5MLC2HU3_cjs.decodeTapscript(chunk5MLC2HU3_cjs.scriptFromTapLeafScript(tapLeaf));
7767
- if (!chunk5MLC2HU3_cjs.MultisigTapscript.is(arkTapscript)) return false;
7772
+ const arkTapscript = chunk5J5PDZRR_cjs.decodeTapscript(chunk5J5PDZRR_cjs.scriptFromTapLeafScript(tapLeaf));
7773
+ if (!chunk5J5PDZRR_cjs.MultisigTapscript.is(arkTapscript)) return false;
7768
7774
  return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
7769
7775
  });
7770
7776
  }
@@ -8045,7 +8051,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
8045
8051
  };
8046
8052
  }
8047
8053
  function scriptFromArkAddress(address) {
8048
- return base.hex.encode(chunk5MLC2HU3_cjs.ArkAddress.decode(address).pkScript);
8054
+ return base.hex.encode(chunk5J5PDZRR_cjs.ArkAddress.decode(address).pkScript);
8049
8055
  }
8050
8056
 
8051
8057
  // src/repositories/indexedDB/schema.ts
@@ -8540,7 +8546,7 @@ function validateVtxosForScript(vtxos, script, context) {
8540
8546
  }
8541
8547
  async function getVtxosForContract(repo, contract) {
8542
8548
  const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8543
- return vtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo);
8549
+ return vtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo);
8544
8550
  }
8545
8551
  async function saveVtxosForContract(repo, contract, vtxos) {
8546
8552
  if (repo.saveVtxosForScript) {
@@ -8682,7 +8688,7 @@ function decodeArkContract(encoded) {
8682
8688
  }
8683
8689
  function contractFromArkContract(encoded, options = {}) {
8684
8690
  const parsed = decodeArkContract(encoded);
8685
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(parsed.type);
8691
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(parsed.type);
8686
8692
  if (!handler) {
8687
8693
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
8688
8694
  }
@@ -8696,9 +8702,9 @@ function contractFromArkContract(encoded, options = {}) {
8696
8702
  metadata: options.metadata
8697
8703
  };
8698
8704
  }
8699
- function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunk5MLC2HU3_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8705
+ function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunk5J5PDZRR_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8700
8706
  const parsed = decodeArkContract(encoded);
8701
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.getOrThrow(parsed.type);
8707
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.getOrThrow(parsed.type);
8702
8708
  const params = parsed.data;
8703
8709
  const vtxoScript = handler.createScript(params);
8704
8710
  return {
@@ -8730,6 +8736,8 @@ var DEFAULT_CONTRACT_WATCHER_CONFIG = {
8730
8736
  var ContractWatcher = class {
8731
8737
  config;
8732
8738
  contracts = /* @__PURE__ */ new Map();
8739
+ /** In-memory and process-lifetime; never persisted. */
8740
+ watchedScripts = /* @__PURE__ */ new Map();
8733
8741
  subscriptionId;
8734
8742
  abortController;
8735
8743
  isWatching = false;
@@ -8850,6 +8858,47 @@ var ContractWatcher = class {
8850
8858
  getWatchedContracts() {
8851
8859
  return this.getAllContracts().filter(isWatchedContract);
8852
8860
  }
8861
+ /**
8862
+ * Every script the subscription must carry. Wider than
8863
+ * {@link getWatchedContracts}, which stays the sync scope.
8864
+ */
8865
+ getSubscribedScripts() {
8866
+ const scripts = new Set(this.getWatchedContracts().map((c) => c.script));
8867
+ for (const script of this.watchedScripts.keys()) {
8868
+ scripts.add(script);
8869
+ }
8870
+ return Array.from(scripts);
8871
+ }
8872
+ /** @see IContractManager.watchScript for the delivery and filter contract. */
8873
+ async addWatchedScript(script, options) {
8874
+ const existing = this.watchedScripts.get(script);
8875
+ if (existing) {
8876
+ if (options?.label !== void 0) existing.label = options.label;
8877
+ return;
8878
+ }
8879
+ this.watchedScripts.set(script, {
8880
+ label: options?.label,
8881
+ lastKnownVtxos: /* @__PURE__ */ new Map()
8882
+ });
8883
+ if (this.isWatching) {
8884
+ await this.pollWatchedScripts([script]);
8885
+ await this.tryUpdateSubscription();
8886
+ }
8887
+ }
8888
+ /** Stop watching a script added by {@link addWatchedScript}. */
8889
+ async removeWatchedScript(script) {
8890
+ if (!this.watchedScripts.delete(script)) return;
8891
+ if (this.isWatching) {
8892
+ await this.tryUpdateSubscription();
8893
+ }
8894
+ }
8895
+ /** Every script registered via {@link addWatchedScript}. */
8896
+ getWatchedScripts() {
8897
+ return Array.from(this.watchedScripts.entries()).map(([script, state]) => ({
8898
+ script,
8899
+ label: state.label
8900
+ }));
8901
+ }
8853
8902
  /**
8854
8903
  * Get virtual outputs for contracts, grouped by contract script.
8855
8904
  * @see WalletRepository for `repo`
@@ -8952,9 +9001,9 @@ var ContractWatcher = class {
8952
9001
  this.connectionState = "connected";
8953
9002
  this.reconnectAttempts = 0;
8954
9003
  this.listenLoop().catch((e) => {
8955
- if (chunk5MLC2HU3_cjs.isEventSourceError(e)) {
9004
+ if (chunk5J5PDZRR_cjs.isEventSourceError(e)) {
8956
9005
  console.debug("ContractWatcher subscription disconnected; reconnecting");
8957
- } else if (!chunk5MLC2HU3_cjs.isEventSourceUnavailableError(e)) {
9006
+ } else if (!chunk5J5PDZRR_cjs.isEventSourceUnavailableError(e)) {
8958
9007
  console.error(e);
8959
9008
  }
8960
9009
  this.connectionState = "disconnected";
@@ -8966,7 +9015,7 @@ var ContractWatcher = class {
8966
9015
  this.scheduleReconnect();
8967
9016
  });
8968
9017
  } catch (error) {
8969
- if (!chunk5MLC2HU3_cjs.isEventSourceUnavailableError(error)) {
9018
+ if (!chunk5J5PDZRR_cjs.isEventSourceUnavailableError(error)) {
8970
9019
  console.error("ContractWatcher connection failed:", error);
8971
9020
  }
8972
9021
  this.connectionState = "disconnected";
@@ -8992,7 +9041,7 @@ var ContractWatcher = class {
8992
9041
  * slower; what it loses is push latency.
8993
9042
  */
8994
9043
  reportEventSourceUnavailable(error) {
8995
- if (!chunk5MLC2HU3_cjs.isEventSourceUnavailableError(error)) return false;
9044
+ if (!chunk5J5PDZRR_cjs.isEventSourceUnavailableError(error)) return false;
8996
9045
  if (!this.eventSourceReported) {
8997
9046
  this.eventSourceReported = true;
8998
9047
  console.warn(
@@ -9041,8 +9090,72 @@ var ContractWatcher = class {
9041
9090
  }
9042
9091
  async pollAllContracts() {
9043
9092
  const scripts = this.getWatchedContracts().map((c) => c.script);
9093
+ if (scripts.length > 0) {
9094
+ await this.pollContracts(scripts);
9095
+ }
9096
+ await this.pollWatchedScripts(Array.from(this.watchedScripts.keys()));
9097
+ }
9098
+ /**
9099
+ * Poll watch-only scripts against the indexer and emit the delta.
9100
+ *
9101
+ * Separate from {@link pollContracts} because that one diffs the wallet
9102
+ * repository, which is permanently empty for a script this wallet does not
9103
+ * own — reusing it would report every live output as spent on every tick.
9104
+ * Not a second poll loop: same timer and callers, different source.
9105
+ */
9106
+ async pollWatchedScripts(candidates) {
9107
+ if (!this.eventCallback) return;
9108
+ const scripts = candidates.filter((s) => {
9109
+ const state = this.contracts.get(s);
9110
+ return this.watchedScripts.has(s) && (state === void 0 || !isWatchedContract(state.contract));
9111
+ });
9044
9112
  if (scripts.length === 0) return;
9045
- await this.pollContracts(scripts);
9113
+ const now = Date.now();
9114
+ let current;
9115
+ try {
9116
+ current = await chunk5J5PDZRR_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9117
+ spendableOnly: true
9118
+ });
9119
+ } catch (error) {
9120
+ console.error("ContractWatcher watch-only poll failed:", error);
9121
+ return;
9122
+ }
9123
+ const byScript = /* @__PURE__ */ new Map();
9124
+ for (const vtxo of current) {
9125
+ let bucket = byScript.get(vtxo.script);
9126
+ if (!bucket) {
9127
+ bucket = [];
9128
+ byScript.set(vtxo.script, bucket);
9129
+ }
9130
+ bucket.push(vtxo);
9131
+ }
9132
+ for (const script of scripts) {
9133
+ const state = this.watchedScripts.get(script);
9134
+ if (!state) continue;
9135
+ const currentVtxos = byScript.get(script) || [];
9136
+ const currentKeys = new Set(currentVtxos.map((v) => `${v.txid}:${v.vout}`));
9137
+ const newVtxos = [];
9138
+ for (const vtxo of currentVtxos) {
9139
+ const key = `${vtxo.txid}:${vtxo.vout}`;
9140
+ if (!state.lastKnownVtxos.has(key)) {
9141
+ newVtxos.push(vtxo);
9142
+ state.lastKnownVtxos.set(key, vtxo);
9143
+ }
9144
+ }
9145
+ const spentVtxos = [];
9146
+ for (const [key, vtxo] of state.lastKnownVtxos) {
9147
+ if (!currentKeys.has(key)) {
9148
+ spentVtxos.push(vtxo);
9149
+ state.lastKnownVtxos.delete(key);
9150
+ }
9151
+ }
9152
+ if (newVtxos.length > 0) {
9153
+ this.emitWatchedScriptEvent(script, newVtxos, "vtxo_received", now);
9154
+ }
9155
+ if (spentVtxos.length > 0) {
9156
+ this.emitWatchedScriptEvent(script, spentVtxos, "vtxo_spent", now);
9157
+ }
9158
+ }
9046
9159
  }
9047
9160
  /**
9048
9161
  * Poll specific contracts and emit events for changes.
@@ -9143,10 +9256,10 @@ var ContractWatcher = class {
9143
9256
  /**
9144
9257
  * Update the subscription with scripts that should be watched.
9145
9258
  *
9146
- * @see getWatchedContracts
9259
+ * @see getSubscribedScripts
9147
9260
  */
9148
9261
  async updateSubscription() {
9149
- const scriptsToWatch = this.getWatchedContracts().map((c) => c.script);
9262
+ const scriptsToWatch = this.getSubscribedScripts();
9150
9263
  if (scriptsToWatch.length === 0) {
9151
9264
  if (this.subscriptionId) {
9152
9265
  try {
@@ -9208,14 +9321,14 @@ var ContractWatcher = class {
9208
9321
  const timestamp = Date.now();
9209
9322
  if (update.newVtxos?.length) {
9210
9323
  this.processSubscriptionVtxos(
9211
- update.newVtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo),
9324
+ update.newVtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo),
9212
9325
  "vtxo_received",
9213
9326
  timestamp
9214
9327
  );
9215
9328
  }
9216
9329
  if (update.spentVtxos?.length) {
9217
9330
  this.processSubscriptionVtxos(
9218
- update.spentVtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo),
9331
+ update.spentVtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo),
9219
9332
  "vtxo_spent",
9220
9333
  timestamp
9221
9334
  );
@@ -9230,16 +9343,26 @@ var ContractWatcher = class {
9230
9343
  */
9231
9344
  processSubscriptionVtxos(vtxos, eventType, timestamp) {
9232
9345
  const byContract = /* @__PURE__ */ new Map();
9346
+ const byWatchedScript = /* @__PURE__ */ new Map();
9233
9347
  let unknownScript = 0;
9348
+ const now = { timestamp: /* @__PURE__ */ new Date() };
9234
9349
  for (const vtxo of vtxos) {
9235
- if (!this.contracts.has(vtxo.script)) {
9350
+ const state = this.contracts.get(vtxo.script);
9351
+ const watchOnly = this.watchedScripts.has(vtxo.script);
9352
+ const preferContract = state !== void 0 && (!watchOnly || isWatchedContract(state.contract));
9353
+ const target = preferContract ? byContract : watchOnly ? byWatchedScript : void 0;
9354
+ if (!target) {
9236
9355
  unknownScript++;
9237
9356
  continue;
9238
9357
  }
9239
- let bucket = byContract.get(vtxo.script);
9358
+ if (target === byWatchedScript && eventType === "vtxo_received") {
9359
+ const n = chunk5J5PDZRR_cjs.normalizeVtxo(vtxo);
9360
+ if (chunk5J5PDZRR_cjs.hasTerminalSpend(n) || n.isSwept || chunk5J5PDZRR_cjs.isPastExpiry(n, now)) continue;
9361
+ }
9362
+ let bucket = target.get(vtxo.script);
9240
9363
  if (!bucket) {
9241
9364
  bucket = [];
9242
- byContract.set(vtxo.script, bucket);
9365
+ target.set(vtxo.script, bucket);
9243
9366
  }
9244
9367
  bucket.push(vtxo);
9245
9368
  }
@@ -9262,6 +9385,29 @@ var ContractWatcher = class {
9262
9385
  }
9263
9386
  this.emitVtxoEvent(contractScript, bucketVtxos, eventType, timestamp);
9264
9387
  }
9388
+ for (const [script, bucketVtxos] of byWatchedScript) {
9389
+ const state = this.watchedScripts.get(script);
9390
+ if (state) {
9391
+ for (const vtxo of bucketVtxos) {
9392
+ const key = `${vtxo.txid}:${vtxo.vout}`;
9393
+ if (eventType === "vtxo_received") {
9394
+ state.lastKnownVtxos.set(key, vtxo);
9395
+ } else {
9396
+ state.lastKnownVtxos.delete(key);
9397
+ }
9398
+ }
9399
+ }
9400
+ this.emitWatchedScriptEvent(script, bucketVtxos, eventType, timestamp);
9401
+ }
9402
+ }
9403
+ /** As {@link emitVtxoEvent}, less the `contract` and the annotation. */
9404
+ emitWatchedScriptEvent(script, vtxos, eventType, timestamp) {
9405
+ if (!this.eventCallback) return;
9406
+ if (eventType === "vtxo_received") {
9407
+ this.eventCallback({ type: "vtxo_received", contractScript: script, vtxos, timestamp });
9408
+ return;
9409
+ }
9410
+ this.eventCallback({ type: "vtxo_spent", contractScript: script, vtxos, timestamp });
9265
9411
  }
9266
9412
  /**
9267
9413
  * Emit a virtual output event for a contract.
@@ -9310,7 +9456,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
9310
9456
  (s) => !isTerminalIntentState(s)
9311
9457
  );
9312
9458
  function isConsumed(vtxo) {
9313
- return vtxo !== void 0 && chunk5MLC2HU3_cjs.hasTerminalSpend(vtxo);
9459
+ return vtxo !== void 0 && chunk5J5PDZRR_cjs.hasTerminalSpend(vtxo);
9314
9460
  }
9315
9461
  async function classifyIntent(intent, vtxosByOutpoint, now) {
9316
9462
  if (isTerminalIntentState(intent.state)) return void 0;
@@ -9353,7 +9499,7 @@ async function reconcileIntents(deps) {
9353
9499
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
9354
9500
  if (outpoints.length > 0) {
9355
9501
  try {
9356
- const { vtxos } = await chunk5MLC2HU3_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9502
+ const { vtxos } = await chunk5J5PDZRR_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9357
9503
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
9358
9504
  } catch (e) {
9359
9505
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -9527,7 +9673,7 @@ var ContractManager = class _ContractManager {
9527
9673
  await this.reconcileWatched();
9528
9674
  this.markSyncOnline();
9529
9675
  } catch (err) {
9530
- if (!chunk5MLC2HU3_cjs.isRetryableProviderError(err)) throw err;
9676
+ if (!chunk5J5PDZRR_cjs.isRetryableProviderError(err)) throw err;
9531
9677
  this.markSyncDegraded(err);
9532
9678
  }
9533
9679
  this.initialized = true;
@@ -9659,7 +9805,7 @@ var ContractManager = class _ContractManager {
9659
9805
  const from = Math.max(0, watermark - lookAhead.size);
9660
9806
  const to = watermark + lookAhead.size;
9661
9807
  const deps = lookAhead.candidateDeps();
9662
- const handlers = chunkWIFL5QYZ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkWIFL5QYZ_cjs.contractHandlers.get(t)).filter(hasCandidates);
9808
+ const handlers = chunkP6EXRY5L_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkP6EXRY5L_cjs.contractHandlers.get(t)).filter(hasCandidates);
9663
9809
  const band = /* @__PURE__ */ new Map();
9664
9810
  for (let index = from; index <= to; index++) {
9665
9811
  const descriptor = lookAhead.materialize(index);
@@ -9670,7 +9816,7 @@ var ContractManager = class _ContractManager {
9670
9816
  index,
9671
9817
  params: {
9672
9818
  ...candidate,
9673
- ...chunkWIFL5QYZ_cjs.speculativeReceiveMetadata(descriptor)
9819
+ ...chunkP6EXRY5L_cjs.speculativeReceiveMetadata(descriptor)
9674
9820
  }
9675
9821
  });
9676
9822
  }
@@ -9732,7 +9878,7 @@ var ContractManager = class _ContractManager {
9732
9878
  });
9733
9879
  for (const entry of pending) entry.catchUpPending = false;
9734
9880
  } catch (err) {
9735
- if (!chunk5MLC2HU3_cjs.isRetryableProviderError(err)) throw err;
9881
+ if (!chunk5J5PDZRR_cjs.isRetryableProviderError(err)) throw err;
9736
9882
  this.markSyncDegraded(err);
9737
9883
  }
9738
9884
  }
@@ -9782,7 +9928,7 @@ var ContractManager = class _ContractManager {
9782
9928
  await this.fetchContractVxosFromIndexer([contract]);
9783
9929
  this.markSyncOnline();
9784
9930
  } catch (err) {
9785
- if (!chunk5MLC2HU3_cjs.isRetryableProviderError(err)) throw err;
9931
+ if (!chunk5J5PDZRR_cjs.isRetryableProviderError(err)) throw err;
9786
9932
  this.markSyncDegraded(err);
9787
9933
  }
9788
9934
  await this.watcher.addContract(contract);
@@ -9819,7 +9965,7 @@ var ContractManager = class _ContractManager {
9819
9965
  return result;
9820
9966
  }
9821
9967
  async upsertContractRow(params) {
9822
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(params.type);
9968
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(params.type);
9823
9969
  if (!handler) {
9824
9970
  throw new Error(`No handler registered for contract type '${params.type}'`);
9825
9971
  }
@@ -9919,7 +10065,7 @@ var ContractManager = class _ContractManager {
9919
10065
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
9920
10066
  );
9921
10067
  }
9922
- const registered = chunkWIFL5QYZ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkWIFL5QYZ_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10068
+ const registered = chunkP6EXRY5L_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkP6EXRY5L_cjs.contractHandlers.get(t)).filter(isDiscoverable);
9923
10069
  const discoverables = [
9924
10070
  ...registered.filter((h) => h.type === "boarding"),
9925
10071
  ...registered.filter((h) => h.type !== "boarding")
@@ -10054,7 +10200,7 @@ var ContractManager = class _ContractManager {
10054
10200
  await this.syncContracts({ contracts, pageSize });
10055
10201
  this.markSyncOnline();
10056
10202
  } catch (err) {
10057
- if (!chunk5MLC2HU3_cjs.isRetryableProviderError(err)) throw err;
10203
+ if (!chunk5J5PDZRR_cjs.isRetryableProviderError(err)) throw err;
10058
10204
  this.markSyncDegraded(err);
10059
10205
  }
10060
10206
  const vtxos = await this.getVtxosForContracts(contracts);
@@ -10075,7 +10221,7 @@ var ContractManager = class _ContractManager {
10075
10221
  }
10076
10222
  const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
10077
10223
  return vtxos.map(
10078
- (vtxo) => extendVirtualCoinForContract(chunk5MLC2HU3_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10224
+ (vtxo) => extendVirtualCoinForContract(chunk5J5PDZRR_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10079
10225
  );
10080
10226
  }
10081
10227
  /** @inheritdoc */
@@ -10119,14 +10265,14 @@ var ContractManager = class _ContractManager {
10119
10265
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
10120
10266
  const asking = vtxos.filter((vtxo) => {
10121
10267
  const contract = byScript.get(vtxo.script);
10122
- return contract !== void 0 && chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10268
+ return contract !== void 0 && chunkP6EXRY5L_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10123
10269
  });
10124
10270
  if (asking.length === 0) return refused;
10125
10271
  const tip = await this.currentChainTip();
10126
10272
  const walletKey = await walletPubKey?.();
10127
10273
  for (const vtxo of asking) {
10128
10274
  const contract = byScript.get(vtxo.script);
10129
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type);
10275
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(contract.type);
10130
10276
  if (!handler?.assertSpendableNow) continue;
10131
10277
  const context = {
10132
10278
  collaborative: true,
@@ -10141,7 +10287,7 @@ var ContractManager = class _ContractManager {
10141
10287
  // the next handler to answer a CSV question would meet a
10142
10288
  // TypeError instead of a `false`. Carry the coin only when it
10143
10289
  // really is one.
10144
- vtxo: chunk5MLC2HU3_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10290
+ vtxo: chunk5J5PDZRR_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10145
10291
  };
10146
10292
  try {
10147
10293
  await handler.assertSpendableNow(
@@ -10297,7 +10443,7 @@ var ContractManager = class _ContractManager {
10297
10443
  const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
10298
10444
  const [contract] = await this.getContracts({ script: contractScript });
10299
10445
  if (!contract) return [];
10300
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type);
10446
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(contract.type);
10301
10447
  if (!handler) return [];
10302
10448
  const script = handler.createScript(contract.params);
10303
10449
  const tip = await this.currentChainTip();
@@ -10325,7 +10471,7 @@ var ContractManager = class _ContractManager {
10325
10471
  const { contractScript, collaborative = true, walletPubKey } = options;
10326
10472
  const [contract] = await this.getContracts({ script: contractScript });
10327
10473
  if (!contract) return [];
10328
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type);
10474
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(contract.type);
10329
10475
  if (!handler) return [];
10330
10476
  const script = handler.createScript(contract.params);
10331
10477
  const context = {
@@ -10381,7 +10527,7 @@ var ContractManager = class _ContractManager {
10381
10527
  }
10382
10528
  async refreshOutpoints(outpoints) {
10383
10529
  if (outpoints.length === 0) return;
10384
- const { vtxos } = await chunk5MLC2HU3_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10530
+ const { vtxos } = await chunk5J5PDZRR_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10385
10531
  outpoints
10386
10532
  });
10387
10533
  if (vtxos.length === 0) return;
@@ -10417,6 +10563,18 @@ var ContractManager = class _ContractManager {
10417
10563
  async isWatching() {
10418
10564
  return this.watcher.isCurrentlyWatching();
10419
10565
  }
10566
+ /** @see IContractManager.watchScript */
10567
+ async watchScript(script, options) {
10568
+ await this.watcher.addWatchedScript(script, options);
10569
+ }
10570
+ /** @see IContractManager.unwatchScript */
10571
+ async unwatchScript(script) {
10572
+ await this.watcher.removeWatchedScript(script);
10573
+ }
10574
+ /** @see IContractManager.getWatchedScripts */
10575
+ async getWatchedScripts() {
10576
+ return this.watcher.getWatchedScripts();
10577
+ }
10420
10578
  /**
10421
10579
  * Emit an event to all registered callbacks.
10422
10580
  */
@@ -10437,11 +10595,15 @@ var ContractManager = class _ContractManager {
10437
10595
  try {
10438
10596
  switch (event.type) {
10439
10597
  // Delta-sync only the changed virtual outputs for this contract.
10598
+ // The guard below is the ownership boundary: a watch-only script
10599
+ // reports these same types, so it must precede `syncContracts`.
10440
10600
  case "vtxo_received":
10601
+ if (!isContractVtxoEvent(event)) break;
10441
10602
  await this.syncContracts({ contracts: [event.contract] });
10442
10603
  this.markSyncOnline();
10443
10604
  break;
10444
10605
  case "vtxo_spent":
10606
+ if (!isContractVtxoEvent(event)) break;
10445
10607
  await this.syncContracts({ contracts: [event.contract] });
10446
10608
  this.markSyncOnline();
10447
10609
  if (this.config.onVtxosSpent) {
@@ -10460,7 +10622,7 @@ var ContractManager = class _ContractManager {
10460
10622
  break;
10461
10623
  }
10462
10624
  } catch (err) {
10463
- if (!chunk5MLC2HU3_cjs.isRetryableProviderError(err)) throw err;
10625
+ if (!chunk5J5PDZRR_cjs.isRetryableProviderError(err)) throw err;
10464
10626
  this.markSyncDegraded(err);
10465
10627
  }
10466
10628
  this.emitEvent(event);
@@ -10539,7 +10701,7 @@ var ContractManager = class _ContractManager {
10539
10701
  */
10540
10702
  async reconcilePendingFrontier(contracts) {
10541
10703
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
10542
- const vtxos = await chunk5MLC2HU3_cjs.getAllNormalizedVtxos(
10704
+ const vtxos = await chunk5J5PDZRR_cjs.getAllNormalizedVtxos(
10543
10705
  this.config.indexerProvider,
10544
10706
  contracts.map((c) => c.script),
10545
10707
  { pendingOnly: true }
@@ -10622,7 +10784,7 @@ var ContractManager = class _ContractManager {
10622
10784
  }
10623
10785
  return result;
10624
10786
  }
10625
- async fetchContractVtxosBulk(contracts, pageSize = chunk5MLC2HU3_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
10787
+ async fetchContractVtxosBulk(contracts, pageSize = chunk5J5PDZRR_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
10626
10788
  if (contracts.length === 0) {
10627
10789
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
10628
10790
  }
@@ -10638,7 +10800,7 @@ var ContractManager = class _ContractManager {
10638
10800
  before: syncWindow.before
10639
10801
  }
10640
10802
  } : {};
10641
- const vtxos = await chunk5MLC2HU3_cjs.getAllNormalizedVtxos(
10803
+ const vtxos = await chunk5J5PDZRR_cjs.getAllNormalizedVtxos(
10642
10804
  this.config.indexerProvider,
10643
10805
  contracts.map((c) => c.script),
10644
10806
  { ...windowOpts, pageSize }
@@ -10783,7 +10945,7 @@ var deserializeTapLeaf = (t) => {
10783
10945
  const s = base.hex.decode(t.s);
10784
10946
  return [cb, s];
10785
10947
  };
10786
- var deserializeVtxo = (o) => chunk5MLC2HU3_cjs.normalizeVtxo({
10948
+ var deserializeVtxo = (o) => chunk5J5PDZRR_cjs.normalizeVtxo({
10787
10949
  ...o,
10788
10950
  createdAt: new Date(o.createdAt),
10789
10951
  tapTree: base.hex.decode(o.tapTree),
@@ -11606,7 +11768,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
11606
11768
  */
11607
11769
  materializeDescriptorAt(index) {
11608
11770
  const descriptor = this.identity.descriptor;
11609
- const network = chunkWIFL5QYZ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11771
+ const network = chunkP6EXRY5L_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11610
11772
  const expansion = descriptorsScure.expand({ descriptor, network, index });
11611
11773
  const keyInfo = expansion.expansionMap?.["@0"];
11612
11774
  if (!keyInfo?.keyExpression) {
@@ -11754,7 +11916,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
11754
11916
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
11755
11917
  if (!provider) return void 0;
11756
11918
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
11757
- const expectedContractType = setup.offchainTapscript instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script ? "delegate" : "default";
11919
+ const expectedContractType = setup.offchainTapscript instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script ? "delegate" : "default";
11758
11920
  const factoryOpts = {
11759
11921
  walletRepository: setup.walletRepository,
11760
11922
  contractRepository: setup.contractRepository,
@@ -11955,7 +12117,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
11955
12117
  };
11956
12118
  function deriveLeafPubkey(descriptor) {
11957
12119
  try {
11958
- return chunkWIFL5QYZ_cjs.deriveDescriptorLeafPubKey(descriptor);
12120
+ return chunkP6EXRY5L_cjs.deriveDescriptorLeafPubKey(descriptor);
11959
12121
  } catch (e) {
11960
12122
  throw new NonRangeableDescriptorError(
11961
12123
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -11967,7 +12129,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
11967
12129
  const pubKey = deriveLeafPubkey(descriptor);
11968
12130
  const tapscript = rebuildTapscript(current, pubKey);
11969
12131
  const serverPubKey = tapscript.options.serverPubKey;
11970
- const csvTimelock = chunk5MLC2HU3_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12132
+ const csvTimelock = chunk5J5PDZRR_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
11971
12133
  const base$1 = {
11972
12134
  script: base.hex.encode(tapscript.pkScript),
11973
12135
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -11978,11 +12140,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
11978
12140
  // index-0 key. Without it, spends produce unsigned PSBTs that the
11979
12141
  // server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
11980
12142
  metadata: {
11981
- ...tagSource && { source: chunkWIFL5QYZ_cjs.WALLET_RECEIVE_SOURCE },
12143
+ ...tagSource && { source: chunkP6EXRY5L_cjs.WALLET_RECEIVE_SOURCE },
11982
12144
  signingDescriptor: descriptor
11983
12145
  }
11984
12146
  };
11985
- const params = tapscript instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script ? {
12147
+ const params = tapscript instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script ? {
11986
12148
  ...base$1,
11987
12149
  type: "delegate",
11988
12150
  params: {
@@ -12003,10 +12165,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12003
12165
  return { tapscript, params };
12004
12166
  }
12005
12167
  function rebuildTapscript(current, pubKey) {
12006
- if (current instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script) {
12007
- return new chunkWIFL5QYZ_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12168
+ if (current instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script) {
12169
+ return new chunkP6EXRY5L_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12008
12170
  }
12009
- return new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12171
+ return new chunkP6EXRY5L_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12010
12172
  }
12011
12173
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
12012
12174
  const candidates = await contractRepository.getContracts({
@@ -12015,7 +12177,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
12015
12177
  });
12016
12178
  const serverPubKeyHex = base.hex.encode(serverPubKey);
12017
12179
  const matching = candidates.filter(
12018
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkWIFL5QYZ_cjs.WALLET_RECEIVE_SOURCE
12180
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkP6EXRY5L_cjs.WALLET_RECEIVE_SOURCE
12019
12181
  ).sort((a, b) => {
12020
12182
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12021
12183
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12071,7 +12233,7 @@ function computeOffchainBalance(vtxos, caps) {
12071
12233
  }
12072
12234
  };
12073
12235
  for (const vtxo of vtxos) {
12074
- if (chunk5MLC2HU3_cjs.hasTerminalSpend(vtxo)) continue;
12236
+ if (chunk5J5PDZRR_cjs.hasTerminalSpend(vtxo)) continue;
12075
12237
  addAssets(owned, vtxo);
12076
12238
  if (vtxo.isUnrolled) {
12077
12239
  unrolled += vtxo.value;
@@ -12081,11 +12243,11 @@ function computeOffchainBalance(vtxos, caps) {
12081
12243
  pendingRecovery += vtxo.value;
12082
12244
  continue;
12083
12245
  }
12084
- if (chunk5MLC2HU3_cjs.canRecoverOnchain(vtxo, now)) {
12246
+ if (chunk5J5PDZRR_cjs.canRecoverOnchain(vtxo, now)) {
12085
12247
  recoverable += vtxo.value;
12086
12248
  continue;
12087
12249
  }
12088
- if (!chunk5MLC2HU3_cjs.canSpendOffchain(vtxo, now)) continue;
12250
+ if (!chunk5J5PDZRR_cjs.canSpendOffchain(vtxo, now)) continue;
12089
12251
  if (vtxo.isPreconfirmed) {
12090
12252
  preconfirmed += vtxo.value;
12091
12253
  } else {
@@ -12255,12 +12417,12 @@ var InputSignerRouter = class {
12255
12417
  };
12256
12418
 
12257
12419
  // src/wallet/wallet.ts
12258
- var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunk5MLC2HU3_cjs.DEFAULT_ARKADE_SERVER_URL;
12420
+ var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunk5J5PDZRR_cjs.DEFAULT_ARKADE_SERVER_URL;
12259
12421
  function intentProofJobs(coins) {
12260
12422
  if (coins.length === 0) return [];
12261
12423
  const coinJobs = coins.map((coin, i) => ({
12262
12424
  index: i + 1,
12263
- lookupScript: chunk5MLC2HU3_cjs.VtxoScript.decode(coin.tapTree).pkScript
12425
+ lookupScript: chunk5J5PDZRR_cjs.VtxoScript.decode(coin.tapTree).pkScript
12264
12426
  }));
12265
12427
  return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
12266
12428
  }
@@ -12292,7 +12454,7 @@ function dedupeTimelocks(timelocks) {
12292
12454
  const seen = /* @__PURE__ */ new Set();
12293
12455
  const deduped = [];
12294
12456
  for (const timelock of timelocks) {
12295
- const sequence = chunk5MLC2HU3_cjs.timelockToSequence(timelock).toString();
12457
+ const sequence = chunk5J5PDZRR_cjs.timelockToSequence(timelock).toString();
12296
12458
  if (seen.has(sequence)) continue;
12297
12459
  seen.add(sequence);
12298
12460
  deduped.push(timelock);
@@ -12309,7 +12471,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12309
12471
  state: "active"
12310
12472
  });
12311
12473
  const newest = candidates.filter(
12312
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkWIFL5QYZ_cjs.WALLET_RECEIVE_SOURCE
12474
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkP6EXRY5L_cjs.WALLET_RECEIVE_SOURCE
12313
12475
  ).sort((a, b) => {
12314
12476
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12315
12477
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12317,7 +12479,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12317
12479
  if (!newest?.params.pubKey) return baseline;
12318
12480
  try {
12319
12481
  const pubKey = base.hex.decode(newest.params.pubKey);
12320
- return new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12482
+ return new chunkP6EXRY5L_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12321
12483
  } catch (e) {
12322
12484
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
12323
12485
  return baseline;
@@ -12336,10 +12498,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
12336
12498
  if (vtxo.isUnrolled) {
12337
12499
  return !!f.withUnrolled;
12338
12500
  }
12339
- if (chunk5MLC2HU3_cjs.hasTerminalSpend(vtxo)) {
12501
+ if (chunk5J5PDZRR_cjs.hasTerminalSpend(vtxo)) {
12340
12502
  return false;
12341
12503
  }
12342
- if (!f.withRecoverable && chunk5MLC2HU3_cjs.canRecoverOnchain(vtxo, now)) {
12504
+ if (!f.withRecoverable && chunk5J5PDZRR_cjs.canRecoverOnchain(vtxo, now)) {
12343
12505
  return false;
12344
12506
  }
12345
12507
  return true;
@@ -12679,7 +12841,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12679
12841
  */
12680
12842
  static async setupWalletConfig(config, pubKey) {
12681
12843
  const arkadeServerUrl = getArkadeServerUrl(config);
12682
- const arkProvider = config.arkProvider || new chunk5MLC2HU3_cjs.RestArkProvider(arkadeServerUrl);
12844
+ const arkProvider = config.arkProvider || new chunk5J5PDZRR_cjs.RestArkProvider(arkadeServerUrl);
12683
12845
  let indexerProvider = config.indexerProvider;
12684
12846
  if (!indexerProvider) {
12685
12847
  let indexerUrl = config.indexerUrl;
@@ -12696,7 +12858,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12696
12858
  indexerUrl = arkadeServerUrl;
12697
12859
  }
12698
12860
  }
12699
- indexerProvider = new chunkGVHUHTRH_cjs.RestIndexerProvider(indexerUrl);
12861
+ indexerProvider = new chunkFM263GKH_cjs.RestIndexerProvider(indexerUrl);
12700
12862
  }
12701
12863
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
12702
12864
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
@@ -12705,7 +12867,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12705
12867
  source: serverInfoSource,
12706
12868
  lastOnlineAt: serverInfoLastOnlineAt
12707
12869
  } = await resolveArkInfo(arkProvider, walletRepository);
12708
- const network = chunk5MLC2HU3_cjs.getNetwork(info.network);
12870
+ const network = chunk5J5PDZRR_cjs.getNetwork(info.network);
12709
12871
  if ("descriptor" in config.identity) {
12710
12872
  const descriptor = config.identity.descriptor;
12711
12873
  const identityIsMainnet = !descriptor.includes("tpub");
@@ -12745,18 +12907,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
12745
12907
  value: info.boardingExitDelay,
12746
12908
  type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
12747
12909
  };
12748
- const serverPubKey = chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
12749
- const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
12910
+ const serverPubKey = chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
12911
+ const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
12750
12912
  const offchainOptions = {
12751
12913
  pubKey,
12752
12914
  serverPubKey,
12753
12915
  csvTimelock: exitTimelock
12754
12916
  };
12755
- const offchainTapscript = !delegatePubKey ? new chunkWIFL5QYZ_cjs.DefaultVtxo.Script(offchainOptions) : new chunkWIFL5QYZ_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
12756
- const boardingTapscript = chunkWIFL5QYZ_cjs.BoardingContractHandler.createScript({
12917
+ const offchainTapscript = !delegatePubKey ? new chunkP6EXRY5L_cjs.DefaultVtxo.Script(offchainOptions) : new chunkP6EXRY5L_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
12918
+ const boardingTapscript = chunkP6EXRY5L_cjs.BoardingContractHandler.createScript({
12757
12919
  pubKey: base.hex.encode(pubKey),
12758
12920
  serverPubKey: base.hex.encode(serverPubKey),
12759
- csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(boardingTimelock).toString()
12921
+ csvTimelock: chunk5J5PDZRR_cjs.timelockToSequence(boardingTimelock).toString()
12760
12922
  });
12761
12923
  return {
12762
12924
  arkProvider,
@@ -12922,7 +13084,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12922
13084
  if (!filter?.withUnrolled) {
12923
13085
  logExcludedVtxos(
12924
13086
  "getSpendableVtxos",
12925
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunk5MLC2HU3_cjs.hasTerminalSpend(vtxo)),
13087
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunk5J5PDZRR_cjs.hasTerminalSpend(vtxo)),
12926
13088
  [() => UNROLLED_REASON]
12927
13089
  );
12928
13090
  }
@@ -13065,7 +13227,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13065
13227
  const response = await contractManager.getContractsWithVtxos();
13066
13228
  const allVtxos = response.flatMap((_) => _.vtxos);
13067
13229
  const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
13068
- const resolveTxCreatedAt = (txids) => chunk5MLC2HU3_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13230
+ const resolveTxCreatedAt = (txids) => chunk5J5PDZRR_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13069
13231
  return buildTransactionHistory(
13070
13232
  allVtxos,
13071
13233
  boardingTxs,
@@ -13159,7 +13321,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13159
13321
  },
13160
13322
  isUnrolled: true,
13161
13323
  ...boardingFacts,
13162
- virtualStatus: chunk5MLC2HU3_cjs.toVirtualStatus(boardingFacts),
13324
+ virtualStatus: chunk5J5PDZRR_cjs.toVirtualStatus(boardingFacts),
13163
13325
  spentBy: "",
13164
13326
  createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
13165
13327
  script: scriptHex
@@ -13215,9 +13377,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13215
13377
  async getBoardingTapscripts(allowedSigners) {
13216
13378
  const byScript = /* @__PURE__ */ new Map();
13217
13379
  const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
13218
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkWIFL5QYZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13380
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkP6EXRY5L_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13219
13381
  add(
13220
- new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({
13382
+ new chunkP6EXRY5L_cjs.DefaultVtxo.Script({
13221
13383
  pubKey: await this.identity.xOnlyPublicKey(),
13222
13384
  serverPubKey: this.boardingTapscript.options.serverPubKey,
13223
13385
  csvTimelock: boardingCsv
@@ -13232,7 +13394,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13232
13394
  for (const c of boardingContracts) {
13233
13395
  if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
13234
13396
  try {
13235
- add(chunkWIFL5QYZ_cjs.BoardingContractHandler.createScript(c.params));
13397
+ add(chunkP6EXRY5L_cjs.BoardingContractHandler.createScript(c.params));
13236
13398
  } catch (e) {
13237
13399
  console.warn("Skipping malformed boarding contract", c.script, e);
13238
13400
  }
@@ -13270,7 +13432,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13270
13432
  // Per-row CSV delay decoded from THIS tapscript's exit leaf —
13271
13433
  // not the wallet's current boarding timelock, which a signer
13272
13434
  // rotation may have changed.
13273
- csvTimelock: chunk5MLC2HU3_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13435
+ csvTimelock: chunk5J5PDZRR_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13274
13436
  coins: utxos
13275
13437
  });
13276
13438
  }
@@ -13368,7 +13530,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13368
13530
  const cm = await this.getContractManager();
13369
13531
  let annotationQueue = Promise.resolve();
13370
13532
  indexerStopFunc = cm.onContractEvent((event) => {
13371
- if (event.type !== "vtxo_received" && event.type !== "vtxo_spent") {
13533
+ if (!isContractVtxoEvent(event)) {
13372
13534
  return;
13373
13535
  }
13374
13536
  if (event.contract.type !== "default" && event.contract.type !== "delegate") {
@@ -13403,7 +13565,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13403
13565
  /** Fetch Arkade transaction ids that are still pending final settlement. */
13404
13566
  async fetchPendingTxs() {
13405
13567
  const scripts = await this.getWalletScripts();
13406
- const vtxos = await chunk5MLC2HU3_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13568
+ const vtxos = await chunk5J5PDZRR_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13407
13569
  return vtxos.filter(
13408
13570
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
13409
13571
  ).map((_) => _.arkTxId);
@@ -13434,7 +13596,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13434
13596
  });
13435
13597
  for (const contract of contracts) {
13436
13598
  if (map.has(contract.script)) continue;
13437
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type);
13599
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(contract.type);
13438
13600
  if (handler) {
13439
13601
  const script = handler.createScript(contract.params);
13440
13602
  map.set(contract.script, script);
@@ -13546,7 +13708,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13546
13708
  }
13547
13709
  });
13548
13710
  const baselinePubkey = await this.identity.xOnlyPublicKey();
13549
- const delegatePubKey = this.offchainTapscript instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
13711
+ const delegatePubKey = this.offchainTapscript instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
13550
13712
  const baselineSigners = [
13551
13713
  this.offchainTapscript.options.serverPubKey,
13552
13714
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
@@ -13554,8 +13716,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
13554
13716
  const seenBaselineScripts = /* @__PURE__ */ new Set();
13555
13717
  for (const serverPubKey of baselineSigners) {
13556
13718
  for (const csvTimelock of this.walletContractTimelocks) {
13557
- const csvTimelockStr = chunk5MLC2HU3_cjs.timelockToSequence(csvTimelock).toString();
13558
- const defaultScript = new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({
13719
+ const csvTimelockStr = chunk5J5PDZRR_cjs.timelockToSequence(csvTimelock).toString();
13720
+ const defaultScript = new chunkP6EXRY5L_cjs.DefaultVtxo.Script({
13559
13721
  pubKey: baselinePubkey,
13560
13722
  serverPubKey,
13561
13723
  csvTimelock
@@ -13576,7 +13738,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13576
13738
  });
13577
13739
  }
13578
13740
  if (delegatePubKey) {
13579
- const delegateScript = new chunkWIFL5QYZ_cjs.DelegateVtxo.Script({
13741
+ const delegateScript = new chunkP6EXRY5L_cjs.DelegateVtxo.Script({
13580
13742
  pubKey: baselinePubkey,
13581
13743
  serverPubKey,
13582
13744
  delegatePubKey,
@@ -13600,9 +13762,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13600
13762
  }
13601
13763
  }
13602
13764
  }
13603
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkWIFL5QYZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13765
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkP6EXRY5L_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13604
13766
  for (const serverPubKey of baselineSigners) {
13605
- const baselineBoarding = new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({
13767
+ const baselineBoarding = new chunkP6EXRY5L_cjs.DefaultVtxo.Script({
13606
13768
  pubKey: baselinePubkey,
13607
13769
  serverPubKey,
13608
13770
  csvTimelock: boardingCsvTimelock
@@ -13615,7 +13777,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13615
13777
  params: {
13616
13778
  pubKey: base.hex.encode(baselineBoarding.options.pubKey),
13617
13779
  serverPubKey: base.hex.encode(serverPubKey),
13618
- csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(boardingCsvTimelock).toString()
13780
+ csvTimelock: chunk5J5PDZRR_cjs.timelockToSequence(boardingCsvTimelock).toString()
13619
13781
  },
13620
13782
  script: boardingScriptHex,
13621
13783
  address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
@@ -13815,7 +13977,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13815
13977
  serverPubKey: this.offchainTapscript.options.serverPubKey,
13816
13978
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
13817
13979
  csvTimelocks: this.walletContractTimelocks,
13818
- delegatePubKey: this.offchainTapscript instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
13980
+ delegatePubKey: this.offchainTapscript instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
13819
13981
  };
13820
13982
  }
13821
13983
  _signerRouter;
@@ -14060,7 +14222,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14060
14222
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
14061
14223
  const persisted = row?.metadata?.signingDescriptor;
14062
14224
  if (typeof persisted === "string") return persisted;
14063
- return chunkWIFL5QYZ_cjs.identityDescriptor(this.identity);
14225
+ return chunkP6EXRY5L_cjs.identityDescriptor(this.identity);
14064
14226
  }
14065
14227
  /**
14066
14228
  * Build, persist and shape one address of `type` owned by `descriptor` —
@@ -14076,7 +14238,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14076
14238
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
14077
14239
  if (type === "boarding") {
14078
14240
  const built2 = this.buildBoardingContract(
14079
- chunkWIFL5QYZ_cjs.deriveDescriptorLeafPubKey(descriptor),
14241
+ chunkP6EXRY5L_cjs.deriveDescriptorLeafPubKey(descriptor),
14080
14242
  descriptor,
14081
14243
  tagSource
14082
14244
  );
@@ -14121,11 +14283,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14121
14283
  * {@link buildReceiveContract}.
14122
14284
  */
14123
14285
  buildBoardingContract(pubKey, descriptor, tagSource) {
14124
- const tapscript = new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({
14286
+ const tapscript = new chunkP6EXRY5L_cjs.DefaultVtxo.Script({
14125
14287
  ...this._boardingTapscript.options,
14126
14288
  pubKey
14127
14289
  });
14128
- const csvTimelock = tapscript.options.csvTimelock ?? chunkWIFL5QYZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14290
+ const csvTimelock = tapscript.options.csvTimelock ?? chunkP6EXRY5L_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14129
14291
  return {
14130
14292
  tapscript,
14131
14293
  params: {
@@ -14133,13 +14295,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14133
14295
  params: {
14134
14296
  pubKey: base.hex.encode(pubKey),
14135
14297
  serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
14136
- csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(csvTimelock).toString()
14298
+ csvTimelock: chunk5J5PDZRR_cjs.timelockToSequence(csvTimelock).toString()
14137
14299
  },
14138
14300
  script: base.hex.encode(tapscript.pkScript),
14139
14301
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
14140
14302
  state: "active",
14141
14303
  metadata: {
14142
- ...tagSource && { source: chunkWIFL5QYZ_cjs.WALLET_RECEIVE_SOURCE },
14304
+ ...tagSource && { source: chunkP6EXRY5L_cjs.WALLET_RECEIVE_SOURCE },
14143
14305
  signingDescriptor: descriptor
14144
14306
  }
14145
14307
  }
@@ -14168,7 +14330,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14168
14330
  if (this._descriptorProvider instanceof HDDescriptorProvider) {
14169
14331
  return (await this.getContractManager()).getNextSigningDescriptor();
14170
14332
  }
14171
- return chunkWIFL5QYZ_cjs.identityDescriptor(this.identity);
14333
+ return chunkP6EXRY5L_cjs.identityDescriptor(this.identity);
14172
14334
  }
14173
14335
  /**
14174
14336
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -14264,7 +14426,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14264
14426
  * the stable public API.
14265
14427
  */
14266
14428
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
14267
- const xonly = chunkWIFL5QYZ_cjs.toXOnly(newServerPubKey, "ark signer key");
14429
+ const xonly = chunkP6EXRY5L_cjs.toXOnly(newServerPubKey, "ark signer key");
14268
14430
  const newServerUnrollScript = assertValidServerUnrollScript(
14269
14431
  checkpointTapscript,
14270
14432
  resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
@@ -14293,21 +14455,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14293
14455
  const [currentBoardingRow] = await manager.getContracts({
14294
14456
  script: currentBoardingScript
14295
14457
  });
14296
- const newOffchain = this.offchainTapscript instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script ? new chunkWIFL5QYZ_cjs.DelegateVtxo.Script({
14458
+ const newOffchain = this.offchainTapscript instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script ? new chunkP6EXRY5L_cjs.DelegateVtxo.Script({
14297
14459
  ...this.offchainTapscript.options,
14298
14460
  serverPubKey: xonly
14299
- }) : new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({
14461
+ }) : new chunkP6EXRY5L_cjs.DefaultVtxo.Script({
14300
14462
  ...this.offchainTapscript.options,
14301
14463
  serverPubKey: xonly
14302
14464
  });
14303
- const newBoarding = new chunkWIFL5QYZ_cjs.DefaultVtxo.Script({
14465
+ const newBoarding = new chunkP6EXRY5L_cjs.DefaultVtxo.Script({
14304
14466
  ...this._boardingTapscript.options,
14305
14467
  serverPubKey: xonly
14306
14468
  });
14307
- const offchainCsv = chunk5MLC2HU3_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14469
+ const offchainCsv = chunk5J5PDZRR_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14308
14470
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
14309
14471
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
14310
- if (newOffchain instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script) {
14472
+ if (newOffchain instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script) {
14311
14473
  await manager.createContract({
14312
14474
  type: "delegate",
14313
14475
  params: {
@@ -14335,13 +14497,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14335
14497
  metadata: currentOffchainRow?.metadata
14336
14498
  });
14337
14499
  }
14338
- const boardingCsv = newBoarding.options.csvTimelock ?? chunkWIFL5QYZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14500
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkP6EXRY5L_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14339
14501
  await manager.createContract({
14340
14502
  type: "boarding",
14341
14503
  params: {
14342
14504
  pubKey: base.hex.encode(newBoarding.options.pubKey),
14343
14505
  serverPubKey: base.hex.encode(xonly),
14344
- csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(boardingCsv).toString()
14506
+ csvTimelock: chunk5J5PDZRR_cjs.timelockToSequence(boardingCsv).toString()
14345
14507
  },
14346
14508
  script: base.hex.encode(newBoarding.pkScript),
14347
14509
  address: newBoarding.address(this.network.hrp, xonly).encode(),
@@ -14374,14 +14536,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14374
14536
  _restoreInFlight;
14375
14537
  _addPendingSpends(inputs) {
14376
14538
  for (const input of inputs) {
14377
- if (chunk5MLC2HU3_cjs.isVirtualCoin(input)) {
14539
+ if (chunk5J5PDZRR_cjs.isVirtualCoin(input)) {
14378
14540
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
14379
14541
  }
14380
14542
  }
14381
14543
  }
14382
14544
  _removePendingSpends(inputs) {
14383
14545
  for (const input of inputs) {
14384
- if (chunk5MLC2HU3_cjs.isVirtualCoin(input)) {
14546
+ if (chunk5J5PDZRR_cjs.isVirtualCoin(input)) {
14385
14547
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
14386
14548
  }
14387
14549
  }
@@ -14439,13 +14601,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14439
14601
  const manager = await this.getContractManager();
14440
14602
  const provider = this._descriptorProvider;
14441
14603
  const hd = provider instanceof HDDescriptorProvider;
14442
- const staticDescriptor = hd ? void 0 : await chunkWIFL5QYZ_cjs.identityDescriptor(this.identity);
14604
+ const staticDescriptor = hd ? void 0 : await chunkP6EXRY5L_cjs.identityDescriptor(this.identity);
14443
14605
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
14444
- const delegatePubKey = this.offchainTapscript instanceof chunkWIFL5QYZ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14606
+ const delegatePubKey = this.offchainTapscript instanceof chunkP6EXRY5L_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14445
14607
  const arkInfo = await this.arkProvider.getInfo();
14446
- const currentSignerPubKey = chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14608
+ const currentSignerPubKey = chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14447
14609
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
14448
- (s) => chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14610
+ (s) => chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14449
14611
  );
14450
14612
  const deps = {
14451
14613
  indexerProvider: this.indexerProvider,
@@ -14460,7 +14622,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14460
14622
  csvTimelocks: this.walletContractTimelocks,
14461
14623
  // Boarding-exit CSV so the boarding handler can build its
14462
14624
  // candidate script (distinct from the unilateral-exit matrix).
14463
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkWIFL5QYZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14625
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkP6EXRY5L_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14464
14626
  delegatePubKey
14465
14627
  };
14466
14628
  const result = await manager.scanContracts({
@@ -14574,7 +14736,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14574
14736
  throw new Error("Invalid configured public key");
14575
14737
  }
14576
14738
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
14577
- const forfeitPubkey = chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14739
+ const forfeitPubkey = chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14578
14740
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
14579
14741
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
14580
14742
  const checkpointExitDelayOverrides = {
@@ -14723,7 +14885,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14723
14885
  inputs: params.selectedVtxos,
14724
14886
  changeAmount: BigInt(changeAmount)
14725
14887
  };
14726
- const outputAddress = chunk5MLC2HU3_cjs.ArkAddress.decode(params.address);
14888
+ const outputAddress = chunk5J5PDZRR_cjs.ArkAddress.decode(params.address);
14727
14889
  assertRecipientArkAddress(
14728
14890
  params.address,
14729
14891
  outputAddress,
@@ -14789,13 +14951,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14789
14951
  void this.logUngatedInputs("settle({ inputs })", params.inputs);
14790
14952
  }
14791
14953
  const offchainAddress = await this.getAddress();
14792
- const offchainPkScript = chunk5MLC2HU3_cjs.ArkAddress.decode(offchainAddress).pkScript;
14954
+ const offchainPkScript = chunk5J5PDZRR_cjs.ArkAddress.decode(offchainAddress).pkScript;
14793
14955
  const offchainOutputScript = base.hex.encode(offchainPkScript);
14794
14956
  if (!params) {
14795
14957
  const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
14796
14958
  const estimator = new Estimator(fees.intentFee);
14797
14959
  let amount = 0;
14798
- const exitScript = chunk5MLC2HU3_cjs.CSVMultisigTapscript.decode(
14960
+ const exitScript = chunk5J5PDZRR_cjs.CSVMultisigTapscript.decode(
14799
14961
  base.hex.decode(this.boardingTapscript.exitScript)
14800
14962
  );
14801
14963
  const boardingTimelock = exitScript.params.timelock;
@@ -14824,7 +14986,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14824
14986
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
14825
14987
  break;
14826
14988
  }
14827
- const inputFee = estimator.evalOffchainInput(chunk5MLC2HU3_cjs.toOffchainInputFeeParams(vtxo));
14989
+ const inputFee = estimator.evalOffchainInput(chunk5J5PDZRR_cjs.toOffchainInputFeeParams(vtxo));
14828
14990
  if (inputFee.satoshis >= vtxo.value) {
14829
14991
  continue;
14830
14992
  }
@@ -14871,7 +15033,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14871
15033
  let script;
14872
15034
  let arkAddress;
14873
15035
  try {
14874
- arkAddress = chunk5MLC2HU3_cjs.ArkAddress.decode(output.address);
15036
+ arkAddress = chunk5J5PDZRR_cjs.ArkAddress.decode(output.address);
14875
15037
  } catch {
14876
15038
  arkAddress = void 0;
14877
15039
  }
@@ -14961,7 +15123,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14961
15123
  const abortController = new AbortController();
14962
15124
  let stream;
14963
15125
  let committedTxid;
14964
- const settleInputVtxos = params.inputs.filter(chunk5MLC2HU3_cjs.isVirtualCoin);
15126
+ const settleInputVtxos = params.inputs.filter(chunk5J5PDZRR_cjs.isVirtualCoin);
14965
15127
  const contractManager = await this.getContractManager();
14966
15128
  await contractManager.assertAnnotatable(settleInputVtxos);
14967
15129
  await contractManager.assertSpendableNow?.(
@@ -15073,7 +15235,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15073
15235
  async maybeRotateBoardingAfterBoard(inputs) {
15074
15236
  if (!this._descriptorProvider) return;
15075
15237
  const consumedBoarding = inputs.some(
15076
- (input) => typeof input !== "string" && !chunk5MLC2HU3_cjs.isVirtualCoin(input)
15238
+ (input) => typeof input !== "string" && !chunk5J5PDZRR_cjs.isVirtualCoin(input)
15077
15239
  );
15078
15240
  if (!consumedBoarding) return;
15079
15241
  try {
@@ -15097,7 +15259,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15097
15259
  let connectorIndex = 0;
15098
15260
  const connectorsLeaves = connectorsGraph?.leaves() || [];
15099
15261
  for (const input of inputs) {
15100
- if (!chunk5MLC2HU3_cjs.isVirtualCoin(input)) {
15262
+ if (!chunk5J5PDZRR_cjs.isVirtualCoin(input)) {
15101
15263
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
15102
15264
  const settlementInput = settlementPsbt.getInput(i);
15103
15265
  if (!settlementInput.txid || settlementInput.index === void 0) {
@@ -15128,7 +15290,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15128
15290
  }
15129
15291
  continue;
15130
15292
  }
15131
- if (chunk5MLC2HU3_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
15293
+ if (chunk5J5PDZRR_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
15132
15294
  continue;
15133
15295
  }
15134
15296
  if (connectorsLeaves.length === 0) {
@@ -15156,7 +15318,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15156
15318
  index: input.vout,
15157
15319
  witnessUtxo: {
15158
15320
  amount: BigInt(input.value),
15159
- script: chunk5MLC2HU3_cjs.VtxoScript.decode(input.tapTree).pkScript
15321
+ script: chunk5J5PDZRR_cjs.VtxoScript.decode(input.tapTree).pkScript
15160
15322
  },
15161
15323
  sighashType: btcSigner.SigHash.DEFAULT,
15162
15324
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -15175,7 +15337,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15175
15337
  forfeitTx = await this._signerRouter.sign(forfeitTx, [
15176
15338
  {
15177
15339
  index: 0,
15178
- lookupScript: chunk5MLC2HU3_cjs.VtxoScript.decode(input.tapTree).pkScript
15340
+ lookupScript: chunk5J5PDZRR_cjs.VtxoScript.decode(input.tapTree).pkScript
15179
15341
  }
15180
15342
  ]);
15181
15343
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -15233,7 +15395,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15233
15395
  resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
15234
15396
  );
15235
15397
  await this.arkProvider.confirmRegistration(intentId);
15236
- const sweepTapscript = chunk5MLC2HU3_cjs.CSVMultisigTapscript.encode({
15398
+ const sweepTapscript = chunk5J5PDZRR_cjs.CSVMultisigTapscript.encode({
15237
15399
  timelock,
15238
15400
  pubkeys: [this.forfeitPubkey]
15239
15401
  }).script;
@@ -15248,10 +15410,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15248
15410
  throw new Error("Sweep tap tree root not set");
15249
15411
  }
15250
15412
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
15251
- (k) => base.hex.encode(chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15413
+ (k) => base.hex.encode(chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15252
15414
  );
15253
15415
  const signerPublicKey = await session.getPublicKey();
15254
- const xonlySignerPublicKey = chunkWIFL5QYZ_cjs.toXOnly(signerPublicKey, "signer key");
15416
+ const xonlySignerPublicKey = chunkP6EXRY5L_cjs.toXOnly(signerPublicKey, "signer key");
15255
15417
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
15256
15418
  return { skip: true };
15257
15419
  }
@@ -15341,9 +15503,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15341
15503
  ...existing ?? {},
15342
15504
  intentTxId,
15343
15505
  registerProof: intent.proof,
15344
- registerProofMessage: chunk5MLC2HU3_cjs.Intent.encodeMessage(intent.message),
15506
+ registerProofMessage: chunk5J5PDZRR_cjs.Intent.encodeMessage(intent.message),
15345
15507
  deleteProof: deleteIntent.proof,
15346
- deleteProofMessage: chunk5MLC2HU3_cjs.Intent.encodeMessage(deleteIntent.message),
15508
+ deleteProofMessage: chunk5J5PDZRR_cjs.Intent.encodeMessage(deleteIntent.message),
15347
15509
  intentVtxos: inputs.map((i) => ({
15348
15510
  txid: i.txid,
15349
15511
  vout: i.vout
@@ -15375,7 +15537,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15375
15537
  try {
15376
15538
  return await this.arkProvider.registerIntent(intent);
15377
15539
  } catch (error) {
15378
- if (error instanceof chunk5MLC2HU3_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15540
+ if (error instanceof chunk5J5PDZRR_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15379
15541
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
15380
15542
  await this.arkProvider.deleteIntent(deleteIntent);
15381
15543
  return this.arkProvider.registerIntent(intent);
@@ -15391,7 +15553,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15391
15553
  expire_at: 0,
15392
15554
  cosigners_public_keys: cosignerPubKeys
15393
15555
  };
15394
- const proof = chunk5MLC2HU3_cjs.Intent.create(message, coins, outputs);
15556
+ const proof = chunk5J5PDZRR_cjs.Intent.create(message, coins, outputs);
15395
15557
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15396
15558
  return {
15397
15559
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15403,7 +15565,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15403
15565
  type: "delete",
15404
15566
  expire_at: 0
15405
15567
  };
15406
- const proof = chunk5MLC2HU3_cjs.Intent.create(message, coins, []);
15568
+ const proof = chunk5J5PDZRR_cjs.Intent.create(message, coins, []);
15407
15569
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15408
15570
  return {
15409
15571
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15415,7 +15577,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15415
15577
  type: "get-pending-tx",
15416
15578
  expire_at: 0
15417
15579
  };
15418
- const proof = chunk5MLC2HU3_cjs.Intent.create(message, coins, []);
15580
+ const proof = chunk5J5PDZRR_cjs.Intent.create(message, coins, []);
15419
15581
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15420
15582
  return {
15421
15583
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15436,7 +15598,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15436
15598
  if (!vtxos || vtxos.length === 0) {
15437
15599
  const scriptMap = await this.getScriptMap();
15438
15600
  const allExtended = [];
15439
- const fetchedVtxos = await chunk5MLC2HU3_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15601
+ const fetchedVtxos = await chunk5J5PDZRR_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15440
15602
  ...scriptMap.keys()
15441
15603
  ]);
15442
15604
  for (const vtxo of fetchedVtxos) {
@@ -15480,7 +15642,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15480
15642
  try {
15481
15643
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
15482
15644
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
15483
- chunk5MLC2HU3_cjs.assertAllowedSighashTypes(tx);
15645
+ chunk5J5PDZRR_cjs.assertAllowedSighashTypes(tx);
15484
15646
  return tx;
15485
15647
  });
15486
15648
  assertCheckpointsMatchInputs(
@@ -15552,11 +15714,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15552
15714
  * against the current key alone would leave it pending forever.
15553
15715
  */
15554
15716
  checkpointUnrollCandidates(info) {
15555
- const current = chunk5MLC2HU3_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15717
+ const current = chunk5J5PDZRR_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15556
15718
  const candidates = [this._serverUnrollScript, current];
15557
15719
  for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
15558
15720
  candidates.push(
15559
- chunk5MLC2HU3_cjs.CSVMultisigTapscript.encode({
15721
+ chunk5J5PDZRR_cjs.CSVMultisigTapscript.encode({
15560
15722
  ...current.params,
15561
15723
  pubkeys: [base.hex.decode(deprecated)]
15562
15724
  })
@@ -15647,7 +15809,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15647
15809
  if (vtxos.length === 0) {
15648
15810
  throw new Error("No VTXOs found for this arkadeCash");
15649
15811
  }
15650
- const myPkScript = chunk5MLC2HU3_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
15812
+ const myPkScript = chunk5J5PDZRR_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
15651
15813
  let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
15652
15814
  let swept = 0;
15653
15815
  const drainable = vtxos.filter(
@@ -15723,7 +15885,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15723
15885
  const spendable = [];
15724
15886
  const unclaimed = [];
15725
15887
  for (const vtxo of vtxos) {
15726
- if (chunk5MLC2HU3_cjs.hasTerminalSpend(vtxo)) {
15888
+ if (chunk5J5PDZRR_cjs.hasTerminalSpend(vtxo)) {
15727
15889
  unclaimed.push(cashReport(vtxo, "already-spent"));
15728
15890
  } else if (vtxo.isUnrolled) {
15729
15891
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -15745,7 +15907,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15745
15907
  const all = [];
15746
15908
  const seen = /* @__PURE__ */ new Set();
15747
15909
  for (let pageIndex = 0; ; pageIndex++) {
15748
- const { vtxos, page } = await chunk5MLC2HU3_cjs.getNormalizedVtxos(this.indexerProvider, {
15910
+ const { vtxos, page } = await chunk5J5PDZRR_cjs.getNormalizedVtxos(this.indexerProvider, {
15749
15911
  scripts,
15750
15912
  pageIndex,
15751
15913
  pageSize
@@ -15792,7 +15954,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15792
15954
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
15793
15955
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
15794
15956
  const message = { type: "get-pending-tx", expire_at: 0 };
15795
- const proof = chunk5MLC2HU3_cjs.Intent.create(message, batch, []);
15957
+ const proof = chunk5J5PDZRR_cjs.Intent.create(message, batch, []);
15796
15958
  const signedProof = await identity.sign(
15797
15959
  proof,
15798
15960
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -15814,7 +15976,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15814
15976
  try {
15815
15977
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
15816
15978
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
15817
- chunk5MLC2HU3_cjs.assertAllowedSighashTypes(tx);
15979
+ chunk5J5PDZRR_cjs.assertAllowedSighashTypes(tx);
15818
15980
  return tx;
15819
15981
  });
15820
15982
  assertCheckpointsMatchInputs(
@@ -16013,7 +16175,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16013
16175
  script: recipient.script,
16014
16176
  amount: BigInt(recipient.amount),
16015
16177
  // Already checked against the recipient address in `validateRecipients`.
16016
- ...recipient.tapTree ? { tapTree: chunk5MLC2HU3_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16178
+ ...recipient.tapTree ? { tapTree: chunk5J5PDZRR_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16017
16179
  }));
16018
16180
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
16019
16181
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -16157,10 +16319,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16157
16319
  const serverPubKey = this.arkServerPublicKey;
16158
16320
  const serverUnrollScript = this.serverUnrollScript;
16159
16321
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
16160
- const normalizedInputs = inputs.map(chunk5MLC2HU3_cjs.normalizeVtxo);
16161
- const at = now ?? await chunk5MLC2HU3_cjs.resolveTimeHeight(this.onchainProvider);
16322
+ const normalizedInputs = inputs.map(chunk5J5PDZRR_cjs.normalizeVtxo);
16323
+ const at = now ?? await chunk5J5PDZRR_cjs.resolveTimeHeight(this.onchainProvider);
16162
16324
  for (const input of normalizedInputs) {
16163
- if (!chunk5MLC2HU3_cjs.canSpendOffchain(input, at)) {
16325
+ if (!chunk5J5PDZRR_cjs.canSpendOffchain(input, at)) {
16164
16326
  throw new Error(
16165
16327
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
16166
16328
  );
@@ -16230,7 +16392,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16230
16392
  );
16231
16393
  const arkTxJobs = inputs.map((input, index) => ({
16232
16394
  index,
16233
- lookupScript: chunk5MLC2HU3_cjs.VtxoScript.decode(input.tapTree).pkScript
16395
+ lookupScript: chunk5J5PDZRR_cjs.VtxoScript.decode(input.tapTree).pkScript
16234
16396
  }));
16235
16397
  const identity = this.identity;
16236
16398
  const signer = {
@@ -16316,14 +16478,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16316
16478
  const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
16317
16479
  spentVtxos.push({
16318
16480
  ...spentFacts,
16319
- virtualStatus: chunk5MLC2HU3_cjs.toVirtualStatus(spentFacts),
16481
+ virtualStatus: chunk5J5PDZRR_cjs.toVirtualStatus(spentFacts),
16320
16482
  ...spentBy ? { spentBy } : {},
16321
16483
  arkTxId: arkTxid
16322
16484
  });
16323
16485
  for (const id of vtxo.commitmentTxIds) {
16324
16486
  commitmentTxIds.add(id);
16325
16487
  }
16326
- const vtxoExpiry = chunk5MLC2HU3_cjs.toBatchExpiry(vtxo);
16488
+ const vtxoExpiry = chunk5J5PDZRR_cjs.toBatchExpiry(vtxo);
16327
16489
  if (vtxoExpiry) {
16328
16490
  batchExpiry = Math.min(batchExpiry, vtxoExpiry);
16329
16491
  }
@@ -16336,7 +16498,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16336
16498
  isSwept: false,
16337
16499
  isPreconfirmed: true,
16338
16500
  commitmentTxIds: Array.from(commitmentTxIds),
16339
- ...chunk5MLC2HU3_cjs.parseLegacyExpiry(batchExpiry)
16501
+ ...chunk5J5PDZRR_cjs.parseLegacyExpiry(batchExpiry)
16340
16502
  };
16341
16503
  changeVtxo = {
16342
16504
  txid: arkTxid,
@@ -16348,7 +16510,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16348
16510
  tapTree: offchainTapscript.encode(),
16349
16511
  value: Number(changeAmount),
16350
16512
  ...changeFacts,
16351
- virtualStatus: chunk5MLC2HU3_cjs.toVirtualStatus(changeFacts),
16513
+ virtualStatus: chunk5J5PDZRR_cjs.toVirtualStatus(changeFacts),
16352
16514
  spentBy: "",
16353
16515
  status: {
16354
16516
  confirmed: false
@@ -16417,12 +16579,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16417
16579
  const spentVtxos = [];
16418
16580
  const inputArkTxIds = /* @__PURE__ */ new Set();
16419
16581
  const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
16420
- const vtxoInputs = inputs.filter(chunk5MLC2HU3_cjs.isVirtualCoin);
16582
+ const vtxoInputs = inputs.filter(chunk5J5PDZRR_cjs.isVirtualCoin);
16421
16583
  const cm = await this.getContractManager();
16422
16584
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
16423
16585
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
16424
16586
  for (const input of inputs) {
16425
- if (chunk5MLC2HU3_cjs.isVirtualCoin(input)) {
16587
+ if (chunk5J5PDZRR_cjs.isVirtualCoin(input)) {
16426
16588
  const outpoint = `${input.txid}:${input.vout}`;
16427
16589
  const vtxo = annotatedByKey.get(outpoint);
16428
16590
  if (!vtxo) {
@@ -16434,13 +16596,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16434
16596
  const settledFacts = { ...vtxo, isSpent: true };
16435
16597
  spentVtxos.push({
16436
16598
  ...settledFacts,
16437
- virtualStatus: chunk5MLC2HU3_cjs.toVirtualStatus(settledFacts),
16599
+ virtualStatus: chunk5J5PDZRR_cjs.toVirtualStatus(settledFacts),
16438
16600
  settledBy: commitmentTxid
16439
16601
  });
16440
16602
  } else {
16441
16603
  let sourceAddress;
16442
16604
  try {
16443
- sourceAddress = chunk5MLC2HU3_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16605
+ sourceAddress = chunk5J5PDZRR_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16444
16606
  this.network
16445
16607
  );
16446
16608
  } catch {
@@ -16498,9 +16660,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16498
16660
  }
16499
16661
  };
16500
16662
  function selectVirtualCoins(coins, targetAmount) {
16501
- const sortedCoins = coins.map(chunk5MLC2HU3_cjs.normalizeVtxo).sort((a, b) => {
16502
- const expiryA = chunk5MLC2HU3_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
16503
- const expiryB = chunk5MLC2HU3_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
16663
+ const sortedCoins = coins.map(chunk5J5PDZRR_cjs.normalizeVtxo).sort((a, b) => {
16664
+ const expiryA = chunk5J5PDZRR_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
16665
+ const expiryB = chunk5J5PDZRR_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
16504
16666
  if (expiryA !== expiryB) {
16505
16667
  return expiryA - expiryB;
16506
16668
  }
@@ -16869,7 +17031,7 @@ var MessageBus = class {
16869
17031
  this.initialized = true;
16870
17032
  }
16871
17033
  async buildServices(config) {
16872
- const arkProvider = new chunk5MLC2HU3_cjs.RestArkProvider(config.arkServer.url);
17034
+ const arkProvider = new chunk5J5PDZRR_cjs.RestArkProvider(config.arkServer.url);
16873
17035
  const storage = {
16874
17036
  walletRepository: this.walletRepository,
16875
17037
  contractRepository: this.contractRepository,
@@ -17211,7 +17373,7 @@ var offboardNetworkNames = [
17211
17373
  function offboardDestinationScript(destinationAddress) {
17212
17374
  for (const networkName of offboardNetworkNames) {
17213
17375
  try {
17214
- const network = chunk5MLC2HU3_cjs.networks[networkName];
17376
+ const network = chunk5J5PDZRR_cjs.networks[networkName];
17215
17377
  const addr = btcSigner.Address(network).decode(destinationAddress);
17216
17378
  return btcSigner.OutScript.encode(addr);
17217
17379
  } catch {
@@ -17275,7 +17437,7 @@ var Ramps = class {
17275
17437
  }
17276
17438
  amount = amount ?? totalAmount;
17277
17439
  const offchainAddress = await this.wallet.getAddress();
17278
- const offchainAddr = chunk5MLC2HU3_cjs.ArkAddress.decode(offchainAddress);
17440
+ const offchainAddr = chunk5J5PDZRR_cjs.ArkAddress.decode(offchainAddress);
17279
17441
  const offchainScript = base.hex.encode(offchainAddr.pkScript);
17280
17442
  const outputFee = estimator.evalOffchainOutput({
17281
17443
  amount,
@@ -17335,7 +17497,7 @@ var Ramps = class {
17335
17497
  const filteredVtxos = [];
17336
17498
  let totalAmount = 0n;
17337
17499
  for (const vtxo of vtxos) {
17338
- const inputFee = estimator.evalOffchainInput(chunk5MLC2HU3_cjs.toOffchainInputFeeParams(vtxo));
17500
+ const inputFee = estimator.evalOffchainInput(chunk5J5PDZRR_cjs.toOffchainInputFeeParams(vtxo));
17339
17501
  if (inputFee.satoshis >= vtxo.value) {
17340
17502
  continue;
17341
17503
  }
@@ -17440,6 +17602,9 @@ var DelegateNotConfiguredError = class extends Error {
17440
17602
  };
17441
17603
  var DelegatorNotConfiguredError = DelegateNotConfiguredError;
17442
17604
  var DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
17605
+ function unsupportedByManager(method) {
17606
+ return new Error(`Contract manager does not support ${method}`);
17607
+ }
17443
17608
  var serializeMigrationVtxoRef = (ref) => ({
17444
17609
  txid: ref.txid,
17445
17610
  vout: ref.vout,
@@ -17824,6 +17989,39 @@ var WalletMessageHandler = class {
17824
17989
  payload: { contracts }
17825
17990
  });
17826
17991
  }
17992
+ case "WATCH_SCRIPT": {
17993
+ const manager = await this.readonlyWallet.getContractManager();
17994
+ if (!manager.watchScript) throw unsupportedByManager("watchScript");
17995
+ await manager.watchScript(message.payload.script, {
17996
+ label: message.payload.label
17997
+ });
17998
+ return this.tagged({
17999
+ id,
18000
+ type: "SCRIPT_WATCHED",
18001
+ payload: { script: message.payload.script }
18002
+ });
18003
+ }
18004
+ case "UNWATCH_SCRIPT": {
18005
+ const manager = await this.readonlyWallet.getContractManager();
18006
+ if (!manager.unwatchScript) throw unsupportedByManager("unwatchScript");
18007
+ await manager.unwatchScript(message.payload.script);
18008
+ return this.tagged({
18009
+ id,
18010
+ type: "SCRIPT_UNWATCHED",
18011
+ payload: { script: message.payload.script }
18012
+ });
18013
+ }
18014
+ case "GET_WATCHED_SCRIPTS": {
18015
+ const manager = await this.readonlyWallet.getContractManager();
18016
+ if (!manager.getWatchedScripts) {
18017
+ throw unsupportedByManager("getWatchedScripts");
18018
+ }
18019
+ return this.tagged({
18020
+ id,
18021
+ type: "WATCHED_SCRIPTS",
18022
+ payload: { scripts: await manager.getWatchedScripts() }
18023
+ });
18024
+ }
17827
18025
  case "ANNOTATE_VTXOS": {
17828
18026
  const manager = await this.readonlyWallet.getContractManager();
17829
18027
  const annotated = await manager.annotateVtxos(message.payload.vtxos);
@@ -18171,7 +18369,7 @@ var WalletMessageHandler = class {
18171
18369
  // Wallet methods
18172
18370
  async handleInitWallet({ payload }) {
18173
18371
  const { arkServerUrl } = payload;
18174
- this.indexerProvider = new chunkGVHUHTRH_cjs.RestIndexerProvider(arkServerUrl);
18372
+ this.indexerProvider = new chunkFM263GKH_cjs.RestIndexerProvider(arkServerUrl);
18175
18373
  await this.onWalletInitialized();
18176
18374
  }
18177
18375
  /**
@@ -18460,7 +18658,7 @@ var WalletMessageHandler = class {
18460
18658
  if (v.isUnrolled) {
18461
18659
  return withUnrolled;
18462
18660
  }
18463
- if (chunk5MLC2HU3_cjs.hasTerminalSpend(v)) {
18661
+ if (chunk5J5PDZRR_cjs.hasTerminalSpend(v)) {
18464
18662
  return false;
18465
18663
  }
18466
18664
  if (includeRecoverable) {
@@ -18469,10 +18667,10 @@ var WalletMessageHandler = class {
18469
18667
  if (dustAmount != null && isSubdust(v, dustAmount)) {
18470
18668
  return false;
18471
18669
  }
18472
- if (chunk5MLC2HU3_cjs.isRecoverable(v)) {
18670
+ if (chunk5J5PDZRR_cjs.isRecoverable(v)) {
18473
18671
  return false;
18474
18672
  }
18475
- if (chunk5MLC2HU3_cjs.isExpired(v)) {
18673
+ if (chunk5J5PDZRR_cjs.isExpired(v)) {
18476
18674
  return false;
18477
18675
  }
18478
18676
  return true;
@@ -18570,7 +18768,7 @@ var WalletMessageHandler = class {
18570
18768
  if (!this.readonlyWallet) return null;
18571
18769
  const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
18572
18770
  const indexerProvider = this.indexerProvider;
18573
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunk5MLC2HU3_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
18771
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunk5J5PDZRR_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
18574
18772
  return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
18575
18773
  }
18576
18774
  async ensureContractEventBroadcasting() {
@@ -18627,6 +18825,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
18627
18825
  GET_TRANSACTION_HISTORY: 2e4,
18628
18826
  GET_CONTRACTS: 2e4,
18629
18827
  GET_CONTRACTS_WITH_VTXOS: 2e4,
18828
+ GET_WATCHED_SCRIPTS: 1e4,
18630
18829
  ANNOTATE_VTXOS: 2e4,
18631
18830
  GET_SPENDABLE_PATHS: 2e4,
18632
18831
  GET_ALL_SPENDING_PATHS: 2e4,
@@ -18663,6 +18862,10 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
18663
18862
  SIGN_TRANSACTION: 3e4,
18664
18863
  CREATE_CONTRACT: 3e4,
18665
18864
  UPDATE_CONTRACT: 3e4,
18865
+ // Registering a watch is an in-memory map write plus one subscription
18866
+ // update — no indexer round trip on the request path.
18867
+ WATCH_SCRIPT: 1e4,
18868
+ UNWATCH_SCRIPT: 1e4,
18666
18869
  DELETE_CONTRACT: 1e4,
18667
18870
  REFRESH_VTXOS: 3e4,
18668
18871
  REFRESH_OUTPOINTS: 3e4
@@ -18683,6 +18886,7 @@ var DEDUPABLE_REQUEST_TYPES = /* @__PURE__ */ new Set([
18683
18886
  "GET_SPENDABLE_VTXOS",
18684
18887
  "GET_CONTRACTS",
18685
18888
  "GET_CONTRACTS_WITH_VTXOS",
18889
+ "GET_WATCHED_SCRIPTS",
18686
18890
  "ANNOTATE_VTXOS",
18687
18891
  "GET_SPENDABLE_PATHS",
18688
18892
  "GET_ALL_SPENDING_PATHS",
@@ -19266,7 +19470,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19266
19470
  };
19267
19471
  try {
19268
19472
  const response = await this.sendMessage(message);
19269
- return response.payload.vtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo);
19473
+ return response.payload.vtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo);
19270
19474
  } catch (error) {
19271
19475
  throw new Error(`Failed to get vtxos: ${error}`);
19272
19476
  }
@@ -19291,7 +19495,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19291
19495
  };
19292
19496
  try {
19293
19497
  const response = await this.sendMessage(message);
19294
- return response.payload.vtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo);
19498
+ return response.payload.vtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo);
19295
19499
  } catch (error) {
19296
19500
  throw new Error(`Failed to get spendable vtxos: ${error}`);
19297
19501
  }
@@ -19391,6 +19595,46 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19391
19595
  throw new Error("Failed to get contracts with vtxos");
19392
19596
  }
19393
19597
  },
19598
+ async watchScript(script, options) {
19599
+ const message = {
19600
+ type: "WATCH_SCRIPT",
19601
+ id: getRandomId(),
19602
+ tag: messageTag,
19603
+ payload: { script, label: options?.label }
19604
+ };
19605
+ try {
19606
+ await sendContractMessage(message);
19607
+ } catch (e) {
19608
+ throw new Error("Failed to watch script");
19609
+ }
19610
+ },
19611
+ async unwatchScript(script) {
19612
+ const message = {
19613
+ type: "UNWATCH_SCRIPT",
19614
+ id: getRandomId(),
19615
+ tag: messageTag,
19616
+ payload: { script }
19617
+ };
19618
+ try {
19619
+ await sendContractMessage(message);
19620
+ } catch (e) {
19621
+ throw new Error("Failed to unwatch script");
19622
+ }
19623
+ },
19624
+ async getWatchedScripts() {
19625
+ const message = {
19626
+ type: "GET_WATCHED_SCRIPTS",
19627
+ id: getRandomId(),
19628
+ tag: messageTag,
19629
+ payload: {}
19630
+ };
19631
+ try {
19632
+ const response = await sendContractMessage(message);
19633
+ return response.payload.scripts;
19634
+ } catch (e) {
19635
+ throw new Error("Failed to get watched scripts");
19636
+ }
19637
+ },
19394
19638
  getSyncState() {
19395
19639
  return syncState;
19396
19640
  },
@@ -19422,7 +19666,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19422
19666
  };
19423
19667
  try {
19424
19668
  const response = await sendContractMessage(message);
19425
- return response.payload.vtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo);
19669
+ return response.payload.vtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo);
19426
19670
  } catch (e) {
19427
19671
  throw new Error("Failed to annotate vtxos");
19428
19672
  }
@@ -20023,7 +20267,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
20023
20267
  };
20024
20268
  try {
20025
20269
  const response = await wallet.sendMessage(message);
20026
- return response.payload.vtxos.map(chunk5MLC2HU3_cjs.normalizeVtxo);
20270
+ return response.payload.vtxos.map(chunk5J5PDZRR_cjs.normalizeVtxo);
20027
20271
  } catch (e) {
20028
20272
  throw new Error(`Failed to get expiring vtxos: ${e}`);
20029
20273
  }
@@ -20135,12 +20379,12 @@ var OnchainWallet = class _OnchainWallet {
20135
20379
  * @returns Configured onchain wallet
20136
20380
  * @throws Error if the configured identity cannot produce a valid x-only public key
20137
20381
  */
20138
- static async create(identity, networkName = chunk5MLC2HU3_cjs.DEFAULT_NETWORK_NAME, provider) {
20382
+ static async create(identity, networkName = chunk5J5PDZRR_cjs.DEFAULT_NETWORK_NAME, provider) {
20139
20383
  const pubkey = await identity.xOnlyPublicKey();
20140
20384
  if (!pubkey) {
20141
20385
  throw new Error("Invalid configured public key");
20142
20386
  }
20143
- const network = chunk5MLC2HU3_cjs.getNetwork(networkName);
20387
+ const network = chunk5J5PDZRR_cjs.getNetwork(networkName);
20144
20388
  const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
20145
20389
  const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
20146
20390
  return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
@@ -20246,7 +20490,7 @@ var OnchainWallet = class _OnchainWallet {
20246
20490
  if (!inputs) {
20247
20491
  throw new Error("Fee estimation failed");
20248
20492
  }
20249
- let tx = new chunk5MLC2HU3_cjs.Transaction();
20493
+ let tx = new chunk5J5PDZRR_cjs.Transaction();
20250
20494
  for (const input of inputs) {
20251
20495
  tx.addInput({
20252
20496
  txid: input.txid,
@@ -20304,7 +20548,7 @@ var OnchainWallet = class _OnchainWallet {
20304
20548
  * @throws If the parent has no anchor, or funding cannot be selected/signed
20305
20549
  */
20306
20550
  async bumpAnchor(parentHex, feeRate) {
20307
- const parent = chunk5MLC2HU3_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20551
+ const parent = chunk5J5PDZRR_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20308
20552
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
20309
20553
  const child = await this.buildBumpPackage(parent, feeRate, coins);
20310
20554
  return [parent.hex, child.hex];
@@ -21211,7 +21455,7 @@ async function resolvePrevTxs(txids, source, onchain) {
21211
21455
  try {
21212
21456
  const { txs } = await source.getVirtualTxs(wanted);
21213
21457
  for (const psbt of txs) {
21214
- const tx = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21458
+ const tx = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21215
21459
  resolved.set(tx.id, tx.toBytes());
21216
21460
  }
21217
21461
  } catch (err) {
@@ -21244,7 +21488,7 @@ async function resolvePrevTxs(txids, source, onchain) {
21244
21488
  async function attachPrevArkTxs(tx, txids, source, onchain) {
21245
21489
  const pending = [];
21246
21490
  for (let i = 0; i < tx.inputsLength; i++) {
21247
- if (chunk5MLC2HU3_cjs.getArkPsbtFields(tx, i, chunk5MLC2HU3_cjs.PrevArkTxField).length === 0) pending.push(i);
21491
+ if (chunk5J5PDZRR_cjs.getArkPsbtFields(tx, i, chunk5J5PDZRR_cjs.PrevArkTxField).length === 0) pending.push(i);
21248
21492
  }
21249
21493
  if (pending.length === 0) return;
21250
21494
  const resolved = await resolvePrevTxs(
@@ -21253,13 +21497,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
21253
21497
  onchain
21254
21498
  );
21255
21499
  for (const i of pending) {
21256
- chunk5MLC2HU3_cjs.setArkPsbtField(tx, i, chunk5MLC2HU3_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
21500
+ chunk5J5PDZRR_cjs.setArkPsbtField(tx, i, chunk5J5PDZRR_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
21257
21501
  }
21258
21502
  }
21259
21503
  async function attachPrevoutTxs(tx, source) {
21260
21504
  const pending = [];
21261
21505
  for (let i = 0; i < tx.inputsLength; i++) {
21262
- if (chunk5MLC2HU3_cjs.getArkPsbtFields(tx, i, chunk5MLC2HU3_cjs.PrevoutTxField).length > 0) continue;
21506
+ if (chunk5J5PDZRR_cjs.getArkPsbtFields(tx, i, chunk5J5PDZRR_cjs.PrevoutTxField).length > 0) continue;
21263
21507
  const input = tx.getInput(i);
21264
21508
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
21265
21509
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -21270,7 +21514,7 @@ async function attachPrevoutTxs(tx, source) {
21270
21514
  resolved.set(txid, await source.getRawTransaction(txid));
21271
21515
  }
21272
21516
  for (const { index, txid } of pending) {
21273
- chunk5MLC2HU3_cjs.setArkPsbtField(tx, index, chunk5MLC2HU3_cjs.PrevoutTxField, resolved.get(txid));
21517
+ chunk5J5PDZRR_cjs.setArkPsbtField(tx, index, chunk5J5PDZRR_cjs.PrevoutTxField, resolved.get(txid));
21274
21518
  }
21275
21519
  }
21276
21520
  async function withPrevTxs(coins, source, onchain) {
@@ -21296,7 +21540,7 @@ exports.BIP322 = void 0;
21296
21540
  async function sign2(message, identity, network) {
21297
21541
  const xOnlyPubKey = await identity.xOnlyPublicKey();
21298
21542
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
21299
- const toSpend = chunk5MLC2HU3_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21543
+ const toSpend = chunk5J5PDZRR_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21300
21544
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
21301
21545
  const signed = await identity.sign(toSign, [0]);
21302
21546
  signed.finalizeIdx(0);
@@ -21354,7 +21598,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
21354
21598
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
21355
21599
  return false;
21356
21600
  }
21357
- const toSpend = chunk5MLC2HU3_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21601
+ const toSpend = chunk5J5PDZRR_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21358
21602
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
21359
21603
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
21360
21604
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -21375,7 +21619,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
21375
21619
  }
21376
21620
  const sighashType = sigWithHash[sigWithHash.length - 1];
21377
21621
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
21378
- const toSpend = chunk5MLC2HU3_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21622
+ const toSpend = chunk5J5PDZRR_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21379
21623
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
21380
21624
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
21381
21625
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -21428,7 +21672,7 @@ function encodeCompactSize(n) {
21428
21672
  return buf;
21429
21673
  }
21430
21674
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21431
- const tx = new chunk5MLC2HU3_cjs.Transaction({ version: 0 });
21675
+ const tx = new chunk5J5PDZRR_cjs.Transaction({ version: 0 });
21432
21676
  tx.addInput({
21433
21677
  txid: toSpend.id,
21434
21678
  index: 0,
@@ -21442,12 +21686,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21442
21686
  });
21443
21687
  tx.addOutput({
21444
21688
  amount: 0n,
21445
- script: chunk5MLC2HU3_cjs.OP_RETURN_EMPTY_PKSCRIPT
21689
+ script: chunk5J5PDZRR_cjs.OP_RETURN_EMPTY_PKSCRIPT
21446
21690
  });
21447
21691
  return tx;
21448
21692
  }
21449
21693
  function craftBIP322ToSignSimple(toSpend, pkScript) {
21450
- const tx = new chunk5MLC2HU3_cjs.Transaction({ version: 0 });
21694
+ const tx = new chunk5J5PDZRR_cjs.Transaction({ version: 0 });
21451
21695
  tx.addInput({
21452
21696
  txid: toSpend.id,
21453
21697
  index: 0,
@@ -21459,7 +21703,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
21459
21703
  });
21460
21704
  tx.addOutput({
21461
21705
  amount: 0n,
21462
- script: chunk5MLC2HU3_cjs.OP_RETURN_EMPTY_PKSCRIPT
21706
+ script: chunk5J5PDZRR_cjs.OP_RETURN_EMPTY_PKSCRIPT
21463
21707
  });
21464
21708
  return tx;
21465
21709
  }
@@ -21590,7 +21834,7 @@ var RestEmulatorProvider = class {
21590
21834
  }
21591
21835
  };
21592
21836
  function finalizeVirtualTx(type, psbtBase64) {
21593
- const tx = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
21837
+ const tx = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
21594
21838
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
21595
21839
  const input = tx.getInput(0);
21596
21840
  if (!input) {
@@ -21617,14 +21861,14 @@ var ExitPathError = class extends Error {
21617
21861
  reason;
21618
21862
  };
21619
21863
  function delayWeight(sequence) {
21620
- const t = chunk5MLC2HU3_cjs.sequenceToTimelock(sequence);
21864
+ const t = chunk5J5PDZRR_cjs.sequenceToTimelock(sequence);
21621
21865
  return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
21622
21866
  }
21623
21867
  async function resolveUnilateralPath(params) {
21624
21868
  const { vtxo, scriptHex, contractRepository } = params;
21625
21869
  const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
21626
21870
  if (contract) {
21627
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type);
21871
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(contract.type);
21628
21872
  if (!handler) {
21629
21873
  throw new ExitPathError(
21630
21874
  "no-handler",
@@ -21647,12 +21891,12 @@ async function resolveUnilateralPath(params) {
21647
21891
  paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
21648
21892
  return { selection: paths[0], label: `${contract.type}:unilateral` };
21649
21893
  }
21650
- const decoded = chunk5MLC2HU3_cjs.VtxoScript.decode(vtxo.tapTree);
21894
+ const decoded = chunk5J5PDZRR_cjs.VtxoScript.decode(vtxo.tapTree);
21651
21895
  let best;
21652
21896
  for (const exit of decoded.exitPaths()) {
21653
21897
  const leaf = decoded.findLeaf(base.hex.encode(exit.script));
21654
21898
  if (!leaf) continue;
21655
- const sequence = chunk5MLC2HU3_cjs.timelockToSequence(exit.params.timelock);
21899
+ const sequence = chunk5J5PDZRR_cjs.timelockToSequence(exit.params.timelock);
21656
21900
  const weight = delayWeight(sequence);
21657
21901
  if (!best || weight < best.weight) {
21658
21902
  best = { selection: { leaf, sequence }, weight };
@@ -21872,7 +22116,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21872
22116
  let totalAmount = 0n;
21873
22117
  const txWeightEstimator = TxWeightEstimator.create();
21874
22118
  for (const vtxo of vtxos) {
21875
- if (!chunk5MLC2HU3_cjs.canSweepOnchain(vtxo)) {
22119
+ if (!chunk5J5PDZRR_cjs.canSweepOnchain(vtxo)) {
21876
22120
  throw new Error(
21877
22121
  `Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
21878
22122
  );
@@ -21883,14 +22127,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21883
22127
  }
21884
22128
  const resolved = await resolveUnilateralPath({
21885
22129
  vtxo,
21886
- scriptHex: base.hex.encode(chunk5MLC2HU3_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22130
+ scriptHex: base.hex.encode(chunk5J5PDZRR_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
21887
22131
  contractRepository: wallet.contractRepository,
21888
22132
  walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
21889
22133
  currentTime: Date.now()
21890
22134
  });
21891
22135
  const spendingLeaf = resolved.selection.leaf;
21892
22136
  const sequence = resolved.selection.sequence;
21893
- const timelock = chunk5MLC2HU3_cjs.sequenceToTimelock(sequence);
22137
+ const timelock = chunk5J5PDZRR_cjs.sequenceToTimelock(sequence);
21894
22138
  const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
21895
22139
  if (!elapsed) {
21896
22140
  throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
@@ -21903,7 +22147,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21903
22147
  sequence,
21904
22148
  witnessUtxo: {
21905
22149
  amount: BigInt(vtxo.value),
21906
- script: chunk5MLC2HU3_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22150
+ script: chunk5J5PDZRR_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
21907
22151
  },
21908
22152
  sighashType: btcSigner.SigHash.DEFAULT
21909
22153
  });
@@ -21913,7 +22157,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
21913
22157
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
21914
22158
  );
21915
22159
  }
21916
- const tx = new chunk5MLC2HU3_cjs.Transaction({ version: 2 });
22160
+ const tx = new chunk5J5PDZRR_cjs.Transaction({ version: 2 });
21917
22161
  for (const input of inputs) {
21918
22162
  tx.addInput(input);
21919
22163
  }
@@ -21996,7 +22240,7 @@ async function buildSignedSweep(params) {
21996
22240
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
21997
22241
  );
21998
22242
  }
21999
- const tx = new chunk5MLC2HU3_cjs.Transaction({ version: 2 });
22243
+ const tx = new chunk5J5PDZRR_cjs.Transaction({ version: 2 });
22000
22244
  tx.addInput({
22001
22245
  txid: vtxo.txid,
22002
22246
  index: vtxo.vout,
@@ -22021,7 +22265,7 @@ async function buildSignedSweep(params) {
22021
22265
  finalScriptWitness: [
22022
22266
  tapScriptSig[0][1],
22023
22267
  ...path.extraWitness,
22024
- chunk5MLC2HU3_cjs.scriptFromTapLeafScript(path.leaf),
22268
+ chunk5J5PDZRR_cjs.scriptFromTapLeafScript(path.leaf),
22025
22269
  btcSigner.TaprootControlBlock.encode(controlBlock)
22026
22270
  ]
22027
22271
  });
@@ -22051,7 +22295,7 @@ async function resolveFeeRate(opts) {
22051
22295
  }
22052
22296
  async function selectExitVtxos(opts) {
22053
22297
  if (!opts.vtxos) return opts.wallet.getVtxos();
22054
- const res = await chunk5MLC2HU3_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22298
+ const res = await chunk5J5PDZRR_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22055
22299
  const tapTrees = /* @__PURE__ */ new Map();
22056
22300
  const out = [];
22057
22301
  for (const vtxo of res.vtxos) {
@@ -22066,7 +22310,7 @@ async function selectExitVtxos(opts) {
22066
22310
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
22067
22311
  );
22068
22312
  }
22069
- const handler = chunkWIFL5QYZ_cjs.contractHandlers.get(contract.type);
22313
+ const handler = chunkP6EXRY5L_cjs.contractHandlers.get(contract.type);
22070
22314
  if (!handler) {
22071
22315
  throw new Error(`no contract handler registered for type '${contract.type}'`);
22072
22316
  }
@@ -22096,7 +22340,7 @@ async function computeExitLayout(opts, feeRate) {
22096
22340
  if (pendingNodes.length > 0) {
22097
22341
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
22098
22342
  for (const psbt of txs) {
22099
- psbts.set(chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22343
+ psbts.set(chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22100
22344
  }
22101
22345
  }
22102
22346
  const childVsize = Number(
@@ -22132,7 +22376,7 @@ async function computeExitLayout(opts, feeRate) {
22132
22376
  try {
22133
22377
  const resolved = await resolveUnilateralPath({
22134
22378
  vtxo,
22135
- scriptHex: base.hex.encode(chunk5MLC2HU3_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22379
+ scriptHex: base.hex.encode(chunk5J5PDZRR_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22136
22380
  contractRepository: wallet.contractRepository,
22137
22381
  walletPubKeyHex,
22138
22382
  currentTime: Date.now()
@@ -22151,7 +22395,7 @@ async function computeExitLayout(opts, feeRate) {
22151
22395
  });
22152
22396
  continue;
22153
22397
  }
22154
- const t = chunk5MLC2HU3_cjs.sequenceToTimelock(resolved.selection.sequence);
22398
+ const t = chunk5J5PDZRR_cjs.sequenceToTimelock(resolved.selection.sequence);
22155
22399
  const delay = { type: t.type, value: Number(t.value) };
22156
22400
  infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
22157
22401
  sweeps.push({ vtxo, resolved, sweepFee, delay });
@@ -22552,7 +22796,7 @@ async function prepare(opts) {
22552
22796
  txid: sweep.vtxo.txid,
22553
22797
  vout: sweep.vtxo.vout,
22554
22798
  value: sweep.vtxo.value,
22555
- pkScript: chunk5MLC2HU3_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
22799
+ pkScript: chunk5J5PDZRR_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
22556
22800
  },
22557
22801
  path: sweep.resolved.selection,
22558
22802
  outputAddress: opts.sweepAddress,
@@ -22640,7 +22884,7 @@ async function prepare(opts) {
22640
22884
  if (newFee <= splitterFee) break;
22641
22885
  splitterFee = newFee;
22642
22886
  }
22643
- const splitter = new chunk5MLC2HU3_cjs.Transaction({ version: 2 });
22887
+ const splitter = new chunk5J5PDZRR_cjs.Transaction({ version: 2 });
22644
22888
  for (const coin of selected.inputs) {
22645
22889
  splitter.addInput({
22646
22890
  txid: coin.txid,
@@ -22784,41 +23028,41 @@ var UnilateralExit = {
22784
23028
  // src/arkade/index.ts
22785
23029
  var arkade_exports = {};
22786
23030
  chunk5BLDMQED_cjs.__export(arkade_exports, {
22787
- ARKADE_OP: () => chunkWIFL5QYZ_cjs.ARKADE_OP,
22788
- ARKADE_OPCODES: () => chunkWIFL5QYZ_cjs.ARKADE_OPCODES,
22789
- ARKADE_OPCODE_NAMES: () => chunkWIFL5QYZ_cjs.ARKADE_OPCODE_NAMES,
22790
- ARKADE_OPCODE_VALUES: () => chunkWIFL5QYZ_cjs.ARKADE_OPCODE_VALUES,
22791
- ARKADE_OPS: () => chunkWIFL5QYZ_cjs.ARKADE_OPS,
23031
+ ARKADE_OP: () => chunkP6EXRY5L_cjs.ARKADE_OP,
23032
+ ARKADE_OPCODES: () => chunkP6EXRY5L_cjs.ARKADE_OPCODES,
23033
+ ARKADE_OPCODE_NAMES: () => chunkP6EXRY5L_cjs.ARKADE_OPCODE_NAMES,
23034
+ ARKADE_OPCODE_VALUES: () => chunkP6EXRY5L_cjs.ARKADE_OPCODE_VALUES,
23035
+ ARKADE_OPS: () => chunkP6EXRY5L_cjs.ARKADE_OPS,
22792
23036
  Arkade: () => Arkade,
22793
23037
  ArkadeContract: () => ArkadeContract,
22794
- ArkadeProgramScript: () => chunkWIFL5QYZ_cjs.ArkadeProgramScript,
22795
- ArkadeScript: () => chunkWIFL5QYZ_cjs.ArkadeScript,
23038
+ ArkadeProgramScript: () => chunkP6EXRY5L_cjs.ArkadeProgramScript,
23039
+ ArkadeScript: () => chunkP6EXRY5L_cjs.ArkadeScript,
22796
23040
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
22797
- BigNum: () => chunkWIFL5QYZ_cjs.bignum_exports,
23041
+ BigNum: () => chunkP6EXRY5L_cjs.bignum_exports,
22798
23042
  OP: () => btcSigner.OP,
22799
- OPCODE_NAMES: () => chunkWIFL5QYZ_cjs.OPCODE_NAMES,
22800
- OPCODE_VALUES: () => chunkWIFL5QYZ_cjs.OPCODE_VALUES,
22801
- SUPPORTED_PROGRAM_VERSION: () => chunkWIFL5QYZ_cjs.SUPPORTED_PROGRAM_VERSION,
23043
+ OPCODE_NAMES: () => chunkP6EXRY5L_cjs.OPCODE_NAMES,
23044
+ OPCODE_VALUES: () => chunkP6EXRY5L_cjs.OPCODE_VALUES,
23045
+ SUPPORTED_PROGRAM_VERSION: () => chunkP6EXRY5L_cjs.SUPPORTED_PROGRAM_VERSION,
22802
23046
  Script: () => btcSigner.Script,
22803
- arkadeScriptHash: () => chunkWIFL5QYZ_cjs.arkadeScriptHash,
22804
- arkadeWitnessHash: () => chunkWIFL5QYZ_cjs.arkadeWitnessHash,
22805
- asmToBytes: () => chunkWIFL5QYZ_cjs.asmToBytes,
22806
- bytesToASM: () => chunkWIFL5QYZ_cjs.bytesToASM,
22807
- computeArkadeScriptPublicKey: () => chunkWIFL5QYZ_cjs.computeArkadeScriptPublicKey,
23047
+ arkadeScriptHash: () => chunkP6EXRY5L_cjs.arkadeScriptHash,
23048
+ arkadeWitnessHash: () => chunkP6EXRY5L_cjs.arkadeWitnessHash,
23049
+ asmToBytes: () => chunkP6EXRY5L_cjs.asmToBytes,
23050
+ bytesToASM: () => chunkP6EXRY5L_cjs.bytesToASM,
23051
+ computeArkadeScriptPublicKey: () => chunkP6EXRY5L_cjs.computeArkadeScriptPublicKey,
22808
23052
  createArkadeBatchHandler: () => createArkadeBatchHandler,
22809
- deserializeArkadeContractParams: () => chunkWIFL5QYZ_cjs.deserializeArkadeContractParams,
22810
- fromASM: () => chunkWIFL5QYZ_cjs.fromASM,
22811
- getOpcodeName: () => chunkWIFL5QYZ_cjs.getOpcodeName,
22812
- getOpcodeValue: () => chunkWIFL5QYZ_cjs.getOpcodeValue,
22813
- parseArtifact: () => chunkWIFL5QYZ_cjs.parseArtifact,
22814
- resolveAsm: () => chunkWIFL5QYZ_cjs.resolveAsm,
22815
- serializeArkadeContractParams: () => chunkWIFL5QYZ_cjs.serializeArkadeContractParams,
22816
- stringifyArtifact: () => chunkWIFL5QYZ_cjs.stringifyArtifact,
22817
- toASM: () => chunkWIFL5QYZ_cjs.toASM,
22818
- validateProgram: () => chunkWIFL5QYZ_cjs.validateProgram,
22819
- witnessRefToBytes: () => chunkWIFL5QYZ_cjs.witnessRefToBytes
23053
+ deserializeArkadeContractParams: () => chunkP6EXRY5L_cjs.deserializeArkadeContractParams,
23054
+ fromASM: () => chunkP6EXRY5L_cjs.fromASM,
23055
+ getOpcodeName: () => chunkP6EXRY5L_cjs.getOpcodeName,
23056
+ getOpcodeValue: () => chunkP6EXRY5L_cjs.getOpcodeValue,
23057
+ parseArtifact: () => chunkP6EXRY5L_cjs.parseArtifact,
23058
+ resolveAsm: () => chunkP6EXRY5L_cjs.resolveAsm,
23059
+ serializeArkadeContractParams: () => chunkP6EXRY5L_cjs.serializeArkadeContractParams,
23060
+ stringifyArtifact: () => chunkP6EXRY5L_cjs.stringifyArtifact,
23061
+ toASM: () => chunkP6EXRY5L_cjs.toASM,
23062
+ validateProgram: () => chunkP6EXRY5L_cjs.validateProgram,
23063
+ witnessRefToBytes: () => chunkP6EXRY5L_cjs.witnessRefToBytes
22820
23064
  });
22821
- var isVtxoCoin = (input) => chunk5MLC2HU3_cjs.isVirtualCoin(input);
23065
+ var isVtxoCoin = (input) => chunk5J5PDZRR_cjs.isVirtualCoin(input);
22822
23066
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
22823
23067
  let batchId;
22824
23068
  let sweepTapTreeRoot;
@@ -22839,23 +23083,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22839
23083
  );
22840
23084
  await arkProvider.confirmRegistration(intentId);
22841
23085
  batchId = event.id;
22842
- const sweepTapscript = chunk5MLC2HU3_cjs.CSVMultisigTapscript.encode({
23086
+ const sweepTapscript = chunk5J5PDZRR_cjs.CSVMultisigTapscript.encode({
22843
23087
  timelock,
22844
- pubkeys: [chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23088
+ pubkeys: [chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
22845
23089
  }).script;
22846
23090
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
22847
23091
  return { skip: false };
22848
23092
  },
22849
23093
  onTreeSigningStarted: async (event, vtxoTree) => {
22850
23094
  const signerPubKey = await session.getPublicKey();
22851
- const xonlySignerPubKey = chunkWIFL5QYZ_cjs.toXOnly(signerPubKey, "signer key");
23095
+ const xonlySignerPubKey = chunkP6EXRY5L_cjs.toXOnly(signerPubKey, "signer key");
22852
23096
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
22853
- (k) => base.hex.encode(chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23097
+ (k) => base.hex.encode(chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
22854
23098
  );
22855
23099
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
22856
23100
  return { skip: true };
22857
23101
  }
22858
- const commitmentTx = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23102
+ const commitmentTx = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
22859
23103
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
22860
23104
  if (recipients && recipients.length > 0) {
22861
23105
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -22887,7 +23131,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22887
23131
  if (connectorTree) {
22888
23132
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
22889
23133
  }
22890
- let commitmentPsbt = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23134
+ let commitmentPsbt = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
22891
23135
  assertFinalCommitmentMatchesValidated(
22892
23136
  commitmentPsbt,
22893
23137
  validatedCommitmentTxid,
@@ -22922,7 +23166,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22922
23166
  boardingIndices.push(boardingIdx);
22923
23167
  continue;
22924
23168
  }
22925
- if (chunk5MLC2HU3_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
23169
+ if (chunk5J5PDZRR_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
22926
23170
  continue;
22927
23171
  }
22928
23172
  if (connectorIndex >= connectorLeaves.length) {
@@ -22943,7 +23187,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22943
23187
  index: input.vout,
22944
23188
  witnessUtxo: {
22945
23189
  amount: BigInt(input.value),
22946
- script: chunk5MLC2HU3_cjs.VtxoScript.decode(input.tapTree).pkScript
23190
+ script: chunk5J5PDZRR_cjs.VtxoScript.decode(input.tapTree).pkScript
22947
23191
  },
22948
23192
  sighashType: btcSigner.SigHash.DEFAULT,
22949
23193
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -23034,16 +23278,16 @@ var Arkade = class _Arkade {
23034
23278
  /** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
23035
23279
  static async connect(opts) {
23036
23280
  const info = await opts.arkade.getInfo();
23037
- const serverKey = chunkWIFL5QYZ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
23038
- const checkpoint = chunk5MLC2HU3_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
23039
- const network = opts.network ?? chunk5MLC2HU3_cjs.DEFAULT_NETWORK;
23281
+ const serverKey = chunkP6EXRY5L_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
23282
+ const checkpoint = chunk5J5PDZRR_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
23283
+ const network = opts.network ?? chunk5J5PDZRR_cjs.DEFAULT_NETWORK;
23040
23284
  let emulatorKey;
23041
23285
  if (opts.emulator) {
23042
- emulatorKey = base.hex.decode(chunk5MLC2HU3_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23286
+ emulatorKey = base.hex.decode(chunk5J5PDZRR_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23043
23287
  }
23044
23288
  let userKey;
23045
23289
  if (opts.identity) {
23046
- userKey = chunkWIFL5QYZ_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23290
+ userKey = chunkP6EXRY5L_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23047
23291
  }
23048
23292
  return new _Arkade({
23049
23293
  arkProvider: opts.arkade,
@@ -23069,7 +23313,7 @@ var Arkade = class _Arkade {
23069
23313
  * key respectively; explicit args always win.
23070
23314
  */
23071
23315
  contract(program, args = {}) {
23072
- const declared = (program.params ?? []).map(chunkWIFL5QYZ_cjs.inputName);
23316
+ const declared = (program.params ?? []).map(chunkP6EXRY5L_cjs.inputName);
23073
23317
  if (declared.includes("server") && args.server === void 0) {
23074
23318
  args = { ...args, server: this.serverKey };
23075
23319
  }
@@ -23089,7 +23333,7 @@ var ArkadeContract = class _ArkadeContract {
23089
23333
  userKey: client.userKey,
23090
23334
  emulatorKey: client.emulatorKey
23091
23335
  };
23092
- this.vtxoScript = new chunkWIFL5QYZ_cjs.ArkadeProgramScript(program, args, this.keys);
23336
+ this.vtxoScript = new chunkP6EXRY5L_cjs.ArkadeProgramScript(program, args, this.keys);
23093
23337
  this.tapTree = this.vtxoScript.encode();
23094
23338
  this.compiled = this.vtxoScript.compiled;
23095
23339
  }
@@ -23117,7 +23361,7 @@ var ArkadeContract = class _ArkadeContract {
23117
23361
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
23118
23362
  );
23119
23363
  }
23120
- const typed = chunkWIFL5QYZ_cjs.deserializeArkadeContractParams(contract.params);
23364
+ const typed = chunkP6EXRY5L_cjs.deserializeArkadeContractParams(contract.params);
23121
23365
  return new _ArkadeContract(client, typed.program, typed.args, {
23122
23366
  serverKey: typed.serverKey,
23123
23367
  userKey: typed.userKey,
@@ -23158,7 +23402,7 @@ var ArkadeContract = class _ArkadeContract {
23158
23402
  toContractParams() {
23159
23403
  return {
23160
23404
  type: "arkade",
23161
- params: chunkWIFL5QYZ_cjs.serializeArkadeContractParams({
23405
+ params: chunkP6EXRY5L_cjs.serializeArkadeContractParams({
23162
23406
  program: this.program,
23163
23407
  args: this.args,
23164
23408
  serverKey: this.keys.serverKey,
@@ -23208,18 +23452,18 @@ var ArkadeContract = class _ArkadeContract {
23208
23452
  if (registered) {
23209
23453
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
23210
23454
  return (withVtxos?.vtxos ?? []).filter(
23211
- (v) => !chunk5MLC2HU3_cjs.hasTerminalSpend(v) && !v.isUnrolled
23455
+ (v) => !chunk5J5PDZRR_cjs.hasTerminalSpend(v) && !v.isUnrolled
23212
23456
  );
23213
23457
  }
23214
23458
  }
23215
23459
  if (!this.client.indexer) {
23216
23460
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
23217
23461
  }
23218
- const { vtxos } = await chunk5MLC2HU3_cjs.getNormalizedVtxos(this.client.indexer, {
23462
+ const { vtxos } = await chunk5J5PDZRR_cjs.getNormalizedVtxos(this.client.indexer, {
23219
23463
  scripts: [scriptHex],
23220
23464
  spendableOnly: true
23221
23465
  });
23222
- return vtxos.filter((v) => !chunk5MLC2HU3_cjs.hasTerminalSpend(v) && !v.isUnrolled);
23466
+ return vtxos.filter((v) => !chunk5J5PDZRR_cjs.hasTerminalSpend(v) && !v.isUnrolled);
23223
23467
  }
23224
23468
  /** Total spendable balance (requires an indexer). */
23225
23469
  async getBalance() {
@@ -23317,7 +23561,7 @@ var ArkadeTransactionBuilder = class {
23317
23561
  this.contract.client.checkpoint
23318
23562
  );
23319
23563
  if (coin.sourceTx) {
23320
- chunk5MLC2HU3_cjs.setArkPsbtField(arkTx, 0, chunk5MLC2HU3_cjs.PrevArkTxField, coin.sourceTx);
23564
+ chunk5J5PDZRR_cjs.setArkPsbtField(arkTx, 0, chunk5J5PDZRR_cjs.PrevArkTxField, coin.sourceTx);
23321
23565
  }
23322
23566
  if (this.fn.arkadeScript) {
23323
23567
  const indexer = this.contract.client.indexer;
@@ -23334,8 +23578,8 @@ var ArkadeTransactionBuilder = class {
23334
23578
  }
23335
23579
  const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
23336
23580
  if (condition.length > 0) {
23337
- chunk5MLC2HU3_cjs.setArkPsbtField(arkTx, 0, chunk5MLC2HU3_cjs.ConditionWitness, condition);
23338
- chunk5MLC2HU3_cjs.setArkPsbtField(checkpoints[0], 0, chunk5MLC2HU3_cjs.ConditionWitness, condition);
23581
+ chunk5J5PDZRR_cjs.setArkPsbtField(arkTx, 0, chunk5J5PDZRR_cjs.ConditionWitness, condition);
23582
+ chunk5J5PDZRR_cjs.setArkPsbtField(checkpoints[0], 0, chunk5J5PDZRR_cjs.ConditionWitness, condition);
23339
23583
  }
23340
23584
  const packets = [];
23341
23585
  if (this.assetSpecs.length > 0) {
@@ -23374,7 +23618,7 @@ var ArkadeTransactionBuilder = class {
23374
23618
  base.base64.encode(signedArk2.toPSBT()),
23375
23619
  signedCps.map((c) => base.base64.encode(c.toPSBT()))
23376
23620
  );
23377
- const txid = chunk5MLC2HU3_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23621
+ const txid = chunk5J5PDZRR_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23378
23622
  return {
23379
23623
  txid,
23380
23624
  signedArkTx: res2.signedArkTx,
@@ -23433,23 +23677,23 @@ var ArkadeTransactionBuilder = class {
23433
23677
  }
23434
23678
  buildAssetPacket() {
23435
23679
  const groups = this.assetSpecs.map((s) => {
23436
- const id = typeof s.assetId === "string" ? chunkGVHUHTRH_cjs.AssetId.fromString(s.assetId) : chunkGVHUHTRH_cjs.AssetId.fromBytes(s.assetId);
23437
- return chunkGVHUHTRH_cjs.AssetGroup.create(
23680
+ const id = typeof s.assetId === "string" ? chunkFM263GKH_cjs.AssetId.fromString(s.assetId) : chunkFM263GKH_cjs.AssetId.fromBytes(s.assetId);
23681
+ return chunkFM263GKH_cjs.AssetGroup.create(
23438
23682
  id,
23439
23683
  null,
23440
- s.inputs.map((i) => chunkGVHUHTRH_cjs.AssetInput.create(i.vin, i.amount)),
23441
- s.outputs.map((o) => chunkGVHUHTRH_cjs.AssetOutput.create(o.vout, o.amount)),
23442
- (s.metadata ?? []).map((m) => chunkGVHUHTRH_cjs.Metadata.create(m.key, m.value))
23684
+ s.inputs.map((i) => chunkFM263GKH_cjs.AssetInput.create(i.vin, i.amount)),
23685
+ s.outputs.map((o) => chunkFM263GKH_cjs.AssetOutput.create(o.vout, o.amount)),
23686
+ (s.metadata ?? []).map((m) => chunkFM263GKH_cjs.Metadata.create(m.key, m.value))
23443
23687
  );
23444
23688
  });
23445
- return chunkGVHUHTRH_cjs.Packet.create(groups);
23689
+ return chunkFM263GKH_cjs.Packet.create(groups);
23446
23690
  }
23447
23691
  witnessBytes(ref) {
23448
- return chunkWIFL5QYZ_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
23692
+ return chunkP6EXRY5L_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
23449
23693
  }
23450
23694
  };
23451
23695
  function bindInputs(fn, callArgs) {
23452
- const names = (fn.def.inputs ?? []).map(chunkWIFL5QYZ_cjs.inputName);
23696
+ const names = (fn.def.inputs ?? []).map(chunkP6EXRY5L_cjs.inputName);
23453
23697
  if (callArgs.length !== names.length) {
23454
23698
  throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
23455
23699
  }
@@ -23642,6 +23886,33 @@ function tryResolveSendAmount(raw, amount) {
23642
23886
  const amt = amount ?? BIP21.amountSats(raw);
23643
23887
  return amt !== void 0 && Number.isInteger(amt) && amt > 0 ? amt : void 0;
23644
23888
  }
23889
+ function assetsOf(req) {
23890
+ return req.assets ?? [];
23891
+ }
23892
+ function assertNoAssets(railId, req) {
23893
+ const assets = assetsOf(req);
23894
+ if (assets.length > 0) {
23895
+ throw new Error(
23896
+ `${railId}: cannot deliver ${assets.map((a) => a.assetId).join(", ")} \u2014 this rail moves BTC only`
23897
+ );
23898
+ }
23899
+ }
23900
+ function resolveAssetAmount(railId, req) {
23901
+ const assets = assetsOf(req);
23902
+ if (assets.length !== 1) {
23903
+ throw new Error(`${railId}: expected exactly one asset to pay, got ${assets.length}`);
23904
+ }
23905
+ const [asset] = assets;
23906
+ if (typeof asset.amount !== "bigint" || asset.amount <= 0n) {
23907
+ throw new Error(
23908
+ `${railId}: invalid amount ${String(asset.amount)} of ${asset.assetId} (expected a positive bigint of atomic units)`
23909
+ );
23910
+ }
23911
+ if (typeof asset.assetId !== "string" || asset.assetId.length === 0) {
23912
+ throw new Error(`${railId}: an asset amount must name an asset`);
23913
+ }
23914
+ return asset;
23915
+ }
23645
23916
 
23646
23917
  // src/payment/handle.ts
23647
23918
  function makeHandle(id, run) {
@@ -23764,8 +24035,10 @@ function arkRail() {
23764
24035
  return {
23765
24036
  id: "ark",
23766
24037
  match: (req) => arkTarget(req.raw) !== void 0,
24038
+ available: (req) => assetsOf(req).length === 0,
23767
24039
  quote: async (req, ctx) => {
23768
24040
  const address = arkTarget(req.raw);
24041
+ assertNoAssets("ark", req);
23769
24042
  const amt = resolveSendAmount("ark", req.raw, req.amount);
23770
24043
  return {
23771
24044
  railId: "ark",
@@ -23782,6 +24055,41 @@ function arkRail() {
23782
24055
  }
23783
24056
  };
23784
24057
  }
24058
+
24059
+ // src/payment/rails/arkAsset.ts
24060
+ var ASSET_CARRIER_SATS = 330;
24061
+ function arkAssetRail() {
24062
+ return {
24063
+ id: "ark-asset",
24064
+ match: (req) => arkTarget(req.raw) !== void 0,
24065
+ // A malformed asset is `quote()`'s to name, not this rail's to drop.
24066
+ available: (req) => assetsOf(req).length > 0,
24067
+ quote: async (req, ctx) => {
24068
+ const address = arkTarget(req.raw);
24069
+ const asset = resolveAssetAmount("ark-asset", req);
24070
+ if (req.amount !== void 0) assertSendableAmount("ark-asset", req.amount);
24071
+ const carrier = tryResolveSendAmount(req.raw, req.amount) ?? ASSET_CARRIER_SATS;
24072
+ return {
24073
+ railId: "ark-asset",
24074
+ amount: carrier,
24075
+ fee: 0,
24076
+ total: carrier,
24077
+ assets: { delivered: asset, spent: asset },
24078
+ send: async () => makeHandle("ark-asset", async (emit) => {
24079
+ const txid = await ctx.wallet.send({
24080
+ address,
24081
+ amount: carrier,
24082
+ assets: [asset]
24083
+ });
24084
+ const result = { railId: "ark-asset", txid };
24085
+ emit({ status: "settled", result });
24086
+ return result;
24087
+ })
24088
+ };
24089
+ }
24090
+ };
24091
+ }
24092
+ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo()).fees;
23785
24093
  var GROSS_UP_MAX_ROUNDS = 8;
23786
24094
  function grossUpOffboard(net, feeInfo, script) {
23787
24095
  const estimator = new Estimator(feeInfo?.intentFee ?? {});
@@ -23794,14 +24102,20 @@ function grossUpOffboard(net, feeInfo, script) {
23794
24102
  }
23795
24103
  return { gross, fee: gross - net };
23796
24104
  }
23797
- function onchainRail() {
24105
+ function onchainRail(deps) {
24106
+ if (typeof deps?.feeInfo !== "function") {
24107
+ throw new Error("onchain rail: a feeInfo source is required");
24108
+ }
23798
24109
  return {
23799
24110
  id: "onchain",
23800
24111
  match: (req) => btcTarget(req.raw) !== void 0,
24112
+ // BTC only: an Arkade asset has no L1 representation to offboard to.
24113
+ available: (req) => assetsOf(req).length === 0,
23801
24114
  quote: async (req, ctx) => {
24115
+ assertNoAssets("onchain", req);
23802
24116
  const address = btcTarget(req.raw);
23803
24117
  const amt = resolveSendAmount("onchain", req.raw, req.amount);
23804
- const { fees } = await ctx.wallet.arkProvider.getInfo();
24118
+ const fees = await deps.feeInfo();
23805
24119
  const script = base.hex.encode(offboardDestinationScript(address));
23806
24120
  const { gross, fee } = grossUpOffboard(amt, fees, script);
23807
24121
  return {
@@ -23828,8 +24142,8 @@ function onchainRail() {
23828
24142
  function createDefaultPaymentRouter(wallet) {
23829
24143
  return new PaymentRouter({
23830
24144
  wallet,
23831
- prefs: { priority: ["ark", "lightning", "onchain"] }
23832
- }).use(arkRail()).use(onchainRail());
24145
+ prefs: { priority: ["ark", "ark-asset", "lightning", "onchain"] }
24146
+ }).use(arkRail()).use(arkAssetRail()).use(onchainRail({ feeInfo: walletFeeSource(wallet) }));
23833
24147
  }
23834
24148
  /*! Bundled license information:
23835
24149
 
@@ -23840,6 +24154,7 @@ function createDefaultPaymentRouter(wallet) {
23840
24154
  exports.ARKADE_MAGIC = ARKADE_MAGIC;
23841
24155
  exports.ARKADE_SALTED_PREIMAGE_TAG = ARKADE_SALTED_PREIMAGE_TAG;
23842
24156
  exports.ARKADE_SWAP_PREIMAGE_TAG = ARKADE_SWAP_PREIMAGE_TAG;
24157
+ exports.ASSET_CARRIER_SATS = ASSET_CARRIER_SATS;
23843
24158
  exports.AbortError = AbortError;
23844
24159
  exports.ActivityRegistry = ActivityRegistry;
23845
24160
  exports.AmbiguousRouteError = AmbiguousRouteError;
@@ -23934,16 +24249,19 @@ exports.WalletNotInitializedError = WalletNotInitializedError;
23934
24249
  exports.WalletRepositoryImpl = WalletRepositoryImpl;
23935
24250
  exports.WsElectrumChainSource = WsElectrumChainSource;
23936
24251
  exports.adoptContractDescriptor = adoptContractDescriptor;
24252
+ exports.arkAssetRail = arkAssetRail;
23937
24253
  exports.arkRail = arkRail;
23938
24254
  exports.arkTarget = arkTarget;
23939
24255
  exports.arkade_exports = arkade_exports;
23940
24256
  exports.assertFinalCommitmentMatchesValidated = assertFinalCommitmentMatchesValidated;
23941
24257
  exports.assertIntentIdUnique = assertIntentIdUnique;
24258
+ exports.assertNoAssets = assertNoAssets;
23942
24259
  exports.assertSendableAmount = assertSendableAmount;
23943
24260
  exports.assertSubmittedArkTxid = assertSubmittedArkTxid;
23944
24261
  exports.assertValidBatchExpiry = assertValidBatchExpiry;
23945
24262
  exports.assertValidServerUnrollScript = assertValidServerUnrollScript;
23946
24263
  exports.assetMintResolver = assetMintResolver;
24264
+ exports.assetsOf = assetsOf;
23947
24265
  exports.attachPrevArkTxs = attachPrevArkTxs;
23948
24266
  exports.attachPrevoutTxs = attachPrevoutTxs;
23949
24267
  exports.awaitTransaction = awaitTransaction;
@@ -23995,6 +24313,7 @@ exports.isArkContract = isArkContract;
23995
24313
  exports.isBatchSignable = isBatchSignable;
23996
24314
  exports.isBtcAddress = isBtcAddress;
23997
24315
  exports.isContractGenericallySpendable = isContractGenericallySpendable;
24316
+ exports.isContractVtxoEvent = isContractVtxoEvent;
23998
24317
  exports.isCooperativelyMigratable = isCooperativelyMigratable;
23999
24318
  exports.isDeterministicSigner = isDeterministicSigner;
24000
24319
  exports.isDiscoverable = isDiscoverable;
@@ -24027,6 +24346,7 @@ exports.promisifyRequest = promisifyRequest;
24027
24346
  exports.provisionClaimSecret = provisionClaimSecret;
24028
24347
  exports.provisionRefundKey = provisionRefundKey;
24029
24348
  exports.requiresMigration = requiresMigration;
24349
+ exports.resolveAssetAmount = resolveAssetAmount;
24030
24350
  exports.resolveBatchExpiryPolicy = resolveBatchExpiryPolicy;
24031
24351
  exports.resolveCheckpointExitDelayPolicy = resolveCheckpointExitDelayPolicy;
24032
24352
  exports.resolveDescriptorSigner = resolveDescriptorSigner;
@@ -24053,7 +24373,8 @@ exports.validateConnectorsTxGraph = validateConnectorsTxGraph;
24053
24373
  exports.validateVtxoTxGraph = validateVtxoTxGraph;
24054
24374
  exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
24055
24375
  exports.waitForIncomingFunds = waitForIncomingFunds;
24376
+ exports.walletFeeSource = walletFeeSource;
24056
24377
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
24057
24378
  exports.withPrevTxs = withPrevTxs;
24058
- //# sourceMappingURL=chunk-EBYCTLET.cjs.map
24059
- //# sourceMappingURL=chunk-EBYCTLET.cjs.map
24379
+ //# sourceMappingURL=chunk-MK5EPTTB.cjs.map
24380
+ //# sourceMappingURL=chunk-MK5EPTTB.cjs.map