@arkade-os/sdk 0.5.11 → 0.5.12

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 (85) hide show
  1. package/dist/adapters/expo.cjs +7 -7
  2. package/dist/adapters/expo.d.cts +2 -2
  3. package/dist/adapters/expo.d.ts +2 -2
  4. package/dist/adapters/expo.js +4 -4
  5. package/dist/{asyncStorageTaskQueue-C0irgPwJ.d.ts → asyncStorageTaskQueue-Bsty8W7d.d.ts} +1 -1
  6. package/dist/{asyncStorageTaskQueue-B6rFkXzW.d.cts → asyncStorageTaskQueue-DTNS2qfN.d.cts} +1 -1
  7. package/dist/{chunk-DPFD5KBK.js → chunk-2YXVU5TK.js} +7 -5
  8. package/dist/chunk-2YXVU5TK.js.map +1 -0
  9. package/dist/{chunk-4DUTRRXF.js → chunk-3ABF4EMM.js} +3 -3
  10. package/dist/{chunk-4DUTRRXF.js.map → chunk-3ABF4EMM.js.map} +1 -1
  11. package/dist/{chunk-LKVVWCIW.js → chunk-3RO63OPW.js} +4 -4
  12. package/dist/{chunk-LKVVWCIW.js.map → chunk-3RO63OPW.js.map} +1 -1
  13. package/dist/{chunk-HRFWODLP.js → chunk-4OY5BCIE.js} +5 -5
  14. package/dist/{chunk-HRFWODLP.js.map → chunk-4OY5BCIE.js.map} +1 -1
  15. package/dist/{chunk-SS5BPVQL.js → chunk-4TMJBLJT.js} +11 -6
  16. package/dist/chunk-4TMJBLJT.js.map +1 -0
  17. package/dist/{chunk-5HCDXBBG.cjs → chunk-4X4SY3RH.cjs} +18 -13
  18. package/dist/chunk-4X4SY3RH.cjs.map +1 -0
  19. package/dist/{chunk-KRKREYKT.js → chunk-5NY5EOS2.js} +4 -4
  20. package/dist/{chunk-KRKREYKT.js.map → chunk-5NY5EOS2.js.map} +1 -1
  21. package/dist/{chunk-VJQMUKPZ.js → chunk-BA3GPO5C.js} +5 -5
  22. package/dist/{chunk-VJQMUKPZ.js.map → chunk-BA3GPO5C.js.map} +1 -1
  23. package/dist/{chunk-VLO3JAP3.cjs → chunk-C3NKBKRY.cjs} +52 -52
  24. package/dist/{chunk-VLO3JAP3.cjs.map → chunk-C3NKBKRY.cjs.map} +1 -1
  25. package/dist/{chunk-DMYHAUTA.cjs → chunk-CJUVKHK4.cjs} +705 -618
  26. package/dist/chunk-CJUVKHK4.cjs.map +1 -0
  27. package/dist/{chunk-WZ2UHHQ7.cjs → chunk-HNLC6F73.cjs} +20 -20
  28. package/dist/{chunk-WZ2UHHQ7.cjs.map → chunk-HNLC6F73.cjs.map} +1 -1
  29. package/dist/{chunk-UPIQZRNJ.cjs → chunk-JA4SYFC7.cjs} +11 -11
  30. package/dist/{chunk-UPIQZRNJ.cjs.map → chunk-JA4SYFC7.cjs.map} +1 -1
  31. package/dist/{chunk-OMZZQTDM.cjs → chunk-PHOJF7OK.cjs} +10 -10
  32. package/dist/{chunk-OMZZQTDM.cjs.map → chunk-PHOJF7OK.cjs.map} +1 -1
  33. package/dist/{chunk-NC6TEEHZ.cjs → chunk-QDX2HUBK.cjs} +11 -11
  34. package/dist/{chunk-NC6TEEHZ.cjs.map → chunk-QDX2HUBK.cjs.map} +1 -1
  35. package/dist/{chunk-GEK6QBSY.cjs → chunk-QV7AOZZN.cjs} +21 -21
  36. package/dist/{chunk-GEK6QBSY.cjs.map → chunk-QV7AOZZN.cjs.map} +1 -1
  37. package/dist/{chunk-PXEFYEKL.js → chunk-UXLETBNK.js} +4 -4
  38. package/dist/{chunk-PXEFYEKL.js.map → chunk-UXLETBNK.js.map} +1 -1
  39. package/dist/{chunk-W2C3KDQA.js → chunk-WBZYYRAB.js} +127 -40
  40. package/dist/chunk-WBZYYRAB.js.map +1 -0
  41. package/dist/{chunk-WIZCF5IX.cjs → chunk-YAVF2PR6.cjs} +7 -5
  42. package/dist/chunk-YAVF2PR6.cjs.map +1 -0
  43. package/dist/compiler.cjs +4 -4
  44. package/dist/compiler.js +3 -3
  45. package/dist/contracts/handlers/index.cjs +11 -11
  46. package/dist/contracts/handlers/index.d.cts +2 -2
  47. package/dist/contracts/handlers/index.d.ts +2 -2
  48. package/dist/contracts/handlers/index.js +4 -4
  49. package/dist/{index-Bq349_ly.d.cts → index-BBmZXXqk.d.cts} +1 -1
  50. package/dist/{index-Mn2POBPj.d.ts → index-DJ32LpfD.d.ts} +1 -1
  51. package/dist/{index-Yh5y9G4E.d.ts → index-D_zLtU-F.d.ts} +1 -1
  52. package/dist/{index-D4ahI0W6.d.cts → index-DenQfCn1.d.cts} +1 -1
  53. package/dist/index.cjs +350 -350
  54. package/dist/index.d.cts +7 -7
  55. package/dist/index.d.ts +7 -7
  56. package/dist/index.js +7 -7
  57. package/dist/repositories/realm/index.cjs +40 -40
  58. package/dist/repositories/realm/index.d.cts +2 -2
  59. package/dist/repositories/realm/index.d.ts +2 -2
  60. package/dist/repositories/realm/index.js +8 -8
  61. package/dist/repositories/sqlite/index.cjs +38 -38
  62. package/dist/repositories/sqlite/index.d.cts +2 -2
  63. package/dist/repositories/sqlite/index.d.ts +2 -2
  64. package/dist/repositories/sqlite/index.js +8 -8
  65. package/dist/{taskRunner-Z3LnHfgs.d.cts → taskRunner-BBGaN4cq.d.cts} +1 -1
  66. package/dist/{taskRunner-BYxEgwM5.d.ts → taskRunner-Cck24OnC.d.ts} +1 -1
  67. package/dist/wallet/expo/background.cjs +17 -17
  68. package/dist/wallet/expo/background.d.cts +3 -3
  69. package/dist/wallet/expo/background.d.ts +3 -3
  70. package/dist/wallet/expo/background.js +9 -9
  71. package/dist/wallet/expo/index.cjs +18 -18
  72. package/dist/wallet/expo/index.d.cts +2 -2
  73. package/dist/wallet/expo/index.d.ts +2 -2
  74. package/dist/wallet/expo/index.js +8 -8
  75. package/dist/worker/expo/index.cjs +12 -12
  76. package/dist/worker/expo/index.d.cts +4 -4
  77. package/dist/worker/expo/index.d.ts +4 -4
  78. package/dist/worker/expo/index.js +8 -8
  79. package/package.json +1 -1
  80. package/dist/chunk-5HCDXBBG.cjs.map +0 -1
  81. package/dist/chunk-DMYHAUTA.cjs.map +0 -1
  82. package/dist/chunk-DPFD5KBK.js.map +0 -1
  83. package/dist/chunk-SS5BPVQL.js.map +0 -1
  84. package/dist/chunk-W2C3KDQA.js.map +0 -1
  85. package/dist/chunk-WIZCF5IX.cjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkOMZZQTDM_cjs = require('./chunk-OMZZQTDM.cjs');
4
- var chunkGEK6QBSY_cjs = require('./chunk-GEK6QBSY.cjs');
5
- var chunkVLO3JAP3_cjs = require('./chunk-VLO3JAP3.cjs');
6
- var chunkUPIQZRNJ_cjs = require('./chunk-UPIQZRNJ.cjs');
7
- var chunk5HCDXBBG_cjs = require('./chunk-5HCDXBBG.cjs');
8
- var chunkWIZCF5IX_cjs = require('./chunk-WIZCF5IX.cjs');
3
+ var chunkPHOJF7OK_cjs = require('./chunk-PHOJF7OK.cjs');
4
+ var chunkQV7AOZZN_cjs = require('./chunk-QV7AOZZN.cjs');
5
+ var chunkC3NKBKRY_cjs = require('./chunk-C3NKBKRY.cjs');
6
+ var chunkJA4SYFC7_cjs = require('./chunk-JA4SYFC7.cjs');
7
+ var chunk4X4SY3RH_cjs = require('./chunk-4X4SY3RH.cjs');
8
+ var chunkYAVF2PR6_cjs = require('./chunk-YAVF2PR6.cjs');
9
9
  var bip39 = require('@scure/bip39');
10
10
  var english_js = require('@scure/bip39/wordlists/english.js');
11
11
  var musig2 = require('@scure/btc-signer/musig2.js');
@@ -337,7 +337,7 @@ var TreeSignerSession = class _TreeSignerSession {
337
337
  noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
338
338
  const tx = this.graph.find(txid);
339
339
  if (!tx) throw new Error(`missing tx for txid ${txid}`);
340
- const cosigners = chunk5HCDXBBG_cjs.getArkPsbtFields(tx.root, 0, chunk5HCDXBBG_cjs.CosignerPublicKey).map(
340
+ const cosigners = chunk4X4SY3RH_cjs.getArkPsbtFields(tx.root, 0, chunk4X4SY3RH_cjs.CosignerPublicKey).map(
341
341
  (c) => base.hex.encode(c.key.subarray(1))
342
342
  // xonly pubkey
343
343
  );
@@ -389,7 +389,7 @@ var TreeSignerSession = class _TreeSignerSession {
389
389
  if (!aggNonce) throw new Error("missing aggregate nonce");
390
390
  const prevoutAmounts = [];
391
391
  const prevoutScripts = [];
392
- const cosigners = chunk5HCDXBBG_cjs.getArkPsbtFields(g.root, 0, chunk5HCDXBBG_cjs.CosignerPublicKey).map((c) => c.key);
392
+ const cosigners = chunk4X4SY3RH_cjs.getArkPsbtFields(g.root, 0, chunk4X4SY3RH_cjs.CosignerPublicKey).map((c) => c.key);
393
393
  const { finalKey } = aggregateKeys(cosigners, true, {
394
394
  taprootTweak: this.scriptRoot
395
395
  });
@@ -472,7 +472,7 @@ var SingleKey = class _SingleKey {
472
472
  async sign(tx, inputIndexes) {
473
473
  const txCpy = tx.clone();
474
474
  if (!inputIndexes) {
475
- chunk5HCDXBBG_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
475
+ chunk4X4SY3RH_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
476
476
  try {
477
477
  if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
478
478
  throw new Error("Failed to sign transaction");
@@ -572,7 +572,7 @@ var SeedIdentity = class _SeedIdentity {
572
572
  let network;
573
573
  if ("descriptor" in opts && typeof opts.descriptor === "string") {
574
574
  descriptor = opts.descriptor;
575
- network = chunkVLO3JAP3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
575
+ network = chunkC3NKBKRY_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
576
576
  } else {
577
577
  network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
578
578
  descriptor = descriptorsScure.scriptExpressions.trBIP32({
@@ -649,7 +649,7 @@ var SeedIdentity = class _SeedIdentity {
649
649
  }
650
650
  /** Returns true when `descriptor` is derived from this identity's seed. */
651
651
  ownsDescriptor(descriptor) {
652
- return chunkVLO3JAP3_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
652
+ return chunkC3NKBKRY_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
653
653
  }
654
654
  /**
655
655
  * Signs each request with the key derived from its descriptor.
@@ -688,7 +688,7 @@ var SeedIdentity = class _SeedIdentity {
688
688
  }
689
689
  // ── internal helpers ─────────────────────────────────────────────
690
690
  derivePrivateKeyForDescriptor(descriptor) {
691
- const network = chunkVLO3JAP3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
691
+ const network = chunkC3NKBKRY_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
692
692
  const expansion = descriptorsScure.expand({ descriptor, network });
693
693
  if (expansion.isRanged) {
694
694
  throw new Error(
@@ -713,7 +713,7 @@ var SeedIdentity = class _SeedIdentity {
713
713
  signTxWithKey(tx, key, inputIndexes) {
714
714
  const txCpy = tx.clone();
715
715
  if (!inputIndexes) {
716
- chunk5HCDXBBG_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
716
+ chunk4X4SY3RH_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
717
717
  try {
718
718
  if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
719
719
  throw new Error("Failed to sign transaction");
@@ -814,7 +814,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
814
814
  /** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
815
815
  descriptor;
816
816
  constructor(descriptor) {
817
- const network = chunkVLO3JAP3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
817
+ const network = chunkC3NKBKRY_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
818
818
  let expansion;
819
819
  try {
820
820
  expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
@@ -849,7 +849,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
849
849
  }
850
850
  /** Returns true when `descriptor` derives from this identity's xpub. */
851
851
  ownsDescriptor(descriptor) {
852
- return chunkVLO3JAP3_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
852
+ return chunkC3NKBKRY_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
853
853
  }
854
854
  };
855
855
  function serializeSeedOwnedSigningIdentity(identity) {
@@ -992,10 +992,10 @@ var DescriptorIdentity = class {
992
992
  this.base = base;
993
993
  }
994
994
  async xOnlyPublicKey() {
995
- return chunkVLO3JAP3_cjs.deriveDescriptorLeafPubKey(this.descriptor);
995
+ return chunkC3NKBKRY_cjs.deriveDescriptorLeafPubKey(this.descriptor);
996
996
  }
997
997
  async compressedPublicKey() {
998
- return chunkVLO3JAP3_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
998
+ return chunkC3NKBKRY_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
999
999
  }
1000
1000
  async sign(tx, inputIndexes) {
1001
1001
  const [signed] = await this.signer.signWithDescriptor([
@@ -1055,8 +1055,8 @@ var StaticDescriptorProvider = class _StaticDescriptorProvider {
1055
1055
  }
1056
1056
  isOurs(descriptor) {
1057
1057
  try {
1058
- const normalized = chunkVLO3JAP3_cjs.normalizeToDescriptor(descriptor);
1059
- const pubKey = chunkVLO3JAP3_cjs.extractPubKey(normalized);
1058
+ const normalized = chunkC3NKBKRY_cjs.normalizeToDescriptor(descriptor);
1059
+ const pubKey = chunkC3NKBKRY_cjs.extractPubKey(normalized);
1060
1060
  return pubKey.toLowerCase() === this.pubKeyHex.toLowerCase();
1061
1061
  } catch {
1062
1062
  return false;
@@ -1398,7 +1398,7 @@ function unwrapKeyring(provider) {
1398
1398
  }
1399
1399
  function keyOf(descriptor) {
1400
1400
  try {
1401
- return chunkVLO3JAP3_cjs.extractPubKey(chunkVLO3JAP3_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
1401
+ return chunkC3NKBKRY_cjs.extractPubKey(chunkC3NKBKRY_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
1402
1402
  } catch {
1403
1403
  return void 0;
1404
1404
  }
@@ -1489,12 +1489,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
1489
1489
  signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
1490
1490
  } : void 0;
1491
1491
  const owner = providerOwner ?? identityOwner;
1492
- if (owner && chunkVLO3JAP3_cjs.parseHDDescriptor(descriptor)) {
1492
+ if (owner && chunkC3NKBKRY_cjs.parseHDDescriptor(descriptor)) {
1493
1493
  return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
1494
1494
  }
1495
1495
  let key;
1496
1496
  try {
1497
- key = chunkVLO3JAP3_cjs.deriveDescriptorLeafPubKey(descriptor);
1497
+ key = chunkC3NKBKRY_cjs.deriveDescriptorLeafPubKey(descriptor);
1498
1498
  } catch {
1499
1499
  throw new ForeignDescriptorError(descriptor);
1500
1500
  }
@@ -1547,14 +1547,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
1547
1547
  }
1548
1548
  var PREIMAGE_INDEX = 0;
1549
1549
  function isPerArtifactDescriptor(descriptor) {
1550
- return chunkVLO3JAP3_cjs.parseHDDescriptor(descriptor) !== null;
1550
+ return chunkC3NKBKRY_cjs.parseHDDescriptor(descriptor) !== null;
1551
1551
  }
1552
1552
  async function provisionDescriptor(wallet) {
1553
1553
  const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
1554
- return allocated ?? await chunkVLO3JAP3_cjs.identityDescriptor(wallet.identity);
1554
+ return allocated ?? await chunkC3NKBKRY_cjs.identityDescriptor(wallet.identity);
1555
1555
  }
1556
1556
  async function provisionRefundKey(wallet) {
1557
- const descriptorPromise = chunkVLO3JAP3_cjs.identityDescriptor(wallet.identity);
1557
+ const descriptorPromise = chunkC3NKBKRY_cjs.identityDescriptor(wallet.identity);
1558
1558
  const identityPubkeyPromise = wallet.identity.xOnlyPublicKey();
1559
1559
  void identityPubkeyPromise.catch(() => void 0);
1560
1560
  const descriptor = await descriptorPromise;
@@ -1569,7 +1569,7 @@ async function provisionRefundKey(wallet) {
1569
1569
  );
1570
1570
  }
1571
1571
  const address = await wallet.getAddress();
1572
- const { pkScript } = chunkWIZCF5IX_cjs.ArkAddress.decode(address);
1572
+ const { pkScript } = chunkYAVF2PR6_cjs.ArkAddress.decode(address);
1573
1573
  return { descriptor, pubkey, pkScript, address };
1574
1574
  }
1575
1575
  async function provisionClaimSecret(wallet, opts = {}) {
@@ -1617,7 +1617,7 @@ async function contractSigner(wallet, descriptor) {
1617
1617
  const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
1618
1618
  let expected;
1619
1619
  try {
1620
- expected = chunkVLO3JAP3_cjs.deriveDescriptorLeafPubKey(descriptor);
1620
+ expected = chunkC3NKBKRY_cjs.deriveDescriptorLeafPubKey(descriptor);
1621
1621
  } catch (cause) {
1622
1622
  throw new ForeignDescriptorError(descriptor, { cause });
1623
1623
  }
@@ -1699,7 +1699,7 @@ function debugLog(debug, ...args) {
1699
1699
  }
1700
1700
  function normalizeOptions(pathOrOptions) {
1701
1701
  const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
1702
- chunk5HCDXBBG_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
1702
+ chunk4X4SY3RH_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
1703
1703
  return {
1704
1704
  path: o.path,
1705
1705
  updateViaCache: o.updateViaCache ?? "none",
@@ -1822,14 +1822,14 @@ var RestDelegateProvider = class {
1822
1822
  */
1823
1823
  async delegate(intent, forfeitTxs, options) {
1824
1824
  const url = `${this.url}/v1/delegate`;
1825
- const response = await chunk5HCDXBBG_cjs.baseFetch(url, {
1825
+ const response = await chunk4X4SY3RH_cjs.baseFetch(url, {
1826
1826
  method: "POST",
1827
1827
  headers: {
1828
1828
  "Content-Type": "application/json"
1829
1829
  },
1830
1830
  body: JSON.stringify({
1831
1831
  intent: {
1832
- message: chunk5HCDXBBG_cjs.Proof.encodeMessage(intent.message),
1832
+ message: chunk4X4SY3RH_cjs.Proof.encodeMessage(intent.message),
1833
1833
  proof: intent.proof
1834
1834
  },
1835
1835
  forfeit_txs: forfeitTxs,
@@ -1848,7 +1848,7 @@ var RestDelegateProvider = class {
1848
1848
  */
1849
1849
  async getDelegateInfo() {
1850
1850
  const url = `${this.url}/v1/delegator/info`;
1851
- const response = await chunk5HCDXBBG_cjs.rateGate.runHttp(url, () => chunk5HCDXBBG_cjs.baseFetch(url));
1851
+ const response = await chunk4X4SY3RH_cjs.rateGate.runHttp(url, () => chunk4X4SY3RH_cjs.baseFetch(url));
1852
1852
  if (!response.ok) {
1853
1853
  const errorText2 = await response.text();
1854
1854
  throw new Error(`Failed to get delegate info: ${errorText2}`);
@@ -1970,7 +1970,7 @@ var ESPLORA_URL = {
1970
1970
  regtest: "http://localhost:3000/api"
1971
1971
  };
1972
1972
  var EsploraProvider = class {
1973
- constructor(baseUrl = ESPLORA_URL[chunkWIZCF5IX_cjs.DEFAULT_NETWORK_NAME], opts) {
1973
+ constructor(baseUrl = ESPLORA_URL[chunkYAVF2PR6_cjs.DEFAULT_NETWORK_NAME], opts) {
1974
1974
  this.baseUrl = baseUrl;
1975
1975
  this.pollingInterval = opts?.pollingInterval ?? 15e3;
1976
1976
  this.forcePolling = opts?.forcePolling ?? false;
@@ -1985,9 +1985,9 @@ var EsploraProvider = class {
1985
1985
  */
1986
1986
  addressWatches = /* @__PURE__ */ new Map();
1987
1987
  async getCoins(address) {
1988
- const response = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1988
+ const response = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1989
1989
  if (!response.ok) {
1990
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to fetch UTXOs", response);
1990
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to fetch UTXOs", response);
1991
1991
  }
1992
1992
  const coins = await response.json();
1993
1993
  const bad = coins.find(
@@ -1999,13 +1999,13 @@ var EsploraProvider = class {
1999
1999
  async getFeeRate() {
2000
2000
  let url = `${this.baseUrl}/fee-estimates`;
2001
2001
  let key = "1";
2002
- let response = await chunk5HCDXBBG_cjs.baseFetch(url);
2002
+ let response = await chunk4X4SY3RH_cjs.baseFetch(url);
2003
2003
  if (response.status === 404) {
2004
2004
  await response.body?.cancel().catch(() => {
2005
2005
  });
2006
2006
  url = `${this.baseUrl}/v1/fees/recommended`;
2007
2007
  key = "fastestFee";
2008
- response = await chunk5HCDXBBG_cjs.baseFetch(url);
2008
+ response = await chunk4X4SY3RH_cjs.baseFetch(url);
2009
2009
  }
2010
2010
  if (response.status === 404) {
2011
2011
  await response.body?.cancel().catch(() => {
@@ -2015,7 +2015,7 @@ var EsploraProvider = class {
2015
2015
  if (!response.ok) {
2016
2016
  await response.body?.cancel().catch(() => {
2017
2017
  });
2018
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to fetch fee rate", response);
2018
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to fetch fee rate", response);
2019
2019
  }
2020
2020
  const mediaType = response.headers.get("content-type")?.split(";", 1)[0].trim().toLowerCase();
2021
2021
  if (mediaType === "text/html") {
@@ -2045,10 +2045,10 @@ var EsploraProvider = class {
2045
2045
  }
2046
2046
  }
2047
2047
  async getTxOutspends(txid) {
2048
- const response = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
2048
+ const response = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
2049
2049
  if (!response.ok) {
2050
2050
  const error = await response.text().catch(() => void 0);
2051
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to get transaction outspends", response, error);
2051
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to get transaction outspends", response, error);
2052
2052
  }
2053
2053
  return response.json();
2054
2054
  }
@@ -2061,7 +2061,7 @@ var EsploraProvider = class {
2061
2061
  const page = await this.getAddressTxs(
2062
2062
  `${this.baseUrl}/address/${address}/txs/chain/${last}`
2063
2063
  ).catch((error) => {
2064
- if (error instanceof chunk5HCDXBBG_cjs.HttpResponseError && error.status === 404) return [];
2064
+ if (error instanceof chunk4X4SY3RH_cjs.HttpResponseError && error.status === 404) return [];
2065
2065
  throw error;
2066
2066
  });
2067
2067
  const fresh = page.filter((tx) => !seen.has(tx.txid));
@@ -2072,26 +2072,26 @@ var EsploraProvider = class {
2072
2072
  return txs;
2073
2073
  }
2074
2074
  async getAddressTxs(url) {
2075
- const response = await chunk5HCDXBBG_cjs.baseFetch(url);
2075
+ const response = await chunk4X4SY3RH_cjs.baseFetch(url);
2076
2076
  if (!response.ok) {
2077
2077
  const error = await response.text().catch(() => void 0);
2078
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to get transactions", response, error);
2078
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to get transactions", response, error);
2079
2079
  }
2080
2080
  return response.json();
2081
2081
  }
2082
2082
  /** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
2083
2083
  async getAddressStats(address) {
2084
- const response = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
2084
+ const response = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
2085
2085
  if (!response.ok) {
2086
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to get address stats", response);
2086
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to get address stats", response);
2087
2087
  }
2088
2088
  return response.json();
2089
2089
  }
2090
2090
  async getRawTransaction(txid) {
2091
- const response = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
2091
+ const response = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
2092
2092
  if (!response.ok) {
2093
2093
  const error = await response.text().catch(() => void 0);
2094
- throw new chunk5HCDXBBG_cjs.HttpResponseError(`Failed to get raw transaction ${txid}`, response, error);
2094
+ throw new chunk4X4SY3RH_cjs.HttpResponseError(`Failed to get raw transaction ${txid}`, response, error);
2095
2095
  }
2096
2096
  const raw = base.hex.decode((await response.text()).trim());
2097
2097
  const { id } = btcSigner.Transaction.fromRaw(raw, {
@@ -2106,17 +2106,17 @@ var EsploraProvider = class {
2106
2106
  return raw;
2107
2107
  }
2108
2108
  async getTxStatus(txid) {
2109
- const txresponse = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
2109
+ const txresponse = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
2110
2110
  if (!txresponse.ok) {
2111
- throw new chunk5HCDXBBG_cjs.HttpResponseError(`Failed to get transaction ${txid}`, txresponse);
2111
+ throw new chunk4X4SY3RH_cjs.HttpResponseError(`Failed to get transaction ${txid}`, txresponse);
2112
2112
  }
2113
2113
  const tx = await txresponse.json();
2114
2114
  if (!tx.status.confirmed) {
2115
2115
  return { confirmed: false };
2116
2116
  }
2117
- const response = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
2117
+ const response = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
2118
2118
  if (!response.ok) {
2119
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to get transaction status", response);
2119
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to get transaction status", response);
2120
2120
  }
2121
2121
  const data = await response.json();
2122
2122
  if (!data.confirmed) {
@@ -2396,12 +2396,12 @@ var EsploraProvider = class {
2396
2396
  return { subscribers, teardown, started };
2397
2397
  }
2398
2398
  async getChainTip() {
2399
- let tipBlocks = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/blocks`);
2399
+ let tipBlocks = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/blocks`);
2400
2400
  if (tipBlocks.status === 404) {
2401
- tipBlocks = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2401
+ tipBlocks = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2402
2402
  }
2403
2403
  if (!tipBlocks.ok) {
2404
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to get chain tip", tipBlocks);
2404
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to get chain tip", tipBlocks);
2405
2405
  }
2406
2406
  const tip = await tipBlocks.json();
2407
2407
  if (!isValidBlocksTip(tip)) {
@@ -2422,18 +2422,18 @@ var EsploraProvider = class {
2422
2422
  if (!Number.isInteger(height) || height < 0) {
2423
2423
  throw new Error(`Invalid block height for median-time-past: ${height}`);
2424
2424
  }
2425
- const hashResponse = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/block-height/${height}`);
2425
+ const hashResponse = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/block-height/${height}`);
2426
2426
  if (!hashResponse.ok) {
2427
- throw new chunk5HCDXBBG_cjs.HttpResponseError(
2427
+ throw new chunk4X4SY3RH_cjs.HttpResponseError(
2428
2428
  `Failed to get block hash at height ${height}`,
2429
2429
  hashResponse
2430
2430
  );
2431
2431
  }
2432
2432
  const hash = (await hashResponse.text()).trim();
2433
2433
  if (!hash) throw new Error(`No block hash returned at height ${height}`);
2434
- const blockResponse = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/block/${hash}`);
2434
+ const blockResponse = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/block/${hash}`);
2435
2435
  if (!blockResponse.ok) {
2436
- throw new chunk5HCDXBBG_cjs.HttpResponseError(`Failed to get block ${hash}`, blockResponse);
2436
+ throw new chunk4X4SY3RH_cjs.HttpResponseError(`Failed to get block ${hash}`, blockResponse);
2437
2437
  }
2438
2438
  const block = await blockResponse.json();
2439
2439
  if (!block || typeof block !== "object" || typeof block.mediantime !== "number" || !Number.isFinite(block.mediantime)) {
@@ -2442,7 +2442,7 @@ var EsploraProvider = class {
2442
2442
  return block.mediantime;
2443
2443
  }
2444
2444
  async broadcastPackage(parent, child) {
2445
- const response = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2445
+ const response = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2446
2446
  method: "POST",
2447
2447
  headers: {
2448
2448
  "Content-Type": "application/json"
@@ -2451,14 +2451,14 @@ var EsploraProvider = class {
2451
2451
  });
2452
2452
  if (!response.ok) {
2453
2453
  const error = await response.text().catch(() => void 0);
2454
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to broadcast package", response, error);
2454
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to broadcast package", response, error);
2455
2455
  }
2456
2456
  const result = await response.json();
2457
2457
  assertPackageAccepted(result);
2458
2458
  return result;
2459
2459
  }
2460
2460
  async broadcastTx(tx) {
2461
- const response = await chunk5HCDXBBG_cjs.baseFetch(`${this.baseUrl}/tx`, {
2461
+ const response = await chunk4X4SY3RH_cjs.baseFetch(`${this.baseUrl}/tx`, {
2462
2462
  method: "POST",
2463
2463
  headers: {
2464
2464
  "Content-Type": "text/plain"
@@ -2467,7 +2467,7 @@ var EsploraProvider = class {
2467
2467
  });
2468
2468
  if (!response.ok) {
2469
2469
  const error = await response.text().catch(() => void 0);
2470
- throw new chunk5HCDXBBG_cjs.HttpResponseError("Failed to broadcast transaction", response, error);
2470
+ throw new chunk4X4SY3RH_cjs.HttpResponseError("Failed to broadcast transaction", response, error);
2471
2471
  }
2472
2472
  return response.text();
2473
2473
  }
@@ -2631,7 +2631,7 @@ function findP2AOutput(tx) {
2631
2631
  var CHILD_DUST_AMOUNT = 546;
2632
2632
  function buildAnchorChild(params) {
2633
2633
  const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
2634
- const child = new chunk5HCDXBBG_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2634
+ const child = new chunk4X4SY3RH_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2635
2635
  const anchor = findP2AOutput(parent);
2636
2636
  child.addInput(anchor);
2637
2637
  const estimator = TxWeightEstimator.create().addP2AInput();
@@ -2680,7 +2680,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
2680
2680
  );
2681
2681
  }
2682
2682
  function buildForfeitTxWithOutput(inputs, output, txLocktime) {
2683
- const tx = new chunk5HCDXBBG_cjs.Transaction({
2683
+ const tx = new chunk4X4SY3RH_cjs.Transaction({
2684
2684
  version: 3,
2685
2685
  lockTime: txLocktime
2686
2686
  });
@@ -2707,7 +2707,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
2707
2707
  connectorsGraph.validate();
2708
2708
  if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
2709
2709
  const rootInput = connectorsGraph.root.getInput(0);
2710
- const settlementTx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
2710
+ const settlementTx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
2711
2711
  if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
2712
2712
  throw ErrInvalidSettlementTxOutputs;
2713
2713
  const expectedRootTxid = settlementTx.id;
@@ -2719,10 +2719,11 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2719
2719
  if (roundTransaction.outputsLength < BATCH_OUTPUT_VTXO_INDEX + 1) {
2720
2720
  throw ErrInvalidRoundTxOutputs;
2721
2721
  }
2722
- const batchOutputAmount = roundTransaction.getOutput(BATCH_OUTPUT_VTXO_INDEX)?.amount;
2723
- if (!batchOutputAmount) {
2722
+ const batchOutput = roundTransaction.getOutput(BATCH_OUTPUT_VTXO_INDEX);
2723
+ if (!batchOutput?.amount || !batchOutput.script) {
2724
2724
  throw ErrInvalidRoundTxOutputs;
2725
2725
  }
2726
+ const batchOutputAmount = batchOutput.amount;
2726
2727
  if (!graph.root) {
2727
2728
  throw ErrEmptyTree;
2728
2729
  }
@@ -2745,6 +2746,9 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2745
2746
  if (leaves.length === 0) {
2746
2747
  throw ErrNoLeaves;
2747
2748
  }
2749
+ if (!utils_js.equalBytes(batchOutput.script, cosignersOutputScript(graph.root, sweepTapTreeRoot))) {
2750
+ throw ErrInvalidRoundTxOutputs;
2751
+ }
2748
2752
  graph.validate();
2749
2753
  for (const g of graph.iterator()) {
2750
2754
  for (const [childIndex, child] of g.children) {
@@ -2752,24 +2756,20 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2752
2756
  if (!parentOutput?.script) {
2753
2757
  throw new Error(`parent output ${childIndex} not found`);
2754
2758
  }
2755
- const previousScriptKey = parentOutput.script.slice(2);
2756
- if (previousScriptKey.length !== 32) {
2757
- throw new Error(`parent output ${childIndex} has invalid script`);
2758
- }
2759
- const cosigners = chunk5HCDXBBG_cjs.getArkPsbtFields(child.root, 0, chunk5HCDXBBG_cjs.CosignerPublicKey);
2760
- if (cosigners.length === 0) {
2761
- throw ErrMissingCosignersPublicKeys;
2762
- }
2763
- const cosignerKeys = cosigners.map((c) => c.key);
2764
- const { finalKey } = aggregateKeys(cosignerKeys, true, {
2765
- taprootTweak: sweepTapTreeRoot
2766
- });
2767
- if (!finalKey || base.hex.encode(finalKey.slice(1)) !== base.hex.encode(previousScriptKey)) {
2759
+ const expected = cosignersOutputScript(child.root, sweepTapTreeRoot);
2760
+ if (!utils_js.equalBytes(parentOutput.script, expected)) {
2768
2761
  throw ErrInvalidTaprootScript;
2769
2762
  }
2770
2763
  }
2771
2764
  }
2772
2765
  }
2766
+ function cosignersOutputScript(tx, sweepTapTreeRoot) {
2767
+ const cosigners = chunk4X4SY3RH_cjs.getArkPsbtFields(tx, 0, chunk4X4SY3RH_cjs.CosignerPublicKey);
2768
+ if (cosigners.length === 0) throw ErrMissingCosignersPublicKeys;
2769
+ const keys = cosigners.map((c) => c.key);
2770
+ const { finalKey } = aggregateKeys(keys, true, { taprootTweak: sweepTapTreeRoot });
2771
+ return script_js.Script.encode(["OP_1", finalKey.slice(1)]);
2772
+ }
2773
2773
 
2774
2774
  // src/extension/packet.ts
2775
2775
  var UnknownPacket = class {
@@ -2814,7 +2814,7 @@ var EmulatorPacket = class _EmulatorPacket {
2814
2814
  return new _EmulatorPacket(entries);
2815
2815
  }
2816
2816
  static fromBytes(data) {
2817
- const reader = new chunkGEK6QBSY_cjs.BufferReader(data);
2817
+ const reader = new chunkQV7AOZZN_cjs.BufferReader(data);
2818
2818
  const entryCount = reader.readCompactSize();
2819
2819
  const entries = [];
2820
2820
  for (let i = 0; i < entryCount; i++) {
@@ -2832,7 +2832,7 @@ var EmulatorPacket = class _EmulatorPacket {
2832
2832
  return _EmulatorPacket.PACKET_TYPE;
2833
2833
  }
2834
2834
  serialize() {
2835
- const writer = new chunkGEK6QBSY_cjs.BufferWriter();
2835
+ const writer = new chunkQV7AOZZN_cjs.BufferWriter();
2836
2836
  writer.writeCompactSize(this.entries.length);
2837
2837
  for (const entry of this.entries) {
2838
2838
  writer.writeUint16LE(entry.vin);
@@ -2919,7 +2919,7 @@ var Extension = class _Extension {
2919
2919
  `expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
2920
2920
  );
2921
2921
  }
2922
- const reader = new chunkGEK6QBSY_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2922
+ const reader = new chunkQV7AOZZN_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2923
2923
  const packets = [];
2924
2924
  while (reader.remaining() > 0) {
2925
2925
  const packetType = reader.readByte();
@@ -2992,7 +2992,7 @@ var Extension = class _Extension {
2992
2992
  * getAssetPacket returns the embedded Packet, or null if not present.
2993
2993
  */
2994
2994
  getAssetPacket() {
2995
- return this.packets.find((p) => p instanceof chunkGEK6QBSY_cjs.Packet) ?? null;
2995
+ return this.packets.find((p) => p instanceof chunkQV7AOZZN_cjs.Packet) ?? null;
2996
2996
  }
2997
2997
  /**
2998
2998
  * getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
@@ -3016,8 +3016,8 @@ var Extension = class _Extension {
3016
3016
  };
3017
3017
  function parsePacket(packetType, data) {
3018
3018
  switch (packetType) {
3019
- case chunkGEK6QBSY_cjs.Packet.PACKET_TYPE:
3020
- return chunkGEK6QBSY_cjs.Packet.fromBytes(data);
3019
+ case chunkQV7AOZZN_cjs.Packet.PACKET_TYPE:
3020
+ return chunkQV7AOZZN_cjs.Packet.fromBytes(data);
3021
3021
  case EmulatorPacket.PACKET_TYPE:
3022
3022
  return EmulatorPacket.fromBytes(data);
3023
3023
  default:
@@ -3064,22 +3064,22 @@ function buildOpReturnScript(data) {
3064
3064
  }
3065
3065
  return script;
3066
3066
  }
3067
- var ErrOffchainOutputNotFound = (address) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
3068
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
3067
+ var ErrOffchainOutputNotFound = (address) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
3068
+ var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
3069
3069
  `invalid asset output amount for ${assetId}: got ${got}, want ${want}`
3070
3070
  );
3071
- var ErrAssetGroupNotFound = (assetId) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
3072
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
3071
+ var ErrAssetGroupNotFound = (assetId) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
3072
+ var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
3073
3073
  `asset output not found in asset group ${assetId} at index ${outputIndex}`
3074
3074
  );
3075
- var ErrOnchainOutputNotFound = (address) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
3076
- var ErrUnvalidatedOffchainOutput = (address) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
3075
+ var ErrOnchainOutputNotFound = (address) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
3076
+ var ErrUnvalidatedOffchainOutput = (address) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
3077
3077
  `offchain output ${address} cannot be validated: virtual output tree signing did not run`
3078
3078
  );
3079
- var ErrIntentOutputNotFound = (index, kind) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
3079
+ var ErrIntentOutputNotFound = (index, kind) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
3080
3080
  `${kind} output ${index} of the proof is not present in what the server built`
3081
3081
  );
3082
- var ErrUnvalidatedIntentOutput = (index) => new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
3082
+ var ErrUnvalidatedIntentOutput = (index) => new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
3083
3083
  `offchain output ${index} of the proof cannot be validated: virtual output tree signing did not run`
3084
3084
  );
3085
3085
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
@@ -3088,7 +3088,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
3088
3088
  function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
3089
3089
  if (!validatedCommitmentTxid) return;
3090
3090
  if (finalCommitmentTx.id === validatedCommitmentTxid) return;
3091
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
3091
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
3092
3092
  `${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
3093
3093
  );
3094
3094
  }
@@ -3098,7 +3098,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
3098
3098
  for (const recipient of recipients) {
3099
3099
  let arkAddress;
3100
3100
  try {
3101
- arkAddress = chunkWIZCF5IX_cjs.ArkAddress.decode(recipient.address);
3101
+ arkAddress = chunkYAVF2PR6_cjs.ArkAddress.decode(recipient.address);
3102
3102
  } catch {
3103
3103
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
3104
3104
  continue;
@@ -3110,7 +3110,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
3110
3110
  const usedOnchainOutputs = /* @__PURE__ */ new Set();
3111
3111
  for (const recipient of recipients) {
3112
3112
  try {
3113
- chunkWIZCF5IX_cjs.ArkAddress.decode(recipient.address);
3113
+ chunkYAVF2PR6_cjs.ArkAddress.decode(recipient.address);
3114
3114
  } catch {
3115
3115
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
3116
3116
  continue;
@@ -3119,7 +3119,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
3119
3119
  }
3120
3120
  }
3121
3121
  function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
3122
- const proof = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
3122
+ const proof = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
3123
3123
  const onchain = new Set(onchainOutputIndexes);
3124
3124
  const declared = [];
3125
3125
  for (let i = 0; i < proof.outputsLength; i++) {
@@ -3411,7 +3411,7 @@ function assetMintResolver() {
3411
3411
  if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
3412
3412
  const minted = tx.assets.filter((a) => {
3413
3413
  try {
3414
- return base.hex.encode(chunkGEK6QBSY_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3414
+ return base.hex.encode(chunkQV7AOZZN_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3415
3415
  } catch {
3416
3416
  return false;
3417
3417
  }
@@ -3488,7 +3488,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3488
3488
  const existing = inputsByAssetId.get(asset.assetId);
3489
3489
  inputsByAssetId.set(asset.assetId, [
3490
3490
  ...existing ?? [],
3491
- chunkGEK6QBSY_cjs.AssetInput.create(inputIndex, asset.amount)
3491
+ chunkQV7AOZZN_cjs.AssetInput.create(inputIndex, asset.amount)
3492
3492
  ]);
3493
3493
  }
3494
3494
  }
@@ -3500,7 +3500,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3500
3500
  const existing = outputsByAssetId.get(asset.assetId);
3501
3501
  outputsByAssetId.set(asset.assetId, [
3502
3502
  ...existing ?? [],
3503
- chunkGEK6QBSY_cjs.AssetOutput.create(outputIndex, asset.amount)
3503
+ chunkQV7AOZZN_cjs.AssetOutput.create(outputIndex, asset.amount)
3504
3504
  ]);
3505
3505
  }
3506
3506
  }
@@ -3511,7 +3511,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3511
3511
  const existing = outputsByAssetId.get(asset.assetId);
3512
3512
  outputsByAssetId.set(asset.assetId, [
3513
3513
  ...existing ?? [],
3514
- chunkGEK6QBSY_cjs.AssetOutput.create(outputIndex, asset.amount)
3514
+ chunkQV7AOZZN_cjs.AssetOutput.create(outputIndex, asset.amount)
3515
3515
  ]);
3516
3516
  }
3517
3517
  }
@@ -3520,11 +3520,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3520
3520
  for (const assetIdStr of allAssetIds) {
3521
3521
  const inputs = inputsByAssetId.get(assetIdStr);
3522
3522
  const outputs = outputsByAssetId.get(assetIdStr);
3523
- const assetId = chunkGEK6QBSY_cjs.AssetId.fromString(assetIdStr);
3524
- const group = chunkGEK6QBSY_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3523
+ const assetId = chunkQV7AOZZN_cjs.AssetId.fromString(assetIdStr);
3524
+ const group = chunkQV7AOZZN_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3525
3525
  groups.push(group);
3526
3526
  }
3527
- return chunkGEK6QBSY_cjs.Packet.create(groups);
3527
+ return chunkQV7AOZZN_cjs.Packet.create(groups);
3528
3528
  }
3529
3529
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
3530
3530
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -3584,7 +3584,7 @@ function isContractVtxoEvent(event) {
3584
3584
  }
3585
3585
  function toXOnlySignerHex(pubkeyHex) {
3586
3586
  const bytes2 = base.hex.decode(pubkeyHex);
3587
- if (bytes2.length === 32 || bytes2.length === 33) return base.hex.encode(chunkUPIQZRNJ_cjs.toXOnly(bytes2, "signer key"));
3587
+ if (bytes2.length === 32 || bytes2.length === 33) return base.hex.encode(chunkJA4SYFC7_cjs.toXOnly(bytes2, "signer key"));
3588
3588
  throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes2.length}`);
3589
3589
  }
3590
3590
  function signerSetFromInfo(info) {
@@ -3634,7 +3634,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
3634
3634
  };
3635
3635
  }
3636
3636
  function deriveContractTapscripts(contract) {
3637
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
3637
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
3638
3638
  if (!handler) {
3639
3639
  throw new Error(`No handler for contract type '${contract.type}'`);
3640
3640
  }
@@ -3643,7 +3643,7 @@ function deriveContractTapscripts(contract) {
3643
3643
  const derived = handler.deriveTapscripts(script, contract);
3644
3644
  return {
3645
3645
  forfeitTapLeafScript: derived.forfeitTapLeafScript,
3646
- proofTapLeafScript: chunkWIZCF5IX_cjs.proofTapLeafScriptOf(derived),
3646
+ proofTapLeafScript: chunkYAVF2PR6_cjs.proofTapLeafScriptOf(derived),
3647
3647
  tapTree: derived.tapTree
3648
3648
  };
3649
3649
  }
@@ -3747,7 +3747,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
3747
3747
  function assertTapTreeDerivesAddress(encoded, tapTree, address) {
3748
3748
  let derived;
3749
3749
  try {
3750
- derived = chunkWIZCF5IX_cjs.VtxoScript.decode(tapTree).pkScript;
3750
+ derived = chunkYAVF2PR6_cjs.VtxoScript.decode(tapTree).pkScript;
3751
3751
  } catch (e) {
3752
3752
  throw new Error(
3753
3753
  `Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
@@ -3764,7 +3764,7 @@ function validateRecipients(recipients, dustAmount, context) {
3764
3764
  for (const recipient of recipients) {
3765
3765
  let address;
3766
3766
  try {
3767
- address = chunkWIZCF5IX_cjs.ArkAddress.decode(recipient.address);
3767
+ address = chunkYAVF2PR6_cjs.ArkAddress.decode(recipient.address);
3768
3768
  } catch (e) {
3769
3769
  throw new Error(`Invalid Arkade address: ${recipient.address}`);
3770
3770
  }
@@ -3810,12 +3810,12 @@ var OnchainWallet = class _OnchainWallet {
3810
3810
  * @returns Configured onchain wallet
3811
3811
  * @throws Error if the configured identity cannot produce a valid x-only public key
3812
3812
  */
3813
- static async create(identity, networkName = chunkWIZCF5IX_cjs.DEFAULT_NETWORK_NAME, provider) {
3813
+ static async create(identity, networkName = chunkYAVF2PR6_cjs.DEFAULT_NETWORK_NAME, provider) {
3814
3814
  const pubkey = await identity.xOnlyPublicKey();
3815
3815
  if (!pubkey) {
3816
3816
  throw new Error("Invalid configured public key");
3817
3817
  }
3818
- const network = chunkWIZCF5IX_cjs.getNetwork(networkName);
3818
+ const network = chunkYAVF2PR6_cjs.getNetwork(networkName);
3819
3819
  const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
3820
3820
  const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
3821
3821
  return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
@@ -3915,7 +3915,7 @@ var OnchainWallet = class _OnchainWallet {
3915
3915
  feeRate,
3916
3916
  params.address
3917
3917
  );
3918
- let tx = new chunk5HCDXBBG_cjs.Transaction();
3918
+ let tx = new chunk4X4SY3RH_cjs.Transaction();
3919
3919
  for (const input of inputs) {
3920
3920
  tx.addInput({
3921
3921
  txid: input.txid,
@@ -3946,7 +3946,15 @@ var OnchainWallet = class _OnchainWallet {
3946
3946
  */
3947
3947
  async bumpP2A(parent) {
3948
3948
  const feeRate = await providerFeeRate(this.provider);
3949
- const child = await this.buildBumpPackage(parent, feeRate, await this.getCoins());
3949
+ const coins = await this.getCoins();
3950
+ const child = await this.buildBumpPackage(
3951
+ parent,
3952
+ feeRate,
3953
+ coins.filter((c) => c.status.confirmed)
3954
+ ).catch((e) => {
3955
+ if (!(e instanceof Error) || e.message !== "Insufficient funds") throw e;
3956
+ return this.buildBumpPackage(parent, feeRate, coins);
3957
+ });
3950
3958
  try {
3951
3959
  await this.provider.broadcastTransaction(parent.hex, child.hex);
3952
3960
  } catch (error) {
@@ -3970,29 +3978,36 @@ var OnchainWallet = class _OnchainWallet {
3970
3978
  * @throws If the parent has no anchor, or funding cannot be selected/signed
3971
3979
  */
3972
3980
  async bumpAnchor(parentHex, feeRate) {
3973
- const parent = chunk5HCDXBBG_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
3981
+ const parent = chunk4X4SY3RH_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
3974
3982
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
3975
3983
  const child = await this.buildBumpPackage(parent, feeRate, coins);
3976
3984
  return [parent.hex, child.hex];
3977
3985
  }
3978
3986
  /**
3979
- * Shared core of {@link bumpP2A} and {@link bumpAnchor}: probe the package
3980
- * fee with a single-input child, select coins for it, then build and sign
3981
- * with the actual selection (the fee grows per extra input).
3987
+ * Shared core of {@link bumpP2A} and {@link bumpAnchor}: select coins that pay the
3988
+ * package fee at their own input count and leave dust-free change, then build and sign.
3982
3989
  */
3983
3990
  async buildBumpPackage(parent, feeRate, coins) {
3984
3991
  let rate = feeRate;
3985
3992
  if (!rate || rate < _OnchainWallet.MIN_FEE_RATE) {
3986
3993
  rate = _OnchainWallet.MIN_FEE_RATE;
3987
3994
  }
3988
- const probeVsize = TxWeightEstimator.create().addKeySpendInput(true).addP2AInput().addOutputAddress(this.address, this.network).vsize().value;
3989
- const probeFee = Math.ceil(rate * (parent.vsize + Number(probeVsize)));
3990
- if (!probeFee) {
3995
+ const anchor = Number(findP2AOutput(parent).witnessUtxo.amount);
3996
+ let selected = { inputs: []};
3997
+ let childVsize = 0;
3998
+ for (let n = 1; ; n = selected.inputs.length) {
3999
+ const estimator = TxWeightEstimator.create().addP2AInput().addOutputAddress(this.address, this.network);
4000
+ for (let i = 0; i < n; i++) estimator.addKeySpendInput(true);
4001
+ childVsize = Number(estimator.vsize().value);
4002
+ const fee = Math.ceil(rate * (parent.vsize + childVsize));
4003
+ selected = selectCoins(coins, Math.max(1, fee + CHILD_DUST_AMOUNT - anchor));
4004
+ if (selected.inputs.length <= n) break;
4005
+ }
4006
+ if (childVsize > 1e3) {
3991
4007
  throw new Error(
3992
- `invalid fee, got ${probeFee} with vsize ${parent.vsize + Number(probeVsize)}, feeRate ${rate}`
4008
+ `fee child needs ${selected.inputs.length} inputs (${childVsize} vB, over the 1000 vB TRUC limit); consolidate the wallet's coins first`
3993
4009
  );
3994
4010
  }
3995
- const selected = selectCoins(coins, probeFee, true);
3996
4011
  const { child } = buildAnchorChild({
3997
4012
  parent,
3998
4013
  feeRate: rate,
@@ -4105,14 +4120,14 @@ var toTimelock = (value) => ({
4105
4120
  var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
4106
4121
  function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
4107
4122
  if (policy.requireSeconds && timelock.type === "blocks") {
4108
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4123
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4109
4124
  `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
4110
4125
  );
4111
4126
  }
4112
4127
  const seconds = toSeconds(timelock);
4113
4128
  if (seconds < policy.minSeconds) {
4114
4129
  const remedy = overrideOption ? `; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it` : "";
4115
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4130
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4116
4131
  `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor${remedy}`
4117
4132
  );
4118
4133
  }
@@ -4133,7 +4148,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
4133
4148
  }
4134
4149
  function assertValidBatchExpiry(batchExpiry, policy) {
4135
4150
  if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
4136
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4151
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4137
4152
  `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
4138
4153
  );
4139
4154
  }
@@ -4142,21 +4157,21 @@ function assertValidBatchExpiry(batchExpiry, policy) {
4142
4157
  function assertValidServerUnrollScript(checkpointTapscript, network, advertisedForfeitPubkey) {
4143
4158
  let script;
4144
4159
  try {
4145
- script = chunkWIZCF5IX_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
4160
+ script = chunkYAVF2PR6_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
4146
4161
  } catch (e) {
4147
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4162
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4148
4163
  `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
4149
4164
  );
4150
4165
  }
4151
4166
  if (advertisedForfeitPubkey !== void 0) {
4152
4167
  const { pubkeys } = script.params;
4153
4168
  if (pubkeys.length !== 1) {
4154
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4169
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4155
4170
  `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
4156
4171
  );
4157
4172
  }
4158
4173
  if (!utils_js.equalBytes(pubkeys[0], advertisedForfeitPubkey)) {
4159
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4174
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4160
4175
  `checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(advertisedForfeitPubkey)}`
4161
4176
  );
4162
4177
  }
@@ -4199,8 +4214,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
4199
4214
  function buildVirtualTx(inputs, outputs) {
4200
4215
  let lockTime = 0n;
4201
4216
  for (const input of inputs) {
4202
- const tapscript = chunkWIZCF5IX_cjs.decodeTapscript(chunkWIZCF5IX_cjs.scriptFromTapLeafScript(input.tapLeafScript));
4203
- if (chunkWIZCF5IX_cjs.CLTVMultisigTapscript.is(tapscript)) {
4217
+ const tapscript = chunkYAVF2PR6_cjs.decodeTapscript(chunkYAVF2PR6_cjs.scriptFromTapLeafScript(input.tapLeafScript));
4218
+ if (chunkYAVF2PR6_cjs.CLTVMultisigTapscript.is(tapscript)) {
4204
4219
  if (lockTime !== 0n) {
4205
4220
  if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
4206
4221
  throw new Error("cannot mix seconds and blocks locktime");
@@ -4211,7 +4226,7 @@ function buildVirtualTx(inputs, outputs) {
4211
4226
  }
4212
4227
  }
4213
4228
  }
4214
- const tx = new chunk5HCDXBBG_cjs.Transaction({
4229
+ const tx = new chunk4X4SY3RH_cjs.Transaction({
4215
4230
  version: 3,
4216
4231
  lockTime: Number(lockTime)
4217
4232
  });
@@ -4221,12 +4236,12 @@ function buildVirtualTx(inputs, outputs) {
4221
4236
  index: input.vout,
4222
4237
  sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
4223
4238
  witnessUtxo: {
4224
- script: chunkWIZCF5IX_cjs.VtxoScript.decode(input.tapTree).pkScript,
4239
+ script: chunkYAVF2PR6_cjs.VtxoScript.decode(input.tapTree).pkScript,
4225
4240
  amount: BigInt(input.value)
4226
4241
  },
4227
4242
  tapLeafScript: [input.tapLeafScript]
4228
4243
  });
4229
- chunk5HCDXBBG_cjs.setArkPsbtField(tx, i, chunk5HCDXBBG_cjs.VtxoTaprootTree, input.tapTree);
4244
+ chunk4X4SY3RH_cjs.setArkPsbtField(tx, i, chunk4X4SY3RH_cjs.VtxoTaprootTree, input.tapTree);
4230
4245
  }
4231
4246
  for (const output of outputs) {
4232
4247
  tx.addOutput(output);
@@ -4237,8 +4252,8 @@ function buildVirtualTx(inputs, outputs) {
4237
4252
  return tx;
4238
4253
  }
4239
4254
  function buildCheckpointTx(vtxo, serverUnrollScript) {
4240
- const collaborativeClosure = chunkWIZCF5IX_cjs.decodeTapscript(chunkWIZCF5IX_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
4241
- const checkpointVtxoScript = new chunkWIZCF5IX_cjs.VtxoScript([
4255
+ const collaborativeClosure = chunkYAVF2PR6_cjs.decodeTapscript(chunkYAVF2PR6_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
4256
+ const checkpointVtxoScript = new chunkYAVF2PR6_cjs.VtxoScript([
4242
4257
  serverUnrollScript.script,
4243
4258
  collaborativeClosure.script
4244
4259
  ]);
@@ -4284,11 +4299,11 @@ function hasBoardingTxExpired(coin, boardingTimelock, chainTipHeight, chainTipMe
4284
4299
  }
4285
4300
  function decodeBoardingExit(coin) {
4286
4301
  try {
4287
- const script = chunkWIZCF5IX_cjs.VtxoScript.decode(coin.tapTree);
4302
+ const script = chunkYAVF2PR6_cjs.VtxoScript.decode(coin.tapTree);
4288
4303
  for (const leaf of script.leaves) {
4289
- const tapscript = chunkWIZCF5IX_cjs.scriptFromTapLeafScript(leaf);
4290
- if (chunkWIZCF5IX_cjs.CSVMultisigTapscript.isScriptValid(tapscript) === true) {
4291
- const { timelock } = chunkWIZCF5IX_cjs.CSVMultisigTapscript.decode(tapscript).params;
4304
+ const tapscript = chunkYAVF2PR6_cjs.scriptFromTapLeafScript(leaf);
4305
+ if (chunkYAVF2PR6_cjs.CSVMultisigTapscript.isScriptValid(tapscript) === true) {
4306
+ const { timelock } = chunkYAVF2PR6_cjs.CSVMultisigTapscript.decode(tapscript).params;
4292
4307
  return { script, leaf, timelock };
4293
4308
  }
4294
4309
  }
@@ -4372,7 +4387,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
4372
4387
  const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
4373
4388
  const sig = signature.subarray(0, 64);
4374
4389
  if (!allowedSighashTypes.includes(sighashType)) {
4375
- const sighashName = chunk5HCDXBBG_cjs.formatSighash(sighashType);
4390
+ const sighashName = chunk4X4SY3RH_cjs.formatSighash(sighashType);
4376
4391
  throw new Error(
4377
4392
  `Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
4378
4393
  );
@@ -4446,7 +4461,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
4446
4461
  }
4447
4462
  function isValidArkAddress(address) {
4448
4463
  try {
4449
- chunkWIZCF5IX_cjs.ArkAddress.decode(address);
4464
+ chunkYAVF2PR6_cjs.ArkAddress.decode(address);
4450
4465
  return true;
4451
4466
  } catch (e) {
4452
4467
  return false;
@@ -4454,16 +4469,16 @@ function isValidArkAddress(address) {
4454
4469
  }
4455
4470
  function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
4456
4471
  if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
4457
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4472
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4458
4473
  `${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
4459
4474
  );
4460
4475
  }
4461
4476
  const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
4462
4477
  return serverCheckpointTxs.map((encoded, index) => {
4463
- const server = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
4478
+ const server = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
4464
4479
  const local = byTxid.get(server.id);
4465
4480
  if (!local) {
4466
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4481
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4467
4482
  `${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
4468
4483
  );
4469
4484
  }
@@ -4473,14 +4488,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
4473
4488
  }
4474
4489
  function assertSubmittedArkTxid(response, signedArkTx, context) {
4475
4490
  if (response.arkTxid !== signedArkTx.id) {
4476
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4491
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4477
4492
  `${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
4478
4493
  );
4479
4494
  }
4480
4495
  if (response.finalArkTx === void 0) return;
4481
- const finalTxid = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
4496
+ const finalTxid = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
4482
4497
  if (finalTxid !== signedArkTx.id) {
4483
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4498
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4484
4499
  `${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
4485
4500
  );
4486
4501
  }
@@ -4492,20 +4507,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
4492
4507
  `${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
4493
4508
  );
4494
4509
  }
4495
- const script = chunkWIZCF5IX_cjs.scriptFromTapLeafScript(leaf);
4510
+ const script = chunkYAVF2PR6_cjs.scriptFromTapLeafScript(leaf);
4496
4511
  let leafPubkeys;
4497
4512
  try {
4498
- leafPubkeys = chunkWIZCF5IX_cjs.decodeTapscript(script).params.pubkeys.map(
4499
- (key) => base.hex.encode(chunkUPIQZRNJ_cjs.toXOnly(key, "leaf key"))
4513
+ leafPubkeys = chunkYAVF2PR6_cjs.decodeTapscript(script).params.pubkeys.map(
4514
+ (key) => base.hex.encode(chunkJA4SYFC7_cjs.toXOnly(key, "leaf key"))
4500
4515
  );
4501
4516
  } catch (error) {
4502
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4517
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4503
4518
  `${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
4504
4519
  );
4505
4520
  }
4506
4521
  const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
4507
4522
  if (!signer) {
4508
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4523
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4509
4524
  `${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
4510
4525
  );
4511
4526
  }
@@ -4522,41 +4537,95 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
4522
4537
  payment_js.tapLeafHash(script)
4523
4538
  );
4524
4539
  } catch (error) {
4525
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4540
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4526
4541
  `${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
4527
4542
  );
4528
4543
  }
4529
4544
  }
4530
4545
  function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, context) {
4531
4546
  const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
4547
+ const matched = [];
4532
4548
  for (const [index, checkpoint] of checkpoints.entries()) {
4533
4549
  if (checkpoint.inputsLength !== 1) {
4534
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4550
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4535
4551
  `${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
4536
4552
  );
4537
4553
  }
4538
4554
  const spent = checkpoint.getInput(0);
4539
4555
  if (!spent.txid || spent.index === void 0) {
4540
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4556
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4541
4557
  `${context}: checkpoint ${index} has no input outpoint`
4542
4558
  );
4543
4559
  }
4544
4560
  const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
4545
4561
  const input = byOutpoint.get(outpoint);
4546
4562
  if (!input) {
4547
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4563
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4548
4564
  `${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
4549
4565
  );
4550
4566
  }
4551
- const rebuilt = unrollCandidates.some(
4552
- (unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
4553
- );
4567
+ let rebuilt;
4568
+ for (const unroll of unrollCandidates) {
4569
+ const candidate = buildCheckpointTx(input, unroll);
4570
+ if (candidate.tx.id === checkpoint.id) {
4571
+ rebuilt = candidate.input;
4572
+ break;
4573
+ }
4574
+ }
4554
4575
  if (!rebuilt) {
4555
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4576
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4556
4577
  `${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
4557
4578
  );
4558
4579
  }
4580
+ matched.push(rebuilt);
4581
+ }
4582
+ return matched;
4583
+ }
4584
+ function assertArkTxSignedOverCheckpoints(arkTx, checkpoints, context) {
4585
+ const byOutpoint = new Map(checkpoints.map((c) => [`${c.txid}:${c.vout}`, c]));
4586
+ const probe = arkTx.clone();
4587
+ const spent = [];
4588
+ for (let index = 0; index < arkTx.inputsLength; index++) {
4589
+ const input = arkTx.getInput(index);
4590
+ const outpoint = input.txid && input.index !== void 0 ? `${base.hex.encode(input.txid)}:${input.index}` : void 0;
4591
+ const local = outpoint ? byOutpoint.get(outpoint) : void 0;
4592
+ if (!local) {
4593
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4594
+ `${context}: ark tx input ${index} spends ${outpoint ?? "no outpoint"}, which is not a checkpoint of this tx`
4595
+ );
4596
+ }
4597
+ probe.updateInput(
4598
+ index,
4599
+ {
4600
+ witnessUtxo: {
4601
+ script: chunkYAVF2PR6_cjs.VtxoScript.decode(local.tapTree).pkScript,
4602
+ amount: BigInt(local.value)
4603
+ },
4604
+ tapLeafScript: [local.tapLeafScript]
4605
+ },
4606
+ true
4607
+ );
4608
+ spent.push(local);
4559
4609
  }
4610
+ const unspent = checkpoints.find((checkpoint) => !spent.includes(checkpoint));
4611
+ if (unspent) {
4612
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4613
+ `${context}: ark tx does not spend checkpoint ${unspent.txid}`
4614
+ );
4615
+ }
4616
+ spent.forEach((local, index) => {
4617
+ const leaf = chunkYAVF2PR6_cjs.scriptFromTapLeafScript(local.tapLeafScript);
4618
+ const keys = chunkYAVF2PR6_cjs.decodeTapscript(leaf).params.pubkeys.map(
4619
+ (key) => base.hex.encode(chunkJA4SYFC7_cjs.toXOnly(key, "leaf key"))
4620
+ );
4621
+ try {
4622
+ verifyTapscriptSignatures(probe, index, keys, void 0, void 0, payment_js.tapLeafHash(leaf));
4623
+ } catch (error) {
4624
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4625
+ `${context}: ark tx input ${index} is not fully signed on the leaf spending ${local.txid} (${error instanceof Error ? error.message : String(error)})`
4626
+ );
4627
+ }
4628
+ });
4560
4629
  }
4561
4630
  async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
4562
4631
  const oneShot = options?.oneShot !== false;
@@ -4581,9 +4650,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
4581
4650
  if (!oneShot) {
4582
4651
  matched.forEach(({ server }, index) => {
4583
4652
  try {
4584
- chunk5HCDXBBG_cjs.assertAllowedSighashTypes(server);
4653
+ chunk4X4SY3RH_cjs.assertAllowedSighashTypes(server);
4585
4654
  } catch (error) {
4586
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4655
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4587
4656
  `submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
4588
4657
  );
4589
4658
  }
@@ -4592,14 +4661,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
4592
4661
  const verify = options?.verifyServerSignatures;
4593
4662
  if (verify) {
4594
4663
  if (response.finalArkTx === void 0) {
4595
- throw new chunk5HCDXBBG_cjs.ServerResponseMismatchError(
4664
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
4596
4665
  "submitTx: server returned no final ark tx to verify its signatures against"
4597
4666
  );
4598
4667
  }
4599
- const finalArkTx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
4668
+ const finalArkTx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
4600
4669
  const serverPubkeys = new Set(
4601
4670
  [verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
4602
- (key) => base.hex.encode(chunkUPIQZRNJ_cjs.toXOnly(key, "server key"))
4671
+ (key) => base.hex.encode(chunkJA4SYFC7_cjs.toXOnly(key, "server key"))
4603
4672
  )
4604
4673
  );
4605
4674
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
@@ -4647,19 +4716,19 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
4647
4716
  return result;
4648
4717
  }
4649
4718
  function carryConditionWitness(ours, server) {
4650
- if (chunk5HCDXBBG_cjs.getArkPsbtFields(server, 0, chunk5HCDXBBG_cjs.ConditionWitness).length > 0) return;
4651
- const [witness] = chunk5HCDXBBG_cjs.getArkPsbtFields(ours, 0, chunk5HCDXBBG_cjs.ConditionWitness);
4652
- if (witness) chunk5HCDXBBG_cjs.setArkPsbtField(server, 0, chunk5HCDXBBG_cjs.ConditionWitness, witness);
4719
+ if (chunk4X4SY3RH_cjs.getArkPsbtFields(server, 0, chunk4X4SY3RH_cjs.ConditionWitness).length > 0) return;
4720
+ const [witness] = chunk4X4SY3RH_cjs.getArkPsbtFields(ours, 0, chunk4X4SY3RH_cjs.ConditionWitness);
4721
+ if (witness) chunk4X4SY3RH_cjs.setArkPsbtField(server, 0, chunk4X4SY3RH_cjs.ConditionWitness, witness);
4653
4722
  }
4654
4723
  function withArkInputWitness(checkpoint, signedArkTx) {
4655
- if (chunk5HCDXBBG_cjs.getArkPsbtFields(checkpoint, 0, chunk5HCDXBBG_cjs.ConditionWitness).length > 0) return checkpoint;
4724
+ if (chunk4X4SY3RH_cjs.getArkPsbtFields(checkpoint, 0, chunk4X4SY3RH_cjs.ConditionWitness).length > 0) return checkpoint;
4656
4725
  for (let i = 0; i < signedArkTx.inputsLength; i++) {
4657
4726
  const { txid } = signedArkTx.getInput(i);
4658
4727
  if (!txid || base.hex.encode(txid) !== checkpoint.id) continue;
4659
- const [witness] = chunk5HCDXBBG_cjs.getArkPsbtFields(signedArkTx, i, chunk5HCDXBBG_cjs.ConditionWitness);
4728
+ const [witness] = chunk4X4SY3RH_cjs.getArkPsbtFields(signedArkTx, i, chunk4X4SY3RH_cjs.ConditionWitness);
4660
4729
  if (!witness) return checkpoint;
4661
4730
  const carried = checkpoint.clone();
4662
- chunk5HCDXBBG_cjs.setArkPsbtField(carried, 0, chunk5HCDXBBG_cjs.ConditionWitness, witness);
4731
+ chunk4X4SY3RH_cjs.setArkPsbtField(carried, 0, chunk4X4SY3RH_cjs.ConditionWitness, witness);
4663
4732
  return carried;
4664
4733
  }
4665
4734
  return checkpoint;
@@ -4700,7 +4769,7 @@ async function submitViaEmulator(emulator, offchainTx, signer, opts) {
4700
4769
  base.base64.encode(arkTx.toPSBT()),
4701
4770
  checkpoints.map((c) => base.base64.encode(c.toPSBT()))
4702
4771
  );
4703
- const txid = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
4772
+ const txid = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
4704
4773
  assertSubmittedArkTxid({ arkTxid: txid }, arkTx, "emulator submitTx");
4705
4774
  matchServerCheckpoints(res.signedCheckpointTxs, checkpoints, "emulator submitTx");
4706
4775
  return { txid, signedArkTx: res.signedArkTx, signedCheckpointTxs: res.signedCheckpointTxs };
@@ -4709,12 +4778,12 @@ function claimWithPreimageIdentity(identity, preimage) {
4709
4778
  return {
4710
4779
  ...identity,
4711
4780
  sign: async (tx, inputIndexes) => {
4712
- const signed = chunk5HCDXBBG_cjs.Transaction.fromPSBT(
4781
+ const signed = chunk4X4SY3RH_cjs.Transaction.fromPSBT(
4713
4782
  (await identity.sign(tx.clone(), inputIndexes)).toPSBT()
4714
4783
  );
4715
4784
  const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
4716
4785
  for (const index of indexes) {
4717
- chunk5HCDXBBG_cjs.setArkPsbtField(signed, index, chunk5HCDXBBG_cjs.ConditionWitness, [preimage]);
4786
+ chunk4X4SY3RH_cjs.setArkPsbtField(signed, index, chunk4X4SY3RH_cjs.ConditionWitness, [preimage]);
4718
4787
  }
4719
4788
  return signed;
4720
4789
  }
@@ -4723,13 +4792,13 @@ function claimWithPreimageIdentity(identity, preimage) {
4723
4792
 
4724
4793
  // src/contracts/scope.ts
4725
4794
  function scopeOf(contract) {
4726
- return contract.scope ?? chunkVLO3JAP3_cjs.contractHandlers.get(contract.type)?.defaultScope ?? "offchain";
4795
+ return contract.scope ?? chunkC3NKBKRY_cjs.contractHandlers.get(contract.type)?.defaultScope ?? "offchain";
4727
4796
  }
4728
4797
  function isOnchainScoped(contract) {
4729
4798
  return scopeOf(contract) !== "offchain";
4730
4799
  }
4731
4800
  function scriptFromArkAddress(address) {
4732
- return base.hex.encode(chunkWIZCF5IX_cjs.ArkAddress.decode(address).pkScript);
4801
+ return base.hex.encode(chunkYAVF2PR6_cjs.ArkAddress.decode(address).pkScript);
4733
4802
  }
4734
4803
 
4735
4804
  // src/repositories/walletRepository.ts
@@ -4800,9 +4869,9 @@ async function collectScriptVtxos(repository, script, options) {
4800
4869
  return [...byOutpoint.values()].map((row) => row.vtxo);
4801
4870
  }
4802
4871
  function unspentScriptVtxos(rows, copies) {
4803
- const spent = copies.filter((copy) => chunk5HCDXBBG_cjs.isVtxoSpent(copy.vtxo));
4872
+ const spent = copies.filter((copy) => chunk4X4SY3RH_cjs.isVtxoSpent(copy.vtxo));
4804
4873
  return rows.filter(
4805
- (row) => !chunk5HCDXBBG_cjs.isVtxoSpent(row.vtxo) && !spent.some(
4874
+ (row) => !chunk4X4SY3RH_cjs.isVtxoSpent(row.vtxo) && !spent.some(
4806
4875
  (copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
4807
4876
  )
4808
4877
  );
@@ -4873,8 +4942,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
4873
4942
  }
4874
4943
  async function getVtxosForContract(repo, contract, options) {
4875
4944
  const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
4876
- const normalized = vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo);
4877
- return options?.unspentOnly ? normalized.filter((vtxo) => !chunk5HCDXBBG_cjs.isVtxoSpent(vtxo)) : normalized;
4945
+ const normalized = vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo);
4946
+ return options?.unspentOnly ? normalized.filter((vtxo) => !chunk4X4SY3RH_cjs.isVtxoSpent(vtxo)) : normalized;
4878
4947
  }
4879
4948
  async function hasVtxosForContract(repo, contract) {
4880
4949
  if (repo.getVtxosForScriptPage) {
@@ -4956,7 +5025,7 @@ async function saveVtxosForContract(repo, contract, vtxos) {
4956
5025
  // src/contracts/onchainCoins.ts
4957
5026
  var MIGRATED_KEY = "legacyUtxosMigrated";
4958
5027
  function createScript(contract) {
4959
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
5028
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
4960
5029
  if (!handler) throw new Error(`No handler for contract type '${contract.type}'`);
4961
5030
  return handler.createScript(contract.params);
4962
5031
  }
@@ -5015,7 +5084,7 @@ async function migrateLegacyUtxos(deps) {
5015
5084
  let migrated = 0;
5016
5085
  for (const contract of await collectContracts(contractRepository)) {
5017
5086
  if (!isOnchainScoped(contract)) continue;
5018
- if (!chunkVLO3JAP3_cjs.contractHandlers.has(contract.type)) {
5087
+ if (!chunkC3NKBKRY_cjs.contractHandlers.has(contract.type)) {
5019
5088
  console.warn("Skipping legacy utxos of a contract with no handler", contract.type);
5020
5089
  continue;
5021
5090
  }
@@ -5041,8 +5110,8 @@ var DEFAULT_COSIGN_MARGIN_BLOCKS = 6;
5041
5110
  var MAX_COSIGN_INPUTS = 64;
5042
5111
  var ONCHAIN_RENEW_WINDOW_BLOCKS = 144;
5043
5112
  function exitCsvOf(contract) {
5044
- const sequence = chunkVLO3JAP3_cjs.exitSequence(contract);
5045
- return sequence === void 0 ? void 0 : chunkWIZCF5IX_cjs.sequenceToTimelock(sequence);
5113
+ const sequence = chunkC3NKBKRY_cjs.exitSequence(contract);
5114
+ return sequence === void 0 ? void 0 : chunkYAVF2PR6_cjs.sequenceToTimelock(sequence);
5046
5115
  }
5047
5116
  var ONCHAIN_COSIGN_PREFLIGHT_PREFIX = "Onchain cosign preflight failed: ";
5048
5117
  var OnchainCosignPreflightError = class extends Error {
@@ -5059,7 +5128,7 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
5059
5128
  tx.updateInput(index, { tapLeafScript: void 0, tapScriptSig: void 0 }, true);
5060
5129
  }
5061
5130
  const kept = unknown?.filter(
5062
- (u) => chunk5HCDXBBG_cjs.VtxoTaprootTree.decode(u) === null && chunk5HCDXBBG_cjs.ConditionWitness.decode(u) === null
5131
+ (u) => chunk4X4SY3RH_cjs.VtxoTaprootTree.decode(u) === null && chunk4X4SY3RH_cjs.ConditionWitness.decode(u) === null
5063
5132
  );
5064
5133
  if (kept && kept.length !== unknown.length) {
5065
5134
  tx.updateInput(index, { unknown: void 0 }, true);
@@ -5070,9 +5139,9 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
5070
5139
  tapLeafScript: [path.leaf],
5071
5140
  sighashType: btcSigner.SigHash.DEFAULT
5072
5141
  });
5073
- chunk5HCDXBBG_cjs.setArkPsbtField(tx, index, chunk5HCDXBBG_cjs.VtxoTaprootTree, tapTree);
5142
+ chunk4X4SY3RH_cjs.setArkPsbtField(tx, index, chunk4X4SY3RH_cjs.VtxoTaprootTree, tapTree);
5074
5143
  if (path.extraWitness?.length) {
5075
- chunk5HCDXBBG_cjs.setArkPsbtField(tx, index, chunk5HCDXBBG_cjs.ConditionWitness, path.extraWitness);
5144
+ chunk4X4SY3RH_cjs.setArkPsbtField(tx, index, chunk4X4SY3RH_cjs.ConditionWitness, path.extraWitness);
5076
5145
  }
5077
5146
  }
5078
5147
  function emulatorInputIndexes(tx) {
@@ -5119,7 +5188,7 @@ function isBoardingContract(contract, boardingCsv) {
5119
5188
  if (!isOnchainScoped(contract)) return false;
5120
5189
  if (contract.type === "boarding") return true;
5121
5190
  if (contract.type !== "default" || scopeOf(contract) !== "both") return false;
5122
- return chunkVLO3JAP3_cjs.exitSequence(contract) === chunkWIZCF5IX_cjs.timelockToSequence(boardingCsv);
5191
+ return chunkC3NKBKRY_cjs.exitSequence(contract) === chunkYAVF2PR6_cjs.timelockToSequence(boardingCsv);
5123
5192
  }
5124
5193
  function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFAULT_COSIGN_MARGIN_BLOCKS) {
5125
5194
  if (!isBoardingContract(contract, boardingCsv) || !isExplorerCoin(coin)) return false;
@@ -5131,7 +5200,7 @@ function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFA
5131
5200
  return left.remaining > margin && left.remaining <= margin + window2;
5132
5201
  }
5133
5202
  function finalizeOwnedInput(tx, index) {
5134
- const condition = chunk5HCDXBBG_cjs.getArkPsbtFields(tx, index, chunk5HCDXBBG_cjs.ConditionWitness)[0];
5203
+ const condition = chunk4X4SY3RH_cjs.getArkPsbtFields(tx, index, chunk4X4SY3RH_cjs.ConditionWitness)[0];
5135
5204
  if (!condition) {
5136
5205
  tx.finalizeIdx(index);
5137
5206
  return;
@@ -5139,7 +5208,7 @@ function finalizeOwnedInput(tx, index) {
5139
5208
  const input = tx.getInput(index);
5140
5209
  const leaf = input.tapLeafScript?.[0];
5141
5210
  if (!leaf) throw new Error(`input ${index} has no tap leaf to finalize`);
5142
- const script = chunkWIZCF5IX_cjs.scriptFromTapLeafScript(leaf);
5211
+ const script = chunkYAVF2PR6_cjs.scriptFromTapLeafScript(leaf);
5143
5212
  const ops = btcSigner.Script.decode(script);
5144
5213
  const position = (pubKey) => ops.findIndex((op) => op instanceof Uint8Array && utils_js.equalBytes(op, pubKey));
5145
5214
  const sigs = (input.tapScriptSig ?? []).map(([{ pubKey }, sig]) => ({ sig, pos: position(pubKey) })).filter((s) => s.pos !== -1).sort((a, b) => a.pos - b.pos).map((s) => s.sig).reverse();
@@ -5154,27 +5223,27 @@ var DEFINITE_COSIGN_REJECTIONS = /* @__PURE__ */ new Set([
5154
5223
  "TX_TOO_LARGE"
5155
5224
  ]);
5156
5225
  function isCosignRejectedAfterSigning(e) {
5157
- return e instanceof chunk5HCDXBBG_cjs.OnchainCosignRejectedError && !isCosignFallback(e);
5226
+ return e instanceof chunk4X4SY3RH_cjs.OnchainCosignRejectedError && !isCosignFallback(e);
5158
5227
  }
5159
5228
  function isCosignFallback(e) {
5160
- if (e instanceof chunk5HCDXBBG_cjs.OnchainCosignRejectedError) {
5229
+ if (e instanceof chunk4X4SY3RH_cjs.OnchainCosignRejectedError) {
5161
5230
  return !!e.arkErrorName && DEFINITE_COSIGN_REJECTIONS.has(e.arkErrorName);
5162
5231
  }
5163
- return e instanceof chunk5HCDXBBG_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError;
5232
+ return e instanceof chunk4X4SY3RH_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError;
5164
5233
  }
5165
5234
  function rehydrateCosignError(e) {
5166
- if (!(e instanceof Error) || e instanceof chunk5HCDXBBG_cjs.OnchainCosignRejectedError || e instanceof chunk5HCDXBBG_cjs.OnchainCosignAmbiguousError || e instanceof chunk5HCDXBBG_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError) {
5235
+ if (!(e instanceof Error) || e instanceof chunk4X4SY3RH_cjs.OnchainCosignRejectedError || e instanceof chunk4X4SY3RH_cjs.OnchainCosignAmbiguousError || e instanceof chunk4X4SY3RH_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError) {
5167
5236
  return e;
5168
5237
  }
5169
5238
  const { message } = e;
5170
- if (message.startsWith(chunk5HCDXBBG_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX)) {
5171
- const rest = message.slice(chunk5HCDXBBG_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX.length);
5239
+ if (message.startsWith(chunk4X4SY3RH_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX)) {
5240
+ const rest = message.slice(chunk4X4SY3RH_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX.length);
5172
5241
  const named = rest.match(/^\[([A-Z0-9_]+)\] ([\s\S]*)$/);
5173
- return named ? new chunk5HCDXBBG_cjs.OnchainCosignRejectedError(named[2], named[1]) : new chunk5HCDXBBG_cjs.OnchainCosignRejectedError(rest);
5242
+ return named ? new chunk4X4SY3RH_cjs.OnchainCosignRejectedError(named[2], named[1]) : new chunk4X4SY3RH_cjs.OnchainCosignRejectedError(rest);
5174
5243
  }
5175
- if (message.startsWith(chunk5HCDXBBG_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX)) {
5176
- return new chunk5HCDXBBG_cjs.OnchainCosignAmbiguousError(
5177
- message.slice(chunk5HCDXBBG_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX.length)
5244
+ if (message.startsWith(chunk4X4SY3RH_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX)) {
5245
+ return new chunk4X4SY3RH_cjs.OnchainCosignAmbiguousError(
5246
+ message.slice(chunk4X4SY3RH_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX.length)
5178
5247
  );
5179
5248
  }
5180
5249
  if (message.startsWith(ONCHAIN_COSIGN_PREFLIGHT_PREFIX)) {
@@ -5182,8 +5251,8 @@ function rehydrateCosignError(e) {
5182
5251
  message.slice(ONCHAIN_COSIGN_PREFLIGHT_PREFIX.length)
5183
5252
  );
5184
5253
  }
5185
- if (message.startsWith(chunk5HCDXBBG_cjs.ONCHAIN_COSIGN_UNSUPPORTED_PREFIX))
5186
- return new chunk5HCDXBBG_cjs.OnchainCosignUnsupportedError();
5254
+ if (message.startsWith(chunk4X4SY3RH_cjs.ONCHAIN_COSIGN_UNSUPPORTED_PREFIX))
5255
+ return new chunk4X4SY3RH_cjs.OnchainCosignUnsupportedError();
5187
5256
  return e;
5188
5257
  }
5189
5258
  function estimateOnchainCosignFee(nIn, nOut, feeRate) {
@@ -5199,13 +5268,13 @@ async function submitOnchainSpend(tx, arkInputs, deps) {
5199
5268
  throw new Error("emulator inputs present but no emulator provider configured");
5200
5269
  }
5201
5270
  const { signedTx } = await deps.emulator.submitOnchainTx(base.base64.encode(tx.toPSBT()));
5202
- tx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(signedTx));
5271
+ tx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(signedTx));
5203
5272
  }
5204
5273
  if (arkInputs.size > 0) {
5205
5274
  if (!deps.arkProvider) {
5206
5275
  throw new Error("arkd-cosigned inputs present but no arkProvider configured");
5207
5276
  }
5208
- if (!deps.arkProvider.cosignOnchainTx) throw new chunk5HCDXBBG_cjs.OnchainCosignUnsupportedError();
5277
+ if (!deps.arkProvider.cosignOnchainTx) throw new chunk4X4SY3RH_cjs.OnchainCosignUnsupportedError();
5209
5278
  return deps.arkProvider.cosignOnchainTx(base.base64.encode(tx.toPSBT()));
5210
5279
  }
5211
5280
  for (let i = 0; i < tx.inputsLength; i++) {
@@ -5356,7 +5425,7 @@ function parseProgram(text, env) {
5356
5425
 
5357
5426
  // src/contracts/spendability.ts
5358
5427
  function isContractGenericallySpendable(contract) {
5359
- return chunkVLO3JAP3_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
5428
+ return chunkC3NKBKRY_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
5360
5429
  }
5361
5430
  function gatedContracts(contracts) {
5362
5431
  const gated = /* @__PURE__ */ new Map();
@@ -5378,7 +5447,7 @@ function gateExclusion(gated) {
5378
5447
  return (vtxo) => {
5379
5448
  const type = gatedTypeOf(vtxo, gated);
5380
5449
  if (type === void 0) return void 0;
5381
- if (!chunkVLO3JAP3_cjs.contractHandlers.has(type)) {
5450
+ if (!chunkC3NKBKRY_cjs.contractHandlers.has(type)) {
5382
5451
  return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
5383
5452
  }
5384
5453
  return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
@@ -5414,7 +5483,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
5414
5483
  continue;
5415
5484
  }
5416
5485
  for (const v of vtxos) {
5417
- if (!chunk5HCDXBBG_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
5486
+ if (!chunk4X4SY3RH_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
5418
5487
  out.add(`${v.txid}:${v.vout}`);
5419
5488
  }
5420
5489
  }
@@ -5456,7 +5525,7 @@ function byValueDescending(vtxos) {
5456
5525
  return [...vtxos].sort((a, b) => b.value - a.value);
5457
5526
  }
5458
5527
  async function fetchTimeHeight(wallet) {
5459
- return chunk5HCDXBBG_cjs.resolveTimeHeight(wallet.onchainProvider);
5528
+ return chunk4X4SY3RH_cjs.resolveTimeHeight(wallet.onchainProvider);
5460
5529
  }
5461
5530
  function heldVtxosOf(wallet) {
5462
5531
  const held = wallet.getHeldVtxos;
@@ -5467,7 +5536,7 @@ async function heldOutpointsOf(wallet) {
5467
5536
  return new Set((await heldVtxosOf(wallet)).map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
5468
5537
  }
5469
5538
  function canMigrateBySend(vtxo, now) {
5470
- if (!chunk5HCDXBBG_cjs.canSpendOffchain(vtxo, now)) return false;
5539
+ if (!chunk4X4SY3RH_cjs.canSpendOffchain(vtxo, now)) return false;
5471
5540
  return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
5472
5541
  }
5473
5542
  function byExpiryAscending(vtxos, now) {
@@ -5475,7 +5544,7 @@ function byExpiryAscending(vtxos, now) {
5475
5544
  if (vtxo.isSwept) return -Infinity;
5476
5545
  if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
5477
5546
  if (vtxo.expiresAtHeight !== void 0) {
5478
- return chunk5HCDXBBG_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
5547
+ return chunk4X4SY3RH_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
5479
5548
  }
5480
5549
  return Infinity;
5481
5550
  };
@@ -5502,7 +5571,7 @@ function priceSettlementInputs(vtxos, estimator) {
5502
5571
  const payable = [];
5503
5572
  const net = /* @__PURE__ */ new Map();
5504
5573
  for (const vtxo of vtxos) {
5505
- const inputFee = estimator.evalOffchainInput(chunk5HCDXBBG_cjs.toOffchainInputFeeParams(vtxo));
5574
+ const inputFee = estimator.evalOffchainInput(chunk4X4SY3RH_cjs.toOffchainInputFeeParams(vtxo));
5506
5575
  if (inputFee.satoshis >= vtxo.value) {
5507
5576
  continue;
5508
5577
  }
@@ -5531,7 +5600,7 @@ function offchainOutputFee(amount, estimator, arkAddress) {
5531
5600
  }
5532
5601
  const outputFee = estimator.evalOffchainOutput({
5533
5602
  amount,
5534
- script: base.hex.encode(chunkWIZCF5IX_cjs.ArkAddress.decode(arkAddress).pkScript)
5603
+ script: base.hex.encode(chunkYAVF2PR6_cjs.ArkAddress.decode(arkAddress).pkScript)
5535
5604
  });
5536
5605
  return BigInt(outputFee.satoshis);
5537
5606
  }
@@ -5582,10 +5651,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
5582
5651
  };
5583
5652
  function getRecoverableVtxos(vtxos, dustAmount, now) {
5584
5653
  return vtxos.filter((vtxo) => {
5585
- if (chunk5HCDXBBG_cjs.canRecoverOnchain(vtxo, now)) {
5654
+ if (chunk4X4SY3RH_cjs.canRecoverOnchain(vtxo, now)) {
5586
5655
  return true;
5587
5656
  }
5588
- if (chunk5HCDXBBG_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
5657
+ if (chunk4X4SY3RH_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
5589
5658
  return true;
5590
5659
  }
5591
5660
  return false;
@@ -5617,7 +5686,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
5617
5686
  function isVtxoExpiringSoon(vtxo, thresholdMs) {
5618
5687
  if (vtxo.isUnrolled) return false;
5619
5688
  const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
5620
- const expiresAt = chunk5HCDXBBG_cjs.normalizeVtxo(vtxo).expiresAt;
5689
+ const expiresAt = chunk4X4SY3RH_cjs.normalizeVtxo(vtxo).expiresAt;
5621
5690
  if (expiresAt === void 0) return false;
5622
5691
  const now = Date.now();
5623
5692
  const batchExpiry = expiresAt.getTime();
@@ -5628,7 +5697,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
5628
5697
  return vtxos.filter(
5629
5698
  // The leading exclusion covers the `isSubdust` arm too, which is a value
5630
5699
  // property and would otherwise re-admit an exited coin on its own.
5631
- (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunk5HCDXBBG_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
5700
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunk4X4SY3RH_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
5632
5701
  );
5633
5702
  }
5634
5703
  function isMigrationCapable(wallet) {
@@ -5688,7 +5757,7 @@ var VtxoManager = class _VtxoManager {
5688
5757
  constructor(wallet, settlementConfig) {
5689
5758
  this.wallet = wallet;
5690
5759
  if (settlementConfig !== false) {
5691
- chunk5HCDXBBG_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
5760
+ chunk4X4SY3RH_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
5692
5761
  }
5693
5762
  this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
5694
5763
  this.contractEventsSubscriptionReady = this.initializeSubscription();
@@ -6007,7 +6076,7 @@ var VtxoManager = class _VtxoManager {
6007
6076
  * {@link recoverImportedContracts}).
6008
6077
  */
6009
6078
  async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
6010
- const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunk5HCDXBBG_cjs.isVtxoSpent(vtxo));
6079
+ const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunk4X4SY3RH_cjs.isVtxoSpent(vtxo));
6011
6080
  const estimator = new Estimator(info?.fees.intentFee ?? {});
6012
6081
  const { payable, net } = priceSettlementInputs(recoverable, estimator);
6013
6082
  const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
@@ -6041,7 +6110,7 @@ var VtxoManager = class _VtxoManager {
6041
6110
  if (vtxos.length === 0) return;
6042
6111
  const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
6043
6112
  const stillSpendable = vtxos.some(
6044
- (vtxo) => !chunk5HCDXBBG_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
6113
+ (vtxo) => !chunk4X4SY3RH_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
6045
6114
  );
6046
6115
  if (!stillSpendable) {
6047
6116
  await wallet.removeRecoveryContract(contract.script);
@@ -6283,7 +6352,7 @@ var VtxoManager = class _VtxoManager {
6283
6352
  return txid;
6284
6353
  } catch (e) {
6285
6354
  if (!isCosignFallback(e)) throw e;
6286
- if (e instanceof chunk5HCDXBBG_cjs.OnchainCosignRejectedError) {
6355
+ if (e instanceof chunk4X4SY3RH_cjs.OnchainCosignRejectedError) {
6287
6356
  console.warn("Onchain cosign sweep rejected, falling back to CSV exit:", e.message);
6288
6357
  }
6289
6358
  return void 0;
@@ -6360,7 +6429,7 @@ var VtxoManager = class _VtxoManager {
6360
6429
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
6361
6430
  );
6362
6431
  }
6363
- const tx = new chunk5HCDXBBG_cjs.Transaction();
6432
+ const tx = new chunk4X4SY3RH_cjs.Transaction();
6364
6433
  for (const { utxo, script, leaf } of inputs) {
6365
6434
  tx.addInput({
6366
6435
  txid: utxo.txid,
@@ -6370,7 +6439,7 @@ var VtxoManager = class _VtxoManager {
6370
6439
  amount: BigInt(utxo.value)
6371
6440
  },
6372
6441
  tapLeafScript: [leaf],
6373
- sequence: chunkWIZCF5IX_cjs.getSequence(leaf)
6442
+ sequence: chunkYAVF2PR6_cjs.getSequence(leaf)
6374
6443
  });
6375
6444
  }
6376
6445
  tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
@@ -6605,8 +6674,8 @@ var VtxoManager = class _VtxoManager {
6605
6674
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
6606
6675
  if (cls.status === "CURRENT") continue;
6607
6676
  const live = vtxos.filter((v) => !v.isUnrolled);
6608
- const recoverable = live.filter((v) => v.isSwept && !chunk5HCDXBBG_cjs.isVtxoSpent(v));
6609
- const spendable = live.filter((v) => !chunk5HCDXBBG_cjs.isVtxoSpent(v) && !v.isSwept);
6677
+ const recoverable = live.filter((v) => v.isSwept && !chunk4X4SY3RH_cjs.isVtxoSpent(v));
6678
+ const spendable = live.filter((v) => !chunk4X4SY3RH_cjs.isVtxoSpent(v) && !v.isSwept);
6610
6679
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
6611
6680
  let recoverableCount = 0;
6612
6681
  let recoverableValue = 0;
@@ -6962,8 +7031,8 @@ var VtxoManager = class _VtxoManager {
6962
7031
  }
6963
7032
  /** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
6964
7033
  extractSpentOutpoint(error) {
6965
- const ark = chunk5HCDXBBG_cjs.maybeArkError(error);
6966
- if (!chunk5HCDXBBG_cjs.isArkError(ark, chunk5HCDXBBG_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
7034
+ const ark = chunk4X4SY3RH_cjs.maybeArkError(error);
7035
+ if (!chunk4X4SY3RH_cjs.isArkError(ark, chunk4X4SY3RH_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
6967
7036
  const raw = ark.metadata?.vtxo_outpoint;
6968
7037
  if (typeof raw !== "string") return void 0;
6969
7038
  const [txid, voutStr] = raw.split(":");
@@ -7144,7 +7213,7 @@ var VtxoManager = class _VtxoManager {
7144
7213
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
7145
7214
  break;
7146
7215
  }
7147
- const inputFee = estimator.evalOffchainInput(chunk5HCDXBBG_cjs.toOffchainInputFeeParams(v));
7216
+ const inputFee = estimator.evalOffchainInput(chunk4X4SY3RH_cjs.toOffchainInputFeeParams(v));
7148
7217
  if (inputFee.satoshis >= v.value) {
7149
7218
  continue;
7150
7219
  }
@@ -7164,7 +7233,7 @@ var VtxoManager = class _VtxoManager {
7164
7233
  const arkAddress = await this.wallet.getAddress();
7165
7234
  const outputFee = estimator.evalOffchainOutput({
7166
7235
  amount: totalAmount,
7167
- script: base.hex.encode(chunkWIZCF5IX_cjs.ArkAddress.decode(arkAddress).pkScript)
7236
+ script: base.hex.encode(chunkYAVF2PR6_cjs.ArkAddress.decode(arkAddress).pkScript)
7168
7237
  });
7169
7238
  totalAmount -= BigInt(outputFee.satoshis);
7170
7239
  if (totalAmount < dustAmount) return;
@@ -7259,7 +7328,7 @@ var ArkNote = class _ArkNote {
7259
7328
  this.value = value;
7260
7329
  this.HRP = HRP;
7261
7330
  const preimageHash = utils_js.sha256(this.preimage);
7262
- this.vtxoScript = new chunkWIZCF5IX_cjs.VtxoScript([noteTapscript(preimageHash)]);
7331
+ this.vtxoScript = new chunkYAVF2PR6_cjs.VtxoScript([noteTapscript(preimageHash)]);
7263
7332
  const leaf = this.vtxoScript.leaves[0];
7264
7333
  this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
7265
7334
  this.tapTree = this.vtxoScript.encode();
@@ -7436,7 +7505,7 @@ var ArkadeCash = class _ArkadeCash {
7436
7505
  const privateKey = data.slice(1, 33);
7437
7506
  const serverPubKey = data.slice(33, 65);
7438
7507
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
7439
- const csvTimelock = chunkWIZCF5IX_cjs.sequenceToTimelock(sequence);
7508
+ const csvTimelock = chunkYAVF2PR6_cjs.sequenceToTimelock(sequence);
7440
7509
  return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
7441
7510
  }
7442
7511
  toString() {
@@ -7444,7 +7513,7 @@ var ArkadeCash = class _ArkadeCash {
7444
7513
  data[0] = _ArkadeCash.Version;
7445
7514
  data.set(this._privateKey, 1);
7446
7515
  data.set(this._serverPubKey, 33);
7447
- const sequence = chunkWIZCF5IX_cjs.timelockToSequence(this.csvTimelock);
7516
+ const sequence = chunkYAVF2PR6_cjs.timelockToSequence(this.csvTimelock);
7448
7517
  new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
7449
7518
  const words = base.bech32m.toWords(data);
7450
7519
  return base.bech32m.encode(this.hrp, words, 1023);
@@ -7453,7 +7522,7 @@ var ArkadeCash = class _ArkadeCash {
7453
7522
  return SingleKey.fromPrivateKey(this._privateKey);
7454
7523
  }
7455
7524
  get vtxoScript() {
7456
- return new chunkVLO3JAP3_cjs.DefaultVtxo.Script({
7525
+ return new chunkC3NKBKRY_cjs.DefaultVtxo.Script({
7457
7526
  pubKey: this._publicKey,
7458
7527
  serverPubKey: this._serverPubKey,
7459
7528
  csvTimelock: this.csvTimelock
@@ -7553,7 +7622,7 @@ async function arkadeCashActivity(records, txs) {
7553
7622
  // src/wallet/intentReconciliation.ts
7554
7623
  var NON_TERMINAL_INTENT_STATES = ALL_BATCH_REGISTRATION_STATES.filter((s) => !isTerminalBatchRegistrationState(s));
7555
7624
  function isConsumed(vtxo) {
7556
- return vtxo !== void 0 && chunk5HCDXBBG_cjs.isVtxoSpent(vtxo);
7625
+ return vtxo !== void 0 && chunk4X4SY3RH_cjs.isVtxoSpent(vtxo);
7557
7626
  }
7558
7627
  async function classifyIntent(intent, vtxosByOutpoint, now) {
7559
7628
  if (isTerminalBatchRegistrationState(intent.state)) return void 0;
@@ -7591,7 +7660,7 @@ async function reconcileIntents(deps) {
7591
7660
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
7592
7661
  if (outpoints.length > 0) {
7593
7662
  try {
7594
- const { vtxos } = await chunk5HCDXBBG_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
7663
+ const { vtxos } = await chunk4X4SY3RH_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
7595
7664
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
7596
7665
  } catch (e) {
7597
7666
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -7651,7 +7720,7 @@ async function releaseFromServer(intent, deps, now) {
7651
7720
  });
7652
7721
  }
7653
7722
  function isNoMatchingIntentsError(e) {
7654
- return chunk5HCDXBBG_cjs.isArkError(e, chunk5HCDXBBG_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
7723
+ return chunk4X4SY3RH_cjs.isArkError(e, chunk4X4SY3RH_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
7655
7724
  }
7656
7725
  function terminal(intent, state, now, patch) {
7657
7726
  return { ...intent, ...patch, state, updatedAt: now };
@@ -7878,7 +7947,7 @@ async function captureExitBranch(params) {
7878
7947
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
7879
7948
  if (nonCommitment.length > 0) {
7880
7949
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
7881
- psbtByTxid.set(chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
7950
+ psbtByTxid.set(chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
7882
7951
  }
7883
7952
  }
7884
7953
  }
@@ -7916,10 +7985,10 @@ var IndexerExitDataSource = class {
7916
7985
  name = "indexer";
7917
7986
  async getVtxoChain(vtxo) {
7918
7987
  const chain = [];
7919
- for await (const { chain: page } of chunk5HCDXBBG_cjs.indexerPages(
7988
+ for await (const { chain: page } of chunk4X4SY3RH_cjs.indexerPages(
7920
7989
  (pageIndex) => this.indexer.getVtxoChain(
7921
7990
  { txid: vtxo.txid, vout: vtxo.vout },
7922
- { pageIndex, pageSize: chunk5HCDXBBG_cjs.DEFAULT_PAGE_SIZE }
7991
+ { pageIndex, pageSize: chunk4X4SY3RH_cjs.DEFAULT_PAGE_SIZE }
7923
7992
  )
7924
7993
  )) {
7925
7994
  chain.push(...page);
@@ -7928,11 +7997,11 @@ var IndexerExitDataSource = class {
7928
7997
  }
7929
7998
  async getVirtualTxs(txids) {
7930
7999
  const out = /* @__PURE__ */ new Map();
7931
- for await (const { txs } of chunk5HCDXBBG_cjs.indexerPages(
7932
- (pageIndex) => this.indexer.getVirtualTxs(txids, { pageIndex, pageSize: chunk5HCDXBBG_cjs.DEFAULT_PAGE_SIZE })
8000
+ for await (const { txs } of chunk4X4SY3RH_cjs.indexerPages(
8001
+ (pageIndex) => this.indexer.getVirtualTxs(txids, { pageIndex, pageSize: chunk4X4SY3RH_cjs.DEFAULT_PAGE_SIZE })
7933
8002
  )) {
7934
8003
  for (const psbt of txs) {
7935
- out.set(chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
8004
+ out.set(chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
7936
8005
  }
7937
8006
  }
7938
8007
  return out;
@@ -7953,7 +8022,7 @@ function chainedTxTypeToChainTxType(t) {
7953
8022
  }
7954
8023
  }
7955
8024
  function psbtInputTxids(psbtBase64) {
7956
- return txInputTxids(chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
8025
+ return txInputTxids(chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
7957
8026
  }
7958
8027
  function txInputTxids(tx) {
7959
8028
  const ids = [];
@@ -8260,10 +8329,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
8260
8329
  try {
8261
8330
  info = await arkProvider.getInfo();
8262
8331
  } catch (err) {
8263
- if (opts?.requireLive || !chunk5HCDXBBG_cjs.isRetryableProviderError(err)) throw err;
8332
+ if (opts?.requireLive || !chunk4X4SY3RH_cjs.isRetryableProviderError(err)) throw err;
8264
8333
  const snapshot = await loadArkInfoSnapshot(walletRepository);
8265
8334
  if (!snapshot) {
8266
- throw new chunk5HCDXBBG_cjs.ProviderUnavailableError(
8335
+ throw new chunk4X4SY3RH_cjs.ProviderUnavailableError(
8267
8336
  "Operator info is unavailable and no cached snapshot exists",
8268
8337
  { cause: err }
8269
8338
  );
@@ -8443,7 +8512,7 @@ function buildGraph(rootTxid, chunksByTxid, visited = /* @__PURE__ */ new Set())
8443
8512
  return new TxTree(rootTx, children);
8444
8513
  }
8445
8514
  function decodeNode(chunk) {
8446
- const tx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
8515
+ const tx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
8447
8516
  return { tx, children: chunk.children };
8448
8517
  }
8449
8518
  exports.Batch = void 0;
@@ -8667,7 +8736,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
8667
8736
  return [...txids];
8668
8737
  }
8669
8738
  async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
8670
- const normalized = vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
8739
+ const normalized = vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
8671
8740
  const localCreatedAt = localCreatedAtByTxid(normalized);
8672
8741
  const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
8673
8742
  const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
@@ -8854,7 +8923,7 @@ var AssetManager = class extends ReadonlyAssetManager {
8854
8923
  withRecoverable: false,
8855
8924
  genericallySpendableOnly: true
8856
8925
  });
8857
- const controlAssetRef = params.controlAssetId ? chunkGEK6QBSY_cjs.AssetRef.fromId(chunkGEK6QBSY_cjs.AssetId.fromString(params.controlAssetId)) : null;
8926
+ const controlAssetRef = params.controlAssetId ? chunkQV7AOZZN_cjs.AssetRef.fromId(chunkQV7AOZZN_cjs.AssetId.fromString(params.controlAssetId)) : null;
8858
8927
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
8859
8928
  let totalBtcSelected = 0n;
8860
8929
  const assetChanges = /* @__PURE__ */ new Map();
@@ -8867,8 +8936,8 @@ var AssetManager = class extends ReadonlyAssetManager {
8867
8936
  }
8868
8937
  }
8869
8938
  const groups = [];
8870
- const issuedAssetOutput = chunkGEK6QBSY_cjs.AssetOutput.create(0, params.amount);
8871
- const issuedAssetGroup = chunkGEK6QBSY_cjs.AssetGroup.create(
8939
+ const issuedAssetOutput = chunkQV7AOZZN_cjs.AssetOutput.create(0, params.amount);
8940
+ const issuedAssetGroup = chunkQV7AOZZN_cjs.AssetGroup.create(
8872
8941
  null,
8873
8942
  controlAssetRef,
8874
8943
  [],
@@ -8881,11 +8950,11 @@ var AssetManager = class extends ReadonlyAssetManager {
8881
8950
  for (const [assetId, amount] of assetChanges) {
8882
8951
  const changeInputs = inputsForAsset(assetInputs, assetId);
8883
8952
  groups.push(
8884
- chunkGEK6QBSY_cjs.AssetGroup.create(
8885
- chunkGEK6QBSY_cjs.AssetId.fromString(assetId),
8953
+ chunkQV7AOZZN_cjs.AssetGroup.create(
8954
+ chunkQV7AOZZN_cjs.AssetId.fromString(assetId),
8886
8955
  null,
8887
8956
  changeInputs,
8888
- [chunkGEK6QBSY_cjs.AssetOutput.create(0, amount)],
8957
+ [chunkQV7AOZZN_cjs.AssetOutput.create(0, amount)],
8889
8958
  []
8890
8959
  )
8891
8960
  );
@@ -8900,7 +8969,7 @@ var AssetManager = class extends ReadonlyAssetManager {
8900
8969
  );
8901
8970
  return {
8902
8971
  arkTxId: arkTxid,
8903
- assetId: chunkGEK6QBSY_cjs.AssetId.create(arkTxid, 0).toString()
8972
+ assetId: chunkQV7AOZZN_cjs.AssetId.create(arkTxid, 0).toString()
8904
8973
  };
8905
8974
  }
8906
8975
  /**
@@ -8974,23 +9043,23 @@ var AssetManager = class extends ReadonlyAssetManager {
8974
9043
  const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
8975
9044
  const reissueInputs = inputsForAsset(assetInputs, params.assetId);
8976
9045
  const totalAssetAmount = assetToReissueAmount + params.amount;
8977
- const reissueAssetIdObj = chunkGEK6QBSY_cjs.AssetId.fromString(params.assetId);
8978
- const reissueAssetGroup = chunkGEK6QBSY_cjs.AssetGroup.create(
9046
+ const reissueAssetIdObj = chunkQV7AOZZN_cjs.AssetId.fromString(params.assetId);
9047
+ const reissueAssetGroup = chunkQV7AOZZN_cjs.AssetGroup.create(
8979
9048
  reissueAssetIdObj,
8980
9049
  null,
8981
9050
  reissueInputs,
8982
- [chunkGEK6QBSY_cjs.AssetOutput.create(0, totalAssetAmount)],
9051
+ [chunkQV7AOZZN_cjs.AssetOutput.create(0, totalAssetAmount)],
8983
9052
  []
8984
9053
  );
8985
9054
  const groups = [reissueAssetGroup];
8986
9055
  for (const [assetId, amount] of assetChanges) {
8987
9056
  const changeInputs = inputsForAsset(assetInputs, assetId);
8988
9057
  groups.push(
8989
- chunkGEK6QBSY_cjs.AssetGroup.create(
8990
- chunkGEK6QBSY_cjs.AssetId.fromString(assetId),
9058
+ chunkQV7AOZZN_cjs.AssetGroup.create(
9059
+ chunkQV7AOZZN_cjs.AssetId.fromString(assetId),
8991
9060
  null,
8992
9061
  changeInputs,
8993
- [chunkGEK6QBSY_cjs.AssetOutput.create(0, amount)],
9062
+ [chunkQV7AOZZN_cjs.AssetOutput.create(0, amount)],
8994
9063
  []
8995
9064
  )
8996
9065
  );
@@ -9061,11 +9130,11 @@ var AssetManager = class extends ReadonlyAssetManager {
9061
9130
  for (const [assetId, amount] of assetChanges) {
9062
9131
  const changeInputs = inputsForAsset(assetInputs, assetId);
9063
9132
  groups.push(
9064
- chunkGEK6QBSY_cjs.AssetGroup.create(
9065
- chunkGEK6QBSY_cjs.AssetId.fromString(assetId),
9133
+ chunkQV7AOZZN_cjs.AssetGroup.create(
9134
+ chunkQV7AOZZN_cjs.AssetId.fromString(assetId),
9066
9135
  null,
9067
9136
  changeInputs,
9068
- amount > 0n ? [chunkGEK6QBSY_cjs.AssetOutput.create(0, amount)] : [],
9137
+ amount > 0n ? [chunkQV7AOZZN_cjs.AssetOutput.create(0, amount)] : [],
9069
9138
  []
9070
9139
  )
9071
9140
  );
@@ -9078,16 +9147,16 @@ function inputsForAsset(assetInputs, assetId) {
9078
9147
  for (const [inputIndex, assets] of assetInputs) {
9079
9148
  for (const asset of assets) {
9080
9149
  if (asset.assetId !== assetId) continue;
9081
- inputs.push(chunkGEK6QBSY_cjs.AssetInput.create(inputIndex, asset.amount));
9150
+ inputs.push(chunkQV7AOZZN_cjs.AssetInput.create(inputIndex, asset.amount));
9082
9151
  }
9083
9152
  }
9084
9153
  return inputs;
9085
9154
  }
9086
9155
  async function submitToSelf(submit, wallet, inputs, amount, groups) {
9087
- const outputAddress = chunkWIZCF5IX_cjs.ArkAddress.decode(await wallet.getAddress());
9156
+ const outputAddress = chunkYAVF2PR6_cjs.ArkAddress.decode(await wallet.getAddress());
9088
9157
  const outputs = [
9089
9158
  { script: outputAddress.pkScript, amount: BigInt(amount) },
9090
- Extension.create([chunkGEK6QBSY_cjs.Packet.create(groups)]).txOut()
9159
+ Extension.create([chunkQV7AOZZN_cjs.Packet.create(groups)]).txOut()
9091
9160
  ];
9092
9161
  const { arkTxid } = await submit(inputs, outputs);
9093
9162
  return arkTxid;
@@ -9111,7 +9180,7 @@ function castMetadata(metadata) {
9111
9180
  } else {
9112
9181
  throw new Error("Invalid metadata value type");
9113
9182
  }
9114
- md.push(chunkGEK6QBSY_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
9183
+ md.push(chunkQV7AOZZN_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
9115
9184
  }
9116
9185
  return md;
9117
9186
  }
@@ -9132,12 +9201,12 @@ var DelegateManagerImpl = class {
9132
9201
  if (vtxos.length === 0) {
9133
9202
  return { delegated: [], failed: [] };
9134
9203
  }
9135
- const destinationScript = chunkWIZCF5IX_cjs.ArkAddress.decode(destination).pkScript;
9204
+ const destinationScript = chunkYAVF2PR6_cjs.ArkAddress.decode(destination).pkScript;
9136
9205
  const [arkInfo, delegateInfo] = await Promise.all([
9137
9206
  this.arkInfoProvider.getInfo(),
9138
9207
  this.delegateProvider.getDelegateInfo()
9139
9208
  ]);
9140
- const eligible = vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo).filter(
9209
+ const eligible = vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo).filter(
9141
9210
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
9142
9211
  );
9143
9212
  if (eligible.length === 0) {
@@ -9169,7 +9238,7 @@ var DelegateManagerImpl = class {
9169
9238
  const groupByExpiry = /* @__PURE__ */ new Map();
9170
9239
  let recoverableVtxos = [];
9171
9240
  for (const vtxo of eligible) {
9172
- if (chunk5HCDXBBG_cjs.canRecoverOnchain(vtxo, now)) {
9241
+ if (chunk4X4SY3RH_cjs.canRecoverOnchain(vtxo, now)) {
9173
9242
  recoverableVtxos.push(vtxo);
9174
9243
  continue;
9175
9244
  }
@@ -9221,7 +9290,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
9221
9290
  }
9222
9291
  if (!delegateAt) {
9223
9292
  const now = { timestamp: /* @__PURE__ */ new Date() };
9224
- const expiryTimestamp = vtxos.filter((coin) => !chunk5HCDXBBG_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
9293
+ const expiryTimestamp = vtxos.filter((coin) => !chunk4X4SY3RH_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
9225
9294
  (min, coin) => Math.min(min, coin.expiresAt.getTime()),
9226
9295
  Number.MAX_SAFE_INTEGER
9227
9296
  );
@@ -9241,7 +9310,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
9241
9310
  let amount = 0n;
9242
9311
  for (const coin of vtxos) {
9243
9312
  const inputFee = estimator.evalOffchainInput({
9244
- ...chunk5HCDXBBG_cjs.toOffchainInputFeeParams(coin),
9313
+ ...chunk4X4SY3RH_cjs.toOffchainInputFeeParams(coin),
9245
9314
  type: "vtxo"
9246
9315
  });
9247
9316
  if (inputFee.satoshis >= coin.value) {
@@ -9255,7 +9324,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
9255
9324
  const delegateFee = BigInt(Number(fee));
9256
9325
  if (delegateFee > 0n) {
9257
9326
  outputs.push({
9258
- script: chunkWIZCF5IX_cjs.ArkAddress.decode(delegateAddress).pkScript,
9327
+ script: chunkYAVF2PR6_cjs.ArkAddress.decode(delegateAddress).pkScript,
9259
9328
  amount: delegateFee
9260
9329
  });
9261
9330
  }
@@ -9293,10 +9362,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
9293
9362
  destinationScript
9294
9363
  );
9295
9364
  const forfeitOutputScript = btcSigner.OutScript.encode(
9296
- btcSigner.Address(chunkWIZCF5IX_cjs.getNetwork(network)).decode(forfeitAddress)
9365
+ btcSigner.Address(chunkYAVF2PR6_cjs.getNetwork(network)).decode(forfeitAddress)
9297
9366
  );
9298
9367
  const forfeits = await Promise.all(
9299
- vtxos.filter((v) => chunk5HCDXBBG_cjs.requiresForfeit(v)).map(async (coin) => {
9368
+ vtxos.filter((v) => chunk4X4SY3RH_cjs.requiresForfeit(v)).map(async (coin) => {
9300
9369
  const forfeit = await makeDelegateForfeitTx(
9301
9370
  coin,
9302
9371
  dust,
@@ -9321,7 +9390,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
9321
9390
  index: input.vout,
9322
9391
  witnessUtxo: {
9323
9392
  amount: BigInt(input.value),
9324
- script: chunkWIZCF5IX_cjs.VtxoScript.decode(input.tapTree).pkScript
9393
+ script: chunkYAVF2PR6_cjs.VtxoScript.decode(input.tapTree).pkScript
9325
9394
  },
9326
9395
  sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
9327
9396
  tapLeafScript: [delegateTapLeaf]
@@ -9379,7 +9448,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
9379
9448
  expire_at: 0,
9380
9449
  cosigners_public_keys: cosignerPubKeys
9381
9450
  };
9382
- const proof = chunk5HCDXBBG_cjs.Proof.create(message, coins, outputs);
9451
+ const proof = chunk4X4SY3RH_cjs.Proof.create(message, coins, outputs);
9383
9452
  const signedProof = await identity.sign(proof);
9384
9453
  return {
9385
9454
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -9397,10 +9466,10 @@ function getDayTimestamp(timestamp) {
9397
9466
  function findDelegateTapLeaf(vtxo, delegatePubkey) {
9398
9467
  if (!vtxo.tapTree) return void 0;
9399
9468
  const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
9400
- const vtxoScript = chunkWIZCF5IX_cjs.VtxoScript.decode(vtxo.tapTree);
9469
+ const vtxoScript = chunkYAVF2PR6_cjs.VtxoScript.decode(vtxo.tapTree);
9401
9470
  return vtxoScript.leaves.find((tapLeaf) => {
9402
- const arkTapscript = chunkWIZCF5IX_cjs.decodeTapscript(chunkWIZCF5IX_cjs.scriptFromTapLeafScript(tapLeaf));
9403
- if (!chunkWIZCF5IX_cjs.MultisigTapscript.is(arkTapscript)) return false;
9471
+ const arkTapscript = chunkYAVF2PR6_cjs.decodeTapscript(chunkYAVF2PR6_cjs.scriptFromTapLeafScript(tapLeaf));
9472
+ if (!chunkYAVF2PR6_cjs.MultisigTapscript.is(arkTapscript)) return false;
9404
9473
  return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
9405
9474
  });
9406
9475
  }
@@ -10152,7 +10221,7 @@ function decodeArkContract(encoded) {
10152
10221
  }
10153
10222
  function contractFromArkContract(encoded, options = {}) {
10154
10223
  const parsed = decodeArkContract(encoded);
10155
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(parsed.type);
10224
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(parsed.type);
10156
10225
  if (!handler) {
10157
10226
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
10158
10227
  }
@@ -10166,9 +10235,9 @@ function contractFromArkContract(encoded, options = {}) {
10166
10235
  metadata: options.metadata
10167
10236
  };
10168
10237
  }
10169
- function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkWIZCF5IX_cjs.DEFAULT_NETWORK.hrp, options = {}) {
10238
+ function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkYAVF2PR6_cjs.DEFAULT_NETWORK.hrp, options = {}) {
10170
10239
  const parsed = decodeArkContract(encoded);
10171
- const handler = chunkVLO3JAP3_cjs.contractHandlers.getOrThrow(parsed.type);
10240
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.getOrThrow(parsed.type);
10172
10241
  const params = parsed.data;
10173
10242
  const vtxoScript = handler.createScript(params);
10174
10243
  return {
@@ -10227,10 +10296,10 @@ var ContractWatcher = class {
10227
10296
  eventSourceReported = false;
10228
10297
  /** @see ContractWatcherConfig */
10229
10298
  constructor(config) {
10230
- chunk5HCDXBBG_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
10231
- chunk5HCDXBBG_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
10232
- chunk5HCDXBBG_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
10233
- chunk5HCDXBBG_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
10299
+ chunk4X4SY3RH_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
10300
+ chunk4X4SY3RH_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
10301
+ chunk4X4SY3RH_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
10302
+ chunk4X4SY3RH_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
10234
10303
  if (config.subscriptionRequestTimeoutMs === 0) {
10235
10304
  throw new Error("subscriptionRequestTimeoutMs must be greater than 0");
10236
10305
  }
@@ -10455,9 +10524,9 @@ var ContractWatcher = class {
10455
10524
  this.connectedAt = Date.now();
10456
10525
  this.listenLoop().catch((e) => {
10457
10526
  if (!this.isWatching || signal?.aborted) return;
10458
- if (chunk5HCDXBBG_cjs.isEventSourceError(e)) {
10527
+ if (chunk4X4SY3RH_cjs.isEventSourceError(e)) {
10459
10528
  console.debug("ContractWatcher subscription disconnected; reconnecting");
10460
- } else if (!chunk5HCDXBBG_cjs.isEventSourceUnavailableError(e)) {
10529
+ } else if (!chunk4X4SY3RH_cjs.isEventSourceUnavailableError(e)) {
10461
10530
  console.error(e);
10462
10531
  }
10463
10532
  this.connectionState = "disconnected";
@@ -10467,7 +10536,7 @@ var ContractWatcher = class {
10467
10536
  });
10468
10537
  } catch (error) {
10469
10538
  if (!this.isWatching || signal?.aborted) return;
10470
- if (!chunk5HCDXBBG_cjs.isEventSourceUnavailableError(error)) {
10539
+ if (!chunk4X4SY3RH_cjs.isEventSourceUnavailableError(error)) {
10471
10540
  console.error("ContractWatcher connection failed:", error);
10472
10541
  }
10473
10542
  this.connectionState = "disconnected";
@@ -10483,7 +10552,7 @@ var ContractWatcher = class {
10483
10552
  * few seconds.
10484
10553
  */
10485
10554
  reportEventSourceUnavailable(error) {
10486
- if (!chunk5HCDXBBG_cjs.isEventSourceUnavailableError(error)) return false;
10555
+ if (!chunk4X4SY3RH_cjs.isEventSourceUnavailableError(error)) return false;
10487
10556
  if (!this.eventSourceReported) {
10488
10557
  this.eventSourceReported = true;
10489
10558
  console.warn(
@@ -10524,7 +10593,7 @@ var ContractWatcher = class {
10524
10593
  this.config.reconnectDelayMs,
10525
10594
  this.config.maxReconnectDelayMs
10526
10595
  );
10527
- const askedFor = Math.min(chunk5HCDXBBG_cjs.retryAfterMsFromError(failure) ?? 0, chunk5HCDXBBG_cjs.MAX_COOLDOWN_MS);
10596
+ const askedFor = Math.min(chunk4X4SY3RH_cjs.retryAfterMsFromError(failure) ?? 0, chunk4X4SY3RH_cjs.MAX_COOLDOWN_MS);
10528
10597
  const floor = Math.max(capped / 2, askedFor);
10529
10598
  const ceiling = Math.max(capped, askedFor * 1.5);
10530
10599
  return floor + Math.random() * (ceiling - floor);
@@ -10564,7 +10633,7 @@ var ContractWatcher = class {
10564
10633
  const now = Date.now();
10565
10634
  let current;
10566
10635
  try {
10567
- current = await chunk5HCDXBBG_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
10636
+ current = await chunk4X4SY3RH_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
10568
10637
  spendableOnly: true
10569
10638
  });
10570
10639
  } catch (error) {
@@ -10846,14 +10915,14 @@ var ContractWatcher = class {
10846
10915
  const timestamp = Date.now();
10847
10916
  if (update.newVtxos?.length) {
10848
10917
  this.processSubscriptionVtxos(
10849
- update.newVtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo),
10918
+ update.newVtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo),
10850
10919
  "vtxo_received",
10851
10920
  timestamp
10852
10921
  );
10853
10922
  }
10854
10923
  if (update.spentVtxos?.length) {
10855
10924
  this.processSubscriptionVtxos(
10856
- update.spentVtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo),
10925
+ update.spentVtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo),
10857
10926
  "vtxo_spent",
10858
10927
  timestamp
10859
10928
  );
@@ -10878,8 +10947,8 @@ var ContractWatcher = class {
10878
10947
  continue;
10879
10948
  }
10880
10949
  if (target === byWatchedScript && eventType === "vtxo_received") {
10881
- const n = chunk5HCDXBBG_cjs.normalizeVtxo(vtxo);
10882
- if (chunk5HCDXBBG_cjs.isVtxoSpent(n) || n.isSwept || chunk5HCDXBBG_cjs.isPastExpiry(n, now)) continue;
10950
+ const n = chunk4X4SY3RH_cjs.normalizeVtxo(vtxo);
10951
+ if (chunk4X4SY3RH_cjs.isVtxoSpent(n) || n.isSwept || chunk4X4SY3RH_cjs.isPastExpiry(n, now)) continue;
10883
10952
  }
10884
10953
  let bucket = target.get(vtxo.script);
10885
10954
  if (!bucket) {
@@ -11067,7 +11136,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
11067
11136
  if (!contract) continue;
11068
11137
  try {
11069
11138
  const key = contractKey(contract);
11070
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
11139
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
11071
11140
  const hit = memo?.get(script);
11072
11141
  let tapscripts;
11073
11142
  if (hit && hit.key === key && hit.handler === handler) {
@@ -11088,7 +11157,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
11088
11157
  scripts.add(script);
11089
11158
  } catch (err) {
11090
11159
  const reason = `'${contract.type}' at ${script}: ${err instanceof Error ? err.message : String(err)}`;
11091
- if (err instanceof chunkUPIQZRNJ_cjs.UnsupportedProgramVersionError) {
11160
+ if (err instanceof chunkJA4SYFC7_cjs.UnsupportedProgramVersionError) {
11092
11161
  unsupported.set(script, { key: contractKey(contract), reason });
11093
11162
  } else {
11094
11163
  failures.set(script, reason);
@@ -11099,7 +11168,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
11099
11168
  }
11100
11169
  function annotateAgainst(vtxos, byScript, tapscripts = /* @__PURE__ */ new Map()) {
11101
11170
  return vtxos.map(
11102
- (vtxo) => extendVirtualCoinForContract(chunk5HCDXBBG_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
11171
+ (vtxo) => extendVirtualCoinForContract(chunk4X4SY3RH_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
11103
11172
  );
11104
11173
  }
11105
11174
  var SCAN_MAX_INDEX = 1e4;
@@ -11148,8 +11217,8 @@ var ContractManager = class _ContractManager {
11148
11217
  /** Serializes onchain read-modify-writes so a pending spender is never overwritten. */
11149
11218
  onchainChain = Promise.resolve();
11150
11219
  constructor(config) {
11151
- chunk5HCDXBBG_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
11152
- chunk5HCDXBBG_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
11220
+ chunk4X4SY3RH_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
11221
+ chunk4X4SY3RH_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
11153
11222
  this.config = { ...config };
11154
11223
  if (config.onchainProvider && config.network) {
11155
11224
  this.onchainWatcher = new OnchainContractWatcher({
@@ -11194,12 +11263,12 @@ var ContractManager = class _ContractManager {
11194
11263
  }
11195
11264
  /** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
11196
11265
  setVtxoSyncMaxAge(maxAgeMs) {
11197
- chunk5HCDXBBG_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
11266
+ chunk4X4SY3RH_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
11198
11267
  this.config.vtxoSyncMaxAgeMs = maxAgeMs;
11199
11268
  }
11200
11269
  /** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
11201
11270
  setVtxoSyncOverlap(overlapMs) {
11202
- chunk5HCDXBBG_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
11271
+ chunk4X4SY3RH_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
11203
11272
  this.config.vtxoSyncOverlapMs = overlapMs;
11204
11273
  }
11205
11274
  markSyncOnline() {
@@ -11263,10 +11332,10 @@ var ContractManager = class _ContractManager {
11263
11332
  if (this.unsupportedContracts.get(contract.script) === key) return true;
11264
11333
  if (this.tapscriptMemo.get(contract.script)?.key === key) return false;
11265
11334
  try {
11266
- chunkVLO3JAP3_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
11335
+ chunkC3NKBKRY_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
11267
11336
  return false;
11268
11337
  } catch (err) {
11269
- if (!(err instanceof chunkUPIQZRNJ_cjs.UnsupportedProgramVersionError)) return false;
11338
+ if (!(err instanceof chunkJA4SYFC7_cjs.UnsupportedProgramVersionError)) return false;
11270
11339
  this.unsupportedContracts.set(contract.script, key);
11271
11340
  return true;
11272
11341
  }
@@ -11279,7 +11348,7 @@ var ContractManager = class _ContractManager {
11279
11348
  this.markSyncOnline();
11280
11349
  return void 0;
11281
11350
  } catch (err) {
11282
- if (!chunk5HCDXBBG_cjs.isRetryableProviderError(err)) throw err;
11351
+ if (!chunk4X4SY3RH_cjs.isRetryableProviderError(err)) throw err;
11283
11352
  this.markSyncDegraded(err);
11284
11353
  return err;
11285
11354
  }
@@ -11302,7 +11371,7 @@ var ContractManager = class _ContractManager {
11302
11371
  try {
11303
11372
  await this.scheduleLookAheadDrain();
11304
11373
  } catch (err) {
11305
- if (!chunk5HCDXBBG_cjs.isRetryableProviderError(err)) throw err;
11374
+ if (!chunk4X4SY3RH_cjs.isRetryableProviderError(err)) throw err;
11306
11375
  this.lookAheadRefillOwed = true;
11307
11376
  this.markSyncDegraded(err);
11308
11377
  }
@@ -11365,7 +11434,7 @@ var ContractManager = class _ContractManager {
11365
11434
  /** No throw: construction returned long ago, so the state is the channel. */
11366
11435
  reportBackgroundFailure(stage, err) {
11367
11436
  this.markSyncDegraded(err);
11368
- if (!chunk5HCDXBBG_cjs.isRetryableProviderError(err)) {
11437
+ if (!chunk4X4SY3RH_cjs.isRetryableProviderError(err)) {
11369
11438
  console.error(`[contracts] background ${stage} failed`, err);
11370
11439
  }
11371
11440
  }
@@ -11477,7 +11546,7 @@ var ContractManager = class _ContractManager {
11477
11546
  const from = Math.max(0, watermark - lookAhead.size);
11478
11547
  const to = watermark + lookAhead.size;
11479
11548
  const deps = lookAhead.candidateDeps();
11480
- const handlers = chunkVLO3JAP3_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkVLO3JAP3_cjs.contractHandlers.get(t)).filter(hasCandidates);
11549
+ const handlers = chunkC3NKBKRY_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkC3NKBKRY_cjs.contractHandlers.get(t)).filter(hasCandidates);
11481
11550
  const band = /* @__PURE__ */ new Map();
11482
11551
  for (let index = from; index <= to; index++) {
11483
11552
  const descriptor = lookAhead.materialize(index);
@@ -11488,7 +11557,7 @@ var ContractManager = class _ContractManager {
11488
11557
  index,
11489
11558
  params: {
11490
11559
  ...candidate,
11491
- ...chunkVLO3JAP3_cjs.speculativeReceiveMetadata(descriptor)
11560
+ ...chunkC3NKBKRY_cjs.speculativeReceiveMetadata(descriptor)
11492
11561
  }
11493
11562
  });
11494
11563
  }
@@ -11547,7 +11616,7 @@ var ContractManager = class _ContractManager {
11547
11616
  });
11548
11617
  for (const entry of pending) entry.catchUpPending = false;
11549
11618
  } catch (err) {
11550
- if (!chunk5HCDXBBG_cjs.isRetryableProviderError(err)) throw err;
11619
+ if (!chunk4X4SY3RH_cjs.isRetryableProviderError(err)) throw err;
11551
11620
  this.markSyncDegraded(err);
11552
11621
  }
11553
11622
  }
@@ -11638,7 +11707,7 @@ var ContractManager = class _ContractManager {
11638
11707
  return result;
11639
11708
  }
11640
11709
  async upsertContractRow(params) {
11641
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(params.type);
11710
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(params.type);
11642
11711
  if (!handler) {
11643
11712
  throw new Error(`No handler registered for contract type '${params.type}'`);
11644
11713
  }
@@ -11740,7 +11809,7 @@ var ContractManager = class _ContractManager {
11740
11809
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
11741
11810
  );
11742
11811
  }
11743
- const registered = chunkVLO3JAP3_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkVLO3JAP3_cjs.contractHandlers.get(t)).filter(isDiscoverable);
11812
+ const registered = chunkC3NKBKRY_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkC3NKBKRY_cjs.contractHandlers.get(t)).filter(isDiscoverable);
11744
11813
  const discoverables = [
11745
11814
  ...registered.filter((h) => h.type === "boarding"),
11746
11815
  ...registered.filter((h) => h.type !== "boarding")
@@ -11871,7 +11940,7 @@ var ContractManager = class _ContractManager {
11871
11940
  return contracts.filter((contract) => this.isUnsupported(contract));
11872
11941
  }
11873
11942
  async getContractsWithVtxos(filter, pageSize, options) {
11874
- chunk5HCDXBBG_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
11943
+ chunk4X4SY3RH_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
11875
11944
  const contracts = await this.getContracts(filter);
11876
11945
  if (this.syncedWithin(
11877
11946
  contracts,
@@ -11979,7 +12048,7 @@ var ContractManager = class _ContractManager {
11979
12048
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
11980
12049
  const asking = vtxos.filter((vtxo) => {
11981
12050
  const contract = byScript.get(vtxo.script);
11982
- return contract !== void 0 && chunkVLO3JAP3_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
12051
+ return contract !== void 0 && chunkC3NKBKRY_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
11983
12052
  });
11984
12053
  if (asking.length === 0) return refused;
11985
12054
  const [tip, walletDescriptorValue] = await Promise.all([
@@ -11988,7 +12057,7 @@ var ContractManager = class _ContractManager {
11988
12057
  ]);
11989
12058
  for (const vtxo of asking) {
11990
12059
  const contract = byScript.get(vtxo.script);
11991
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
12060
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
11992
12061
  if (!handler?.assertSpendableNow) continue;
11993
12062
  const context = {
11994
12063
  collaborative: true,
@@ -11998,7 +12067,7 @@ var ContractManager = class _ContractManager {
11998
12067
  walletDescriptor: walletDescriptorValue,
11999
12068
  // `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
12000
12069
  // reads `vtxo.status.block_time` unguarded, so require `status` too.
12001
- vtxo: chunk5HCDXBBG_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
12070
+ vtxo: chunk4X4SY3RH_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
12002
12071
  };
12003
12072
  try {
12004
12073
  await handler.assertSpendableNow(
@@ -12112,7 +12181,7 @@ var ContractManager = class _ContractManager {
12112
12181
  const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
12113
12182
  const [contract] = await this.getContracts({ script: contractScript });
12114
12183
  if (!contract) return [];
12115
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
12184
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
12116
12185
  if (!handler) return [];
12117
12186
  const script = handler.createScript(contract.params);
12118
12187
  const tip = await this.currentChainTip();
@@ -12134,7 +12203,7 @@ var ContractManager = class _ContractManager {
12134
12203
  const { contractScript, collaborative = true, walletDescriptor } = options;
12135
12204
  const [contract] = await this.getContracts({ script: contractScript });
12136
12205
  if (!contract) return [];
12137
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
12206
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
12138
12207
  if (!handler) return [];
12139
12208
  const script = handler.createScript(contract.params);
12140
12209
  const context = {
@@ -12180,7 +12249,7 @@ var ContractManager = class _ContractManager {
12180
12249
  }
12181
12250
  async refreshOutpoints(outpoints) {
12182
12251
  if (outpoints.length === 0) return;
12183
- const { vtxos } = await chunk5HCDXBBG_cjs.getNormalizedVtxos(this.config.indexerProvider, {
12252
+ const { vtxos } = await chunk4X4SY3RH_cjs.getNormalizedVtxos(this.config.indexerProvider, {
12184
12253
  outpoints
12185
12254
  });
12186
12255
  if (vtxos.length === 0) return;
@@ -12305,7 +12374,7 @@ var ContractManager = class _ContractManager {
12305
12374
  ...Object.values(pending).map((p) => p.script)
12306
12375
  ]);
12307
12376
  const targets = contracts.filter(
12308
- (c) => chunkVLO3JAP3_cjs.contractHandlers.has(c.type) && (c.state === "active" && isOnchainScoped(c) || owners.has(c.script))
12377
+ (c) => chunkC3NKBKRY_cjs.contractHandlers.has(c.type) && (c.state === "active" && isOnchainScoped(c) || owners.has(c.script))
12309
12378
  );
12310
12379
  const wanted = scripts && new Set(scripts);
12311
12380
  const settled = [];
@@ -12340,7 +12409,7 @@ var ContractManager = class _ContractManager {
12340
12409
  ).catch((e) => console.warn("[contracts] onchain watch failed", e));
12341
12410
  }
12342
12411
  async syncOnchainContract(contract, onchainProvider, network, pending, tipHeight, prefetched) {
12343
- chunkVLO3JAP3_cjs.contractHandlers.get(contract.type).createScript(contract.params);
12412
+ chunkC3NKBKRY_cjs.contractHandlers.get(contract.type).createScript(contract.params);
12344
12413
  const coins = prefetched ?? await onchainProvider.getCoins(onchainAddressOf(contract, network));
12345
12414
  const stored = new Map(
12346
12415
  (await getVtxosForContract(this.config.walletRepository, contract)).map((v) => [
@@ -12438,8 +12507,8 @@ var ContractManager = class _ContractManager {
12438
12507
  const found = /* @__PURE__ */ new Map();
12439
12508
  if (!indexerProvider.getUtxos || rows.length === 0) return found;
12440
12509
  try {
12441
- for (let i = 0; i < rows.length; i += chunk5HCDXBBG_cjs.OUTPOINT_QUERY_CHUNK_SIZE) {
12442
- const outpoints = rows.slice(i, i + chunk5HCDXBBG_cjs.OUTPOINT_QUERY_CHUNK_SIZE).map(({ txid, vout }) => ({ txid, vout }));
12510
+ for (let i = 0; i < rows.length; i += chunk4X4SY3RH_cjs.OUTPOINT_QUERY_CHUNK_SIZE) {
12511
+ const outpoints = rows.slice(i, i + chunk4X4SY3RH_cjs.OUTPOINT_QUERY_CHUNK_SIZE).map(({ txid, vout }) => ({ txid, vout }));
12443
12512
  let pageIndex;
12444
12513
  let pages = 0;
12445
12514
  do {
@@ -12449,7 +12518,7 @@ var ContractManager = class _ContractManager {
12449
12518
  const { utxos, page } = await indexerProvider.getUtxos({
12450
12519
  outpoints,
12451
12520
  pageIndex,
12452
- pageSize: chunk5HCDXBBG_cjs.OUTPOINT_QUERY_CHUNK_SIZE
12521
+ pageSize: chunk4X4SY3RH_cjs.OUTPOINT_QUERY_CHUNK_SIZE
12453
12522
  });
12454
12523
  for (const utxo of utxos) found.set(vtxoOutpoint(utxo), utxo);
12455
12524
  const more = page && page.current < page.total && page.next > page.current;
@@ -12457,7 +12526,7 @@ var ContractManager = class _ContractManager {
12457
12526
  } while (pageIndex !== void 0);
12458
12527
  }
12459
12528
  } catch (e) {
12460
- if (e instanceof chunkGEK6QBSY_cjs.IndexerUtxosUnsupportedError) return found;
12529
+ if (e instanceof chunkQV7AOZZN_cjs.IndexerUtxosUnsupportedError) return found;
12461
12530
  console.warn("[contracts] arkd spend lookup failed; using the explorer", e);
12462
12531
  return void 0;
12463
12532
  }
@@ -12510,7 +12579,7 @@ var ContractManager = class _ContractManager {
12510
12579
  break;
12511
12580
  }
12512
12581
  } catch (err) {
12513
- if (!chunk5HCDXBBG_cjs.isRetryableProviderError(err)) throw err;
12582
+ if (!chunk4X4SY3RH_cjs.isRetryableProviderError(err)) throw err;
12514
12583
  this.markSyncDegraded(err);
12515
12584
  synced = false;
12516
12585
  }
@@ -12598,7 +12667,7 @@ var ContractManager = class _ContractManager {
12598
12667
  */
12599
12668
  async reconcilePendingFrontier(contracts) {
12600
12669
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
12601
- const vtxos = await chunk5HCDXBBG_cjs.getAllNormalizedVtxos(
12670
+ const vtxos = await chunk4X4SY3RH_cjs.getAllNormalizedVtxos(
12602
12671
  this.config.indexerProvider,
12603
12672
  contracts.map((c) => c.script),
12604
12673
  { pendingOnly: true }
@@ -12673,7 +12742,7 @@ var ContractManager = class _ContractManager {
12673
12742
  }
12674
12743
  return result;
12675
12744
  }
12676
- async fetchContractVtxosBulk(contracts, pageSize = chunk5HCDXBBG_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
12745
+ async fetchContractVtxosBulk(contracts, pageSize = chunk4X4SY3RH_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
12677
12746
  if (contracts.length === 0) {
12678
12747
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
12679
12748
  }
@@ -12689,7 +12758,7 @@ var ContractManager = class _ContractManager {
12689
12758
  before: syncWindow.before
12690
12759
  }
12691
12760
  } : {};
12692
- const vtxos = await chunk5HCDXBBG_cjs.getAllNormalizedVtxos(
12761
+ const vtxos = await chunk4X4SY3RH_cjs.getAllNormalizedVtxos(
12693
12762
  this.config.indexerProvider,
12694
12763
  contracts.map((c) => c.script),
12695
12764
  { ...windowOpts, pageSize }
@@ -12796,7 +12865,7 @@ function parseLegacyExpiry(batchExpiry) {
12796
12865
  if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
12797
12866
  return {};
12798
12867
  }
12799
- if (batchExpiry >= chunk5HCDXBBG_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
12868
+ if (batchExpiry >= chunk4X4SY3RH_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
12800
12869
  return { expiresAtHeight: batchExpiry / 1e3 };
12801
12870
  }
12802
12871
  function legacyVtxoFacts(status) {
@@ -13034,7 +13103,7 @@ function backfillContractWatchState(store) {
13034
13103
  };
13035
13104
  readPage();
13036
13105
  }
13037
- var unspentFlag = (vtxo) => chunk5HCDXBBG_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
13106
+ var unspentFlag = (vtxo) => chunk4X4SY3RH_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
13038
13107
  function backfillVtxoIndexFields(transaction) {
13039
13108
  const store = transaction.objectStore(STORE_VTXOS);
13040
13109
  const pageSize = 1e3;
@@ -13065,7 +13134,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
13065
13134
  var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
13066
13135
  function normalizeOptions2(pathOrOptions) {
13067
13136
  const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
13068
- chunk5HCDXBBG_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
13137
+ chunk4X4SY3RH_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
13069
13138
  return {
13070
13139
  path: o.path,
13071
13140
  activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
@@ -13293,7 +13362,7 @@ var deserializeTapLeaf = (t) => {
13293
13362
  var deserializeVtxo = ({
13294
13363
  intentTapLeafScript,
13295
13364
  ...o
13296
- }) => chunk5HCDXBBG_cjs.normalizeVtxo({
13365
+ }) => chunk4X4SY3RH_cjs.normalizeVtxo({
13297
13366
  ...o,
13298
13367
  createdAt: new Date(o.createdAt),
13299
13368
  tapTree: base.hex.decode(o.tapTree),
@@ -13693,7 +13762,7 @@ var RestEmulatorProvider = class {
13693
13762
  serverUrl;
13694
13763
  async getInfo() {
13695
13764
  const url = `${this.serverUrl}/v1/info`;
13696
- const response = await chunk5HCDXBBG_cjs.baseFetch(url);
13765
+ const response = await chunk4X4SY3RH_cjs.baseFetch(url);
13697
13766
  if (!response.ok) {
13698
13767
  const errorText2 = await response.text();
13699
13768
  throw new Error(`Failed to get emulator info: ${errorText2}`);
@@ -13813,11 +13882,11 @@ var RestEmulatorProvider = class {
13813
13882
 
13814
13883
  // src/arkade/service.ts
13815
13884
  function arkadeServiceUrl(service) {
13816
- return "operatorUrl" in service ? service.operatorUrl : chunkWIZCF5IX_cjs.DEFAULT_ARKADE_SERVER_URL;
13885
+ return "operatorUrl" in service ? service.operatorUrl : chunkYAVF2PR6_cjs.DEFAULT_ARKADE_SERVER_URL;
13817
13886
  }
13818
13887
  async function resolveArkadeService(service, opts = {}) {
13819
13888
  const operatorUrl = arkadeServiceUrl(service);
13820
- const arkProvider = opts.arkProvider ?? new chunk5HCDXBBG_cjs.RestOperatorProvider(operatorUrl);
13889
+ const arkProvider = opts.arkProvider ?? new chunk4X4SY3RH_cjs.RestOperatorProvider(operatorUrl);
13821
13890
  const info = opts.info ?? await arkProvider.getInfo();
13822
13891
  if ("network" in service && service.network !== info.network) {
13823
13892
  throw new Error(
@@ -13830,13 +13899,13 @@ async function resolveArkadeService(service, opts = {}) {
13830
13899
  }
13831
13900
  let emulator;
13832
13901
  if ("network" in service) {
13833
- emulator = new RestEmulatorProvider(chunkWIZCF5IX_cjs.DEFAULT_ARKADE_EMULATOR_URL);
13902
+ emulator = new RestEmulatorProvider(chunkYAVF2PR6_cjs.DEFAULT_ARKADE_EMULATOR_URL);
13834
13903
  } else if (service.emulatorUrl) {
13835
13904
  emulator = new RestEmulatorProvider(service.emulatorUrl);
13836
13905
  }
13837
13906
  return {
13838
13907
  arkProvider,
13839
- indexerProvider: new chunkGEK6QBSY_cjs.RestIndexerProvider(operatorUrl),
13908
+ indexerProvider: new chunkQV7AOZZN_cjs.RestIndexerProvider(operatorUrl),
13840
13909
  onchainProvider: new EsploraProvider(esploraUrl),
13841
13910
  emulator,
13842
13911
  info
@@ -13920,7 +13989,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
13920
13989
  */
13921
13990
  materializeDescriptorAt(index) {
13922
13991
  const descriptor = this.identity.descriptor;
13923
- const network = chunkVLO3JAP3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
13992
+ const network = chunkC3NKBKRY_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
13924
13993
  const expansion = descriptorsScure.expand({ descriptor, network, index });
13925
13994
  const keyInfo = expansion.expansionMap?.["@0"];
13926
13995
  if (!keyInfo?.keyExpression) {
@@ -13988,7 +14057,7 @@ function signingDescriptorIndex(descriptor) {
13988
14057
  }
13989
14058
  function newestWalletReceiveContract(contracts, serverPubKeyHex) {
13990
14059
  return contracts.filter(
13991
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkVLO3JAP3_cjs.WALLET_RECEIVE_SOURCE
14060
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkC3NKBKRY_cjs.WALLET_RECEIVE_SOURCE
13992
14061
  ).sort((a, b) => {
13993
14062
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
13994
14063
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -14039,7 +14108,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
14039
14108
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
14040
14109
  if (!provider) return void 0;
14041
14110
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
14042
- const expectedContractType = setup.offchainTapscript instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script ? "delegate" : "default";
14111
+ const expectedContractType = setup.offchainTapscript instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script ? "delegate" : "default";
14043
14112
  const factoryOpts = {
14044
14113
  walletRepository: setup.walletRepository,
14045
14114
  contractRepository: setup.contractRepository,
@@ -14199,7 +14268,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
14199
14268
  };
14200
14269
  function deriveLeafPubkey(descriptor) {
14201
14270
  try {
14202
- return chunkVLO3JAP3_cjs.deriveDescriptorLeafPubKey(descriptor);
14271
+ return chunkC3NKBKRY_cjs.deriveDescriptorLeafPubKey(descriptor);
14203
14272
  } catch (e) {
14204
14273
  throw new NonRangeableDescriptorError(
14205
14274
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -14211,7 +14280,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
14211
14280
  const pubKey = deriveLeafPubkey(descriptor);
14212
14281
  const tapscript = rebuildTapscript(current, pubKey);
14213
14282
  const serverPubKey = tapscript.options.serverPubKey;
14214
- const csvTimelock = chunkWIZCF5IX_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
14283
+ const csvTimelock = chunkYAVF2PR6_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
14215
14284
  const base$1 = {
14216
14285
  script: base.hex.encode(tapscript.pkScript),
14217
14286
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -14219,11 +14288,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
14219
14288
  // Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
14220
14289
  // it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
14221
14290
  metadata: {
14222
- ...tagSource && { source: chunkVLO3JAP3_cjs.WALLET_RECEIVE_SOURCE },
14291
+ ...tagSource && { source: chunkC3NKBKRY_cjs.WALLET_RECEIVE_SOURCE },
14223
14292
  signingDescriptor: descriptor
14224
14293
  }
14225
14294
  };
14226
- const params = tapscript instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script ? {
14295
+ const params = tapscript instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script ? {
14227
14296
  ...base$1,
14228
14297
  type: "delegate",
14229
14298
  params: {
@@ -14244,10 +14313,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
14244
14313
  return { tapscript, params };
14245
14314
  }
14246
14315
  function rebuildTapscript(current, pubKey) {
14247
- if (current instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script) {
14248
- return new chunkVLO3JAP3_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
14316
+ if (current instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script) {
14317
+ return new chunkC3NKBKRY_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
14249
14318
  }
14250
- return new chunkVLO3JAP3_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
14319
+ return new chunkC3NKBKRY_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
14251
14320
  }
14252
14321
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
14253
14322
  const candidates = await collectContracts(contractRepository, {
@@ -14300,7 +14369,7 @@ async function resolvePrevTxs(txids, source, onchain) {
14300
14369
  try {
14301
14370
  const { txs } = await source.getVirtualTxs(wanted);
14302
14371
  for (const psbt of txs) {
14303
- const tx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
14372
+ const tx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
14304
14373
  resolved.set(tx.id, tx.toBytes());
14305
14374
  }
14306
14375
  } catch (err) {
@@ -14333,7 +14402,7 @@ async function resolvePrevTxs(txids, source, onchain) {
14333
14402
  async function attachPrevArkTxs(tx, txids, source, onchain) {
14334
14403
  const pending = [];
14335
14404
  for (let i = 0; i < tx.inputsLength; i++) {
14336
- if (chunk5HCDXBBG_cjs.getArkPsbtFields(tx, i, chunk5HCDXBBG_cjs.PrevArkTxField).length === 0) pending.push(i);
14405
+ if (chunk4X4SY3RH_cjs.getArkPsbtFields(tx, i, chunk4X4SY3RH_cjs.PrevArkTxField).length === 0) pending.push(i);
14337
14406
  }
14338
14407
  if (pending.length === 0) return;
14339
14408
  const resolved = await resolvePrevTxs(
@@ -14342,13 +14411,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
14342
14411
  onchain
14343
14412
  );
14344
14413
  for (const i of pending) {
14345
- chunk5HCDXBBG_cjs.setArkPsbtField(tx, i, chunk5HCDXBBG_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
14414
+ chunk4X4SY3RH_cjs.setArkPsbtField(tx, i, chunk4X4SY3RH_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
14346
14415
  }
14347
14416
  }
14348
14417
  async function attachPrevoutTxs(tx, source) {
14349
14418
  const pending = [];
14350
14419
  for (let i = 0; i < tx.inputsLength; i++) {
14351
- if (chunk5HCDXBBG_cjs.getArkPsbtFields(tx, i, chunk5HCDXBBG_cjs.PrevoutTxField).length > 0) continue;
14420
+ if (chunk4X4SY3RH_cjs.getArkPsbtFields(tx, i, chunk4X4SY3RH_cjs.PrevoutTxField).length > 0) continue;
14352
14421
  const input = tx.getInput(i);
14353
14422
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
14354
14423
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -14363,7 +14432,7 @@ async function attachPrevoutTxs(tx, source) {
14363
14432
  resolved.set(txids[i], result.value);
14364
14433
  }
14365
14434
  for (const { index, txid } of pending) {
14366
- chunk5HCDXBBG_cjs.setArkPsbtField(tx, index, chunk5HCDXBBG_cjs.PrevoutTxField, resolved.get(txid));
14435
+ chunk4X4SY3RH_cjs.setArkPsbtField(tx, index, chunk4X4SY3RH_cjs.PrevoutTxField, resolved.get(txid));
14367
14436
  }
14368
14437
  }
14369
14438
  async function withPrevTxs(coins, source, onchain) {
@@ -14404,7 +14473,7 @@ function computeOffchainBalance(vtxos, caps) {
14404
14473
  }
14405
14474
  };
14406
14475
  for (const vtxo of vtxos) {
14407
- if (chunk5HCDXBBG_cjs.isVtxoSpent(vtxo)) continue;
14476
+ if (chunk4X4SY3RH_cjs.isVtxoSpent(vtxo)) continue;
14408
14477
  addAssets(owned, vtxo);
14409
14478
  if (vtxo.isUnrolled) {
14410
14479
  unrolled += vtxo.value;
@@ -14414,11 +14483,11 @@ function computeOffchainBalance(vtxos, caps) {
14414
14483
  deprecatedSignerLocked += vtxo.value;
14415
14484
  continue;
14416
14485
  }
14417
- if (chunk5HCDXBBG_cjs.canRecoverOnchain(vtxo, now)) {
14486
+ if (chunk4X4SY3RH_cjs.canRecoverOnchain(vtxo, now)) {
14418
14487
  recoverable += vtxo.value;
14419
14488
  continue;
14420
14489
  }
14421
- if (!chunk5HCDXBBG_cjs.canSpendOffchain(vtxo, now)) continue;
14490
+ if (!chunk4X4SY3RH_cjs.canSpendOffchain(vtxo, now)) continue;
14422
14491
  if (vtxo.isPreconfirmed) {
14423
14492
  preconfirmed += vtxo.value;
14424
14493
  } else {
@@ -14637,7 +14706,7 @@ function intentProofJobs(coins) {
14637
14706
  if (coins.length === 0) return [];
14638
14707
  const coinJobs = coins.map((coin, i) => ({
14639
14708
  index: i + 1,
14640
- lookupScript: chunkWIZCF5IX_cjs.VtxoScript.decode(coin.tapTree).pkScript
14709
+ lookupScript: chunkYAVF2PR6_cjs.VtxoScript.decode(coin.tapTree).pkScript
14641
14710
  }));
14642
14711
  return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
14643
14712
  }
@@ -14677,7 +14746,7 @@ function dedupeTimelocks(timelocks) {
14677
14746
  const seen = /* @__PURE__ */ new Set();
14678
14747
  const deduped = [];
14679
14748
  for (const timelock of timelocks) {
14680
- const sequence = chunkWIZCF5IX_cjs.timelockToSequence(timelock).toString();
14749
+ const sequence = chunkYAVF2PR6_cjs.timelockToSequence(timelock).toString();
14681
14750
  if (seen.has(sequence)) continue;
14682
14751
  seen.add(sequence);
14683
14752
  deduped.push(timelock);
@@ -14693,7 +14762,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
14693
14762
  if (!newest?.params.pubKey) return baseline;
14694
14763
  try {
14695
14764
  const pubKey = base.hex.decode(newest.params.pubKey);
14696
- return new chunkVLO3JAP3_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
14765
+ return new chunkC3NKBKRY_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
14697
14766
  } catch (e) {
14698
14767
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
14699
14768
  return baseline;
@@ -14725,21 +14794,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
14725
14794
  if (vtxo.isUnrolled) {
14726
14795
  return !!f.withUnrolled;
14727
14796
  }
14728
- if (chunk5HCDXBBG_cjs.isVtxoSpent(vtxo)) {
14797
+ if (chunk4X4SY3RH_cjs.isVtxoSpent(vtxo)) {
14729
14798
  return false;
14730
14799
  }
14731
- if (!f.withRecoverable && chunk5HCDXBBG_cjs.canRecoverOnchain(vtxo, now)) {
14800
+ if (!f.withRecoverable && chunk4X4SY3RH_cjs.canRecoverOnchain(vtxo, now)) {
14732
14801
  return false;
14733
14802
  }
14734
14803
  return true;
14735
14804
  });
14736
14805
  }
14737
14806
  async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
14738
- const candidates = inputs.filter(chunk5HCDXBBG_cjs.isVirtualCoin).map(chunk5HCDXBBG_cjs.normalizeVtxo).filter((v) => !v.isSwept);
14807
+ const candidates = inputs.filter(chunk4X4SY3RH_cjs.isVirtualCoin).map(chunk4X4SY3RH_cjs.normalizeVtxo).filter((v) => !v.isSwept);
14739
14808
  if (candidates.length === 0) return inputs;
14740
- const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunk5HCDXBBG_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
14809
+ const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunk4X4SY3RH_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
14741
14810
  const suspects = candidates.filter(
14742
- (v) => chunk5HCDXBBG_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
14811
+ (v) => chunk4X4SY3RH_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
14743
14812
  );
14744
14813
  if (suspects.length === 0) return inputs;
14745
14814
  let sweptNow;
@@ -14753,12 +14822,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
14753
14822
  );
14754
14823
  } catch (e) {
14755
14824
  const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
14756
- throw chunk5HCDXBBG_cjs.isRetryableProviderError(e) ? new chunk5HCDXBBG_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
14825
+ throw chunk4X4SY3RH_cjs.isRetryableProviderError(e) ? new chunk4X4SY3RH_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
14757
14826
  }
14758
14827
  if (sweptNow.size === 0) return inputs;
14759
14828
  return inputs.map((input) => {
14760
- if (!chunk5HCDXBBG_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
14761
- return { ...chunk5HCDXBBG_cjs.normalizeVtxo(input), isSwept: true };
14829
+ if (!chunk4X4SY3RH_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
14830
+ return { ...chunk4X4SY3RH_cjs.normalizeVtxo(input), isSwept: true };
14762
14831
  });
14763
14832
  }
14764
14833
  var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
@@ -15072,7 +15141,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15072
15141
  async getArkadeReader() {
15073
15142
  const indexer = this.indexerProvider;
15074
15143
  return {
15075
- getVtxos: (opts) => chunk5HCDXBBG_cjs.getNormalizedVtxos(indexer, opts),
15144
+ getVtxos: (opts) => chunk4X4SY3RH_cjs.getNormalizedVtxos(indexer, opts),
15076
15145
  getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
15077
15146
  };
15078
15147
  }
@@ -15122,7 +15191,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15122
15191
  "Pass either `service` or `operatorProvider`/`indexerProvider`/`onchainProvider`, not both"
15123
15192
  );
15124
15193
  }
15125
- const arkProvider = callerProvider || new chunk5HCDXBBG_cjs.RestOperatorProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
15194
+ const arkProvider = callerProvider || new chunk4X4SY3RH_cjs.RestOperatorProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
15126
15195
  let indexerProvider = config.indexerProvider;
15127
15196
  if (!indexerProvider && !config.service) {
15128
15197
  const derived = extractOperatorProviderUrl(arkProvider);
@@ -15131,11 +15200,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
15131
15200
  "indexerProvider is required when operatorProvider is provided without a discoverable serverUrl"
15132
15201
  );
15133
15202
  }
15134
- indexerProvider = new chunkGEK6QBSY_cjs.RestIndexerProvider(derived ?? chunkWIZCF5IX_cjs.DEFAULT_ARKADE_SERVER_URL);
15203
+ indexerProvider = new chunkQV7AOZZN_cjs.RestIndexerProvider(derived ?? chunkYAVF2PR6_cjs.DEFAULT_ARKADE_SERVER_URL);
15135
15204
  }
15136
15205
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
15137
15206
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
15138
- const delegatePubKeyPromise = config.delegateProvider?.getDelegateInfo().then((info2) => chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0);
15207
+ const delegatePubKeyPromise = config.delegateProvider?.getDelegateInfo().then((info2) => chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0);
15139
15208
  const {
15140
15209
  info,
15141
15210
  source: serverInfoSource,
@@ -15146,7 +15215,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15146
15215
  if (!resolvedService) throw new Error("indexerProvider is unresolved");
15147
15216
  indexerProvider = resolvedService.indexerProvider;
15148
15217
  }
15149
- const network = chunkWIZCF5IX_cjs.networkFromOperatorInfo(info);
15218
+ const network = chunkYAVF2PR6_cjs.networkFromOperatorInfo(info);
15150
15219
  if ("descriptor" in config.identity) {
15151
15220
  const descriptor = config.identity.descriptor;
15152
15221
  const identityIsMainnet = !descriptor.includes("tpub");
@@ -15182,18 +15251,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
15182
15251
  }
15183
15252
  }
15184
15253
  const boardingTimelock = config.boardingTimelock ?? toTimelock(info.boardingExitDelay);
15185
- const serverPubKey = chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
15254
+ const serverPubKey = chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
15186
15255
  const delegatePubKey = await delegatePubKeyPromise;
15187
15256
  const offchainOptions = {
15188
15257
  pubKey,
15189
15258
  serverPubKey,
15190
15259
  csvTimelock: exitTimelock
15191
15260
  };
15192
- const offchainTapscript = !delegatePubKey ? new chunkVLO3JAP3_cjs.DefaultVtxo.Script(offchainOptions) : new chunkVLO3JAP3_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
15193
- const boardingTapscript = chunkVLO3JAP3_cjs.BoardingContractHandler.createScript({
15261
+ const offchainTapscript = !delegatePubKey ? new chunkC3NKBKRY_cjs.DefaultVtxo.Script(offchainOptions) : new chunkC3NKBKRY_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
15262
+ const boardingTapscript = chunkC3NKBKRY_cjs.BoardingContractHandler.createScript({
15194
15263
  pubKey: base.hex.encode(pubKey),
15195
15264
  serverPubKey: base.hex.encode(serverPubKey),
15196
- csvTimelock: chunkWIZCF5IX_cjs.timelockToSequence(boardingTimelock).toString()
15265
+ csvTimelock: chunkYAVF2PR6_cjs.timelockToSequence(boardingTimelock).toString()
15197
15266
  });
15198
15267
  return {
15199
15268
  arkProvider,
@@ -15360,7 +15429,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15360
15429
  if (!filter?.withUnrolled) {
15361
15430
  logExcludedVtxos(
15362
15431
  "getSpendableVtxos",
15363
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunk5HCDXBBG_cjs.isVtxoSpent(vtxo)),
15432
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunk4X4SY3RH_cjs.isVtxoSpent(vtxo)),
15364
15433
  [() => UNROLLED_REASON]
15365
15434
  );
15366
15435
  }
@@ -15502,7 +15571,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15502
15571
  ]);
15503
15572
  const snapshot = fullSnapshot.filter(({ contract }) => !isRecoveryOnlyContract(contract));
15504
15573
  const allVtxos = snapshot.flatMap((_) => _.vtxos);
15505
- const resolveTxCreatedAt = (txids) => chunk5HCDXBBG_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
15574
+ const resolveTxCreatedAt = (txids) => chunk4X4SY3RH_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
15506
15575
  return buildTransactionHistory(
15507
15576
  allVtxos,
15508
15577
  boardingTxs,
@@ -15702,11 +15771,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
15702
15771
  const currentServerPubKey = this.boardingTapscript.options.serverPubKey;
15703
15772
  const currentServerSigner = toXOnlySignerHex(base.hex.encode(currentServerPubKey));
15704
15773
  const signers = /* @__PURE__ */ new Set([currentServerSigner, ...allowedSigners ?? []]);
15705
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkVLO3JAP3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
15774
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkC3NKBKRY_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
15706
15775
  const baselinePubkey = await this.identity.xOnlyPublicKey();
15707
15776
  for (const signer of signers) {
15708
15777
  add(
15709
- new chunkVLO3JAP3_cjs.DefaultVtxo.Script({
15778
+ new chunkC3NKBKRY_cjs.DefaultVtxo.Script({
15710
15779
  pubKey: baselinePubkey,
15711
15780
  serverPubKey: base.hex.decode(signer),
15712
15781
  csvTimelock: boardingCsv
@@ -15727,7 +15796,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15727
15796
  continue;
15728
15797
  }
15729
15798
  add(
15730
- c.type === "default" ? chunkVLO3JAP3_cjs.DefaultContractHandler.createScript(c.params) : chunkVLO3JAP3_cjs.BoardingContractHandler.createScript(c.params)
15799
+ c.type === "default" ? chunkC3NKBKRY_cjs.DefaultContractHandler.createScript(c.params) : chunkC3NKBKRY_cjs.BoardingContractHandler.createScript(c.params)
15731
15800
  );
15732
15801
  } catch (e) {
15733
15802
  console.warn("Skipping malformed boarding contract", c.script, e);
@@ -15776,7 +15845,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15776
15845
  tapscripts.map(async (tapscript, i) => {
15777
15846
  const contract = contracts.get(scripts[i]);
15778
15847
  const spent = new Set(
15779
- contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(chunk5HCDXBBG_cjs.isVtxoSpent).map(vtxoOutpoint) : []
15848
+ contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(chunk4X4SY3RH_cjs.isVtxoSpent).map(vtxoOutpoint) : []
15780
15849
  );
15781
15850
  const utxos = fetched[i].filter((c) => !spent.has(vtxoOutpoint(c))).map((utxo) => extendCoinWithTapscript(tapscript, utxo));
15782
15851
  return {
@@ -15786,7 +15855,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15786
15855
  // Per-row CSV delay decoded from THIS tapscript's exit leaf —
15787
15856
  // not the wallet's current boarding timelock, which a signer
15788
15857
  // rotation may have changed.
15789
- csvTimelock: chunkWIZCF5IX_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
15858
+ csvTimelock: chunkYAVF2PR6_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
15790
15859
  coins: utxos
15791
15860
  };
15792
15861
  })
@@ -15805,10 +15874,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
15805
15874
  timer = setTimeout(
15806
15875
  () => reject(
15807
15876
  new Error(
15808
- `Boarding address lookup timed out after ${chunk5HCDXBBG_cjs.READ_TIMEOUT_MS}ms`
15877
+ `Boarding address lookup timed out after ${chunk4X4SY3RH_cjs.READ_TIMEOUT_MS}ms`
15809
15878
  )
15810
15879
  ),
15811
- chunk5HCDXBBG_cjs.READ_TIMEOUT_MS
15880
+ chunk4X4SY3RH_cjs.READ_TIMEOUT_MS
15812
15881
  );
15813
15882
  })
15814
15883
  ]);
@@ -15994,7 +16063,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15994
16063
  /** Fetch Arkade transaction ids that are still pending final settlement. */
15995
16064
  async fetchPendingTxs() {
15996
16065
  const scripts = await this.getWalletScripts();
15997
- const vtxos = await chunk5HCDXBBG_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
16066
+ const vtxos = await chunk4X4SY3RH_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
15998
16067
  return vtxos.filter(
15999
16068
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
16000
16069
  ).map((_) => _.arkTxId);
@@ -16025,7 +16094,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
16025
16094
  });
16026
16095
  for (const contract of contracts) {
16027
16096
  if (map.has(contract.script)) continue;
16028
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
16097
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
16029
16098
  if (handler) {
16030
16099
  const script = handler.createScript(contract.params);
16031
16100
  map.set(contract.script, script);
@@ -16144,7 +16213,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
16144
16213
  });
16145
16214
  try {
16146
16215
  const baselinePubkey = await baselinePubkeyPromise;
16147
- const delegatePubKey = this.offchainTapscript instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
16216
+ const delegatePubKey = this.offchainTapscript instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
16148
16217
  const baselineSigners = [
16149
16218
  this.offchainTapscript.options.serverPubKey,
16150
16219
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
@@ -16153,8 +16222,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
16153
16222
  const baseline = [];
16154
16223
  for (const serverPubKey of baselineSigners) {
16155
16224
  for (const csvTimelock of this.walletContractTimelocks) {
16156
- const csvTimelockStr = chunkWIZCF5IX_cjs.timelockToSequence(csvTimelock).toString();
16157
- const defaultScript = new chunkVLO3JAP3_cjs.DefaultVtxo.Script({
16225
+ const csvTimelockStr = chunkYAVF2PR6_cjs.timelockToSequence(csvTimelock).toString();
16226
+ const defaultScript = new chunkC3NKBKRY_cjs.DefaultVtxo.Script({
16158
16227
  pubKey: baselinePubkey,
16159
16228
  serverPubKey,
16160
16229
  csvTimelock
@@ -16175,7 +16244,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
16175
16244
  });
16176
16245
  }
16177
16246
  if (delegatePubKey) {
16178
- const delegateScript = new chunkVLO3JAP3_cjs.DelegateVtxo.Script({
16247
+ const delegateScript = new chunkC3NKBKRY_cjs.DelegateVtxo.Script({
16179
16248
  pubKey: baselinePubkey,
16180
16249
  serverPubKey,
16181
16250
  delegatePubKey,
@@ -16199,9 +16268,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
16199
16268
  }
16200
16269
  }
16201
16270
  }
16202
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkVLO3JAP3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16271
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkC3NKBKRY_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16203
16272
  for (const serverPubKey of baselineSigners) {
16204
- const baselineBoarding = new chunkVLO3JAP3_cjs.DefaultVtxo.Script({
16273
+ const baselineBoarding = new chunkC3NKBKRY_cjs.DefaultVtxo.Script({
16205
16274
  pubKey: baselinePubkey,
16206
16275
  serverPubKey,
16207
16276
  csvTimelock: boardingCsvTimelock
@@ -16212,7 +16281,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
16212
16281
  params: {
16213
16282
  pubKey: base.hex.encode(baselineBoarding.options.pubKey),
16214
16283
  serverPubKey: base.hex.encode(serverPubKey),
16215
- csvTimelock: chunkWIZCF5IX_cjs.timelockToSequence(boardingCsvTimelock).toString()
16284
+ csvTimelock: chunkYAVF2PR6_cjs.timelockToSequence(boardingCsvTimelock).toString()
16216
16285
  },
16217
16286
  script: boardingScriptHex,
16218
16287
  address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
@@ -16418,7 +16487,7 @@ var Wallet2 = class extends ReadonlyWallet {
16418
16487
  serverPubKey: this.offchainTapscript.options.serverPubKey,
16419
16488
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
16420
16489
  csvTimelocks: this.walletContractTimelocks,
16421
- delegatePubKey: this.offchainTapscript instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
16490
+ delegatePubKey: this.offchainTapscript instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
16422
16491
  };
16423
16492
  }
16424
16493
  _signerRouter;
@@ -16580,7 +16649,7 @@ var Wallet2 = class extends ReadonlyWallet {
16580
16649
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
16581
16650
  const persisted = row?.metadata?.signingDescriptor;
16582
16651
  if (typeof persisted === "string") return persisted;
16583
- return chunkVLO3JAP3_cjs.identityDescriptor(this.identity);
16652
+ return chunkC3NKBKRY_cjs.identityDescriptor(this.identity);
16584
16653
  }
16585
16654
  /**
16586
16655
  * Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
@@ -16590,7 +16659,7 @@ var Wallet2 = class extends ReadonlyWallet {
16590
16659
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
16591
16660
  if (type === "boarding") {
16592
16661
  const built2 = this.buildBoardingContract(
16593
- chunkVLO3JAP3_cjs.deriveDescriptorLeafPubKey(descriptor),
16662
+ chunkC3NKBKRY_cjs.deriveDescriptorLeafPubKey(descriptor),
16594
16663
  descriptor,
16595
16664
  tagSource
16596
16665
  );
@@ -16627,11 +16696,11 @@ var Wallet2 = class extends ReadonlyWallet {
16627
16696
  * (offchain analogue: {@link buildReceiveContract}).
16628
16697
  */
16629
16698
  buildBoardingContract(pubKey, descriptor, tagSource) {
16630
- const tapscript = new chunkVLO3JAP3_cjs.DefaultVtxo.Script({
16699
+ const tapscript = new chunkC3NKBKRY_cjs.DefaultVtxo.Script({
16631
16700
  ...this._boardingTapscript.options,
16632
16701
  pubKey
16633
16702
  });
16634
- const csvTimelock = tapscript.options.csvTimelock ?? chunkVLO3JAP3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16703
+ const csvTimelock = tapscript.options.csvTimelock ?? chunkC3NKBKRY_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16635
16704
  return {
16636
16705
  tapscript,
16637
16706
  params: {
@@ -16639,13 +16708,13 @@ var Wallet2 = class extends ReadonlyWallet {
16639
16708
  params: {
16640
16709
  pubKey: base.hex.encode(pubKey),
16641
16710
  serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
16642
- csvTimelock: chunkWIZCF5IX_cjs.timelockToSequence(csvTimelock).toString()
16711
+ csvTimelock: chunkYAVF2PR6_cjs.timelockToSequence(csvTimelock).toString()
16643
16712
  },
16644
16713
  script: base.hex.encode(tapscript.pkScript),
16645
16714
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
16646
16715
  state: "active",
16647
16716
  metadata: {
16648
- ...tagSource && { source: chunkVLO3JAP3_cjs.WALLET_RECEIVE_SOURCE },
16717
+ ...tagSource && { source: chunkC3NKBKRY_cjs.WALLET_RECEIVE_SOURCE },
16649
16718
  signingDescriptor: descriptor
16650
16719
  }
16651
16720
  }
@@ -16667,7 +16736,7 @@ var Wallet2 = class extends ReadonlyWallet {
16667
16736
  if (this._hdProvider) {
16668
16737
  return (await this.getContractManager()).getNextSigningDescriptor();
16669
16738
  }
16670
- return chunkVLO3JAP3_cjs.identityDescriptor(this.identity);
16739
+ return chunkC3NKBKRY_cjs.identityDescriptor(this.identity);
16671
16740
  }
16672
16741
  /**
16673
16742
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -16743,7 +16812,7 @@ var Wallet2 = class extends ReadonlyWallet {
16743
16812
  * the stable public API.
16744
16813
  */
16745
16814
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
16746
- const xonly = chunkUPIQZRNJ_cjs.toXOnly(newServerPubKey, "ark signer key");
16815
+ const xonly = chunkJA4SYFC7_cjs.toXOnly(newServerPubKey, "ark signer key");
16747
16816
  const newServerUnrollScript = assertValidServerUnrollScript(
16748
16817
  checkpointTapscript,
16749
16818
  this.network,
@@ -16773,21 +16842,21 @@ var Wallet2 = class extends ReadonlyWallet {
16773
16842
  ]);
16774
16843
  const [currentOffchainRow] = offchainRows2;
16775
16844
  const [currentBoardingRow] = boardingRows;
16776
- const newOffchain = this.offchainTapscript instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script ? new chunkVLO3JAP3_cjs.DelegateVtxo.Script({
16845
+ const newOffchain = this.offchainTapscript instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script ? new chunkC3NKBKRY_cjs.DelegateVtxo.Script({
16777
16846
  ...this.offchainTapscript.options,
16778
16847
  serverPubKey: xonly
16779
- }) : new chunkVLO3JAP3_cjs.DefaultVtxo.Script({
16848
+ }) : new chunkC3NKBKRY_cjs.DefaultVtxo.Script({
16780
16849
  ...this.offchainTapscript.options,
16781
16850
  serverPubKey: xonly
16782
16851
  });
16783
- const newBoarding = new chunkVLO3JAP3_cjs.DefaultVtxo.Script({
16852
+ const newBoarding = new chunkC3NKBKRY_cjs.DefaultVtxo.Script({
16784
16853
  ...this._boardingTapscript.options,
16785
16854
  serverPubKey: xonly
16786
16855
  });
16787
- const offchainCsv = chunkWIZCF5IX_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
16856
+ const offchainCsv = chunkYAVF2PR6_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
16788
16857
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
16789
16858
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
16790
- if (newOffchain instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script) {
16859
+ if (newOffchain instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script) {
16791
16860
  await manager.createContract({
16792
16861
  type: "delegate",
16793
16862
  params: {
@@ -16815,13 +16884,13 @@ var Wallet2 = class extends ReadonlyWallet {
16815
16884
  metadata: currentOffchainRow?.metadata
16816
16885
  });
16817
16886
  }
16818
- const boardingCsv = newBoarding.options.csvTimelock ?? chunkVLO3JAP3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16887
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkC3NKBKRY_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16819
16888
  await manager.createContract({
16820
16889
  type: "boarding",
16821
16890
  params: {
16822
16891
  pubKey: base.hex.encode(newBoarding.options.pubKey),
16823
16892
  serverPubKey: base.hex.encode(xonly),
16824
- csvTimelock: chunkWIZCF5IX_cjs.timelockToSequence(boardingCsv).toString()
16893
+ csvTimelock: chunkYAVF2PR6_cjs.timelockToSequence(boardingCsv).toString()
16825
16894
  },
16826
16895
  script: base.hex.encode(newBoarding.pkScript),
16827
16896
  address: newBoarding.address(this.network.hrp, xonly).encode(),
@@ -16849,14 +16918,14 @@ var Wallet2 = class extends ReadonlyWallet {
16849
16918
  _restoreInFlight;
16850
16919
  _addPendingSpends(inputs) {
16851
16920
  for (const input of inputs) {
16852
- if (chunk5HCDXBBG_cjs.isVirtualCoin(input)) {
16921
+ if (chunk4X4SY3RH_cjs.isVirtualCoin(input)) {
16853
16922
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
16854
16923
  }
16855
16924
  }
16856
16925
  }
16857
16926
  _removePendingSpends(inputs) {
16858
16927
  for (const input of inputs) {
16859
- if (chunk5HCDXBBG_cjs.isVirtualCoin(input)) {
16928
+ if (chunk4X4SY3RH_cjs.isVirtualCoin(input)) {
16860
16929
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
16861
16930
  }
16862
16931
  }
@@ -17004,7 +17073,7 @@ var Wallet2 = class extends ReadonlyWallet {
17004
17073
  if (clashing.length > 0) throw new VtxoReservedError(clashing, "in-flight");
17005
17074
  }
17006
17075
  _assertNotHeld(inputs) {
17007
- const held = coinKeys(inputs.filter(chunk5HCDXBBG_cjs.isVirtualCoin)).filter(
17076
+ const held = coinKeys(inputs.filter(chunk4X4SY3RH_cjs.isVirtualCoin)).filter(
17008
17077
  (key) => this._heldOutpoints.has(key)
17009
17078
  );
17010
17079
  if (held.length > 0) throw new VtxoReservedError(held, "held");
@@ -17043,14 +17112,14 @@ var Wallet2 = class extends ReadonlyWallet {
17043
17112
  const hd = provider !== void 0;
17044
17113
  const [manager, staticDescriptor, arkInfo] = await Promise.all([
17045
17114
  this.getContractManager(),
17046
- hd ? void 0 : chunkVLO3JAP3_cjs.identityDescriptor(this.identity),
17115
+ hd ? void 0 : chunkC3NKBKRY_cjs.identityDescriptor(this.identity),
17047
17116
  this.arkProvider.getInfo()
17048
17117
  ]);
17049
17118
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
17050
- const delegatePubKey = this.offchainTapscript instanceof chunkVLO3JAP3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
17051
- const currentSignerPubKey = chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
17119
+ const delegatePubKey = this.offchainTapscript instanceof chunkC3NKBKRY_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
17120
+ const currentSignerPubKey = chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
17052
17121
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
17053
- (s) => chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
17122
+ (s) => chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
17054
17123
  );
17055
17124
  const deps = {
17056
17125
  indexerProvider: this.indexerProvider,
@@ -17062,7 +17131,7 @@ var Wallet2 = class extends ReadonlyWallet {
17062
17131
  deprecatedSignerPubKeys,
17063
17132
  csvTimelocks: this.walletContractTimelocks,
17064
17133
  // Boarding-exit CSV, distinct from the unilateral-exit matrix.
17065
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkVLO3JAP3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
17134
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkC3NKBKRY_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
17066
17135
  delegatePubKey
17067
17136
  };
17068
17137
  const result = await manager.scanContracts({
@@ -17196,7 +17265,7 @@ var Wallet2 = class extends ReadonlyWallet {
17196
17265
  throw new Error("Invalid configured public key");
17197
17266
  }
17198
17267
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
17199
- const forfeitPubkey = chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
17268
+ const forfeitPubkey = chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
17200
17269
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
17201
17270
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
17202
17271
  const serverUnrollScript = assertValidServerUnrollScript(
@@ -17395,7 +17464,7 @@ var Wallet2 = class extends ReadonlyWallet {
17395
17464
  void this.logUngatedInputs("settle({ inputs })", params.inputs);
17396
17465
  }
17397
17466
  const offchainAddress = await this.getAddress();
17398
- const offchainPkScript = chunkWIZCF5IX_cjs.ArkAddress.decode(offchainAddress).pkScript;
17467
+ const offchainPkScript = chunkYAVF2PR6_cjs.ArkAddress.decode(offchainAddress).pkScript;
17399
17468
  const offchainOutputScript = base.hex.encode(offchainPkScript);
17400
17469
  if (!params) {
17401
17470
  const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
@@ -17435,7 +17504,7 @@ var Wallet2 = class extends ReadonlyWallet {
17435
17504
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
17436
17505
  break;
17437
17506
  }
17438
- const inputFee = estimator.evalOffchainInput(chunk5HCDXBBG_cjs.toOffchainInputFeeParams(vtxo));
17507
+ const inputFee = estimator.evalOffchainInput(chunk4X4SY3RH_cjs.toOffchainInputFeeParams(vtxo));
17439
17508
  if (inputFee.satoshis >= vtxo.value) {
17440
17509
  continue;
17441
17510
  }
@@ -17487,7 +17556,7 @@ var Wallet2 = class extends ReadonlyWallet {
17487
17556
  let script;
17488
17557
  let arkAddress;
17489
17558
  try {
17490
- arkAddress = chunkWIZCF5IX_cjs.ArkAddress.decode(output.address);
17559
+ arkAddress = chunkYAVF2PR6_cjs.ArkAddress.decode(output.address);
17491
17560
  } catch {
17492
17561
  arkAddress = void 0;
17493
17562
  }
@@ -17559,11 +17628,11 @@ var Wallet2 = class extends ReadonlyWallet {
17559
17628
  ]);
17560
17629
  let intentTxId;
17561
17630
  try {
17562
- intentTxId = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
17631
+ intentTxId = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
17563
17632
  } catch {
17564
17633
  intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
17565
17634
  }
17566
- const settleInputVtxos = params.inputs.filter(chunk5HCDXBBG_cjs.isVirtualCoin);
17635
+ const settleInputVtxos = params.inputs.filter(chunk4X4SY3RH_cjs.isVirtualCoin);
17567
17636
  const contractManager = await this.getContractManager();
17568
17637
  await contractManager.assertAnnotatable(settleInputVtxos);
17569
17638
  await contractManager.assertSpendableNow?.(
@@ -17574,7 +17643,7 @@ var Wallet2 = class extends ReadonlyWallet {
17574
17643
  assertNoPersistentReservation(params.inputs, this.persistentReservedOutpoints);
17575
17644
  if (picked) this._assertNotHeld(params.inputs);
17576
17645
  this._addPendingSpends(params.inputs);
17577
- const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunk5HCDXBBG_cjs.isVirtualCoin(i))) : [];
17646
+ const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunk4X4SY3RH_cjs.isVirtualCoin(i))) : [];
17578
17647
  for (const key of boardingKeys) this._pendingSpendOutpoints.add(key);
17579
17648
  const settlingKeys = params.inputs.map((i) => `${i.txid}:${i.vout}`);
17580
17649
  for (const key of settlingKeys) this._settlingOutpoints.add(key);
@@ -17688,7 +17757,7 @@ var Wallet2 = class extends ReadonlyWallet {
17688
17757
  async maybeRotateBoardingAfterBoard(inputs) {
17689
17758
  if (!this._descriptorProvider) return;
17690
17759
  const consumedBoarding = inputs.some(
17691
- (input) => typeof input !== "string" && !chunk5HCDXBBG_cjs.isVirtualCoin(input)
17760
+ (input) => typeof input !== "string" && !chunk4X4SY3RH_cjs.isVirtualCoin(input)
17692
17761
  );
17693
17762
  if (!consumedBoarding) return;
17694
17763
  try {
@@ -17699,7 +17768,7 @@ var Wallet2 = class extends ReadonlyWallet {
17699
17768
  }
17700
17769
  async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
17701
17770
  const signedForfeits = [];
17702
- let settlementPsbt = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
17771
+ let settlementPsbt = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
17703
17772
  assertFinalCommitmentMatchesValidated(
17704
17773
  settlementPsbt,
17705
17774
  validatedCommitmentTxid,
@@ -17712,7 +17781,7 @@ var Wallet2 = class extends ReadonlyWallet {
17712
17781
  let connectorIndex = 0;
17713
17782
  const connectorsLeaves = connectorsGraph?.leaves() || [];
17714
17783
  for (const input of inputs) {
17715
- if (!chunk5HCDXBBG_cjs.isVirtualCoin(input)) {
17784
+ if (!chunk4X4SY3RH_cjs.isVirtualCoin(input)) {
17716
17785
  let matched = false;
17717
17786
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
17718
17787
  const settlementInput = settlementPsbt.getInput(i);
@@ -17725,7 +17794,8 @@ var Wallet2 = class extends ReadonlyWallet {
17725
17794
  if (inputTxId !== input.txid) continue;
17726
17795
  if (settlementInput.index !== input.vout) continue;
17727
17796
  settlementPsbt.updateInput(i, {
17728
- tapLeafScript: [input.forfeitTapLeafScript]
17797
+ tapLeafScript: [input.forfeitTapLeafScript],
17798
+ sighashType: btcSigner.SigHash.DEFAULT
17729
17799
  });
17730
17800
  const script = settlementPsbt.getInput(i).witnessUtxo?.script;
17731
17801
  if (!script) {
@@ -17750,7 +17820,7 @@ var Wallet2 = class extends ReadonlyWallet {
17750
17820
  }
17751
17821
  continue;
17752
17822
  }
17753
- if (!chunk5HCDXBBG_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
17823
+ if (!chunk4X4SY3RH_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
17754
17824
  continue;
17755
17825
  }
17756
17826
  if (connectorsLeaves.length === 0) {
@@ -17778,7 +17848,7 @@ var Wallet2 = class extends ReadonlyWallet {
17778
17848
  index: input.vout,
17779
17849
  witnessUtxo: {
17780
17850
  amount: BigInt(input.value),
17781
- script: chunkWIZCF5IX_cjs.VtxoScript.decode(input.tapTree).pkScript
17851
+ script: chunkYAVF2PR6_cjs.VtxoScript.decode(input.tapTree).pkScript
17782
17852
  },
17783
17853
  sighashType: btcSigner.SigHash.DEFAULT,
17784
17854
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -17797,7 +17867,7 @@ var Wallet2 = class extends ReadonlyWallet {
17797
17867
  forfeitTx = await this._signerRouter.sign(forfeitTx, [
17798
17868
  {
17799
17869
  index: 0,
17800
- lookupScript: chunkWIZCF5IX_cjs.VtxoScript.decode(input.tapTree).pkScript
17870
+ lookupScript: chunkYAVF2PR6_cjs.VtxoScript.decode(input.tapTree).pkScript
17801
17871
  }
17802
17872
  ]);
17803
17873
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -17855,7 +17925,7 @@ var Wallet2 = class extends ReadonlyWallet {
17855
17925
  resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
17856
17926
  );
17857
17927
  await this.arkProvider.confirmRegistration(intentId);
17858
- const sweepTapscript = chunkWIZCF5IX_cjs.CSVMultisigTapscript.encode({
17928
+ const sweepTapscript = chunkYAVF2PR6_cjs.CSVMultisigTapscript.encode({
17859
17929
  timelock,
17860
17930
  pubkeys: [this.forfeitPubkey]
17861
17931
  }).script;
@@ -17870,14 +17940,14 @@ var Wallet2 = class extends ReadonlyWallet {
17870
17940
  throw new Error("Sweep tap tree root not set");
17871
17941
  }
17872
17942
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
17873
- (k) => base.hex.encode(chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
17943
+ (k) => base.hex.encode(chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
17874
17944
  );
17875
17945
  const signerPublicKey = await session.getPublicKey();
17876
- const xonlySignerPublicKey = chunkUPIQZRNJ_cjs.toXOnly(signerPublicKey, "signer key");
17946
+ const xonlySignerPublicKey = chunkJA4SYFC7_cjs.toXOnly(signerPublicKey, "signer key");
17877
17947
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
17878
17948
  return { skip: true };
17879
17949
  }
17880
- const commitmentTx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(
17950
+ const commitmentTx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(
17881
17951
  base.base64.decode(event.unsignedCommitmentTx)
17882
17952
  );
17883
17953
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
@@ -17967,9 +18037,9 @@ var Wallet2 = class extends ReadonlyWallet {
17967
18037
  ...existing ?? {},
17968
18038
  proofTxId: intentTxId,
17969
18039
  registerProof: intent.proof,
17970
- registerProofMessage: chunk5HCDXBBG_cjs.Proof.encodeMessage(intent.message),
18040
+ registerProofMessage: chunk4X4SY3RH_cjs.Proof.encodeMessage(intent.message),
17971
18041
  deleteProof: deleteIntent.proof,
17972
- deleteProofMessage: chunk5HCDXBBG_cjs.Proof.encodeMessage(deleteIntent.message),
18042
+ deleteProofMessage: chunk4X4SY3RH_cjs.Proof.encodeMessage(deleteIntent.message),
17973
18043
  proofInputs: inputs.map((i) => ({
17974
18044
  txid: i.txid,
17975
18045
  vout: i.vout
@@ -18001,7 +18071,7 @@ var Wallet2 = class extends ReadonlyWallet {
18001
18071
  }
18002
18072
  /** @see IWallet.cosignOnchainTx */
18003
18073
  async cosignOnchainTx(psbt) {
18004
- const tx = typeof psbt === "string" ? chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(psbt)) : psbt;
18074
+ const tx = typeof psbt === "string" ? chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(psbt)) : psbt;
18005
18075
  return this._withTxLock(async () => {
18006
18076
  await (await this.getContractManager()).syncOnchain();
18007
18077
  return this._cosignOnchainTxImpl(tx);
@@ -18066,7 +18136,7 @@ var Wallet2 = class extends ReadonlyWallet {
18066
18136
  if (reasons.length > 0) throw new OnchainCosignPreflightError(reasons.join("; "));
18067
18137
  }
18068
18138
  const feeRate = await providerFeeRate(this.onchainProvider);
18069
- const tx = new chunk5HCDXBBG_cjs.Transaction({ version: 2 });
18139
+ const tx = new chunk4X4SY3RH_cjs.Transaction({ version: 2 });
18070
18140
  if (sweepTo) {
18071
18141
  const swept = candidates.slice(0, MAX_COSIGN_INPUTS);
18072
18142
  for (const { coin } of swept) {
@@ -18127,7 +18197,7 @@ var Wallet2 = class extends ReadonlyWallet {
18127
18197
  continue;
18128
18198
  }
18129
18199
  const { coin, contract, script } = mine;
18130
- const path = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type).selectPath(script, contract, {
18200
+ const path = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type).selectPath(script, contract, {
18131
18201
  collaborative: true,
18132
18202
  currentTime: Date.now(),
18133
18203
  blockHeight: tip.height,
@@ -18177,7 +18247,7 @@ var Wallet2 = class extends ReadonlyWallet {
18177
18247
  onchainProvider: this.onchainProvider
18178
18248
  });
18179
18249
  } catch (e) {
18180
- if (e instanceof chunk5HCDXBBG_cjs.OnchainCosignAmbiguousError || isCosignRejectedAfterSigning(e)) {
18250
+ if (e instanceof chunk4X4SY3RH_cjs.OnchainCosignAmbiguousError || isCosignRejectedAfterSigning(e)) {
18181
18251
  await markPending(signed.id);
18182
18252
  }
18183
18253
  throw e;
@@ -18197,7 +18267,7 @@ var Wallet2 = class extends ReadonlyWallet {
18197
18267
  this.lockedOutpoints(),
18198
18268
  this.onchainCoins(manager)
18199
18269
  ]);
18200
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkVLO3JAP3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
18270
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkC3NKBKRY_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
18201
18271
  return coins.filter(
18202
18272
  ({ coin, contract }) => !locked.has(vtxoOutpoint(coin)) && needsOnchainSweep(coin, contract, boardingCsv, tip, this._cosignMarginBlocks)
18203
18273
  ).slice(0, MAX_COSIGN_INPUTS).map(({ coin }) => ({ txid: coin.txid, vout: coin.vout }));
@@ -18209,8 +18279,8 @@ var Wallet2 = class extends ReadonlyWallet {
18209
18279
  unspentOnly: true
18210
18280
  });
18211
18281
  return snapshot.flatMap(({ contract, vtxos }) => {
18212
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
18213
- const coins = vtxos.filter((v) => v.isUnrolled && !chunk5HCDXBBG_cjs.isVtxoSpent(v));
18282
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
18283
+ const coins = vtxos.filter((v) => v.isUnrolled && !chunk4X4SY3RH_cjs.isVtxoSpent(v));
18214
18284
  if (!handler || coins.length === 0) return [];
18215
18285
  const script = handler.createScript(contract.params);
18216
18286
  return coins.map((coin) => ({ coin, contract, script }));
@@ -18220,7 +18290,7 @@ var Wallet2 = class extends ReadonlyWallet {
18220
18290
  try {
18221
18291
  return await this.arkProvider.registerIntent(intent);
18222
18292
  } catch (error) {
18223
- if (error instanceof chunk5HCDXBBG_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
18293
+ if (error instanceof chunk4X4SY3RH_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
18224
18294
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
18225
18295
  await this.arkProvider.deleteIntent(deleteIntent);
18226
18296
  return this.arkProvider.registerIntent(intent);
@@ -18236,7 +18306,7 @@ var Wallet2 = class extends ReadonlyWallet {
18236
18306
  expire_at: 0,
18237
18307
  cosigners_public_keys: cosignerPubKeys
18238
18308
  };
18239
- const proof = chunk5HCDXBBG_cjs.Proof.create(message, coins, outputs);
18309
+ const proof = chunk4X4SY3RH_cjs.Proof.create(message, coins, outputs);
18240
18310
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
18241
18311
  return {
18242
18312
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -18248,7 +18318,7 @@ var Wallet2 = class extends ReadonlyWallet {
18248
18318
  type: "delete",
18249
18319
  expire_at: 0
18250
18320
  };
18251
- const proof = chunk5HCDXBBG_cjs.Proof.create(message, coins, []);
18321
+ const proof = chunk4X4SY3RH_cjs.Proof.create(message, coins, []);
18252
18322
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
18253
18323
  return {
18254
18324
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -18260,7 +18330,7 @@ var Wallet2 = class extends ReadonlyWallet {
18260
18330
  type: "get-pending-tx",
18261
18331
  expire_at: 0
18262
18332
  };
18263
- const proof = chunk5HCDXBBG_cjs.Proof.create(message, coins, []);
18333
+ const proof = chunk4X4SY3RH_cjs.Proof.create(message, coins, []);
18264
18334
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
18265
18335
  return {
18266
18336
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -18281,7 +18351,7 @@ var Wallet2 = class extends ReadonlyWallet {
18281
18351
  if (!vtxos || vtxos.length === 0) {
18282
18352
  const scriptMap = await this.getScriptMap();
18283
18353
  const allExtended = [];
18284
- const fetchedVtxos = await chunk5HCDXBBG_cjs.getAllNormalizedVtxos(this.indexerProvider, [
18354
+ const fetchedVtxos = await chunk4X4SY3RH_cjs.getAllNormalizedVtxos(this.indexerProvider, [
18285
18355
  ...scriptMap.keys()
18286
18356
  ]);
18287
18357
  for (const vtxo of fetchedVtxos) {
@@ -18323,17 +18393,32 @@ var Wallet2 = class extends ReadonlyWallet {
18323
18393
  seen.add(pendingTx.arkTxid);
18324
18394
  batchPending.push(pendingTx.arkTxid);
18325
18395
  try {
18396
+ const context = `pending tx ${pendingTx.arkTxid}`;
18326
18397
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
18327
- const tx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(c));
18328
- chunk5HCDXBBG_cjs.assertAllowedSighashTypes(tx);
18398
+ const tx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(c));
18399
+ chunk4X4SY3RH_cjs.assertAllowedSighashTypes(tx);
18329
18400
  return tx;
18330
18401
  });
18331
- assertCheckpointsMatchInputs(
18402
+ const localCheckpoints = assertCheckpointsMatchInputs(
18332
18403
  checkpointTxs,
18333
18404
  checkpointInputs,
18334
18405
  unrollCandidates,
18335
- `pending tx ${pendingTx.arkTxid}`
18406
+ context
18407
+ );
18408
+ if (!pendingTx.finalArkTx) {
18409
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
18410
+ `${context}: no final ark tx to bind the checkpoints to`
18411
+ );
18412
+ }
18413
+ const finalArkTx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(
18414
+ base.base64.decode(pendingTx.finalArkTx)
18336
18415
  );
18416
+ if (finalArkTx.id !== pendingTx.arkTxid) {
18417
+ throw new chunk4X4SY3RH_cjs.ServerResponseMismatchError(
18418
+ `${context}: final ark tx is ${finalArkTx.id}`
18419
+ );
18420
+ }
18421
+ assertArkTxSignedOverCheckpoints(finalArkTx, localCheckpoints, context);
18337
18422
  const checkpointJobs = checkpointTxs.map(
18338
18423
  (tx) => this.inputSigningJobsFromWitnessUtxos(tx)
18339
18424
  );
@@ -18402,7 +18487,7 @@ var Wallet2 = class extends ReadonlyWallet {
18402
18487
  const candidates = [this._serverUnrollScript, current];
18403
18488
  for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
18404
18489
  candidates.push(
18405
- chunkWIZCF5IX_cjs.CSVMultisigTapscript.encode({
18490
+ chunkYAVF2PR6_cjs.CSVMultisigTapscript.encode({
18406
18491
  ...current.params,
18407
18492
  pubkeys: [base.hex.decode(deprecated)]
18408
18493
  })
@@ -18497,7 +18582,7 @@ var Wallet2 = class extends ReadonlyWallet {
18497
18582
  if (vtxos.length === 0) {
18498
18583
  throw new Error("No VTXOs found for this arkadeCash");
18499
18584
  }
18500
- const myPkScript = chunkWIZCF5IX_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
18585
+ const myPkScript = chunkYAVF2PR6_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
18501
18586
  let { spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos);
18502
18587
  let swept = 0;
18503
18588
  const claims = [];
@@ -18553,6 +18638,7 @@ var Wallet2 = class extends ReadonlyWallet {
18553
18638
  ],
18554
18639
  outputs: [{ script: myPkScript, amount: BigInt(vtxo.value) }],
18555
18640
  serverUnrollScript,
18641
+ verifyServerSignatures: { serverPubkey: cash.serverPubKey },
18556
18642
  oneShot: this.oneShotSubmit
18557
18643
  });
18558
18644
  claims.push({ txid: registeredTxid, amount: vtxo.value });
@@ -18634,7 +18720,7 @@ var Wallet2 = class extends ReadonlyWallet {
18634
18720
  params: {
18635
18721
  pubKey: base.hex.encode(cash.publicKey),
18636
18722
  serverPubKey: base.hex.encode(cash.serverPubKey),
18637
- csvTimelock: chunkWIZCF5IX_cjs.timelockToSequence(cash.csvTimelock).toString()
18723
+ csvTimelock: chunkYAVF2PR6_cjs.timelockToSequence(cash.csvTimelock).toString()
18638
18724
  },
18639
18725
  script: base.hex.encode(cashScript.pkScript),
18640
18726
  address: cashAddress.encode(),
@@ -18745,7 +18831,7 @@ var Wallet2 = class extends ReadonlyWallet {
18745
18831
  const recoverable = [];
18746
18832
  const unclaimed = [];
18747
18833
  for (const vtxo of vtxos) {
18748
- if (chunk5HCDXBBG_cjs.isVtxoSpent(vtxo)) {
18834
+ if (chunk4X4SY3RH_cjs.isVtxoSpent(vtxo)) {
18749
18835
  unclaimed.push(cashReport(vtxo, "already-spent"));
18750
18836
  } else if (vtxo.isUnrolled) {
18751
18837
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -18765,8 +18851,8 @@ var Wallet2 = class extends ReadonlyWallet {
18765
18851
  async fetchAllVtxos(scripts) {
18766
18852
  const all = [];
18767
18853
  const seen = /* @__PURE__ */ new Set();
18768
- for await (const { vtxos } of chunk5HCDXBBG_cjs.indexerPages(
18769
- (pageIndex) => chunk5HCDXBBG_cjs.getNormalizedVtxos(this.indexerProvider, {
18854
+ for await (const { vtxos } of chunk4X4SY3RH_cjs.indexerPages(
18855
+ (pageIndex) => chunk4X4SY3RH_cjs.getNormalizedVtxos(this.indexerProvider, {
18770
18856
  scripts,
18771
18857
  pageIndex,
18772
18858
  pageSize: 100
@@ -18810,7 +18896,7 @@ var Wallet2 = class extends ReadonlyWallet {
18810
18896
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_PROOF) {
18811
18897
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_PROOF);
18812
18898
  const message = { type: "get-pending-tx", expire_at: 0 };
18813
- const proof = chunk5HCDXBBG_cjs.Proof.create(message, batch, []);
18899
+ const proof = chunk4X4SY3RH_cjs.Proof.create(message, batch, []);
18814
18900
  const signedProof = await identity.sign(
18815
18901
  proof,
18816
18902
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -18831,8 +18917,8 @@ var Wallet2 = class extends ReadonlyWallet {
18831
18917
  for (const pendingTx of pendingTxs) {
18832
18918
  try {
18833
18919
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
18834
- const tx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
18835
- chunk5HCDXBBG_cjs.assertAllowedSighashTypes(tx);
18920
+ const tx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
18921
+ chunk4X4SY3RH_cjs.assertAllowedSighashTypes(tx);
18836
18922
  return tx;
18837
18923
  });
18838
18924
  assertCheckpointsMatchInputs(
@@ -18873,7 +18959,7 @@ var Wallet2 = class extends ReadonlyWallet {
18873
18959
  }
18874
18960
  /** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
18875
18961
  arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
18876
- const arkTx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
18962
+ const arkTx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
18877
18963
  let total = 0;
18878
18964
  for (let i = 0; i < arkTx.outputsLength; i++) {
18879
18965
  const output = arkTx.getOutput(i);
@@ -18933,7 +19019,7 @@ var Wallet2 = class extends ReadonlyWallet {
18933
19019
  }
18934
19020
  if (selectedVtxos) {
18935
19021
  await assertNoIntentLockedInputs(selectedVtxos, this.intentRepository);
18936
- if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo);
19022
+ if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo);
18937
19023
  if (inputExpiryFloor && selectedVtxos.some((coin) => !meetsInputExpiryFloor(coin, inputExpiryFloor))) {
18938
19024
  throw new Error("send({ selectedVtxos }): input expiry floor not met");
18939
19025
  }
@@ -19068,7 +19154,7 @@ var Wallet2 = class extends ReadonlyWallet {
19068
19154
  script: recipient.script,
19069
19155
  amount: BigInt(recipient.amount),
19070
19156
  // Already checked against the recipient address in `validateRecipients`.
19071
- ...recipient.tapTree ? { tapTree: chunkWIZCF5IX_cjs.toBIP371TapTree(recipient.tapTree) } : {}
19157
+ ...recipient.tapTree ? { tapTree: chunkYAVF2PR6_cjs.toBIP371TapTree(recipient.tapTree) } : {}
19072
19158
  }));
19073
19159
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
19074
19160
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -19262,10 +19348,10 @@ var Wallet2 = class extends ReadonlyWallet {
19262
19348
  const serverPubKey = this.arkServerPublicKey;
19263
19349
  const serverUnrollScript = this.serverUnrollScript;
19264
19350
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
19265
- const normalizedInputs = inputs.map(chunk5HCDXBBG_cjs.normalizeVtxo);
19266
- const at = now ?? await chunk5HCDXBBG_cjs.resolveTimeHeight(this.onchainProvider);
19351
+ const normalizedInputs = inputs.map(chunk4X4SY3RH_cjs.normalizeVtxo);
19352
+ const at = now ?? await chunk4X4SY3RH_cjs.resolveTimeHeight(this.onchainProvider);
19267
19353
  for (const input of normalizedInputs) {
19268
- if (!chunk5HCDXBBG_cjs.canSpendOffchain(input, at)) {
19354
+ if (!chunk4X4SY3RH_cjs.canSpendOffchain(input, at)) {
19269
19355
  throw new Error(
19270
19356
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
19271
19357
  );
@@ -19361,7 +19447,7 @@ var Wallet2 = class extends ReadonlyWallet {
19361
19447
  );
19362
19448
  const arkTxJobs = inputs.map((input, index) => ({
19363
19449
  index,
19364
- lookupScript: chunkWIZCF5IX_cjs.VtxoScript.decode(input.tapTree).pkScript
19450
+ lookupScript: chunkYAVF2PR6_cjs.VtxoScript.decode(input.tapTree).pkScript
19365
19451
  }));
19366
19452
  const identity = this.identity;
19367
19453
  const signer = {
@@ -19471,7 +19557,7 @@ var Wallet2 = class extends ReadonlyWallet {
19471
19557
  }
19472
19558
  const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
19473
19559
  for (const encoded of signedCheckpointTxs) {
19474
- const checkpoint = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
19560
+ const checkpoint = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
19475
19561
  for (let i = 0; i < checkpoint.inputsLength; i++) {
19476
19562
  const input = checkpoint.getInput(i);
19477
19563
  if (!input.txid) continue;
@@ -19588,12 +19674,12 @@ var Wallet2 = class extends ReadonlyWallet {
19588
19674
  const inputArkTxIds = /* @__PURE__ */ new Set();
19589
19675
  const boardingScripts = /* @__PURE__ */ new Set();
19590
19676
  const boardingOutpoints = [];
19591
- const vtxoInputs = inputs.filter(chunk5HCDXBBG_cjs.isVirtualCoin);
19677
+ const vtxoInputs = inputs.filter(chunk4X4SY3RH_cjs.isVirtualCoin);
19592
19678
  const cm = await this.getContractManager();
19593
19679
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
19594
19680
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
19595
19681
  for (const input of inputs) {
19596
- if (chunk5HCDXBBG_cjs.isVirtualCoin(input)) {
19682
+ if (chunk4X4SY3RH_cjs.isVirtualCoin(input)) {
19597
19683
  const outpoint = `${input.txid}:${input.vout}`;
19598
19684
  const vtxo = annotatedByKey.get(outpoint);
19599
19685
  if (!vtxo) {
@@ -19610,7 +19696,7 @@ var Wallet2 = class extends ReadonlyWallet {
19610
19696
  } else {
19611
19697
  let pkScript;
19612
19698
  try {
19613
- pkScript = chunkWIZCF5IX_cjs.VtxoScript.decode(input.tapTree).pkScript;
19699
+ pkScript = chunkYAVF2PR6_cjs.VtxoScript.decode(input.tapTree).pkScript;
19614
19700
  } catch {
19615
19701
  pkScript = this.boardingTapscript.pkScript;
19616
19702
  }
@@ -19676,7 +19762,7 @@ function bySelectionOrder(a, b) {
19676
19762
  return b.value - a.value;
19677
19763
  }
19678
19764
  function selectVirtualCoins(coins, targetAmount) {
19679
- const sortedCoins = coins.map(chunk5HCDXBBG_cjs.normalizeVtxo).sort(bySelectionOrder);
19765
+ const sortedCoins = coins.map(chunk4X4SY3RH_cjs.normalizeVtxo).sort(bySelectionOrder);
19680
19766
  const selectedCoins = [];
19681
19767
  let selectedAmount = 0;
19682
19768
  for (const coin of sortedCoins) {
@@ -20130,7 +20216,7 @@ function assertTimeoutMap(name, timeouts) {
20130
20216
  if (value === void 0) {
20131
20217
  throw new Error(`${name}.${key} must be a non-negative safe integer`);
20132
20218
  }
20133
- chunk5HCDXBBG_cjs.assertTimerMs(`${name}.${key}`, value);
20219
+ chunk4X4SY3RH_cjs.assertTimerMs(`${name}.${key}`, value);
20134
20220
  }
20135
20221
  }
20136
20222
  var MessageBus = class {
@@ -20147,8 +20233,8 @@ var MessageBus = class {
20147
20233
  }) {
20148
20234
  this.walletRepository = walletRepository;
20149
20235
  this.contractRepository = contractRepository;
20150
- chunk5HCDXBBG_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
20151
- chunk5HCDXBBG_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
20236
+ chunk4X4SY3RH_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
20237
+ chunk4X4SY3RH_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
20152
20238
  assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
20153
20239
  this.intentRepository = intentRepository;
20154
20240
  this.onchainProvider = onchainProvider;
@@ -20407,14 +20493,14 @@ var MessageBus = class {
20407
20493
  this.initialized = true;
20408
20494
  }
20409
20495
  async buildServices(config) {
20410
- const arkProvider = new chunk5HCDXBBG_cjs.RestOperatorProvider(config.arkServer.url);
20496
+ const arkProvider = new chunk4X4SY3RH_cjs.RestOperatorProvider(config.arkServer.url);
20411
20497
  const storage = {
20412
20498
  walletRepository: this.walletRepository,
20413
20499
  contractRepository: this.contractRepository,
20414
20500
  ...this.intentRepository && { intentRepository: this.intentRepository }
20415
20501
  };
20416
20502
  const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
20417
- const indexerProvider = new chunkGEK6QBSY_cjs.RestIndexerProvider(config.arkServer.url);
20503
+ const indexerProvider = new chunkQV7AOZZN_cjs.RestIndexerProvider(config.arkServer.url);
20418
20504
  const serialized = normalizeSerializedIdentity(config.wallet);
20419
20505
  if (isSigningSerialized(serialized)) {
20420
20506
  const identity2 = hydrateIdentity(serialized);
@@ -20791,7 +20877,7 @@ var offboardNetworkNames = [
20791
20877
  function offboardDestinationScript(destinationAddress) {
20792
20878
  for (const networkName of offboardNetworkNames) {
20793
20879
  try {
20794
- const network = chunkWIZCF5IX_cjs.networks[networkName];
20880
+ const network = chunkYAVF2PR6_cjs.networks[networkName];
20795
20881
  const addr = btcSigner.Address(network).decode(destinationAddress);
20796
20882
  return btcSigner.OutScript.encode(addr);
20797
20883
  } catch {
@@ -20831,7 +20917,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
20831
20917
  const inputs = [];
20832
20918
  let subtotal = 0n;
20833
20919
  for (const vtxo of vtxos) {
20834
- const inputFee = estimator.evalOffchainInput(chunk5HCDXBBG_cjs.toOffchainInputFeeParams(vtxo));
20920
+ const inputFee = estimator.evalOffchainInput(chunk4X4SY3RH_cjs.toOffchainInputFeeParams(vtxo));
20835
20921
  if (inputFee.satoshis >= vtxo.value) {
20836
20922
  if (named) {
20837
20923
  throw new Error(
@@ -20928,7 +21014,7 @@ var Ramps = class {
20928
21014
  }
20929
21015
  amount = amount ?? totalAmount;
20930
21016
  const offchainAddress = await this.wallet.getAddress();
20931
- const offchainAddr = chunkWIZCF5IX_cjs.ArkAddress.decode(offchainAddress);
21017
+ const offchainAddr = chunkYAVF2PR6_cjs.ArkAddress.decode(offchainAddress);
20932
21018
  const offchainScript = base.hex.encode(offchainAddr.pkScript);
20933
21019
  const outputFee = estimator.evalOffchainOutput({
20934
21020
  amount,
@@ -21073,7 +21159,7 @@ var Ramps = class {
21073
21159
  outputs: [{ address, amount: Number(amount) }]
21074
21160
  });
21075
21161
  } catch (e) {
21076
- if (!isCosignFallback(e)) throw e;
21162
+ if (!isCosignFallback(e) || e instanceof chunk4X4SY3RH_cjs.OnchainCosignRejectedError) throw e;
21077
21163
  return void 0;
21078
21164
  }
21079
21165
  }
@@ -21096,7 +21182,7 @@ var Ramps = class {
21096
21182
  const ordered = [...candidates].sort(bySelectionOrder);
21097
21183
  let covered = 0n;
21098
21184
  for (let i = 0; i < ordered.length && i < MAX_VTXOS_PER_SETTLEMENT; i++) {
21099
- const fee = estimator.evalOffchainInput(chunk5HCDXBBG_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
21185
+ const fee = estimator.evalOffchainInput(chunk4X4SY3RH_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
21100
21186
  covered += BigInt(ordered[i].value) - BigInt(fee);
21101
21187
  if (covered < needed) continue;
21102
21188
  try {
@@ -21130,7 +21216,7 @@ var Ramps = class {
21130
21216
  async fundChange(left, estimator) {
21131
21217
  if (left <= 0n) return { change: 0n };
21132
21218
  const changeAddress = await this.wallet.getAddress();
21133
- const changeScript = base.hex.encode(chunkWIZCF5IX_cjs.ArkAddress.decode(changeAddress).pkScript);
21219
+ const changeScript = base.hex.encode(chunkYAVF2PR6_cjs.ArkAddress.decode(changeAddress).pkScript);
21134
21220
  const { change } = changeAfterOutputFee(
21135
21221
  left,
21136
21222
  (amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
@@ -21169,11 +21255,11 @@ async function readArkadeCash(token, indexer, info, onchain) {
21169
21255
  if (signer.status === "UNKNOWN_SIGNER") {
21170
21256
  throw new Error("ArkadeCash belongs to another operator");
21171
21257
  }
21172
- const coins = await chunk5HCDXBBG_cjs.getAllNormalizedVtxos(indexer, [arkadeCashId(cash)]);
21258
+ const coins = await chunk4X4SY3RH_cjs.getAllNormalizedVtxos(indexer, [arkadeCashId(cash)]);
21173
21259
  return classifyArkadeCash(
21174
21260
  coins,
21175
21261
  info.dust,
21176
- await chunk5HCDXBBG_cjs.resolveTimeHeight(onchain),
21262
+ await chunk4X4SY3RH_cjs.resolveTimeHeight(onchain),
21177
21263
  signer.status === "EXPIRED"
21178
21264
  );
21179
21265
  }
@@ -21181,16 +21267,16 @@ function classifyArkadeCash(coins, dust, now, awaitingSweep = false) {
21181
21267
  const eligible = coins.filter(
21182
21268
  (coin) => coin.value >= Number(dust) && !(coin.assets && coin.assets.length > 0)
21183
21269
  );
21184
- const hasSpent = eligible.some(chunk5HCDXBBG_cjs.isVtxoSpent);
21185
- const hasLive = eligible.some((coin) => !chunk5HCDXBBG_cjs.isVtxoSpent(coin) && !coin.isUnrolled);
21186
- const hasExit = eligible.some((coin) => !chunk5HCDXBBG_cjs.isVtxoSpent(coin) && coin.isUnrolled);
21187
- const recoverable = eligible.some((coin) => !chunk5HCDXBBG_cjs.isVtxoSpent(coin) && coin.isSwept);
21270
+ const hasSpent = eligible.some(chunk4X4SY3RH_cjs.isVtxoSpent);
21271
+ const hasLive = eligible.some((coin) => !chunk4X4SY3RH_cjs.isVtxoSpent(coin) && !coin.isUnrolled);
21272
+ const hasExit = eligible.some((coin) => !chunk4X4SY3RH_cjs.isVtxoSpent(coin) && coin.isUnrolled);
21273
+ const recoverable = eligible.some((coin) => !chunk4X4SY3RH_cjs.isVtxoSpent(coin) && coin.isSwept);
21188
21274
  const elapsedBatch = eligible.some(
21189
- (coin) => !chunk5HCDXBBG_cjs.isVtxoSpent(coin) && !coin.isSwept && chunk5HCDXBBG_cjs.isPastExpiry(coin, now)
21275
+ (coin) => !chunk4X4SY3RH_cjs.isVtxoSpent(coin) && !coin.isSwept && chunk4X4SY3RH_cjs.isPastExpiry(coin, now)
21190
21276
  );
21191
21277
  return {
21192
21278
  status: eligible.length === 0 ? "unissued" : hasExit && !hasLive ? "exited" : hasSpent && !hasLive ? "claimed" : recoverable ? "recovering" : elapsedBatch || awaitingSweep ? "expired" : "available",
21193
- amount: eligible.reduce((sum, coin) => sum + (chunk5HCDXBBG_cjs.isVtxoSpent(coin) ? 0 : coin.value), 0),
21279
+ amount: eligible.reduce((sum, coin) => sum + (chunk4X4SY3RH_cjs.isVtxoSpent(coin) ? 0 : coin.value), 0),
21194
21280
  issues: groupByTxid(eligible),
21195
21281
  claims: groupByTxid(
21196
21282
  // `||`: the indexer reports an unset id as an empty string, not as absent.
@@ -22883,7 +22969,7 @@ var WalletMessageHandler = class {
22883
22969
  this.repoSnapshot({}, context),
22884
22970
  wallet.getBoardingTxs()
22885
22971
  ]);
22886
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunk5HCDXBBG_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
22972
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunk4X4SY3RH_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
22887
22973
  return buildTransactionHistory(
22888
22974
  vtxos,
22889
22975
  boardingTxs,
@@ -22952,9 +23038,9 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
22952
23038
  // budget so the worker's snapshot fallback stays reachable before this
22953
23039
  // page deadline fires — lowering it below the budget would time the page
22954
23040
  // out while the worker is still seconds from answering from cache.
22955
- GET_OPERATOR_INFO: chunk5HCDXBBG_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
23041
+ GET_OPERATOR_INFO: chunk4X4SY3RH_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
22956
23042
  /** @deprecated Use `GET_OPERATOR_INFO`. */
22957
- GET_ARKADE_INFO: chunk5HCDXBBG_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
23043
+ GET_ARKADE_INFO: chunk4X4SY3RH_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
22958
23044
  INDEXER_GET_VTXOS: 2e4,
22959
23045
  INDEXER_GET_VIRTUAL_TXS: 2e4,
22960
23046
  GET_VTXOS: 2e4,
@@ -23057,10 +23143,10 @@ function getRequestDedupKey(request) {
23057
23143
  }
23058
23144
  function cosignWorkerError(e) {
23059
23145
  if (e instanceof Error && e.message === "Unknown message") {
23060
- return new chunk5HCDXBBG_cjs.OnchainCosignUnsupportedError();
23146
+ return new chunk4X4SY3RH_cjs.OnchainCosignUnsupportedError();
23061
23147
  }
23062
23148
  if (e instanceof ServiceWorkerTimeoutError) {
23063
- return new chunk5HCDXBBG_cjs.OnchainCosignAmbiguousError(e.message, { cause: e });
23149
+ return new chunk4X4SY3RH_cjs.OnchainCosignAmbiguousError(e.message, { cause: e });
23064
23150
  }
23065
23151
  return rehydrateCosignError(e);
23066
23152
  }
@@ -23115,7 +23201,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
23115
23201
  }
23116
23202
  };
23117
23203
  var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
23118
- chunk5HCDXBBG_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
23204
+ chunk4X4SY3RH_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
23119
23205
  const initCmd = {
23120
23206
  tag: "INITIALIZE_MESSAGE_BUS",
23121
23207
  id: getRandomId(),
@@ -23228,7 +23314,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
23228
23314
  }
23229
23315
  /** Shared tail of both `create()` factories: boot the bus, INIT_WALLET, cache for reinit. */
23230
23316
  static async bootstrap(wallet, options, serializedWallet, busConfig) {
23231
- const arkServer = { ...options.arkServer ?? { url: chunkWIZCF5IX_cjs.DEFAULT_ARKADE_SERVER_URL } };
23317
+ const arkServer = { ...options.arkServer ?? { url: chunkYAVF2PR6_cjs.DEFAULT_ARKADE_SERVER_URL } };
23232
23318
  wallet.expectedWalletScope = vtxoReservationScope(
23233
23319
  arkServer.url,
23234
23320
  await wallet.identity.xOnlyPublicKey()
@@ -23243,7 +23329,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
23243
23329
  Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
23244
23330
  );
23245
23331
  for (const [key, value] of Object.entries(overrides)) {
23246
- chunk5HCDXBBG_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
23332
+ chunk4X4SY3RH_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
23247
23333
  }
23248
23334
  const messageTimeouts = {
23249
23335
  ...DEFAULT_MESSAGE_TIMEOUTS,
@@ -23535,7 +23621,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
23535
23621
  if (!this.expectedWalletScope || binding.scope !== this.expectedWalletScope) {
23536
23622
  throw new Error("Worker wallet request scope differs from the configured operator");
23537
23623
  }
23538
- chunkWIZCF5IX_cjs.getNetwork(binding.network);
23624
+ chunkYAVF2PR6_cjs.getNetwork(binding.network);
23539
23625
  if (this.expectedNetwork !== void 0 && binding.network !== this.expectedNetwork) {
23540
23626
  throw new Error("Worker wallet mutation network differs from the configured network");
23541
23627
  }
@@ -23622,7 +23708,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
23622
23708
  try {
23623
23709
  const response = await this.sendMessage(message);
23624
23710
  const { vtxos, page } = response.payload;
23625
- return { vtxos: vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo), page: page && { ...page } };
23711
+ return { vtxos: vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo), page: page && { ...page } };
23626
23712
  } catch (cause) {
23627
23713
  throw new Error(`Failed to get vtxos: ${cause}`, { cause });
23628
23714
  }
@@ -23731,7 +23817,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
23731
23817
  };
23732
23818
  try {
23733
23819
  const response = await this.sendMessage(message);
23734
- return response.payload.vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo);
23820
+ return response.payload.vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo);
23735
23821
  } catch (error) {
23736
23822
  throw new Error(`Failed to get vtxos: ${error}`);
23737
23823
  }
@@ -23762,7 +23848,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
23762
23848
  "Service worker does not support the requested contract scope or freshness check"
23763
23849
  );
23764
23850
  }
23765
- return payload.vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo);
23851
+ return payload.vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo);
23766
23852
  } catch (error) {
23767
23853
  throw new Error(`Failed to get spendable vtxos: ${error}`);
23768
23854
  }
@@ -23971,7 +24057,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
23971
24057
  };
23972
24058
  try {
23973
24059
  const response = await sendContractMessage(message);
23974
- return response.payload.vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo);
24060
+ return response.payload.vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo);
23975
24061
  } catch (cause) {
23976
24062
  throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
23977
24063
  }
@@ -24669,7 +24755,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
24669
24755
  };
24670
24756
  try {
24671
24757
  const response = await wallet.sendMessage(message);
24672
- return response.payload.vtxos.map(chunk5HCDXBBG_cjs.normalizeVtxo);
24758
+ return response.payload.vtxos.map(chunk4X4SY3RH_cjs.normalizeVtxo);
24673
24759
  } catch (e) {
24674
24760
  throw new Error(`Failed to get expiring vtxos: ${e}`);
24675
24761
  }
@@ -25550,7 +25636,7 @@ var CachingOperatorProvider = class {
25550
25636
  constructor(inner, ttlMs = DEFAULT_TTL_MS) {
25551
25637
  this.inner = inner;
25552
25638
  this.ttlMs = ttlMs;
25553
- chunk5HCDXBBG_cjs.assertNonNegativeMs("ttlMs", ttlMs);
25639
+ chunk4X4SY3RH_cjs.assertNonNegativeMs("ttlMs", ttlMs);
25554
25640
  this.unsubscribe = inner.onServerInfoChanged?.((info) => {
25555
25641
  this.cached = info;
25556
25642
  this.expiresAt = Date.now() + this.ttlMs;
@@ -25637,7 +25723,7 @@ exports.BIP322 = void 0;
25637
25723
  async function sign2(message, identity, network) {
25638
25724
  const xOnlyPubKey = await identity.xOnlyPublicKey();
25639
25725
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
25640
- const toSpend = chunk5HCDXBBG_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
25726
+ const toSpend = chunk4X4SY3RH_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
25641
25727
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
25642
25728
  const signed = await identity.sign(toSign, [0]);
25643
25729
  signed.finalizeIdx(0);
@@ -25695,7 +25781,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
25695
25781
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
25696
25782
  return false;
25697
25783
  }
25698
- const toSpend = chunk5HCDXBBG_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
25784
+ const toSpend = chunk4X4SY3RH_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
25699
25785
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
25700
25786
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
25701
25787
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -25716,7 +25802,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
25716
25802
  }
25717
25803
  const sighashType = sigWithHash[sigWithHash.length - 1];
25718
25804
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
25719
- const toSpend = chunk5HCDXBBG_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
25805
+ const toSpend = chunk4X4SY3RH_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
25720
25806
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
25721
25807
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
25722
25808
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -25769,7 +25855,7 @@ function encodeCompactSize(n) {
25769
25855
  return buf;
25770
25856
  }
25771
25857
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
25772
- const tx = new chunk5HCDXBBG_cjs.Transaction({ version: 0 });
25858
+ const tx = new chunk4X4SY3RH_cjs.Transaction({ version: 0 });
25773
25859
  tx.addInput({
25774
25860
  txid: toSpend.id,
25775
25861
  index: 0,
@@ -25783,12 +25869,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
25783
25869
  });
25784
25870
  tx.addOutput({
25785
25871
  amount: 0n,
25786
- script: chunk5HCDXBBG_cjs.OP_RETURN_EMPTY_PKSCRIPT
25872
+ script: chunk4X4SY3RH_cjs.OP_RETURN_EMPTY_PKSCRIPT
25787
25873
  });
25788
25874
  return tx;
25789
25875
  }
25790
25876
  function craftBIP322ToSignSimple(toSpend, pkScript) {
25791
- const tx = new chunk5HCDXBBG_cjs.Transaction({ version: 0 });
25877
+ const tx = new chunk4X4SY3RH_cjs.Transaction({ version: 0 });
25792
25878
  tx.addInput({
25793
25879
  txid: toSpend.id,
25794
25880
  index: 0,
@@ -25800,12 +25886,12 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
25800
25886
  });
25801
25887
  tx.addOutput({
25802
25888
  amount: 0n,
25803
- script: chunk5HCDXBBG_cjs.OP_RETURN_EMPTY_PKSCRIPT
25889
+ script: chunk4X4SY3RH_cjs.OP_RETURN_EMPTY_PKSCRIPT
25804
25890
  });
25805
25891
  return tx;
25806
25892
  }
25807
25893
  function finalizeVirtualTx(type, psbtBase64) {
25808
- const tx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
25894
+ const tx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
25809
25895
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
25810
25896
  const input = tx.getInput(0);
25811
25897
  if (!input) {
@@ -25832,14 +25918,14 @@ var ExitPathError = class extends Error {
25832
25918
  reason;
25833
25919
  };
25834
25920
  function delayWeight(sequence) {
25835
- const t = chunkWIZCF5IX_cjs.sequenceToTimelock(sequence);
25921
+ const t = chunkYAVF2PR6_cjs.sequenceToTimelock(sequence);
25836
25922
  return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
25837
25923
  }
25838
25924
  async function resolveUnilateralPath(params) {
25839
25925
  const { vtxo, scriptHex, contractRepository } = params;
25840
25926
  const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
25841
25927
  if (contract) {
25842
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
25928
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
25843
25929
  if (!handler) {
25844
25930
  throw new ExitPathError(
25845
25931
  "no-handler",
@@ -25861,12 +25947,12 @@ async function resolveUnilateralPath(params) {
25861
25947
  paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
25862
25948
  return { selection: paths[0], label: `${contract.type}:unilateral` };
25863
25949
  }
25864
- const decoded = chunkWIZCF5IX_cjs.VtxoScript.decode(vtxo.tapTree);
25950
+ const decoded = chunkYAVF2PR6_cjs.VtxoScript.decode(vtxo.tapTree);
25865
25951
  let best;
25866
25952
  for (const exit of decoded.exitPaths()) {
25867
25953
  const leaf = decoded.findLeaf(base.hex.encode(exit.script));
25868
25954
  if (!leaf) continue;
25869
- const sequence = chunkWIZCF5IX_cjs.timelockToSequence(exit.params.timelock);
25955
+ const sequence = chunkYAVF2PR6_cjs.timelockToSequence(exit.params.timelock);
25870
25956
  const weight = delayWeight(sequence);
25871
25957
  if (!best || weight < best.weight) {
25872
25958
  best = { selection: { leaf, sequence }, weight };
@@ -26075,7 +26161,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
26075
26161
  let totalAmount = 0n;
26076
26162
  const txWeightEstimator = TxWeightEstimator.create();
26077
26163
  for (const vtxo of vtxos) {
26078
- if (!chunk5HCDXBBG_cjs.canSweepOnchain(vtxo)) {
26164
+ if (!chunk4X4SY3RH_cjs.canSweepOnchain(vtxo)) {
26079
26165
  throw new Error(
26080
26166
  `Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
26081
26167
  );
@@ -26087,7 +26173,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
26087
26173
  wallet.onchainProvider.getTxStatus(vtxo.txid),
26088
26174
  resolveUnilateralPath({
26089
26175
  vtxo,
26090
- scriptHex: base.hex.encode(chunkWIZCF5IX_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
26176
+ scriptHex: base.hex.encode(chunkYAVF2PR6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
26091
26177
  contractRepository: wallet.contractRepository,
26092
26178
  walletDescriptor,
26093
26179
  currentTime: Date.now()
@@ -26098,7 +26184,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
26098
26184
  }
26099
26185
  const spendingLeaf = resolved.selection.leaf;
26100
26186
  const sequence = resolved.selection.sequence;
26101
- const timelock = chunkWIZCF5IX_cjs.sequenceToTimelock(sequence);
26187
+ const timelock = chunkYAVF2PR6_cjs.sequenceToTimelock(sequence);
26102
26188
  const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
26103
26189
  if (!elapsed) {
26104
26190
  throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
@@ -26117,7 +26203,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
26117
26203
  sequence,
26118
26204
  witnessUtxo: {
26119
26205
  amount: BigInt(vtxo.value),
26120
- script: chunkWIZCF5IX_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
26206
+ script: chunkYAVF2PR6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
26121
26207
  },
26122
26208
  sighashType: btcSigner.SigHash.DEFAULT
26123
26209
  });
@@ -26127,7 +26213,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
26127
26213
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
26128
26214
  );
26129
26215
  }
26130
- const tx = new chunk5HCDXBBG_cjs.Transaction({ version: 2 });
26216
+ const tx = new chunk4X4SY3RH_cjs.Transaction({ version: 2 });
26131
26217
  for (const input of inputs) {
26132
26218
  tx.addInput(input);
26133
26219
  }
@@ -26207,7 +26293,7 @@ async function buildSignedSweep(params) {
26207
26293
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
26208
26294
  );
26209
26295
  }
26210
- const tx = new chunk5HCDXBBG_cjs.Transaction({ version: 2 });
26296
+ const tx = new chunk4X4SY3RH_cjs.Transaction({ version: 2 });
26211
26297
  tx.addInput({
26212
26298
  txid: vtxo.txid,
26213
26299
  index: vtxo.vout,
@@ -26232,7 +26318,7 @@ async function buildSignedSweep(params) {
26232
26318
  finalScriptWitness: [
26233
26319
  tapScriptSig[0][1],
26234
26320
  ...path.extraWitness,
26235
- chunkWIZCF5IX_cjs.scriptFromTapLeafScript(path.leaf),
26321
+ chunkYAVF2PR6_cjs.scriptFromTapLeafScript(path.leaf),
26236
26322
  btcSigner.TaprootControlBlock.encode(controlBlock)
26237
26323
  ]
26238
26324
  });
@@ -26260,7 +26346,7 @@ async function resolveFeeRate(opts) {
26260
26346
  }
26261
26347
  async function selectExitVtxos(opts) {
26262
26348
  if (!opts.vtxos) return opts.wallet.getVtxos();
26263
- const res = await chunk5HCDXBBG_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
26349
+ const res = await chunk4X4SY3RH_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
26264
26350
  const scripts = [
26265
26351
  ...new Set(res.vtxos.filter((vtxo) => !vtxo.isSpent).map((vtxo) => vtxo.script))
26266
26352
  ];
@@ -26278,7 +26364,7 @@ async function selectExitVtxos(opts) {
26278
26364
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
26279
26365
  );
26280
26366
  }
26281
- const handler = chunkVLO3JAP3_cjs.contractHandlers.get(contract.type);
26367
+ const handler = chunkC3NKBKRY_cjs.contractHandlers.get(contract.type);
26282
26368
  if (!handler) {
26283
26369
  throw new Error(`no contract handler registered for type '${contract.type}'`);
26284
26370
  }
@@ -26312,7 +26398,7 @@ async function computeExitLayout(opts, feeRate) {
26312
26398
  if (pendingNodes.length > 0) {
26313
26399
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
26314
26400
  for (const psbt of txs) {
26315
- psbts.set(chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
26401
+ psbts.set(chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
26316
26402
  }
26317
26403
  }
26318
26404
  const childVsize = Number(
@@ -26340,7 +26426,7 @@ async function computeExitLayout(opts, feeRate) {
26340
26426
  vtxo,
26341
26427
  resolved: await resolveUnilateralPath({
26342
26428
  vtxo,
26343
- scriptHex: base.hex.encode(chunkWIZCF5IX_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
26429
+ scriptHex: base.hex.encode(chunkYAVF2PR6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
26344
26430
  contractRepository: wallet.contractRepository,
26345
26431
  walletDescriptor,
26346
26432
  currentTime: Date.now()
@@ -26377,7 +26463,7 @@ async function computeExitLayout(opts, feeRate) {
26377
26463
  });
26378
26464
  continue;
26379
26465
  }
26380
- const t = chunkWIZCF5IX_cjs.sequenceToTimelock(resolved.selection.sequence);
26466
+ const t = chunkYAVF2PR6_cjs.sequenceToTimelock(resolved.selection.sequence);
26381
26467
  const delay = { type: t.type, value: Number(t.value) };
26382
26468
  infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
26383
26469
  sweeps.push({ vtxo, resolved, sweepFee, delay });
@@ -26477,7 +26563,7 @@ var Executor = class {
26477
26563
  constructor(pkg, provider, opts) {
26478
26564
  this.pkg = pkg;
26479
26565
  this.provider = provider;
26480
- chunk5HCDXBBG_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
26566
+ chunk4X4SY3RH_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
26481
26567
  this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
26482
26568
  this.feeWallet = opts?.feeWallet;
26483
26569
  this.signal = opts?.signal;
@@ -26772,7 +26858,7 @@ async function prepare(opts) {
26772
26858
  txid: sweep.vtxo.txid,
26773
26859
  vout: sweep.vtxo.vout,
26774
26860
  value: sweep.vtxo.value,
26775
- pkScript: chunkWIZCF5IX_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
26861
+ pkScript: chunkYAVF2PR6_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
26776
26862
  },
26777
26863
  path: sweep.resolved.selection,
26778
26864
  outputAddress: opts.sweepAddress,
@@ -26861,7 +26947,7 @@ async function prepare(opts) {
26861
26947
  if (newFee <= splitterFee) break;
26862
26948
  splitterFee = newFee;
26863
26949
  }
26864
- const splitter = new chunk5HCDXBBG_cjs.Transaction({ version: 2 });
26950
+ const splitter = new chunk4X4SY3RH_cjs.Transaction({ version: 2 });
26865
26951
  for (const coin of selected.inputs) {
26866
26952
  splitter.addInput({
26867
26953
  txid: coin.txid,
@@ -27000,47 +27086,47 @@ var UnilateralExit = {
27000
27086
 
27001
27087
  // src/arkade/index.ts
27002
27088
  var arkade_exports = {};
27003
- chunkWIZCF5IX_cjs.__export(arkade_exports, {
27004
- ARKADE_OP: () => chunkUPIQZRNJ_cjs.ARKADE_OP,
27005
- ARKADE_OPCODES: () => chunkUPIQZRNJ_cjs.ARKADE_OPCODES,
27006
- ARKADE_OPCODE_NAMES: () => chunkUPIQZRNJ_cjs.ARKADE_OPCODE_NAMES,
27007
- ARKADE_OPCODE_VALUES: () => chunkUPIQZRNJ_cjs.ARKADE_OPCODE_VALUES,
27008
- ARKADE_OPS: () => chunkUPIQZRNJ_cjs.ARKADE_OPS,
27089
+ chunkYAVF2PR6_cjs.__export(arkade_exports, {
27090
+ ARKADE_OP: () => chunkJA4SYFC7_cjs.ARKADE_OP,
27091
+ ARKADE_OPCODES: () => chunkJA4SYFC7_cjs.ARKADE_OPCODES,
27092
+ ARKADE_OPCODE_NAMES: () => chunkJA4SYFC7_cjs.ARKADE_OPCODE_NAMES,
27093
+ ARKADE_OPCODE_VALUES: () => chunkJA4SYFC7_cjs.ARKADE_OPCODE_VALUES,
27094
+ ARKADE_OPS: () => chunkJA4SYFC7_cjs.ARKADE_OPS,
27009
27095
  Arkade: () => Arkade,
27010
27096
  ArkadeContract: () => ArkadeContract,
27011
- ArkadeProgramScript: () => chunkUPIQZRNJ_cjs.ArkadeProgramScript,
27012
- ArkadeScript: () => chunkUPIQZRNJ_cjs.ArkadeScript,
27097
+ ArkadeProgramScript: () => chunkJA4SYFC7_cjs.ArkadeProgramScript,
27098
+ ArkadeScript: () => chunkJA4SYFC7_cjs.ArkadeScript,
27013
27099
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
27014
- BigNum: () => chunkUPIQZRNJ_cjs.bignum_exports,
27100
+ BigNum: () => chunkJA4SYFC7_cjs.bignum_exports,
27015
27101
  OP: () => btcSigner.OP,
27016
- OPCODE_NAMES: () => chunkUPIQZRNJ_cjs.OPCODE_NAMES,
27017
- OPCODE_VALUES: () => chunkUPIQZRNJ_cjs.OPCODE_VALUES,
27018
- SUPPORTED_PROGRAM_VERSION: () => chunkUPIQZRNJ_cjs.SUPPORTED_PROGRAM_VERSION,
27102
+ OPCODE_NAMES: () => chunkJA4SYFC7_cjs.OPCODE_NAMES,
27103
+ OPCODE_VALUES: () => chunkJA4SYFC7_cjs.OPCODE_VALUES,
27104
+ SUPPORTED_PROGRAM_VERSION: () => chunkJA4SYFC7_cjs.SUPPORTED_PROGRAM_VERSION,
27019
27105
  Script: () => btcSigner.Script,
27020
- UnsupportedProgramVersionError: () => chunkUPIQZRNJ_cjs.UnsupportedProgramVersionError,
27021
- arkadeScriptHash: () => chunkUPIQZRNJ_cjs.arkadeScriptHash,
27022
- arkadeWitnessHash: () => chunkUPIQZRNJ_cjs.arkadeWitnessHash,
27023
- asmToBytes: () => chunkUPIQZRNJ_cjs.asmToBytes,
27024
- bytesToASM: () => chunkUPIQZRNJ_cjs.bytesToASM,
27025
- computeArkadeScriptPublicKey: () => chunkUPIQZRNJ_cjs.computeArkadeScriptPublicKey,
27106
+ UnsupportedProgramVersionError: () => chunkJA4SYFC7_cjs.UnsupportedProgramVersionError,
27107
+ arkadeScriptHash: () => chunkJA4SYFC7_cjs.arkadeScriptHash,
27108
+ arkadeWitnessHash: () => chunkJA4SYFC7_cjs.arkadeWitnessHash,
27109
+ asmToBytes: () => chunkJA4SYFC7_cjs.asmToBytes,
27110
+ bytesToASM: () => chunkJA4SYFC7_cjs.bytesToASM,
27111
+ computeArkadeScriptPublicKey: () => chunkJA4SYFC7_cjs.computeArkadeScriptPublicKey,
27026
27112
  createArkadeBatchHandler: () => createArkadeBatchHandler,
27027
- deserializeArkadeContractParams: () => chunkUPIQZRNJ_cjs.deserializeArkadeContractParams,
27028
- fromASM: () => chunkUPIQZRNJ_cjs.fromASM,
27029
- getOpcodeName: () => chunkUPIQZRNJ_cjs.getOpcodeName,
27030
- getOpcodeValue: () => chunkUPIQZRNJ_cjs.getOpcodeValue,
27031
- isContractArtifact: () => chunkOMZZQTDM_cjs.isContractArtifact,
27032
- parseArtifact: () => chunkUPIQZRNJ_cjs.parseArtifact,
27033
- programFromArtifact: () => chunkOMZZQTDM_cjs.programFromArtifact,
27113
+ deserializeArkadeContractParams: () => chunkJA4SYFC7_cjs.deserializeArkadeContractParams,
27114
+ fromASM: () => chunkJA4SYFC7_cjs.fromASM,
27115
+ getOpcodeName: () => chunkJA4SYFC7_cjs.getOpcodeName,
27116
+ getOpcodeValue: () => chunkJA4SYFC7_cjs.getOpcodeValue,
27117
+ isContractArtifact: () => chunkPHOJF7OK_cjs.isContractArtifact,
27118
+ parseArtifact: () => chunkJA4SYFC7_cjs.parseArtifact,
27119
+ programFromArtifact: () => chunkPHOJF7OK_cjs.programFromArtifact,
27034
27120
  renewProgramContractOutputs: () => renewProgramContractOutputs,
27035
27121
  resolveArkadeService: () => resolveArkadeService,
27036
- resolveAsm: () => chunkUPIQZRNJ_cjs.resolveAsm,
27037
- serializeArkadeContractParams: () => chunkUPIQZRNJ_cjs.serializeArkadeContractParams,
27038
- stringifyArtifact: () => chunkUPIQZRNJ_cjs.stringifyArtifact,
27039
- toASM: () => chunkUPIQZRNJ_cjs.toASM,
27040
- validateProgram: () => chunkUPIQZRNJ_cjs.validateProgram,
27041
- witnessRefToBytes: () => chunkUPIQZRNJ_cjs.witnessRefToBytes
27122
+ resolveAsm: () => chunkJA4SYFC7_cjs.resolveAsm,
27123
+ serializeArkadeContractParams: () => chunkJA4SYFC7_cjs.serializeArkadeContractParams,
27124
+ stringifyArtifact: () => chunkJA4SYFC7_cjs.stringifyArtifact,
27125
+ toASM: () => chunkJA4SYFC7_cjs.toASM,
27126
+ validateProgram: () => chunkJA4SYFC7_cjs.validateProgram,
27127
+ witnessRefToBytes: () => chunkJA4SYFC7_cjs.witnessRefToBytes
27042
27128
  });
27043
- var isVtxoCoin = (input) => chunk5HCDXBBG_cjs.isVirtualCoin(input);
27129
+ var isVtxoCoin = (input) => chunk4X4SY3RH_cjs.isVirtualCoin(input);
27044
27130
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
27045
27131
  if (!signer && inputs.some((input) => !isVtxoCoin(input))) {
27046
27132
  throw new Error("createArkadeBatchHandler: boarding inputs need a signer");
@@ -27067,23 +27153,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
27067
27153
  );
27068
27154
  await arkProvider.confirmRegistration(intentId);
27069
27155
  batchId = event.id;
27070
- const sweepTapscript = chunkWIZCF5IX_cjs.CSVMultisigTapscript.encode({
27156
+ const sweepTapscript = chunkYAVF2PR6_cjs.CSVMultisigTapscript.encode({
27071
27157
  timelock,
27072
- pubkeys: [chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
27158
+ pubkeys: [chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
27073
27159
  }).script;
27074
27160
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
27075
27161
  return { skip: false };
27076
27162
  },
27077
27163
  onTreeSigningStarted: async (event, vtxoTree) => {
27078
27164
  const signerPubKey = await session.getPublicKey();
27079
- const xonlySignerPubKey = chunkUPIQZRNJ_cjs.toXOnly(signerPubKey, "signer key");
27165
+ const xonlySignerPubKey = chunkJA4SYFC7_cjs.toXOnly(signerPubKey, "signer key");
27080
27166
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
27081
- (k) => base.hex.encode(chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
27167
+ (k) => base.hex.encode(chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
27082
27168
  );
27083
27169
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
27084
27170
  return { skip: true };
27085
27171
  }
27086
- const commitmentTx = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
27172
+ const commitmentTx = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
27087
27173
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
27088
27174
  if (recipients && recipients.length > 0) {
27089
27175
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -27121,7 +27207,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
27121
27207
  if (connectorTree) {
27122
27208
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
27123
27209
  }
27124
- let commitmentPsbt = chunk5HCDXBBG_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
27210
+ let commitmentPsbt = chunk4X4SY3RH_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
27125
27211
  assertFinalCommitmentMatchesValidated(
27126
27212
  commitmentPsbt,
27127
27213
  validatedCommitmentTxid,
@@ -27158,12 +27244,13 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
27158
27244
  );
27159
27245
  }
27160
27246
  commitmentPsbt.updateInput(boardingIdx, {
27161
- tapLeafScript: [input.forfeitTapLeafScript]
27247
+ tapLeafScript: [input.forfeitTapLeafScript],
27248
+ sighashType: btcSigner.SigHash.DEFAULT
27162
27249
  });
27163
27250
  boardingIndices.push(boardingIdx);
27164
27251
  continue;
27165
27252
  }
27166
- if (!chunk5HCDXBBG_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
27253
+ if (!chunk4X4SY3RH_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
27167
27254
  continue;
27168
27255
  }
27169
27256
  if (connectorIndex >= connectorLeaves.length) {
@@ -27184,7 +27271,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
27184
27271
  index: input.vout,
27185
27272
  witnessUtxo: {
27186
27273
  amount: BigInt(input.value),
27187
- script: chunkWIZCF5IX_cjs.VtxoScript.decode(input.tapTree).pkScript
27274
+ script: chunkYAVF2PR6_cjs.VtxoScript.decode(input.tapTree).pkScript
27188
27275
  },
27189
27276
  sighashType: btcSigner.SigHash.DEFAULT,
27190
27277
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -27201,7 +27288,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
27201
27288
  forfeitOutputScript
27202
27289
  );
27203
27290
  if (input.extraWitness?.length) {
27204
- chunk5HCDXBBG_cjs.setArkPsbtField(forfeitTx, 0, chunk5HCDXBBG_cjs.ConditionWitness, input.extraWitness);
27291
+ chunk4X4SY3RH_cjs.setArkPsbtField(forfeitTx, 0, chunk4X4SY3RH_cjs.ConditionWitness, input.extraWitness);
27205
27292
  }
27206
27293
  if (signer) forfeitTx = await signer.sign(forfeitTx, [0]);
27207
27294
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -27285,8 +27372,8 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
27285
27372
  if (compiled.def.tapscript.csv) {
27286
27373
  throw new Error(`renewProgramContractOutputs: ${fn} has a CSV timelock`);
27287
27374
  }
27288
- const condition = chunkUPIQZRNJ_cjs.staticWitness(compiled.def.tapscript.witness, contract.args);
27289
- const stack = chunkUPIQZRNJ_cjs.staticWitness(compiled.def.arkadeScript?.witness, contract.args);
27375
+ const condition = chunkJA4SYFC7_cjs.staticWitness(compiled.def.tapscript.witness, contract.args);
27376
+ const stack = chunkJA4SYFC7_cjs.staticWitness(compiled.def.arkadeScript?.witness, contract.args);
27290
27377
  if (!condition || !stack) {
27291
27378
  throw new Error(
27292
27379
  `renewProgramContractOutputs: ${fn} needs call arguments, which a renewal cannot supply`
@@ -27296,7 +27383,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
27296
27383
  });
27297
27384
  const { fees } = await arkProvider.getInfo();
27298
27385
  const fee = new Estimator(fees?.intentFee ?? {}).evaluate(
27299
- legs.map(({ coin }) => chunk5HCDXBBG_cjs.toOffchainInputFeeParams(chunk5HCDXBBG_cjs.normalizeVtxo(coin))),
27386
+ legs.map(({ coin }) => chunk4X4SY3RH_cjs.toOffchainInputFeeParams(chunk4X4SY3RH_cjs.normalizeVtxo(coin))),
27300
27387
  [],
27301
27388
  legs.map(({ contract, coin }) => ({
27302
27389
  amount: BigInt(coin.value),
@@ -27359,7 +27446,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
27359
27446
  const [signedProof, deleteProof] = await Promise.all(
27360
27447
  [message, deleteMessage].map(
27361
27448
  (m) => emulator.submitIntent({
27362
- proof: base.base64.encode(chunk5HCDXBBG_cjs.Proof.create(m, coins, outputs).toPSBT()),
27449
+ proof: base.base64.encode(chunk4X4SY3RH_cjs.Proof.create(m, coins, outputs).toPSBT()),
27363
27450
  message: m
27364
27451
  })
27365
27452
  )
@@ -27511,20 +27598,20 @@ var Arkade = class _Arkade {
27511
27598
  indexer = opts.indexer;
27512
27599
  info = await opts.arkade.getInfo();
27513
27600
  }
27514
- const serverKey = chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
27515
- const network = opts.network ?? (Object.hasOwn(chunkWIZCF5IX_cjs.networks, info.network) ? chunkWIZCF5IX_cjs.getNetwork(info.network) : chunkWIZCF5IX_cjs.DEFAULT_NETWORK);
27601
+ const serverKey = chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
27602
+ const network = opts.network ?? (Object.hasOwn(chunkYAVF2PR6_cjs.networks, info.network) ? chunkYAVF2PR6_cjs.getNetwork(info.network) : chunkYAVF2PR6_cjs.DEFAULT_NETWORK);
27516
27603
  const checkpoint = assertValidServerUnrollScript(
27517
27604
  info.checkpointTapscript,
27518
27605
  network,
27519
- info.forfeitPubkey ? chunkUPIQZRNJ_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key") : void 0
27606
+ info.forfeitPubkey ? chunkJA4SYFC7_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key") : void 0
27520
27607
  );
27521
27608
  let emulatorKey;
27522
27609
  if (emulator) {
27523
- emulatorKey = base.hex.decode(chunkWIZCF5IX_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
27610
+ emulatorKey = base.hex.decode(chunkYAVF2PR6_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
27524
27611
  }
27525
27612
  let userKey;
27526
27613
  if (opts.identity) {
27527
- userKey = chunkUPIQZRNJ_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
27614
+ userKey = chunkJA4SYFC7_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
27528
27615
  }
27529
27616
  let contractManager = opts.contractManager;
27530
27617
  let ownsContractManager = false;
@@ -27646,7 +27733,7 @@ var Arkade = class _Arkade {
27646
27733
  `compiler artifact: server exit delay ${delay}s must be a multiple of 512 seconds`
27647
27734
  );
27648
27735
  }
27649
- const sequence = BigInt(chunkWIZCF5IX_cjs.timelockToSequence(typed));
27736
+ const sequence = BigInt(chunkYAVF2PR6_cjs.timelockToSequence(typed));
27650
27737
  if (args.SERVER_EXIT_DELAY !== void 0 && args.SERVER_EXIT_DELAY !== sequence && args.SERVER_EXIT_DELAY !== Number(sequence)) {
27651
27738
  throw new Error(
27652
27739
  "compiler artifact: reserved SERVER_EXIT_DELAY must match the connected server"
@@ -27675,7 +27762,7 @@ var ArkadeContract = class _ArkadeContract {
27675
27762
  userKey: client.userKey,
27676
27763
  emulatorKey: client.emulatorKey
27677
27764
  };
27678
- this.vtxoScript = new chunkUPIQZRNJ_cjs.ArkadeProgramScript(program, this.args, this.keys);
27765
+ this.vtxoScript = new chunkJA4SYFC7_cjs.ArkadeProgramScript(program, this.args, this.keys);
27679
27766
  this.tapTree = this.vtxoScript.encode();
27680
27767
  this.compiled = this.vtxoScript.compiled;
27681
27768
  }
@@ -27701,7 +27788,7 @@ var ArkadeContract = class _ArkadeContract {
27701
27788
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
27702
27789
  );
27703
27790
  }
27704
- const typed = chunkUPIQZRNJ_cjs.deserializeArkadeContractParams(contract.params);
27791
+ const typed = chunkJA4SYFC7_cjs.deserializeArkadeContractParams(contract.params);
27705
27792
  return new _ArkadeContract(client, typed.program, typed.args, {
27706
27793
  serverKey: typed.serverKey,
27707
27794
  userKey: typed.userKey,
@@ -27756,7 +27843,7 @@ var ArkadeContract = class _ArkadeContract {
27756
27843
  toContractParams() {
27757
27844
  return {
27758
27845
  type: "arkade",
27759
- params: chunkUPIQZRNJ_cjs.serializeArkadeContractParams({
27846
+ params: chunkJA4SYFC7_cjs.serializeArkadeContractParams({
27760
27847
  program: this.program,
27761
27848
  args: this.args,
27762
27849
  serverKey: this.keys.serverKey,
@@ -27843,17 +27930,17 @@ var ArkadeContract = class _ArkadeContract {
27843
27930
  const [registered] = await manager.getContracts({ script: scriptHex });
27844
27931
  if (registered) {
27845
27932
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
27846
- return (withVtxos?.vtxos ?? []).filter((v) => !chunk5HCDXBBG_cjs.isVtxoSpent(v) && !v.isUnrolled);
27933
+ return (withVtxos?.vtxos ?? []).filter((v) => !chunk4X4SY3RH_cjs.isVtxoSpent(v) && !v.isUnrolled);
27847
27934
  }
27848
27935
  }
27849
27936
  if (!this.client.indexer) {
27850
27937
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
27851
27938
  }
27852
- const { vtxos } = await chunk5HCDXBBG_cjs.getNormalizedVtxos(this.client.indexer, {
27939
+ const { vtxos } = await chunk4X4SY3RH_cjs.getNormalizedVtxos(this.client.indexer, {
27853
27940
  scripts: [scriptHex],
27854
27941
  spendableOnly: true
27855
27942
  });
27856
- return vtxos.filter((v) => !chunk5HCDXBBG_cjs.isVtxoSpent(v) && !v.isUnrolled);
27943
+ return vtxos.filter((v) => !chunk4X4SY3RH_cjs.isVtxoSpent(v) && !v.isUnrolled);
27857
27944
  }
27858
27945
  /** Total spendable balance (requires an indexer). */
27859
27946
  async getBalance() {
@@ -28019,7 +28106,7 @@ var ArkadeTransactionBuilder = class {
28019
28106
  this.client.checkpoint
28020
28107
  );
28021
28108
  inputs.forEach(({ coin }, i) => {
28022
- if (coin.sourceTx) chunk5HCDXBBG_cjs.setArkPsbtField(arkTx, i, chunk5HCDXBBG_cjs.PrevArkTxField, coin.sourceTx);
28109
+ if (coin.sourceTx) chunk4X4SY3RH_cjs.setArkPsbtField(arkTx, i, chunk4X4SY3RH_cjs.PrevArkTxField, coin.sourceTx);
28023
28110
  });
28024
28111
  if (inputs.some(({ unlocker }) => unlocker.fn.arkadeScript)) {
28025
28112
  const indexer = this.client.indexer;
@@ -28039,8 +28126,8 @@ var ArkadeTransactionBuilder = class {
28039
28126
  (w) => witnessBytes(unlocker, "tapscript", w)
28040
28127
  );
28041
28128
  if (condition.length === 0) return;
28042
- chunk5HCDXBBG_cjs.setArkPsbtField(arkTx, i, chunk5HCDXBBG_cjs.ConditionWitness, condition);
28043
- chunk5HCDXBBG_cjs.setArkPsbtField(checkpoints[i], 0, chunk5HCDXBBG_cjs.ConditionWitness, condition);
28129
+ chunk4X4SY3RH_cjs.setArkPsbtField(arkTx, i, chunk4X4SY3RH_cjs.ConditionWitness, condition);
28130
+ chunk4X4SY3RH_cjs.setArkPsbtField(checkpoints[i], 0, chunk4X4SY3RH_cjs.ConditionWitness, condition);
28044
28131
  });
28045
28132
  const packets = [];
28046
28133
  if (this.assetSpecs.length > 0) {
@@ -28105,7 +28192,7 @@ var ArkadeTransactionBuilder = class {
28105
28192
  );
28106
28193
  }
28107
28194
  const { sequence, lockTime } = this.leafTimelocks(fn);
28108
- const tx = new chunk5HCDXBBG_cjs.Transaction({ version: 2, lockTime });
28195
+ const tx = new chunk4X4SY3RH_cjs.Transaction({ version: 2, lockTime });
28109
28196
  tx.addInput({ txid: base.hex.decode(coin.txid), index: coin.vout, sequence });
28110
28197
  for (const o of outputs) tx.addOutput(o);
28111
28198
  const condition = (fn.def.tapscript.witness ?? []).map(
@@ -28147,15 +28234,15 @@ var ArkadeTransactionBuilder = class {
28147
28234
  return fn.signerKeys.some((k) => utils_js.equalBytes(k, serverKey));
28148
28235
  }
28149
28236
  leafTimelocks(fn) {
28150
- const tapscript = chunkWIZCF5IX_cjs.decodeTapscript(fn.leafScript);
28151
- if (chunkWIZCF5IX_cjs.CLTVMultisigTapscript.is(tapscript)) {
28237
+ const tapscript = chunkYAVF2PR6_cjs.decodeTapscript(fn.leafScript);
28238
+ if (chunkYAVF2PR6_cjs.CLTVMultisigTapscript.is(tapscript)) {
28152
28239
  return {
28153
28240
  sequence: btcSigner.DEFAULT_SEQUENCE - 1,
28154
28241
  lockTime: Number(tapscript.params.absoluteTimelock)
28155
28242
  };
28156
28243
  }
28157
- if (chunkWIZCF5IX_cjs.CSVMultisigTapscript.is(tapscript) || chunkWIZCF5IX_cjs.ConditionCSVMultisigTapscript.is(tapscript)) {
28158
- return { sequence: chunkWIZCF5IX_cjs.timelockToSequence(tapscript.params.timelock), lockTime: 0 };
28244
+ if (chunkYAVF2PR6_cjs.CSVMultisigTapscript.is(tapscript) || chunkYAVF2PR6_cjs.ConditionCSVMultisigTapscript.is(tapscript)) {
28245
+ return { sequence: chunkYAVF2PR6_cjs.timelockToSequence(tapscript.params.timelock), lockTime: 0 };
28159
28246
  }
28160
28247
  return { lockTime: 0 };
28161
28248
  }
@@ -28271,20 +28358,20 @@ var ArkadeTransactionBuilder = class {
28271
28358
  * A caller's packet counts for every input, unread; arkd checks what it actually routes.
28272
28359
  */
28273
28360
  routesAssetsFrom(vin) {
28274
- return this.extraPackets.some((p) => p.type() === chunkGEK6QBSY_cjs.Packet.PACKET_TYPE) || this.assetSpecs.some((spec) => spec.inputs.some((i) => i.vin === vin));
28361
+ return this.extraPackets.some((p) => p.type() === chunkQV7AOZZN_cjs.Packet.PACKET_TYPE) || this.assetSpecs.some((spec) => spec.inputs.some((i) => i.vin === vin));
28275
28362
  }
28276
28363
  buildAssetPacket() {
28277
28364
  const groups = this.assetSpecs.map((s) => {
28278
- const id = typeof s.assetId === "string" ? chunkGEK6QBSY_cjs.AssetId.fromString(s.assetId) : chunkGEK6QBSY_cjs.AssetId.fromBytes(s.assetId);
28279
- return chunkGEK6QBSY_cjs.AssetGroup.create(
28365
+ const id = typeof s.assetId === "string" ? chunkQV7AOZZN_cjs.AssetId.fromString(s.assetId) : chunkQV7AOZZN_cjs.AssetId.fromBytes(s.assetId);
28366
+ return chunkQV7AOZZN_cjs.AssetGroup.create(
28280
28367
  id,
28281
28368
  null,
28282
- s.inputs.map((i) => chunkGEK6QBSY_cjs.AssetInput.create(i.vin, i.amount)),
28283
- s.outputs.map((o) => chunkGEK6QBSY_cjs.AssetOutput.create(o.vout, o.amount)),
28284
- (s.metadata ?? []).map((m) => chunkGEK6QBSY_cjs.Metadata.create(m.key, m.value))
28369
+ s.inputs.map((i) => chunkQV7AOZZN_cjs.AssetInput.create(i.vin, i.amount)),
28370
+ s.outputs.map((o) => chunkQV7AOZZN_cjs.AssetOutput.create(o.vout, o.amount)),
28371
+ (s.metadata ?? []).map((m) => chunkQV7AOZZN_cjs.Metadata.create(m.key, m.value))
28285
28372
  );
28286
28373
  });
28287
- return chunkGEK6QBSY_cjs.Packet.create(groups);
28374
+ return chunkQV7AOZZN_cjs.Packet.create(groups);
28288
28375
  }
28289
28376
  };
28290
28377
  function unspendable(coin, now) {
@@ -28293,7 +28380,7 @@ function unspendable(coin, now) {
28293
28380
  return void 0;
28294
28381
  }
28295
28382
  function witnessBytes({ contract, args }, segment, ref) {
28296
- return chunkUPIQZRNJ_cjs.witnessRefToBytes(ref, args[segment], contract.args);
28383
+ return chunkJA4SYFC7_cjs.witnessRefToBytes(ref, args[segment], contract.args);
28297
28384
  }
28298
28385
  function flattenValue(name, value, out, ancestors = /* @__PURE__ */ new Set()) {
28299
28386
  if (typeof value !== "object" || value === null || ArrayBuffer.isView(value)) {
@@ -28356,7 +28443,7 @@ function bindInputs(label, inputs, callArgs) {
28356
28443
  }
28357
28444
  for (const def of inputs) {
28358
28445
  if (bound[def.name] === void 0) throw new Error(`${label}: missing input '${def.name}'`);
28359
- chunkUPIQZRNJ_cjs.validateParamValue(def, bound[def.name]);
28446
+ chunkJA4SYFC7_cjs.validateParamValue(def, bound[def.name]);
28360
28447
  }
28361
28448
  return bound;
28362
28449
  }
@@ -28766,17 +28853,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
28766
28853
  function offchainInputFees(vtxos, fees) {
28767
28854
  const estimator = new Estimator(fees?.intentFee ?? {});
28768
28855
  return vtxos.reduce(
28769
- (total, vtxo) => total + estimator.evalOffchainInput(chunk5HCDXBBG_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
28856
+ (total, vtxo) => total + estimator.evalOffchainInput(chunk4X4SY3RH_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
28770
28857
  0
28771
28858
  );
28772
28859
  }
28773
28860
  async function changeOutputFee(wallet, inputs, needed, fees) {
28774
28861
  const estimator = new Estimator(fees?.intentFee ?? {});
28775
28862
  const net = inputs.reduce(
28776
- (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunk5HCDXBBG_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
28863
+ (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunk4X4SY3RH_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
28777
28864
  0n
28778
28865
  );
28779
- const script = base.hex.encode(chunkWIZCF5IX_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
28866
+ const script = base.hex.encode(chunkYAVF2PR6_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
28780
28867
  return changeAfterOutputFee(
28781
28868
  net - needed,
28782
28869
  (amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
@@ -29112,5 +29199,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
29112
29199
  exports.walletFeeSource = walletFeeSource;
29113
29200
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
29114
29201
  exports.withPrevTxs = withPrevTxs;
29115
- //# sourceMappingURL=chunk-DMYHAUTA.cjs.map
29116
- //# sourceMappingURL=chunk-DMYHAUTA.cjs.map
29202
+ //# sourceMappingURL=chunk-CJUVKHK4.cjs.map
29203
+ //# sourceMappingURL=chunk-CJUVKHK4.cjs.map