@arkade-os/sdk 0.5.7 → 0.5.8

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 (94) hide show
  1. package/README.md +2 -2
  2. package/dist/adapters/expo.cjs +6 -6
  3. package/dist/adapters/expo.d.cts +2 -2
  4. package/dist/adapters/expo.d.ts +2 -2
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/{asyncStorageTaskQueue-B9byr6ij.d.cts → asyncStorageTaskQueue-B5NPtkXo.d.cts} +2 -2
  7. package/dist/{asyncStorageTaskQueue-XP4CCdRY.d.ts → asyncStorageTaskQueue-YPwiJyVA.d.ts} +2 -2
  8. package/dist/{chunk-V2DDN4MV.js → chunk-3F5AJ235.js} +4 -4
  9. package/dist/{chunk-V2DDN4MV.js.map → chunk-3F5AJ235.js.map} +1 -1
  10. package/dist/{chunk-3NALVGMJ.cjs → chunk-4IDCSOP2.cjs} +22 -16
  11. package/dist/chunk-4IDCSOP2.cjs.map +1 -0
  12. package/dist/{chunk-JFJNB7ZH.cjs → chunk-5PWL7WOT.cjs} +7 -5
  13. package/dist/chunk-5PWL7WOT.cjs.map +1 -0
  14. package/dist/{chunk-MWMO2ZQP.js → chunk-E7LKKEVR.js} +10 -4
  15. package/dist/chunk-E7LKKEVR.js.map +1 -0
  16. package/dist/{chunk-URGVQ5TQ.cjs → chunk-EQ3JVVUR.cjs} +599 -547
  17. package/dist/chunk-EQ3JVVUR.cjs.map +1 -0
  18. package/dist/{chunk-MWEDDWFU.js → chunk-F5O6JI2H.js} +8 -6
  19. package/dist/chunk-F5O6JI2H.js.map +1 -0
  20. package/dist/{chunk-4AJRIM44.js → chunk-H7GT3QC4.js} +4 -4
  21. package/dist/{chunk-4AJRIM44.js.map → chunk-H7GT3QC4.js.map} +1 -1
  22. package/dist/{chunk-MXCB6EVM.cjs → chunk-JQSHFSME.cjs} +19 -17
  23. package/dist/chunk-JQSHFSME.cjs.map +1 -0
  24. package/dist/{chunk-MQUATTIM.cjs → chunk-JYQXB7OH.cjs} +19 -19
  25. package/dist/{chunk-MQUATTIM.cjs.map → chunk-JYQXB7OH.cjs.map} +1 -1
  26. package/dist/{chunk-V5WRO3P6.cjs → chunk-KWR37J6L.cjs} +10 -10
  27. package/dist/{chunk-V5WRO3P6.cjs.map → chunk-KWR37J6L.cjs.map} +1 -1
  28. package/dist/{chunk-X6ZI53DZ.cjs → chunk-L7OOPAUG.cjs} +14 -26
  29. package/dist/chunk-L7OOPAUG.cjs.map +1 -0
  30. package/dist/{chunk-RLD7DRSZ.js → chunk-OLKZUJIN.js} +127 -75
  31. package/dist/chunk-OLKZUJIN.js.map +1 -0
  32. package/dist/{chunk-OMPDPBT5.cjs → chunk-SOJDUKY6.cjs} +271 -225
  33. package/dist/chunk-SOJDUKY6.cjs.map +1 -0
  34. package/dist/{chunk-V3ZLL5VY.js → chunk-U34GU5RM.js} +9 -21
  35. package/dist/chunk-U34GU5RM.js.map +1 -0
  36. package/dist/{chunk-DNFTHG73.js → chunk-XXNPX4MK.js} +7 -5
  37. package/dist/chunk-XXNPX4MK.js.map +1 -0
  38. package/dist/{chunk-VMVFRTF4.js → chunk-YTOABP6J.js} +268 -226
  39. package/dist/chunk-YTOABP6J.js.map +1 -0
  40. package/dist/compiler.cjs +3 -3
  41. package/dist/compiler.d.cts +1 -1
  42. package/dist/compiler.d.ts +1 -1
  43. package/dist/compiler.js +2 -2
  44. package/dist/contracts/handlers/index.cjs +10 -10
  45. package/dist/contracts/handlers/index.d.cts +3 -3
  46. package/dist/contracts/handlers/index.d.ts +3 -3
  47. package/dist/contracts/handlers/index.js +3 -3
  48. package/dist/{index-Ccfhdfvj.d.cts → index-CKzBYoDa.d.cts} +2 -2
  49. package/dist/{index-B_kcptF8.d.ts → index-COs69e8T.d.ts} +2 -2
  50. package/dist/{index-18cDMayF.d.ts → index-Pk3i_MMU.d.ts} +12 -2
  51. package/dist/{index-DDJFHfba.d.cts → index-czozpKPT.d.cts} +12 -2
  52. package/dist/index.cjs +325 -321
  53. package/dist/index.d.cts +52 -23
  54. package/dist/index.d.ts +52 -23
  55. package/dist/index.js +6 -6
  56. package/dist/{keyringDescriptorProvider-DL-jAiRO.d.ts → keyringDescriptorProvider-CbNzWwbS.d.ts} +15 -2
  57. package/dist/{keyringDescriptorProvider-Dtv0JWrT.d.cts → keyringDescriptorProvider-nC8fIjBN.d.cts} +15 -2
  58. package/dist/{program-BARSNg3X.d.ts → program-38A2Twvj.d.ts} +4 -2
  59. package/dist/{program-znrWkxE4.d.cts → program-DPzf5qsk.d.cts} +4 -2
  60. package/dist/repositories/realm/index.cjs +39 -39
  61. package/dist/repositories/realm/index.d.cts +2 -2
  62. package/dist/repositories/realm/index.d.ts +2 -2
  63. package/dist/repositories/realm/index.js +7 -7
  64. package/dist/repositories/sqlite/index.cjs +37 -37
  65. package/dist/repositories/sqlite/index.d.cts +2 -2
  66. package/dist/repositories/sqlite/index.d.ts +2 -2
  67. package/dist/repositories/sqlite/index.js +7 -7
  68. package/dist/{taskRunner-DUafWu0o.d.ts → taskRunner-DBOqvP33.d.ts} +2 -2
  69. package/dist/{taskRunner-JYHaLPne.d.cts → taskRunner-DXivOJHc.d.cts} +2 -2
  70. package/dist/wallet/expo/background.cjs +16 -16
  71. package/dist/wallet/expo/background.d.cts +3 -3
  72. package/dist/wallet/expo/background.d.ts +3 -3
  73. package/dist/wallet/expo/background.js +8 -8
  74. package/dist/wallet/expo/index.cjs +17 -17
  75. package/dist/wallet/expo/index.d.cts +3 -3
  76. package/dist/wallet/expo/index.d.ts +3 -3
  77. package/dist/wallet/expo/index.js +7 -7
  78. package/dist/worker/expo/index.cjs +11 -11
  79. package/dist/worker/expo/index.d.cts +4 -4
  80. package/dist/worker/expo/index.d.ts +4 -4
  81. package/dist/worker/expo/index.js +7 -7
  82. package/package.json +1 -1
  83. package/dist/chunk-3NALVGMJ.cjs.map +0 -1
  84. package/dist/chunk-DNFTHG73.js.map +0 -1
  85. package/dist/chunk-JFJNB7ZH.cjs.map +0 -1
  86. package/dist/chunk-MWEDDWFU.js.map +0 -1
  87. package/dist/chunk-MWMO2ZQP.js.map +0 -1
  88. package/dist/chunk-MXCB6EVM.cjs.map +0 -1
  89. package/dist/chunk-OMPDPBT5.cjs.map +0 -1
  90. package/dist/chunk-RLD7DRSZ.js.map +0 -1
  91. package/dist/chunk-URGVQ5TQ.cjs.map +0 -1
  92. package/dist/chunk-V3ZLL5VY.js.map +0 -1
  93. package/dist/chunk-VMVFRTF4.js.map +0 -1
  94. package/dist/chunk-X6ZI53DZ.cjs.map +0 -1
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkX6ZI53DZ_cjs = require('./chunk-X6ZI53DZ.cjs');
4
- var chunk3NALVGMJ_cjs = require('./chunk-3NALVGMJ.cjs');
5
- var chunkMQUATTIM_cjs = require('./chunk-MQUATTIM.cjs');
6
- var chunkJFJNB7ZH_cjs = require('./chunk-JFJNB7ZH.cjs');
7
- var chunkOMPDPBT5_cjs = require('./chunk-OMPDPBT5.cjs');
3
+ var chunkL7OOPAUG_cjs = require('./chunk-L7OOPAUG.cjs');
4
+ var chunk4IDCSOP2_cjs = require('./chunk-4IDCSOP2.cjs');
5
+ var chunkJYQXB7OH_cjs = require('./chunk-JYQXB7OH.cjs');
6
+ var chunk5PWL7WOT_cjs = require('./chunk-5PWL7WOT.cjs');
7
+ var chunkSOJDUKY6_cjs = require('./chunk-SOJDUKY6.cjs');
8
8
  var chunkFLPWNMX3_cjs = require('./chunk-FLPWNMX3.cjs');
9
9
  var bip39 = require('@scure/bip39');
10
10
  var english_js = require('@scure/bip39/wordlists/english.js');
@@ -43,8 +43,13 @@ var musig2__namespace = /*#__PURE__*/_interopNamespace(musig2);
43
43
 
44
44
  var PrfUnavailable = class extends Error {
45
45
  name = "PrfUnavailable";
46
- /** Set when the passkey was created before this failure, so an app can still use it some other way. */
46
+ /** Set when the passkey was created before this failure; check `reason` before using it some other way. */
47
47
  credentialId;
48
+ reason;
49
+ constructor(message, options) {
50
+ super(message, options);
51
+ this.reason = options?.reason;
52
+ }
48
53
  };
49
54
  var PasskeyCancelled = class extends Error {
50
55
  name = "PasskeyCancelled";
@@ -54,6 +59,7 @@ var PasskeyCancelled = class extends Error {
54
59
  };
55
60
  var PasskeyUnconfirmed = class extends PrfUnavailable {
56
61
  name = "PasskeyUnconfirmed";
62
+ reason = "unconfirmed";
57
63
  };
58
64
  var DEFAULT_PASSKEY_LABEL = "Default";
59
65
  var UNUSABLE = "This passkey returned no usable secret.";
@@ -61,17 +67,17 @@ function bytes(x) {
61
67
  if (Object.prototype.toString.call(x) === "[object ArrayBuffer]")
62
68
  return new Uint8Array(x.slice(0));
63
69
  if (ArrayBuffer.isView(x)) return new Uint8Array(x.buffer, x.byteOffset, x.byteLength).slice();
64
- if (!Array.isArray(x)) throw new PrfUnavailable(UNUSABLE);
70
+ if (!Array.isArray(x)) throw new PrfUnavailable(UNUSABLE, { reason: "malformed" });
65
71
  for (let i = 0; i < x.length; i++) {
66
72
  const v = x[i];
67
73
  if (!(i in x) || !Number.isInteger(v) || v < 0 || v > 255)
68
- throw new PrfUnavailable(UNUSABLE);
74
+ throw new PrfUnavailable(UNUSABLE, { reason: "malformed" });
69
75
  }
70
76
  return Uint8Array.from(x);
71
77
  }
72
78
  function secret(x) {
73
79
  const b = typeof x === "object" && x !== null ? bytes(x) : null;
74
- if (!b || b.length !== 32) throw new PrfUnavailable(UNUSABLE);
80
+ if (!b || b.length !== 32) throw new PrfUnavailable(UNUSABLE, { reason: "malformed" });
75
81
  return b;
76
82
  }
77
83
  var same = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
@@ -80,7 +86,7 @@ var prf = (salt) => ({ prf: { eval: { first: bytes(salt) } } });
80
86
  var prfOf = (c) => c.getClientExtensionResults().prf;
81
87
  function browser() {
82
88
  if (typeof navigator === "undefined" || !navigator.credentials) {
83
- throw new PrfUnavailable("No WebAuthn here; pass a client.");
89
+ throw new PrfUnavailable("No WebAuthn here; pass a client.", { reason: "unsupported" });
84
90
  }
85
91
  return navigator.credentials;
86
92
  }
@@ -135,8 +141,10 @@ async function createPrfPasskey(o) {
135
141
  }
136
142
  async function confirmPrf(cred, credentialId, o, client) {
137
143
  const out = prfOf(cred);
138
- if (!out?.results?.first && (!out || out.enabled === false))
139
- throw new PrfUnavailable("This passkey cannot derive a key.");
144
+ if (!out)
145
+ throw new PrfUnavailable("This browser returned no PRF result.", { reason: "unknown" });
146
+ if (!out.results?.first && out.enabled === false)
147
+ throw new PrfUnavailable("This passkey cannot derive a key.", { reason: "unsupported" });
140
148
  const made = out.results?.first ? secret(out.results.first) : null;
141
149
  const { prf: used } = await evaluatePrf({
142
150
  rpId: o.rp.id,
@@ -145,7 +153,9 @@ async function confirmPrf(cred, credentialId, o, client) {
145
153
  client
146
154
  });
147
155
  if (made && !same(made, used)) {
148
- throw new PrfUnavailable("This passkey gave a different secret on its next use.");
156
+ throw new PrfUnavailable("This passkey gave a different secret on its next use.", {
157
+ reason: "secret-changed"
158
+ });
149
159
  }
150
160
  return used;
151
161
  }
@@ -166,7 +176,8 @@ async function evaluatePrf(o) {
166
176
  })
167
177
  );
168
178
  const first = prfOf(cred)?.results?.first;
169
- if (first === void 0) throw new PrfUnavailable("This passkey cannot derive a key.");
179
+ if (first === void 0)
180
+ throw new PrfUnavailable("This passkey cannot derive a key.", { reason: "no-secret" });
170
181
  const handle = cred.response.userHandle;
171
182
  return {
172
183
  credentialId: bytes(cred.rawId),
@@ -325,7 +336,7 @@ var TreeSignerSession = class _TreeSignerSession {
325
336
  noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
326
337
  const tx = this.graph.find(txid);
327
338
  if (!tx) throw new Error(`missing tx for txid ${txid}`);
328
- const cosigners = chunkOMPDPBT5_cjs.getArkPsbtFields(tx.root, 0, chunkOMPDPBT5_cjs.CosignerPublicKey).map(
339
+ const cosigners = chunkSOJDUKY6_cjs.getArkPsbtFields(tx.root, 0, chunkSOJDUKY6_cjs.CosignerPublicKey).map(
329
340
  (c) => base.hex.encode(c.key.subarray(1))
330
341
  // xonly pubkey
331
342
  );
@@ -377,7 +388,7 @@ var TreeSignerSession = class _TreeSignerSession {
377
388
  if (!aggNonce) throw new Error("missing aggregate nonce");
378
389
  const prevoutAmounts = [];
379
390
  const prevoutScripts = [];
380
- const cosigners = chunkOMPDPBT5_cjs.getArkPsbtFields(g.root, 0, chunkOMPDPBT5_cjs.CosignerPublicKey).map((c) => c.key);
391
+ const cosigners = chunkSOJDUKY6_cjs.getArkPsbtFields(g.root, 0, chunkSOJDUKY6_cjs.CosignerPublicKey).map((c) => c.key);
381
392
  const { finalKey } = aggregateKeys(cosigners, true, {
382
393
  taprootTweak: this.scriptRoot
383
394
  });
@@ -460,7 +471,7 @@ var SingleKey = class _SingleKey {
460
471
  async sign(tx, inputIndexes) {
461
472
  const txCpy = tx.clone();
462
473
  if (!inputIndexes) {
463
- chunkOMPDPBT5_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
474
+ chunkSOJDUKY6_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
464
475
  try {
465
476
  if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
466
477
  throw new Error("Failed to sign transaction");
@@ -560,7 +571,7 @@ var SeedIdentity = class _SeedIdentity {
560
571
  let network;
561
572
  if ("descriptor" in opts && typeof opts.descriptor === "string") {
562
573
  descriptor = opts.descriptor;
563
- network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
574
+ network = chunkJYQXB7OH_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
564
575
  } else {
565
576
  network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
566
577
  descriptor = descriptorsScure.scriptExpressions.trBIP32({
@@ -637,7 +648,7 @@ var SeedIdentity = class _SeedIdentity {
637
648
  }
638
649
  /** Returns true when `descriptor` is derived from this identity's seed. */
639
650
  ownsDescriptor(descriptor) {
640
- return chunkMQUATTIM_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
651
+ return chunkJYQXB7OH_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
641
652
  }
642
653
  /**
643
654
  * Signs each request with the key derived from its descriptor.
@@ -676,7 +687,7 @@ var SeedIdentity = class _SeedIdentity {
676
687
  }
677
688
  // ── internal helpers ─────────────────────────────────────────────
678
689
  derivePrivateKeyForDescriptor(descriptor) {
679
- const network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
690
+ const network = chunkJYQXB7OH_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
680
691
  const expansion = descriptorsScure.expand({ descriptor, network });
681
692
  if (expansion.isRanged) {
682
693
  throw new Error(
@@ -701,7 +712,7 @@ var SeedIdentity = class _SeedIdentity {
701
712
  signTxWithKey(tx, key, inputIndexes) {
702
713
  const txCpy = tx.clone();
703
714
  if (!inputIndexes) {
704
- chunkOMPDPBT5_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
715
+ chunkSOJDUKY6_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
705
716
  try {
706
717
  if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
707
718
  throw new Error("Failed to sign transaction");
@@ -802,7 +813,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
802
813
  /** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
803
814
  descriptor;
804
815
  constructor(descriptor) {
805
- const network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
816
+ const network = chunkJYQXB7OH_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
806
817
  let expansion;
807
818
  try {
808
819
  expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
@@ -837,7 +848,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
837
848
  }
838
849
  /** Returns true when `descriptor` derives from this identity's xpub. */
839
850
  ownsDescriptor(descriptor) {
840
- return chunkMQUATTIM_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
851
+ return chunkJYQXB7OH_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
841
852
  }
842
853
  };
843
854
  function serializeSeedOwnedSigningIdentity(identity) {
@@ -980,10 +991,10 @@ var DescriptorIdentity = class {
980
991
  this.base = base;
981
992
  }
982
993
  async xOnlyPublicKey() {
983
- return chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(this.descriptor);
994
+ return chunkJYQXB7OH_cjs.deriveDescriptorLeafPubKey(this.descriptor);
984
995
  }
985
996
  async compressedPublicKey() {
986
- return chunkMQUATTIM_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
997
+ return chunkJYQXB7OH_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
987
998
  }
988
999
  async sign(tx, inputIndexes) {
989
1000
  const [signed] = await this.signer.signWithDescriptor([
@@ -1043,8 +1054,8 @@ var StaticDescriptorProvider = class _StaticDescriptorProvider {
1043
1054
  }
1044
1055
  isOurs(descriptor) {
1045
1056
  try {
1046
- const normalized = chunkMQUATTIM_cjs.normalizeToDescriptor(descriptor);
1047
- const pubKey = chunkMQUATTIM_cjs.extractPubKey(normalized);
1057
+ const normalized = chunkJYQXB7OH_cjs.normalizeToDescriptor(descriptor);
1058
+ const pubKey = chunkJYQXB7OH_cjs.extractPubKey(normalized);
1048
1059
  return pubKey.toLowerCase() === this.pubKeyHex.toLowerCase();
1049
1060
  } catch {
1050
1061
  return false;
@@ -1386,7 +1397,7 @@ function unwrapKeyring(provider) {
1386
1397
  }
1387
1398
  function keyOf(descriptor) {
1388
1399
  try {
1389
- return chunkMQUATTIM_cjs.extractPubKey(chunkMQUATTIM_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
1400
+ return chunkJYQXB7OH_cjs.extractPubKey(chunkJYQXB7OH_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
1390
1401
  } catch {
1391
1402
  return void 0;
1392
1403
  }
@@ -1477,12 +1488,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
1477
1488
  signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
1478
1489
  } : void 0;
1479
1490
  const owner = providerOwner ?? identityOwner;
1480
- if (owner && chunkMQUATTIM_cjs.parseHDDescriptor(descriptor)) {
1491
+ if (owner && chunkJYQXB7OH_cjs.parseHDDescriptor(descriptor)) {
1481
1492
  return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
1482
1493
  }
1483
1494
  let key;
1484
1495
  try {
1485
- key = chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor);
1496
+ key = chunkJYQXB7OH_cjs.deriveDescriptorLeafPubKey(descriptor);
1486
1497
  } catch {
1487
1498
  throw new ForeignDescriptorError(descriptor);
1488
1499
  }
@@ -1535,14 +1546,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
1535
1546
  }
1536
1547
  var PREIMAGE_INDEX = 0;
1537
1548
  function isPerArtifactDescriptor(descriptor) {
1538
- return chunkMQUATTIM_cjs.parseHDDescriptor(descriptor) !== null;
1549
+ return chunkJYQXB7OH_cjs.parseHDDescriptor(descriptor) !== null;
1539
1550
  }
1540
1551
  async function provisionDescriptor(wallet) {
1541
1552
  const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
1542
- return allocated ?? await chunkMQUATTIM_cjs.identityDescriptor(wallet.identity);
1553
+ return allocated ?? await chunkJYQXB7OH_cjs.identityDescriptor(wallet.identity);
1543
1554
  }
1544
1555
  async function provisionRefundKey(wallet) {
1545
- const descriptorPromise = chunkMQUATTIM_cjs.identityDescriptor(wallet.identity);
1556
+ const descriptorPromise = chunkJYQXB7OH_cjs.identityDescriptor(wallet.identity);
1546
1557
  const identityPubkeyPromise = wallet.identity.xOnlyPublicKey();
1547
1558
  void identityPubkeyPromise.catch(() => void 0);
1548
1559
  const descriptor = await descriptorPromise;
@@ -1605,7 +1616,7 @@ async function contractSigner(wallet, descriptor) {
1605
1616
  const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
1606
1617
  let expected;
1607
1618
  try {
1608
- expected = chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor);
1619
+ expected = chunkJYQXB7OH_cjs.deriveDescriptorLeafPubKey(descriptor);
1609
1620
  } catch (cause) {
1610
1621
  throw new ForeignDescriptorError(descriptor, { cause });
1611
1622
  }
@@ -1687,7 +1698,7 @@ function debugLog(debug, ...args) {
1687
1698
  }
1688
1699
  function normalizeOptions(pathOrOptions) {
1689
1700
  const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
1690
- chunkOMPDPBT5_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
1701
+ chunkSOJDUKY6_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
1691
1702
  return {
1692
1703
  path: o.path,
1693
1704
  updateViaCache: o.updateViaCache ?? "none",
@@ -1810,14 +1821,14 @@ var RestDelegateProvider = class {
1810
1821
  */
1811
1822
  async delegate(intent, forfeitTxs, options) {
1812
1823
  const url = `${this.url}/v1/delegate`;
1813
- const response = await chunkOMPDPBT5_cjs.baseFetch(url, {
1824
+ const response = await chunkSOJDUKY6_cjs.baseFetch(url, {
1814
1825
  method: "POST",
1815
1826
  headers: {
1816
1827
  "Content-Type": "application/json"
1817
1828
  },
1818
1829
  body: JSON.stringify({
1819
1830
  intent: {
1820
- message: chunkOMPDPBT5_cjs.Proof.encodeMessage(intent.message),
1831
+ message: chunkSOJDUKY6_cjs.Proof.encodeMessage(intent.message),
1821
1832
  proof: intent.proof
1822
1833
  },
1823
1834
  forfeit_txs: forfeitTxs,
@@ -1836,7 +1847,7 @@ var RestDelegateProvider = class {
1836
1847
  */
1837
1848
  async getDelegateInfo() {
1838
1849
  const url = `${this.url}/v1/delegator/info`;
1839
- const response = await chunkOMPDPBT5_cjs.rateGate.runHttp(url, () => chunkOMPDPBT5_cjs.baseFetch(url));
1850
+ const response = await chunkSOJDUKY6_cjs.rateGate.runHttp(url, () => chunkSOJDUKY6_cjs.baseFetch(url));
1840
1851
  if (!response.ok) {
1841
1852
  const errorText2 = await response.text();
1842
1853
  throw new Error(`Failed to get delegate info: ${errorText2}`);
@@ -1973,33 +1984,37 @@ var EsploraProvider = class {
1973
1984
  */
1974
1985
  addressWatches = /* @__PURE__ */ new Map();
1975
1986
  async getCoins(address) {
1976
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1987
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1977
1988
  if (!response.ok) {
1978
- throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
1989
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to fetch UTXOs", response);
1979
1990
  }
1980
1991
  return response.json();
1981
1992
  }
1982
1993
  async getFeeRate() {
1983
1994
  let url = `${this.baseUrl}/fee-estimates`;
1984
1995
  let key = "1";
1985
- let response = await chunkOMPDPBT5_cjs.baseFetch(url);
1996
+ let response = await chunkSOJDUKY6_cjs.baseFetch(url);
1986
1997
  if (response.status === 404) {
1987
- await response.body?.cancel();
1998
+ await response.body?.cancel().catch(() => {
1999
+ });
1988
2000
  url = `${this.baseUrl}/v1/fees/recommended`;
1989
2001
  key = "fastestFee";
1990
- response = await chunkOMPDPBT5_cjs.baseFetch(url);
2002
+ response = await chunkSOJDUKY6_cjs.baseFetch(url);
1991
2003
  }
1992
2004
  if (response.status === 404) {
1993
- await response.body?.cancel();
2005
+ await response.body?.cancel().catch(() => {
2006
+ });
1994
2007
  return void 0;
1995
2008
  }
1996
2009
  if (!response.ok) {
1997
- await response.body?.cancel();
1998
- throw new Error(`Failed to fetch fee rate: ${response.statusText}`);
2010
+ await response.body?.cancel().catch(() => {
2011
+ });
2012
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to fetch fee rate", response);
1999
2013
  }
2000
2014
  const mediaType = response.headers.get("content-type")?.split(";", 1)[0].trim().toLowerCase();
2001
2015
  if (mediaType === "text/html") {
2002
- await response.body?.cancel();
2016
+ await response.body?.cancel().catch(() => {
2017
+ });
2003
2018
  throw new Error(`Invalid fee estimate from ${url}: received HTML`);
2004
2019
  }
2005
2020
  const fees = await response.json();
@@ -2024,49 +2039,49 @@ var EsploraProvider = class {
2024
2039
  }
2025
2040
  }
2026
2041
  async getTxOutspends(txid) {
2027
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
2042
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
2028
2043
  if (!response.ok) {
2029
- const error = await response.text();
2030
- throw new Error(`Failed to get transaction outspends: ${error}`);
2044
+ const error = await response.text().catch(() => void 0);
2045
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to get transaction outspends", response, error);
2031
2046
  }
2032
2047
  return response.json();
2033
2048
  }
2034
2049
  async getTransactions(address) {
2035
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
2050
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
2036
2051
  if (!response.ok) {
2037
- const error = await response.text();
2038
- throw new Error(`Failed to get transactions: ${error}`);
2052
+ const error = await response.text().catch(() => void 0);
2053
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to get transactions", response, error);
2039
2054
  }
2040
2055
  return response.json();
2041
2056
  }
2042
2057
  /** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
2043
2058
  async getAddressStats(address) {
2044
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
2059
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
2045
2060
  if (!response.ok) {
2046
- throw new Error(`Failed to get address stats: ${response.statusText}`);
2061
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to get address stats", response);
2047
2062
  }
2048
2063
  return response.json();
2049
2064
  }
2050
2065
  async getRawTransaction(txid) {
2051
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
2066
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
2052
2067
  if (!response.ok) {
2053
- const error = await response.text();
2054
- throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
2068
+ const error = await response.text().catch(() => void 0);
2069
+ throw new chunkSOJDUKY6_cjs.HttpResponseError(`Failed to get raw transaction ${txid}`, response, error);
2055
2070
  }
2056
2071
  return base.hex.decode((await response.text()).trim());
2057
2072
  }
2058
2073
  async getTxStatus(txid) {
2059
- const txresponse = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
2074
+ const txresponse = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
2060
2075
  if (!txresponse.ok) {
2061
- throw new Error(txresponse.statusText);
2076
+ throw new chunkSOJDUKY6_cjs.HttpResponseError(`Failed to get transaction ${txid}`, txresponse);
2062
2077
  }
2063
2078
  const tx = await txresponse.json();
2064
2079
  if (!tx.status.confirmed) {
2065
2080
  return { confirmed: false };
2066
2081
  }
2067
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
2082
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
2068
2083
  if (!response.ok) {
2069
- throw new Error(`Failed to get transaction status: ${response.statusText}`);
2084
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to get transaction status", response);
2070
2085
  }
2071
2086
  const data = await response.json();
2072
2087
  if (!data.confirmed) {
@@ -2346,12 +2361,12 @@ var EsploraProvider = class {
2346
2361
  return { subscribers, teardown, started };
2347
2362
  }
2348
2363
  async getChainTip() {
2349
- let tipBlocks = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/blocks`);
2364
+ let tipBlocks = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/blocks`);
2350
2365
  if (tipBlocks.status === 404) {
2351
- tipBlocks = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2366
+ tipBlocks = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2352
2367
  }
2353
2368
  if (!tipBlocks.ok) {
2354
- throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
2369
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to get chain tip", tipBlocks);
2355
2370
  }
2356
2371
  const tip = await tipBlocks.json();
2357
2372
  if (!isValidBlocksTip(tip)) {
@@ -2372,17 +2387,18 @@ var EsploraProvider = class {
2372
2387
  if (!Number.isInteger(height) || height < 0) {
2373
2388
  throw new Error(`Invalid block height for median-time-past: ${height}`);
2374
2389
  }
2375
- const hashResponse = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/block-height/${height}`);
2390
+ const hashResponse = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/block-height/${height}`);
2376
2391
  if (!hashResponse.ok) {
2377
- throw new Error(
2378
- `Failed to get block hash at height ${height}: ${hashResponse.statusText}`
2392
+ throw new chunkSOJDUKY6_cjs.HttpResponseError(
2393
+ `Failed to get block hash at height ${height}`,
2394
+ hashResponse
2379
2395
  );
2380
2396
  }
2381
2397
  const hash = (await hashResponse.text()).trim();
2382
2398
  if (!hash) throw new Error(`No block hash returned at height ${height}`);
2383
- const blockResponse = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/block/${hash}`);
2399
+ const blockResponse = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/block/${hash}`);
2384
2400
  if (!blockResponse.ok) {
2385
- throw new Error(`Failed to get block ${hash}: ${blockResponse.statusText}`);
2401
+ throw new chunkSOJDUKY6_cjs.HttpResponseError(`Failed to get block ${hash}`, blockResponse);
2386
2402
  }
2387
2403
  const block = await blockResponse.json();
2388
2404
  if (!block || typeof block !== "object" || typeof block.mediantime !== "number" || !Number.isFinite(block.mediantime)) {
@@ -2391,7 +2407,7 @@ var EsploraProvider = class {
2391
2407
  return block.mediantime;
2392
2408
  }
2393
2409
  async broadcastPackage(parent, child) {
2394
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2410
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2395
2411
  method: "POST",
2396
2412
  headers: {
2397
2413
  "Content-Type": "application/json"
@@ -2399,15 +2415,15 @@ var EsploraProvider = class {
2399
2415
  body: JSON.stringify([parent, child])
2400
2416
  });
2401
2417
  if (!response.ok) {
2402
- const error = await response.text();
2403
- throw new Error(`Failed to broadcast package: ${error}`);
2418
+ const error = await response.text().catch(() => void 0);
2419
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to broadcast package", response, error);
2404
2420
  }
2405
2421
  const result = await response.json();
2406
2422
  assertPackageAccepted(result);
2407
2423
  return result;
2408
2424
  }
2409
2425
  async broadcastTx(tx) {
2410
- const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx`, {
2426
+ const response = await chunkSOJDUKY6_cjs.baseFetch(`${this.baseUrl}/tx`, {
2411
2427
  method: "POST",
2412
2428
  headers: {
2413
2429
  "Content-Type": "text/plain"
@@ -2415,8 +2431,8 @@ var EsploraProvider = class {
2415
2431
  body: tx
2416
2432
  });
2417
2433
  if (!response.ok) {
2418
- const error = await response.text();
2419
- throw new Error(`Failed to broadcast transaction: ${error}`);
2434
+ const error = await response.text().catch(() => void 0);
2435
+ throw new chunkSOJDUKY6_cjs.HttpResponseError("Failed to broadcast transaction", response, error);
2420
2436
  }
2421
2437
  return response.text();
2422
2438
  }
@@ -2579,7 +2595,7 @@ function findP2AOutput(tx) {
2579
2595
  var CHILD_DUST_AMOUNT = 546;
2580
2596
  function buildAnchorChild(params) {
2581
2597
  const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
2582
- const child = new chunkOMPDPBT5_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2598
+ const child = new chunkSOJDUKY6_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2583
2599
  const anchor = findP2AOutput(parent);
2584
2600
  child.addInput(anchor);
2585
2601
  const estimator = TxWeightEstimator.create().addP2AInput();
@@ -2628,7 +2644,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
2628
2644
  );
2629
2645
  }
2630
2646
  function buildForfeitTxWithOutput(inputs, output, txLocktime) {
2631
- const tx = new chunkOMPDPBT5_cjs.Transaction({
2647
+ const tx = new chunkSOJDUKY6_cjs.Transaction({
2632
2648
  version: 3,
2633
2649
  lockTime: txLocktime
2634
2650
  });
@@ -2655,7 +2671,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
2655
2671
  connectorsGraph.validate();
2656
2672
  if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
2657
2673
  const rootInput = connectorsGraph.root.getInput(0);
2658
- const settlementTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
2674
+ const settlementTx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
2659
2675
  if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
2660
2676
  throw ErrInvalidSettlementTxOutputs;
2661
2677
  const expectedRootTxid = settlementTx.id;
@@ -2704,7 +2720,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2704
2720
  if (previousScriptKey.length !== 32) {
2705
2721
  throw new Error(`parent output ${childIndex} has invalid script`);
2706
2722
  }
2707
- const cosigners = chunkOMPDPBT5_cjs.getArkPsbtFields(child.root, 0, chunkOMPDPBT5_cjs.CosignerPublicKey);
2723
+ const cosigners = chunkSOJDUKY6_cjs.getArkPsbtFields(child.root, 0, chunkSOJDUKY6_cjs.CosignerPublicKey);
2708
2724
  if (cosigners.length === 0) {
2709
2725
  throw ErrMissingCosignersPublicKeys;
2710
2726
  }
@@ -2762,7 +2778,7 @@ var EmulatorPacket = class _EmulatorPacket {
2762
2778
  return new _EmulatorPacket(entries);
2763
2779
  }
2764
2780
  static fromBytes(data) {
2765
- const reader = new chunk3NALVGMJ_cjs.BufferReader(data);
2781
+ const reader = new chunk4IDCSOP2_cjs.BufferReader(data);
2766
2782
  const entryCount = reader.readCompactSize();
2767
2783
  const entries = [];
2768
2784
  for (let i = 0; i < entryCount; i++) {
@@ -2780,7 +2796,7 @@ var EmulatorPacket = class _EmulatorPacket {
2780
2796
  return _EmulatorPacket.PACKET_TYPE;
2781
2797
  }
2782
2798
  serialize() {
2783
- const writer = new chunk3NALVGMJ_cjs.BufferWriter();
2799
+ const writer = new chunk4IDCSOP2_cjs.BufferWriter();
2784
2800
  writer.writeCompactSize(this.entries.length);
2785
2801
  for (const entry of this.entries) {
2786
2802
  writer.writeUint16LE(entry.vin);
@@ -2867,7 +2883,7 @@ var Extension = class _Extension {
2867
2883
  `expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
2868
2884
  );
2869
2885
  }
2870
- const reader = new chunk3NALVGMJ_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2886
+ const reader = new chunk4IDCSOP2_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2871
2887
  const packets = [];
2872
2888
  while (reader.remaining() > 0) {
2873
2889
  const packetType = reader.readByte();
@@ -2940,7 +2956,7 @@ var Extension = class _Extension {
2940
2956
  * getAssetPacket returns the embedded Packet, or null if not present.
2941
2957
  */
2942
2958
  getAssetPacket() {
2943
- return this.packets.find((p) => p instanceof chunk3NALVGMJ_cjs.Packet) ?? null;
2959
+ return this.packets.find((p) => p instanceof chunk4IDCSOP2_cjs.Packet) ?? null;
2944
2960
  }
2945
2961
  /**
2946
2962
  * getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
@@ -2964,8 +2980,8 @@ var Extension = class _Extension {
2964
2980
  };
2965
2981
  function parsePacket(packetType, data) {
2966
2982
  switch (packetType) {
2967
- case chunk3NALVGMJ_cjs.Packet.PACKET_TYPE:
2968
- return chunk3NALVGMJ_cjs.Packet.fromBytes(data);
2983
+ case chunk4IDCSOP2_cjs.Packet.PACKET_TYPE:
2984
+ return chunk4IDCSOP2_cjs.Packet.fromBytes(data);
2969
2985
  case EmulatorPacket.PACKET_TYPE:
2970
2986
  return EmulatorPacket.fromBytes(data);
2971
2987
  default:
@@ -3012,22 +3028,22 @@ function buildOpReturnScript(data) {
3012
3028
  }
3013
3029
  return script;
3014
3030
  }
3015
- var ErrOffchainOutputNotFound = (address) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
3016
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3031
+ var ErrOffchainOutputNotFound = (address) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
3032
+ var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3017
3033
  `invalid asset output amount for ${assetId}: got ${got}, want ${want}`
3018
3034
  );
3019
- var ErrAssetGroupNotFound = (assetId) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
3020
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3035
+ var ErrAssetGroupNotFound = (assetId) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
3036
+ var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3021
3037
  `asset output not found in asset group ${assetId} at index ${outputIndex}`
3022
3038
  );
3023
- var ErrOnchainOutputNotFound = (address) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
3024
- var ErrUnvalidatedOffchainOutput = (address) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3039
+ var ErrOnchainOutputNotFound = (address) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
3040
+ var ErrUnvalidatedOffchainOutput = (address) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3025
3041
  `offchain output ${address} cannot be validated: virtual output tree signing did not run`
3026
3042
  );
3027
- var ErrIntentOutputNotFound = (index, kind) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3043
+ var ErrIntentOutputNotFound = (index, kind) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3028
3044
  `${kind} output ${index} of the proof is not present in what the server built`
3029
3045
  );
3030
- var ErrUnvalidatedIntentOutput = (index) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3046
+ var ErrUnvalidatedIntentOutput = (index) => new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3031
3047
  `offchain output ${index} of the proof cannot be validated: virtual output tree signing did not run`
3032
3048
  );
3033
3049
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
@@ -3036,7 +3052,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
3036
3052
  function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
3037
3053
  if (!validatedCommitmentTxid) return;
3038
3054
  if (finalCommitmentTx.id === validatedCommitmentTxid) return;
3039
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3055
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3040
3056
  `${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
3041
3057
  );
3042
3058
  }
@@ -3067,7 +3083,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
3067
3083
  }
3068
3084
  }
3069
3085
  function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
3070
- const proof = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
3086
+ const proof = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
3071
3087
  const onchain = new Set(onchainOutputIndexes);
3072
3088
  const declared = [];
3073
3089
  for (let i = 0; i < proof.outputsLength; i++) {
@@ -3359,7 +3375,7 @@ function assetMintResolver() {
3359
3375
  if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
3360
3376
  const minted = tx.assets.filter((a) => {
3361
3377
  try {
3362
- return base.hex.encode(chunk3NALVGMJ_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3378
+ return base.hex.encode(chunk4IDCSOP2_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3363
3379
  } catch {
3364
3380
  return false;
3365
3381
  }
@@ -3436,7 +3452,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3436
3452
  const existing = inputsByAssetId.get(asset.assetId);
3437
3453
  inputsByAssetId.set(asset.assetId, [
3438
3454
  ...existing ?? [],
3439
- chunk3NALVGMJ_cjs.AssetInput.create(inputIndex, asset.amount)
3455
+ chunk4IDCSOP2_cjs.AssetInput.create(inputIndex, asset.amount)
3440
3456
  ]);
3441
3457
  }
3442
3458
  }
@@ -3448,7 +3464,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3448
3464
  const existing = outputsByAssetId.get(asset.assetId);
3449
3465
  outputsByAssetId.set(asset.assetId, [
3450
3466
  ...existing ?? [],
3451
- chunk3NALVGMJ_cjs.AssetOutput.create(outputIndex, asset.amount)
3467
+ chunk4IDCSOP2_cjs.AssetOutput.create(outputIndex, asset.amount)
3452
3468
  ]);
3453
3469
  }
3454
3470
  }
@@ -3459,7 +3475,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3459
3475
  const existing = outputsByAssetId.get(asset.assetId);
3460
3476
  outputsByAssetId.set(asset.assetId, [
3461
3477
  ...existing ?? [],
3462
- chunk3NALVGMJ_cjs.AssetOutput.create(outputIndex, asset.amount)
3478
+ chunk4IDCSOP2_cjs.AssetOutput.create(outputIndex, asset.amount)
3463
3479
  ]);
3464
3480
  }
3465
3481
  }
@@ -3468,11 +3484,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3468
3484
  for (const assetIdStr of allAssetIds) {
3469
3485
  const inputs = inputsByAssetId.get(assetIdStr);
3470
3486
  const outputs = outputsByAssetId.get(assetIdStr);
3471
- const assetId = chunk3NALVGMJ_cjs.AssetId.fromString(assetIdStr);
3472
- const group = chunk3NALVGMJ_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3487
+ const assetId = chunk4IDCSOP2_cjs.AssetId.fromString(assetIdStr);
3488
+ const group = chunk4IDCSOP2_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3473
3489
  groups.push(group);
3474
3490
  }
3475
- return chunk3NALVGMJ_cjs.Packet.create(groups);
3491
+ return chunk4IDCSOP2_cjs.Packet.create(groups);
3476
3492
  }
3477
3493
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
3478
3494
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -3556,7 +3572,7 @@ function meetsInputExpiryFloor(coin, floor) {
3556
3572
  }
3557
3573
  function toXOnlySignerHex(pubkeyHex) {
3558
3574
  const bytes2 = base.hex.decode(pubkeyHex);
3559
- if (bytes2.length === 32 || bytes2.length === 33) return base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(bytes2, "signer key"));
3575
+ if (bytes2.length === 32 || bytes2.length === 33) return base.hex.encode(chunk5PWL7WOT_cjs.toXOnly(bytes2, "signer key"));
3560
3576
  throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes2.length}`);
3561
3577
  }
3562
3578
  function signerSetFromInfo(info) {
@@ -3603,14 +3619,14 @@ var toTimelock = (value) => ({
3603
3619
  var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
3604
3620
  function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
3605
3621
  if (policy.requireSeconds && timelock.type === "blocks") {
3606
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3622
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3607
3623
  `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
3608
3624
  );
3609
3625
  }
3610
3626
  const seconds = toSeconds(timelock);
3611
3627
  if (seconds < policy.minSeconds) {
3612
3628
  const remedy = overrideOption ? `; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it` : "";
3613
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3629
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3614
3630
  `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor${remedy}`
3615
3631
  );
3616
3632
  }
@@ -3631,7 +3647,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
3631
3647
  }
3632
3648
  function assertValidBatchExpiry(batchExpiry, policy) {
3633
3649
  if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
3634
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3650
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3635
3651
  `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
3636
3652
  );
3637
3653
  }
@@ -3642,19 +3658,19 @@ function assertValidServerUnrollScript(checkpointTapscript, network, advertisedF
3642
3658
  try {
3643
3659
  script = chunkFLPWNMX3_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3644
3660
  } catch (e) {
3645
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3661
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3646
3662
  `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
3647
3663
  );
3648
3664
  }
3649
3665
  if (advertisedForfeitPubkey !== void 0) {
3650
3666
  const { pubkeys } = script.params;
3651
3667
  if (pubkeys.length !== 1) {
3652
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3668
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3653
3669
  `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
3654
3670
  );
3655
3671
  }
3656
3672
  if (!utils_js.equalBytes(pubkeys[0], advertisedForfeitPubkey)) {
3657
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3673
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3658
3674
  `checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(advertisedForfeitPubkey)}`
3659
3675
  );
3660
3676
  }
@@ -3709,7 +3725,7 @@ function buildVirtualTx(inputs, outputs) {
3709
3725
  }
3710
3726
  }
3711
3727
  }
3712
- const tx = new chunkOMPDPBT5_cjs.Transaction({
3728
+ const tx = new chunkSOJDUKY6_cjs.Transaction({
3713
3729
  version: 3,
3714
3730
  lockTime: Number(lockTime)
3715
3731
  });
@@ -3724,7 +3740,7 @@ function buildVirtualTx(inputs, outputs) {
3724
3740
  },
3725
3741
  tapLeafScript: [input.tapLeafScript]
3726
3742
  });
3727
- chunkOMPDPBT5_cjs.setArkPsbtField(tx, i, chunkOMPDPBT5_cjs.VtxoTaprootTree, input.tapTree);
3743
+ chunkSOJDUKY6_cjs.setArkPsbtField(tx, i, chunkSOJDUKY6_cjs.VtxoTaprootTree, input.tapTree);
3728
3744
  }
3729
3745
  for (const output of outputs) {
3730
3746
  tx.addOutput(output);
@@ -3870,7 +3886,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
3870
3886
  const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
3871
3887
  const sig = signature.subarray(0, 64);
3872
3888
  if (!allowedSighashTypes.includes(sighashType)) {
3873
- const sighashName = chunkOMPDPBT5_cjs.formatSighash(sighashType);
3889
+ const sighashName = chunkSOJDUKY6_cjs.formatSighash(sighashType);
3874
3890
  throw new Error(
3875
3891
  `Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
3876
3892
  );
@@ -3952,16 +3968,16 @@ function isValidArkAddress(address) {
3952
3968
  }
3953
3969
  function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
3954
3970
  if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
3955
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3971
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3956
3972
  `${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
3957
3973
  );
3958
3974
  }
3959
3975
  const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
3960
3976
  return serverCheckpointTxs.map((encoded, index) => {
3961
- const server = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3977
+ const server = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3962
3978
  const local = byTxid.get(server.id);
3963
3979
  if (!local) {
3964
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3980
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3965
3981
  `${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
3966
3982
  );
3967
3983
  }
@@ -3971,14 +3987,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
3971
3987
  }
3972
3988
  function assertSubmittedArkTxid(response, signedArkTx, context) {
3973
3989
  if (response.arkTxid !== signedArkTx.id) {
3974
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3990
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3975
3991
  `${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
3976
3992
  );
3977
3993
  }
3978
3994
  if (response.finalArkTx === void 0) return;
3979
- const finalTxid = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3995
+ const finalTxid = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3980
3996
  if (finalTxid !== signedArkTx.id) {
3981
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
3997
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
3982
3998
  `${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
3983
3999
  );
3984
4000
  }
@@ -3994,16 +4010,16 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
3994
4010
  let leafPubkeys;
3995
4011
  try {
3996
4012
  leafPubkeys = chunkFLPWNMX3_cjs.decodeTapscript(script).params.pubkeys.map(
3997
- (key) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(key, "leaf key"))
4013
+ (key) => base.hex.encode(chunk5PWL7WOT_cjs.toXOnly(key, "leaf key"))
3998
4014
  );
3999
4015
  } catch (error) {
4000
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4016
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4001
4017
  `${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
4002
4018
  );
4003
4019
  }
4004
4020
  const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
4005
4021
  if (!signer) {
4006
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4022
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4007
4023
  `${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
4008
4024
  );
4009
4025
  }
@@ -4017,7 +4033,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
4017
4033
  payment_js.tapLeafHash(script)
4018
4034
  );
4019
4035
  } catch (error) {
4020
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4036
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4021
4037
  `${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
4022
4038
  );
4023
4039
  }
@@ -4026,20 +4042,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
4026
4042
  const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
4027
4043
  for (const [index, checkpoint] of checkpoints.entries()) {
4028
4044
  if (checkpoint.inputsLength !== 1) {
4029
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4045
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4030
4046
  `${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
4031
4047
  );
4032
4048
  }
4033
4049
  const spent = checkpoint.getInput(0);
4034
4050
  if (!spent.txid || spent.index === void 0) {
4035
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4051
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4036
4052
  `${context}: checkpoint ${index} has no input outpoint`
4037
4053
  );
4038
4054
  }
4039
4055
  const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
4040
4056
  const input = byOutpoint.get(outpoint);
4041
4057
  if (!input) {
4042
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4058
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4043
4059
  `${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
4044
4060
  );
4045
4061
  }
@@ -4047,7 +4063,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
4047
4063
  (unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
4048
4064
  );
4049
4065
  if (!rebuilt) {
4050
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4066
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4051
4067
  `${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
4052
4068
  );
4053
4069
  }
@@ -4076,9 +4092,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
4076
4092
  if (!oneShot) {
4077
4093
  matched.forEach(({ server }, index) => {
4078
4094
  try {
4079
- chunkOMPDPBT5_cjs.assertAllowedSighashTypes(server);
4095
+ chunkSOJDUKY6_cjs.assertAllowedSighashTypes(server);
4080
4096
  } catch (error) {
4081
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4097
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4082
4098
  `submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
4083
4099
  );
4084
4100
  }
@@ -4087,14 +4103,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
4087
4103
  const verify = options?.verifyServerSignatures;
4088
4104
  if (verify) {
4089
4105
  if (response.finalArkTx === void 0) {
4090
- throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
4106
+ throw new chunkSOJDUKY6_cjs.ServerResponseMismatchError(
4091
4107
  "submitTx: server returned no final ark tx to verify its signatures against"
4092
4108
  );
4093
4109
  }
4094
- const finalArkTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
4110
+ const finalArkTx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
4095
4111
  const serverPubkeys = new Set(
4096
4112
  [verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
4097
- (key) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(key, "server key"))
4113
+ (key) => base.hex.encode(chunk5PWL7WOT_cjs.toXOnly(key, "server key"))
4098
4114
  )
4099
4115
  );
4100
4116
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
@@ -4142,19 +4158,19 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
4142
4158
  return result;
4143
4159
  }
4144
4160
  function carryConditionWitness(ours, server) {
4145
- if (chunkOMPDPBT5_cjs.getArkPsbtFields(server, 0, chunkOMPDPBT5_cjs.ConditionWitness).length > 0) return;
4146
- const [witness] = chunkOMPDPBT5_cjs.getArkPsbtFields(ours, 0, chunkOMPDPBT5_cjs.ConditionWitness);
4147
- if (witness) chunkOMPDPBT5_cjs.setArkPsbtField(server, 0, chunkOMPDPBT5_cjs.ConditionWitness, witness);
4161
+ if (chunkSOJDUKY6_cjs.getArkPsbtFields(server, 0, chunkSOJDUKY6_cjs.ConditionWitness).length > 0) return;
4162
+ const [witness] = chunkSOJDUKY6_cjs.getArkPsbtFields(ours, 0, chunkSOJDUKY6_cjs.ConditionWitness);
4163
+ if (witness) chunkSOJDUKY6_cjs.setArkPsbtField(server, 0, chunkSOJDUKY6_cjs.ConditionWitness, witness);
4148
4164
  }
4149
4165
  function withArkInputWitness(checkpoint, signedArkTx) {
4150
- if (chunkOMPDPBT5_cjs.getArkPsbtFields(checkpoint, 0, chunkOMPDPBT5_cjs.ConditionWitness).length > 0) return checkpoint;
4166
+ if (chunkSOJDUKY6_cjs.getArkPsbtFields(checkpoint, 0, chunkSOJDUKY6_cjs.ConditionWitness).length > 0) return checkpoint;
4151
4167
  for (let i = 0; i < signedArkTx.inputsLength; i++) {
4152
4168
  const { txid } = signedArkTx.getInput(i);
4153
4169
  if (!txid || base.hex.encode(txid) !== checkpoint.id) continue;
4154
- const [witness] = chunkOMPDPBT5_cjs.getArkPsbtFields(signedArkTx, i, chunkOMPDPBT5_cjs.ConditionWitness);
4170
+ const [witness] = chunkSOJDUKY6_cjs.getArkPsbtFields(signedArkTx, i, chunkSOJDUKY6_cjs.ConditionWitness);
4155
4171
  if (!witness) return checkpoint;
4156
4172
  const carried = checkpoint.clone();
4157
- chunkOMPDPBT5_cjs.setArkPsbtField(carried, 0, chunkOMPDPBT5_cjs.ConditionWitness, witness);
4173
+ chunkSOJDUKY6_cjs.setArkPsbtField(carried, 0, chunkSOJDUKY6_cjs.ConditionWitness, witness);
4158
4174
  return carried;
4159
4175
  }
4160
4176
  return checkpoint;
@@ -4195,7 +4211,7 @@ async function submitViaEmulator(emulator, offchainTx, signer, opts) {
4195
4211
  base.base64.encode(arkTx.toPSBT()),
4196
4212
  checkpoints.map((c) => base.base64.encode(c.toPSBT()))
4197
4213
  );
4198
- const txid = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
4214
+ const txid = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
4199
4215
  assertSubmittedArkTxid({ arkTxid: txid }, arkTx, "emulator submitTx");
4200
4216
  return { txid, signedArkTx: res.signedArkTx, signedCheckpointTxs: res.signedCheckpointTxs };
4201
4217
  }
@@ -4203,12 +4219,12 @@ function claimWithPreimageIdentity(identity, preimage) {
4203
4219
  return {
4204
4220
  ...identity,
4205
4221
  sign: async (tx, inputIndexes) => {
4206
- const signed = chunkOMPDPBT5_cjs.Transaction.fromPSBT(
4222
+ const signed = chunkSOJDUKY6_cjs.Transaction.fromPSBT(
4207
4223
  (await identity.sign(tx.clone(), inputIndexes)).toPSBT()
4208
4224
  );
4209
4225
  const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
4210
4226
  for (const index of indexes) {
4211
- chunkOMPDPBT5_cjs.setArkPsbtField(signed, index, chunkOMPDPBT5_cjs.ConditionWitness, [preimage]);
4227
+ chunkSOJDUKY6_cjs.setArkPsbtField(signed, index, chunkSOJDUKY6_cjs.ConditionWitness, [preimage]);
4212
4228
  }
4213
4229
  return signed;
4214
4230
  }
@@ -4217,7 +4233,7 @@ function claimWithPreimageIdentity(identity, preimage) {
4217
4233
 
4218
4234
  // src/contracts/scope.ts
4219
4235
  function scopeOf(contract) {
4220
- return contract.scope ?? chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.defaultScope ?? "offchain";
4236
+ return contract.scope ?? chunkJYQXB7OH_cjs.contractHandlers.get(contract.type)?.defaultScope ?? "offchain";
4221
4237
  }
4222
4238
  function isOnchainScoped(contract) {
4223
4239
  return scopeOf(contract) !== "offchain";
@@ -4294,9 +4310,9 @@ async function collectScriptVtxos(repository, script, options) {
4294
4310
  return [...byOutpoint.values()].map((row) => row.vtxo);
4295
4311
  }
4296
4312
  function unspentScriptVtxos(rows, copies) {
4297
- const spent = copies.filter((copy) => chunkOMPDPBT5_cjs.isVtxoSpent(copy.vtxo));
4313
+ const spent = copies.filter((copy) => chunkSOJDUKY6_cjs.isVtxoSpent(copy.vtxo));
4298
4314
  return rows.filter(
4299
- (row) => !chunkOMPDPBT5_cjs.isVtxoSpent(row.vtxo) && !spent.some(
4315
+ (row) => !chunkSOJDUKY6_cjs.isVtxoSpent(row.vtxo) && !spent.some(
4300
4316
  (copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
4301
4317
  )
4302
4318
  );
@@ -4353,7 +4369,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
4353
4369
  };
4354
4370
  }
4355
4371
  function deriveContractTapscripts(contract) {
4356
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
4372
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
4357
4373
  if (!handler) {
4358
4374
  throw new Error(`No handler for contract type '${contract.type}'`);
4359
4375
  }
@@ -4556,8 +4572,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
4556
4572
  }
4557
4573
  async function getVtxosForContract(repo, contract, options) {
4558
4574
  const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
4559
- const normalized = vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
4560
- return options?.unspentOnly ? normalized.filter((vtxo) => !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) : normalized;
4575
+ const normalized = vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo);
4576
+ return options?.unspentOnly ? normalized.filter((vtxo) => !chunkSOJDUKY6_cjs.isVtxoSpent(vtxo)) : normalized;
4561
4577
  }
4562
4578
  async function hasVtxosForContract(repo, contract) {
4563
4579
  if (repo.getVtxosForScriptPage) {
@@ -4639,7 +4655,7 @@ async function saveVtxosForContract(repo, contract, vtxos) {
4639
4655
  // src/contracts/onchainCoins.ts
4640
4656
  var MIGRATED_KEY = "legacyUtxosMigrated";
4641
4657
  function createScript(contract) {
4642
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
4658
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
4643
4659
  if (!handler) throw new Error(`No handler for contract type '${contract.type}'`);
4644
4660
  return handler.createScript(contract.params);
4645
4661
  }
@@ -4698,7 +4714,7 @@ async function migrateLegacyUtxos(deps) {
4698
4714
  let migrated = 0;
4699
4715
  for (const contract of await collectContracts(contractRepository)) {
4700
4716
  if (!isOnchainScoped(contract)) continue;
4701
- if (!chunkMQUATTIM_cjs.contractHandlers.has(contract.type)) {
4717
+ if (!chunkJYQXB7OH_cjs.contractHandlers.has(contract.type)) {
4702
4718
  console.warn("Skipping legacy utxos of a contract with no handler", contract.type);
4703
4719
  continue;
4704
4720
  }
@@ -4724,7 +4740,7 @@ var DEFAULT_COSIGN_MARGIN_BLOCKS = 6;
4724
4740
  var MAX_COSIGN_INPUTS = 64;
4725
4741
  var ONCHAIN_RENEW_WINDOW_BLOCKS = 144;
4726
4742
  function exitCsvOf(contract) {
4727
- const sequence = chunkMQUATTIM_cjs.exitSequence(contract);
4743
+ const sequence = chunkJYQXB7OH_cjs.exitSequence(contract);
4728
4744
  return sequence === void 0 ? void 0 : chunkFLPWNMX3_cjs.sequenceToTimelock(sequence);
4729
4745
  }
4730
4746
  var ONCHAIN_COSIGN_PREFLIGHT_PREFIX = "Onchain cosign preflight failed: ";
@@ -4742,7 +4758,7 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
4742
4758
  tx.updateInput(index, { tapLeafScript: void 0, tapScriptSig: void 0 }, true);
4743
4759
  }
4744
4760
  const kept = unknown?.filter(
4745
- (u) => chunkOMPDPBT5_cjs.VtxoTaprootTree.decode(u) === null && chunkOMPDPBT5_cjs.ConditionWitness.decode(u) === null
4761
+ (u) => chunkSOJDUKY6_cjs.VtxoTaprootTree.decode(u) === null && chunkSOJDUKY6_cjs.ConditionWitness.decode(u) === null
4746
4762
  );
4747
4763
  if (kept && kept.length !== unknown.length) {
4748
4764
  tx.updateInput(index, { unknown: void 0 }, true);
@@ -4753,9 +4769,9 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
4753
4769
  tapLeafScript: [path.leaf],
4754
4770
  sighashType: btcSigner.SigHash.DEFAULT
4755
4771
  });
4756
- chunkOMPDPBT5_cjs.setArkPsbtField(tx, index, chunkOMPDPBT5_cjs.VtxoTaprootTree, tapTree);
4772
+ chunkSOJDUKY6_cjs.setArkPsbtField(tx, index, chunkSOJDUKY6_cjs.VtxoTaprootTree, tapTree);
4757
4773
  if (path.extraWitness?.length) {
4758
- chunkOMPDPBT5_cjs.setArkPsbtField(tx, index, chunkOMPDPBT5_cjs.ConditionWitness, path.extraWitness);
4774
+ chunkSOJDUKY6_cjs.setArkPsbtField(tx, index, chunkSOJDUKY6_cjs.ConditionWitness, path.extraWitness);
4759
4775
  }
4760
4776
  }
4761
4777
  function emulatorInputIndexes(tx) {
@@ -4802,7 +4818,7 @@ function isBoardingContract(contract, boardingCsv) {
4802
4818
  if (!isOnchainScoped(contract)) return false;
4803
4819
  if (contract.type === "boarding") return true;
4804
4820
  if (contract.type !== "default" || scopeOf(contract) !== "both") return false;
4805
- return chunkMQUATTIM_cjs.exitSequence(contract) === chunkFLPWNMX3_cjs.timelockToSequence(boardingCsv);
4821
+ return chunkJYQXB7OH_cjs.exitSequence(contract) === chunkFLPWNMX3_cjs.timelockToSequence(boardingCsv);
4806
4822
  }
4807
4823
  function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFAULT_COSIGN_MARGIN_BLOCKS) {
4808
4824
  if (!isBoardingContract(contract, boardingCsv) || !isExplorerCoin(coin)) return false;
@@ -4814,7 +4830,7 @@ function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFA
4814
4830
  return left.remaining > margin && left.remaining <= margin + window2;
4815
4831
  }
4816
4832
  function finalizeOwnedInput(tx, index) {
4817
- const condition = chunkOMPDPBT5_cjs.getArkPsbtFields(tx, index, chunkOMPDPBT5_cjs.ConditionWitness)[0];
4833
+ const condition = chunkSOJDUKY6_cjs.getArkPsbtFields(tx, index, chunkSOJDUKY6_cjs.ConditionWitness)[0];
4818
4834
  if (!condition) {
4819
4835
  tx.finalizeIdx(index);
4820
4836
  return;
@@ -4837,27 +4853,27 @@ var DEFINITE_COSIGN_REJECTIONS = /* @__PURE__ */ new Set([
4837
4853
  "TX_TOO_LARGE"
4838
4854
  ]);
4839
4855
  function isCosignRejectedAfterSigning(e) {
4840
- return e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError && !isCosignFallback(e);
4856
+ return e instanceof chunkSOJDUKY6_cjs.OnchainCosignRejectedError && !isCosignFallback(e);
4841
4857
  }
4842
4858
  function isCosignFallback(e) {
4843
- if (e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError) {
4859
+ if (e instanceof chunkSOJDUKY6_cjs.OnchainCosignRejectedError) {
4844
4860
  return !!e.arkErrorName && DEFINITE_COSIGN_REJECTIONS.has(e.arkErrorName);
4845
4861
  }
4846
- return e instanceof chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError;
4862
+ return e instanceof chunkSOJDUKY6_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError;
4847
4863
  }
4848
4864
  function rehydrateCosignError(e) {
4849
- if (!(e instanceof Error) || e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError || e instanceof chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError || e instanceof chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError) {
4865
+ if (!(e instanceof Error) || e instanceof chunkSOJDUKY6_cjs.OnchainCosignRejectedError || e instanceof chunkSOJDUKY6_cjs.OnchainCosignAmbiguousError || e instanceof chunkSOJDUKY6_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError) {
4850
4866
  return e;
4851
4867
  }
4852
4868
  const { message } = e;
4853
- if (message.startsWith(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX)) {
4854
- const rest = message.slice(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX.length);
4869
+ if (message.startsWith(chunkSOJDUKY6_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX)) {
4870
+ const rest = message.slice(chunkSOJDUKY6_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX.length);
4855
4871
  const named = rest.match(/^\[([A-Z0-9_]+)\] ([\s\S]*)$/);
4856
- return named ? new chunkOMPDPBT5_cjs.OnchainCosignRejectedError(named[2], named[1]) : new chunkOMPDPBT5_cjs.OnchainCosignRejectedError(rest);
4872
+ return named ? new chunkSOJDUKY6_cjs.OnchainCosignRejectedError(named[2], named[1]) : new chunkSOJDUKY6_cjs.OnchainCosignRejectedError(rest);
4857
4873
  }
4858
- if (message.startsWith(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX)) {
4859
- return new chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError(
4860
- message.slice(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX.length)
4874
+ if (message.startsWith(chunkSOJDUKY6_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX)) {
4875
+ return new chunkSOJDUKY6_cjs.OnchainCosignAmbiguousError(
4876
+ message.slice(chunkSOJDUKY6_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX.length)
4861
4877
  );
4862
4878
  }
4863
4879
  if (message.startsWith(ONCHAIN_COSIGN_PREFLIGHT_PREFIX)) {
@@ -4865,8 +4881,8 @@ function rehydrateCosignError(e) {
4865
4881
  message.slice(ONCHAIN_COSIGN_PREFLIGHT_PREFIX.length)
4866
4882
  );
4867
4883
  }
4868
- if (message.startsWith(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_UNSUPPORTED_PREFIX))
4869
- return new chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError();
4884
+ if (message.startsWith(chunkSOJDUKY6_cjs.ONCHAIN_COSIGN_UNSUPPORTED_PREFIX))
4885
+ return new chunkSOJDUKY6_cjs.OnchainCosignUnsupportedError();
4870
4886
  return e;
4871
4887
  }
4872
4888
  function estimateOnchainCosignFee(nIn, nOut, feeRate) {
@@ -4882,13 +4898,13 @@ async function submitOnchainSpend(tx, arkInputs, deps) {
4882
4898
  throw new Error("emulator inputs present but no emulator provider configured");
4883
4899
  }
4884
4900
  const { signedTx } = await deps.emulator.submitOnchainTx(base.base64.encode(tx.toPSBT()));
4885
- tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(signedTx));
4901
+ tx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(signedTx));
4886
4902
  }
4887
4903
  if (arkInputs.size > 0) {
4888
4904
  if (!deps.arkProvider) {
4889
4905
  throw new Error("arkd-cosigned inputs present but no arkProvider configured");
4890
4906
  }
4891
- if (!deps.arkProvider.cosignOnchainTx) throw new chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError();
4907
+ if (!deps.arkProvider.cosignOnchainTx) throw new chunkSOJDUKY6_cjs.OnchainCosignUnsupportedError();
4892
4908
  return deps.arkProvider.cosignOnchainTx(base.base64.encode(tx.toPSBT()));
4893
4909
  }
4894
4910
  for (let i = 0; i < tx.inputsLength; i++) {
@@ -5039,7 +5055,7 @@ function parseProgram(text, env) {
5039
5055
 
5040
5056
  // src/contracts/spendability.ts
5041
5057
  function isContractGenericallySpendable(contract) {
5042
- return chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
5058
+ return chunkJYQXB7OH_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
5043
5059
  }
5044
5060
  function gatedContracts(contracts) {
5045
5061
  const gated = /* @__PURE__ */ new Map();
@@ -5061,7 +5077,7 @@ function gateExclusion(gated) {
5061
5077
  return (vtxo) => {
5062
5078
  const type = gatedTypeOf(vtxo, gated);
5063
5079
  if (type === void 0) return void 0;
5064
- if (!chunkMQUATTIM_cjs.contractHandlers.has(type)) {
5080
+ if (!chunkJYQXB7OH_cjs.contractHandlers.has(type)) {
5065
5081
  return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
5066
5082
  }
5067
5083
  return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
@@ -5097,7 +5113,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
5097
5113
  continue;
5098
5114
  }
5099
5115
  for (const v of vtxos) {
5100
- if (!chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
5116
+ if (!chunkSOJDUKY6_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
5101
5117
  out.add(`${v.txid}:${v.vout}`);
5102
5118
  }
5103
5119
  }
@@ -5139,14 +5155,14 @@ function byValueDescending(vtxos) {
5139
5155
  return [...vtxos].sort((a, b) => b.value - a.value);
5140
5156
  }
5141
5157
  async function fetchTimeHeight(wallet) {
5142
- return chunkOMPDPBT5_cjs.resolveTimeHeight(wallet.onchainProvider);
5158
+ return chunkSOJDUKY6_cjs.resolveTimeHeight(wallet.onchainProvider);
5143
5159
  }
5144
5160
  function heldVtxosOf(wallet) {
5145
5161
  const held = wallet.getHeldVtxos;
5146
5162
  return typeof held === "function" ? held.call(wallet) : Promise.resolve([]);
5147
5163
  }
5148
5164
  function canMigrateBySend(vtxo, now) {
5149
- if (!chunkOMPDPBT5_cjs.canSpendOffchain(vtxo, now)) return false;
5165
+ if (!chunkSOJDUKY6_cjs.canSpendOffchain(vtxo, now)) return false;
5150
5166
  return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
5151
5167
  }
5152
5168
  function byExpiryAscending(vtxos, now) {
@@ -5154,7 +5170,7 @@ function byExpiryAscending(vtxos, now) {
5154
5170
  if (vtxo.isSwept) return -Infinity;
5155
5171
  if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
5156
5172
  if (vtxo.expiresAtHeight !== void 0) {
5157
- return chunkOMPDPBT5_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
5173
+ return chunkSOJDUKY6_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
5158
5174
  }
5159
5175
  return Infinity;
5160
5176
  };
@@ -5181,7 +5197,7 @@ function priceSettlementInputs(vtxos, estimator) {
5181
5197
  const payable = [];
5182
5198
  const net = /* @__PURE__ */ new Map();
5183
5199
  for (const vtxo of vtxos) {
5184
- const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo));
5200
+ const inputFee = estimator.evalOffchainInput(chunkSOJDUKY6_cjs.toOffchainInputFeeParams(vtxo));
5185
5201
  if (inputFee.satoshis >= vtxo.value) {
5186
5202
  continue;
5187
5203
  }
@@ -5261,10 +5277,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
5261
5277
  };
5262
5278
  function getRecoverableVtxos(vtxos, dustAmount, now) {
5263
5279
  return vtxos.filter((vtxo) => {
5264
- if (chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
5280
+ if (chunkSOJDUKY6_cjs.canRecoverOnchain(vtxo, now)) {
5265
5281
  return true;
5266
5282
  }
5267
- if (chunkOMPDPBT5_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
5283
+ if (chunkSOJDUKY6_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
5268
5284
  return true;
5269
5285
  }
5270
5286
  return false;
@@ -5296,7 +5312,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
5296
5312
  function isVtxoExpiringSoon(vtxo, thresholdMs) {
5297
5313
  if (vtxo.isUnrolled) return false;
5298
5314
  const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
5299
- const expiresAt = chunkOMPDPBT5_cjs.normalizeVtxo(vtxo).expiresAt;
5315
+ const expiresAt = chunkSOJDUKY6_cjs.normalizeVtxo(vtxo).expiresAt;
5300
5316
  if (expiresAt === void 0) return false;
5301
5317
  const now = Date.now();
5302
5318
  const batchExpiry = expiresAt.getTime();
@@ -5307,7 +5323,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
5307
5323
  return vtxos.filter(
5308
5324
  // The leading exclusion covers the `isSubdust` arm too, which is a value
5309
5325
  // property and would otherwise re-admit an exited coin on its own.
5310
- (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
5326
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkSOJDUKY6_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
5311
5327
  );
5312
5328
  }
5313
5329
  function isMigrationCapable(wallet) {
@@ -5367,7 +5383,7 @@ var VtxoManager = class _VtxoManager {
5367
5383
  constructor(wallet, settlementConfig) {
5368
5384
  this.wallet = wallet;
5369
5385
  if (settlementConfig !== false) {
5370
- chunkOMPDPBT5_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
5386
+ chunkSOJDUKY6_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
5371
5387
  }
5372
5388
  this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
5373
5389
  this.contractEventsSubscriptionReady = this.initializeSubscription();
@@ -5679,7 +5695,7 @@ var VtxoManager = class _VtxoManager {
5679
5695
  * {@link recoverImportedContracts}).
5680
5696
  */
5681
5697
  async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
5682
- const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo));
5698
+ const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkSOJDUKY6_cjs.isVtxoSpent(vtxo));
5683
5699
  const estimator = new Estimator(info?.fees.intentFee ?? {});
5684
5700
  const { payable, net } = priceSettlementInputs(recoverable, estimator);
5685
5701
  const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
@@ -5713,7 +5729,7 @@ var VtxoManager = class _VtxoManager {
5713
5729
  if (vtxos.length === 0) return;
5714
5730
  const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
5715
5731
  const stillSpendable = vtxos.some(
5716
- (vtxo) => !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
5732
+ (vtxo) => !chunkSOJDUKY6_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
5717
5733
  );
5718
5734
  if (!stillSpendable) {
5719
5735
  await wallet.removeRecoveryContract(contract.script);
@@ -5955,7 +5971,7 @@ var VtxoManager = class _VtxoManager {
5955
5971
  return txid;
5956
5972
  } catch (e) {
5957
5973
  if (!isCosignFallback(e)) throw e;
5958
- if (e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError) {
5974
+ if (e instanceof chunkSOJDUKY6_cjs.OnchainCosignRejectedError) {
5959
5975
  console.warn("Onchain cosign sweep rejected, falling back to CSV exit:", e.message);
5960
5976
  }
5961
5977
  return void 0;
@@ -6032,7 +6048,7 @@ var VtxoManager = class _VtxoManager {
6032
6048
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
6033
6049
  );
6034
6050
  }
6035
- const tx = new chunkOMPDPBT5_cjs.Transaction();
6051
+ const tx = new chunkSOJDUKY6_cjs.Transaction();
6036
6052
  for (const { utxo, script, leaf } of inputs) {
6037
6053
  tx.addInput({
6038
6054
  txid: utxo.txid,
@@ -6270,8 +6286,8 @@ var VtxoManager = class _VtxoManager {
6270
6286
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
6271
6287
  if (cls.status === "CURRENT") continue;
6272
6288
  const live = vtxos.filter((v) => !v.isUnrolled);
6273
- const recoverable = live.filter((v) => v.isSwept && !chunkOMPDPBT5_cjs.isVtxoSpent(v));
6274
- const spendable = live.filter((v) => !chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isSwept);
6289
+ const recoverable = live.filter((v) => v.isSwept && !chunkSOJDUKY6_cjs.isVtxoSpent(v));
6290
+ const spendable = live.filter((v) => !chunkSOJDUKY6_cjs.isVtxoSpent(v) && !v.isSwept);
6275
6291
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
6276
6292
  let recoverableCount = 0;
6277
6293
  let recoverableValue = 0;
@@ -6627,8 +6643,8 @@ var VtxoManager = class _VtxoManager {
6627
6643
  }
6628
6644
  /** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
6629
6645
  extractSpentOutpoint(error) {
6630
- const ark = chunkOMPDPBT5_cjs.maybeArkError(error);
6631
- if (!chunkOMPDPBT5_cjs.isArkError(ark, chunkOMPDPBT5_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
6646
+ const ark = chunkSOJDUKY6_cjs.maybeArkError(error);
6647
+ if (!chunkSOJDUKY6_cjs.isArkError(ark, chunkSOJDUKY6_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
6632
6648
  const raw = ark.metadata?.vtxo_outpoint;
6633
6649
  if (typeof raw !== "string") return void 0;
6634
6650
  const [txid, voutStr] = raw.split(":");
@@ -6809,7 +6825,7 @@ var VtxoManager = class _VtxoManager {
6809
6825
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
6810
6826
  break;
6811
6827
  }
6812
- const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(v));
6828
+ const inputFee = estimator.evalOffchainInput(chunkSOJDUKY6_cjs.toOffchainInputFeeParams(v));
6813
6829
  if (inputFee.satoshis >= v.value) {
6814
6830
  continue;
6815
6831
  }
@@ -7118,7 +7134,7 @@ var ArkadeCash = class _ArkadeCash {
7118
7134
  return SingleKey.fromPrivateKey(this._privateKey);
7119
7135
  }
7120
7136
  get vtxoScript() {
7121
- return new chunkMQUATTIM_cjs.DefaultVtxo.Script({
7137
+ return new chunkJYQXB7OH_cjs.DefaultVtxo.Script({
7122
7138
  pubKey: this._publicKey,
7123
7139
  serverPubKey: this._serverPubKey,
7124
7140
  csvTimelock: this.csvTimelock
@@ -7218,7 +7234,7 @@ async function arkadeCashActivity(records, txs) {
7218
7234
  // src/wallet/intentReconciliation.ts
7219
7235
  var NON_TERMINAL_INTENT_STATES = ALL_BATCH_REGISTRATION_STATES.filter((s) => !isTerminalBatchRegistrationState(s));
7220
7236
  function isConsumed(vtxo) {
7221
- return vtxo !== void 0 && chunkOMPDPBT5_cjs.isVtxoSpent(vtxo);
7237
+ return vtxo !== void 0 && chunkSOJDUKY6_cjs.isVtxoSpent(vtxo);
7222
7238
  }
7223
7239
  async function classifyIntent(intent, vtxosByOutpoint, now) {
7224
7240
  if (isTerminalBatchRegistrationState(intent.state)) return void 0;
@@ -7256,7 +7272,7 @@ async function reconcileIntents(deps) {
7256
7272
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
7257
7273
  if (outpoints.length > 0) {
7258
7274
  try {
7259
- const { vtxos } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
7275
+ const { vtxos } = await chunkSOJDUKY6_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
7260
7276
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
7261
7277
  } catch (e) {
7262
7278
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -7316,7 +7332,7 @@ async function releaseFromServer(intent, deps, now) {
7316
7332
  });
7317
7333
  }
7318
7334
  function isNoMatchingIntentsError(e) {
7319
- return chunkOMPDPBT5_cjs.isArkError(e, chunkOMPDPBT5_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
7335
+ return chunkSOJDUKY6_cjs.isArkError(e, chunkSOJDUKY6_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
7320
7336
  }
7321
7337
  function terminal(intent, state, now, patch) {
7322
7338
  return { ...intent, ...patch, state, updatedAt: now };
@@ -7543,7 +7559,7 @@ async function captureExitBranch(params) {
7543
7559
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
7544
7560
  if (nonCommitment.length > 0) {
7545
7561
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
7546
- psbtByTxid.set(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
7562
+ psbtByTxid.set(chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
7547
7563
  }
7548
7564
  }
7549
7565
  }
@@ -7586,10 +7602,10 @@ var IndexerExitDataSource = class {
7586
7602
  while (hasMore) {
7587
7603
  const { chain: page, page: meta } = await this.indexer.getVtxoChain(
7588
7604
  { txid: vtxo.txid, vout: vtxo.vout },
7589
- { pageIndex, pageSize: chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE }
7605
+ { pageIndex, pageSize: chunkSOJDUKY6_cjs.DEFAULT_PAGE_SIZE }
7590
7606
  );
7591
7607
  chain.push(...page);
7592
- hasMore = meta ? page.length === chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE : false;
7608
+ hasMore = meta ? page.length === chunkSOJDUKY6_cjs.DEFAULT_PAGE_SIZE : false;
7593
7609
  pageIndex++;
7594
7610
  }
7595
7611
  return chain;
@@ -7601,12 +7617,12 @@ var IndexerExitDataSource = class {
7601
7617
  while (hasMore) {
7602
7618
  const { txs, page } = await this.indexer.getVirtualTxs(txids, {
7603
7619
  pageIndex,
7604
- pageSize: chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE
7620
+ pageSize: chunkSOJDUKY6_cjs.DEFAULT_PAGE_SIZE
7605
7621
  });
7606
7622
  for (const psbt of txs) {
7607
- out.set(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
7623
+ out.set(chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
7608
7624
  }
7609
- hasMore = page ? txs.length === chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE : false;
7625
+ hasMore = page ? txs.length === chunkSOJDUKY6_cjs.DEFAULT_PAGE_SIZE : false;
7610
7626
  pageIndex++;
7611
7627
  }
7612
7628
  return out;
@@ -7627,7 +7643,7 @@ function chainedTxTypeToChainTxType(t) {
7627
7643
  }
7628
7644
  }
7629
7645
  function psbtInputTxids(psbtBase64) {
7630
- return txInputTxids(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
7646
+ return txInputTxids(chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
7631
7647
  }
7632
7648
  function txInputTxids(tx) {
7633
7649
  const ids = [];
@@ -7934,10 +7950,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
7934
7950
  try {
7935
7951
  info = await arkProvider.getInfo();
7936
7952
  } catch (err) {
7937
- if (opts?.requireLive || !chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
7953
+ if (opts?.requireLive || !chunkSOJDUKY6_cjs.isRetryableProviderError(err)) throw err;
7938
7954
  const snapshot = await loadArkInfoSnapshot(walletRepository);
7939
7955
  if (!snapshot) {
7940
- throw new chunkOMPDPBT5_cjs.ProviderUnavailableError(
7956
+ throw new chunkSOJDUKY6_cjs.ProviderUnavailableError(
7941
7957
  "Operator info is unavailable and no cached snapshot exists",
7942
7958
  { cause: err }
7943
7959
  );
@@ -8129,7 +8145,7 @@ function buildGraph(rootTxid, chunksByTxid) {
8129
8145
  return new TxTree(rootTx, children);
8130
8146
  }
8131
8147
  function decodeNode(chunk) {
8132
- const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
8148
+ const tx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
8133
8149
  return { tx, children: chunk.children };
8134
8150
  }
8135
8151
  exports.Batch = void 0;
@@ -8353,7 +8369,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
8353
8369
  return [...txids];
8354
8370
  }
8355
8371
  async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
8356
- const normalized = vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
8372
+ const normalized = vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
8357
8373
  const localCreatedAt = localCreatedAtByTxid(normalized);
8358
8374
  const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
8359
8375
  const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
@@ -8540,7 +8556,7 @@ var AssetManager = class extends ReadonlyAssetManager {
8540
8556
  withRecoverable: false,
8541
8557
  genericallySpendableOnly: true
8542
8558
  });
8543
- const controlAssetRef = params.controlAssetId ? chunk3NALVGMJ_cjs.AssetRef.fromId(chunk3NALVGMJ_cjs.AssetId.fromString(params.controlAssetId)) : null;
8559
+ const controlAssetRef = params.controlAssetId ? chunk4IDCSOP2_cjs.AssetRef.fromId(chunk4IDCSOP2_cjs.AssetId.fromString(params.controlAssetId)) : null;
8544
8560
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
8545
8561
  let totalBtcSelected = 0n;
8546
8562
  const assetChanges = /* @__PURE__ */ new Map();
@@ -8553,8 +8569,8 @@ var AssetManager = class extends ReadonlyAssetManager {
8553
8569
  }
8554
8570
  }
8555
8571
  const groups = [];
8556
- const issuedAssetOutput = chunk3NALVGMJ_cjs.AssetOutput.create(0, params.amount);
8557
- const issuedAssetGroup = chunk3NALVGMJ_cjs.AssetGroup.create(
8572
+ const issuedAssetOutput = chunk4IDCSOP2_cjs.AssetOutput.create(0, params.amount);
8573
+ const issuedAssetGroup = chunk4IDCSOP2_cjs.AssetGroup.create(
8558
8574
  null,
8559
8575
  controlAssetRef,
8560
8576
  [],
@@ -8567,11 +8583,11 @@ var AssetManager = class extends ReadonlyAssetManager {
8567
8583
  for (const [assetId, amount] of assetChanges) {
8568
8584
  const changeInputs = inputsForAsset(assetInputs, assetId);
8569
8585
  groups.push(
8570
- chunk3NALVGMJ_cjs.AssetGroup.create(
8571
- chunk3NALVGMJ_cjs.AssetId.fromString(assetId),
8586
+ chunk4IDCSOP2_cjs.AssetGroup.create(
8587
+ chunk4IDCSOP2_cjs.AssetId.fromString(assetId),
8572
8588
  null,
8573
8589
  changeInputs,
8574
- [chunk3NALVGMJ_cjs.AssetOutput.create(0, amount)],
8590
+ [chunk4IDCSOP2_cjs.AssetOutput.create(0, amount)],
8575
8591
  []
8576
8592
  )
8577
8593
  );
@@ -8586,7 +8602,7 @@ var AssetManager = class extends ReadonlyAssetManager {
8586
8602
  );
8587
8603
  return {
8588
8604
  arkTxId: arkTxid,
8589
- assetId: chunk3NALVGMJ_cjs.AssetId.create(arkTxid, 0).toString()
8605
+ assetId: chunk4IDCSOP2_cjs.AssetId.create(arkTxid, 0).toString()
8590
8606
  };
8591
8607
  }
8592
8608
  /**
@@ -8660,23 +8676,23 @@ var AssetManager = class extends ReadonlyAssetManager {
8660
8676
  const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
8661
8677
  const reissueInputs = inputsForAsset(assetInputs, params.assetId);
8662
8678
  const totalAssetAmount = assetToReissueAmount + params.amount;
8663
- const reissueAssetIdObj = chunk3NALVGMJ_cjs.AssetId.fromString(params.assetId);
8664
- const reissueAssetGroup = chunk3NALVGMJ_cjs.AssetGroup.create(
8679
+ const reissueAssetIdObj = chunk4IDCSOP2_cjs.AssetId.fromString(params.assetId);
8680
+ const reissueAssetGroup = chunk4IDCSOP2_cjs.AssetGroup.create(
8665
8681
  reissueAssetIdObj,
8666
8682
  null,
8667
8683
  reissueInputs,
8668
- [chunk3NALVGMJ_cjs.AssetOutput.create(0, totalAssetAmount)],
8684
+ [chunk4IDCSOP2_cjs.AssetOutput.create(0, totalAssetAmount)],
8669
8685
  []
8670
8686
  );
8671
8687
  const groups = [reissueAssetGroup];
8672
8688
  for (const [assetId, amount] of assetChanges) {
8673
8689
  const changeInputs = inputsForAsset(assetInputs, assetId);
8674
8690
  groups.push(
8675
- chunk3NALVGMJ_cjs.AssetGroup.create(
8676
- chunk3NALVGMJ_cjs.AssetId.fromString(assetId),
8691
+ chunk4IDCSOP2_cjs.AssetGroup.create(
8692
+ chunk4IDCSOP2_cjs.AssetId.fromString(assetId),
8677
8693
  null,
8678
8694
  changeInputs,
8679
- [chunk3NALVGMJ_cjs.AssetOutput.create(0, amount)],
8695
+ [chunk4IDCSOP2_cjs.AssetOutput.create(0, amount)],
8680
8696
  []
8681
8697
  )
8682
8698
  );
@@ -8747,11 +8763,11 @@ var AssetManager = class extends ReadonlyAssetManager {
8747
8763
  for (const [assetId, amount] of assetChanges) {
8748
8764
  const changeInputs = inputsForAsset(assetInputs, assetId);
8749
8765
  groups.push(
8750
- chunk3NALVGMJ_cjs.AssetGroup.create(
8751
- chunk3NALVGMJ_cjs.AssetId.fromString(assetId),
8766
+ chunk4IDCSOP2_cjs.AssetGroup.create(
8767
+ chunk4IDCSOP2_cjs.AssetId.fromString(assetId),
8752
8768
  null,
8753
8769
  changeInputs,
8754
- amount > 0n ? [chunk3NALVGMJ_cjs.AssetOutput.create(0, amount)] : [],
8770
+ amount > 0n ? [chunk4IDCSOP2_cjs.AssetOutput.create(0, amount)] : [],
8755
8771
  []
8756
8772
  )
8757
8773
  );
@@ -8764,7 +8780,7 @@ function inputsForAsset(assetInputs, assetId) {
8764
8780
  for (const [inputIndex, assets] of assetInputs) {
8765
8781
  for (const asset of assets) {
8766
8782
  if (asset.assetId !== assetId) continue;
8767
- inputs.push(chunk3NALVGMJ_cjs.AssetInput.create(inputIndex, asset.amount));
8783
+ inputs.push(chunk4IDCSOP2_cjs.AssetInput.create(inputIndex, asset.amount));
8768
8784
  }
8769
8785
  }
8770
8786
  return inputs;
@@ -8773,7 +8789,7 @@ async function submitToSelf(submit, wallet, inputs, amount, groups) {
8773
8789
  const outputAddress = chunkFLPWNMX3_cjs.ArkAddress.decode(await wallet.getAddress());
8774
8790
  const outputs = [
8775
8791
  { script: outputAddress.pkScript, amount: BigInt(amount) },
8776
- Extension.create([chunk3NALVGMJ_cjs.Packet.create(groups)]).txOut()
8792
+ Extension.create([chunk4IDCSOP2_cjs.Packet.create(groups)]).txOut()
8777
8793
  ];
8778
8794
  const { arkTxid } = await submit(inputs, outputs);
8779
8795
  return arkTxid;
@@ -8797,7 +8813,7 @@ function castMetadata(metadata) {
8797
8813
  } else {
8798
8814
  throw new Error("Invalid metadata value type");
8799
8815
  }
8800
- md.push(chunk3NALVGMJ_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
8816
+ md.push(chunk4IDCSOP2_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
8801
8817
  }
8802
8818
  return md;
8803
8819
  }
@@ -8823,7 +8839,7 @@ var DelegateManagerImpl = class {
8823
8839
  this.arkInfoProvider.getInfo(),
8824
8840
  this.delegateProvider.getDelegateInfo()
8825
8841
  ]);
8826
- const eligible = vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo).filter(
8842
+ const eligible = vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo).filter(
8827
8843
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
8828
8844
  );
8829
8845
  if (eligible.length === 0) {
@@ -8855,7 +8871,7 @@ var DelegateManagerImpl = class {
8855
8871
  const groupByExpiry = /* @__PURE__ */ new Map();
8856
8872
  let recoverableVtxos = [];
8857
8873
  for (const vtxo of eligible) {
8858
- if (chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
8874
+ if (chunkSOJDUKY6_cjs.canRecoverOnchain(vtxo, now)) {
8859
8875
  recoverableVtxos.push(vtxo);
8860
8876
  continue;
8861
8877
  }
@@ -8907,7 +8923,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
8907
8923
  }
8908
8924
  if (!delegateAt) {
8909
8925
  const now = { timestamp: /* @__PURE__ */ new Date() };
8910
- const expiryTimestamp = vtxos.filter((coin) => !chunkOMPDPBT5_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
8926
+ const expiryTimestamp = vtxos.filter((coin) => !chunkSOJDUKY6_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
8911
8927
  (min, coin) => Math.min(min, coin.expiresAt.getTime()),
8912
8928
  Number.MAX_SAFE_INTEGER
8913
8929
  );
@@ -8927,7 +8943,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
8927
8943
  let amount = 0n;
8928
8944
  for (const coin of vtxos) {
8929
8945
  const inputFee = estimator.evalOffchainInput({
8930
- ...chunkOMPDPBT5_cjs.toOffchainInputFeeParams(coin),
8946
+ ...chunkSOJDUKY6_cjs.toOffchainInputFeeParams(coin),
8931
8947
  type: "vtxo"
8932
8948
  });
8933
8949
  if (inputFee.satoshis >= coin.value) {
@@ -8977,7 +8993,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
8977
8993
  btcSigner.Address(chunkFLPWNMX3_cjs.getNetwork(network)).decode(forfeitAddress)
8978
8994
  );
8979
8995
  const forfeits = await Promise.all(
8980
- vtxos.filter((v) => chunkOMPDPBT5_cjs.requiresForfeit(v)).map(async (coin) => {
8996
+ vtxos.filter((v) => chunkSOJDUKY6_cjs.requiresForfeit(v)).map(async (coin) => {
8981
8997
  const forfeit = await makeDelegateForfeitTx(
8982
8998
  coin,
8983
8999
  dust,
@@ -9060,7 +9076,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
9060
9076
  expire_at: 0,
9061
9077
  cosigners_public_keys: cosignerPubKeys
9062
9078
  };
9063
- const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, outputs);
9079
+ const proof = chunkSOJDUKY6_cjs.Proof.create(message, coins, outputs);
9064
9080
  const signedProof = await identity.sign(proof);
9065
9081
  return {
9066
9082
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -9802,7 +9818,7 @@ function decodeArkContract(encoded) {
9802
9818
  }
9803
9819
  function contractFromArkContract(encoded, options = {}) {
9804
9820
  const parsed = decodeArkContract(encoded);
9805
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(parsed.type);
9821
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(parsed.type);
9806
9822
  if (!handler) {
9807
9823
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
9808
9824
  }
@@ -9818,7 +9834,7 @@ function contractFromArkContract(encoded, options = {}) {
9818
9834
  }
9819
9835
  function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkFLPWNMX3_cjs.DEFAULT_NETWORK.hrp, options = {}) {
9820
9836
  const parsed = decodeArkContract(encoded);
9821
- const handler = chunkMQUATTIM_cjs.contractHandlers.getOrThrow(parsed.type);
9837
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.getOrThrow(parsed.type);
9822
9838
  const params = parsed.data;
9823
9839
  const vtxoScript = handler.createScript(params);
9824
9840
  return {
@@ -9840,10 +9856,11 @@ function isArkContract(str) {
9840
9856
  function computeReconnectDelay(attempt, baseMs, maxMs) {
9841
9857
  return Math.min(baseMs * Math.pow(2, attempt - 1), maxMs);
9842
9858
  }
9859
+ var STABLE_CONNECTION_MS = 3e4;
9843
9860
  var DEFAULT_CONTRACT_WATCHER_CONFIG = {
9844
9861
  failsafePollIntervalMs: 2e4,
9845
9862
  reconnectDelayMs: 1e3,
9846
- maxReconnectDelayMs: 5e3,
9863
+ maxReconnectDelayMs: 6e4,
9847
9864
  maxReconnectAttempts: 0,
9848
9865
  // unlimited
9849
9866
  subscriptionRequestTimeoutMs: 3e4
@@ -9859,6 +9876,7 @@ var ContractWatcher = class {
9859
9876
  eventCallback;
9860
9877
  connectionState = "disconnected";
9861
9878
  reconnectAttempts = 0;
9879
+ connectedAt;
9862
9880
  reconnectTimeoutId;
9863
9881
  failsafePollIntervalId;
9864
9882
  /** See {@link withCoalescedSubscription}. */
@@ -9875,10 +9893,10 @@ var ContractWatcher = class {
9875
9893
  eventSourceReported = false;
9876
9894
  /** @see ContractWatcherConfig */
9877
9895
  constructor(config) {
9878
- chunkOMPDPBT5_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
9879
- chunkOMPDPBT5_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
9880
- chunkOMPDPBT5_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
9881
- chunkOMPDPBT5_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
9896
+ chunkSOJDUKY6_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
9897
+ chunkSOJDUKY6_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
9898
+ chunkSOJDUKY6_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
9899
+ chunkSOJDUKY6_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
9882
9900
  if (config.subscriptionRequestTimeoutMs === 0) {
9883
9901
  throw new Error("subscriptionRequestTimeoutMs must be greater than 0");
9884
9902
  }
@@ -10044,6 +10062,7 @@ var ContractWatcher = class {
10044
10062
  const session = new AbortController();
10045
10063
  this.abortController = session;
10046
10064
  this.reconnectAttempts = 0;
10065
+ this.connectedAt = void 0;
10047
10066
  this.subscriptionUpdate = Promise.resolve();
10048
10067
  await this.connect();
10049
10068
  if (session.signal.aborted) return () => this.stopWatching();
@@ -10053,6 +10072,7 @@ var ContractWatcher = class {
10053
10072
  async stopWatching() {
10054
10073
  this.isWatching = false;
10055
10074
  this.connectionState = "disconnected";
10075
+ this.connectedAt = void 0;
10056
10076
  this.abortController?.abort();
10057
10077
  this.cancelSubscriptionRetry();
10058
10078
  this.subscriptionRetryAttempts = 0;
@@ -10098,28 +10118,28 @@ var ContractWatcher = class {
10098
10118
  await this.pollAllContracts();
10099
10119
  if (!this.isWatching || signal?.aborted) return;
10100
10120
  this.connectionState = "connected";
10101
- this.reconnectAttempts = 0;
10121
+ this.connectedAt = Date.now();
10102
10122
  this.listenLoop().catch((e) => {
10103
10123
  if (!this.isWatching || signal?.aborted) return;
10104
- if (chunkOMPDPBT5_cjs.isEventSourceError(e)) {
10124
+ if (chunkSOJDUKY6_cjs.isEventSourceError(e)) {
10105
10125
  console.debug("ContractWatcher subscription disconnected; reconnecting");
10106
- } else if (!chunkOMPDPBT5_cjs.isEventSourceUnavailableError(e)) {
10126
+ } else if (!chunkSOJDUKY6_cjs.isEventSourceUnavailableError(e)) {
10107
10127
  console.error(e);
10108
10128
  }
10109
10129
  this.connectionState = "disconnected";
10110
10130
  if (this.reportEventSourceUnavailable(e)) return;
10111
10131
  this.emitConnectionReset();
10112
- this.scheduleReconnect();
10132
+ this.scheduleReconnect(e);
10113
10133
  });
10114
10134
  } catch (error) {
10115
10135
  if (!this.isWatching || signal?.aborted) return;
10116
- if (!chunkOMPDPBT5_cjs.isEventSourceUnavailableError(error)) {
10136
+ if (!chunkSOJDUKY6_cjs.isEventSourceUnavailableError(error)) {
10117
10137
  console.error("ContractWatcher connection failed:", error);
10118
10138
  }
10119
10139
  this.connectionState = "disconnected";
10120
10140
  if (this.reportEventSourceUnavailable(error)) return;
10121
10141
  this.emitConnectionReset();
10122
- this.scheduleReconnect();
10142
+ this.scheduleReconnect(error);
10123
10143
  }
10124
10144
  }
10125
10145
  /**
@@ -10129,7 +10149,7 @@ var ContractWatcher = class {
10129
10149
  * few seconds.
10130
10150
  */
10131
10151
  reportEventSourceUnavailable(error) {
10132
- if (!chunkOMPDPBT5_cjs.isEventSourceUnavailableError(error)) return false;
10152
+ if (!chunkSOJDUKY6_cjs.isEventSourceUnavailableError(error)) return false;
10133
10153
  if (!this.eventSourceReported) {
10134
10154
  this.eventSourceReported = true;
10135
10155
  console.warn(
@@ -10138,9 +10158,13 @@ var ContractWatcher = class {
10138
10158
  }
10139
10159
  return true;
10140
10160
  }
10141
- scheduleReconnect() {
10161
+ scheduleReconnect(failure) {
10142
10162
  if (!this.isWatching) return;
10143
10163
  this.cancelSubscriptionRetry();
10164
+ const refused = typeof failure?.status === "number";
10165
+ const wasStable = !refused && this.connectedAt !== void 0 && Date.now() - this.connectedAt >= Math.min(this.config.maxReconnectDelayMs, STABLE_CONNECTION_MS);
10166
+ if (wasStable) this.reconnectAttempts = 0;
10167
+ this.connectedAt = void 0;
10144
10168
  if (this.config.maxReconnectAttempts > 0 && this.reconnectAttempts >= this.config.maxReconnectAttempts) {
10145
10169
  console.error(
10146
10170
  `ContractWatcher: Max reconnection attempts (${this.config.maxReconnectAttempts}) reached`
@@ -10149,15 +10173,27 @@ var ContractWatcher = class {
10149
10173
  }
10150
10174
  this.connectionState = "reconnecting";
10151
10175
  this.reconnectAttempts++;
10152
- const delay = computeReconnectDelay(
10176
+ this.reconnectTimeoutId = setTimeout(() => {
10177
+ this.reconnectTimeoutId = void 0;
10178
+ this.connect();
10179
+ }, this.nextReconnectDelay(failure));
10180
+ }
10181
+ /**
10182
+ * Equal jitter over the exponential backoff, never shorter than a `Retry-After` the server
10183
+ * asked for (clamped like the rate gate's own cooldown, so a bogus header cannot park the
10184
+ * stream). Without jitter the clients one restart dropped all return in the same instant, so
10185
+ * a dominant `Retry-After` is spread over half its own length too.
10186
+ */
10187
+ nextReconnectDelay(failure) {
10188
+ const capped = computeReconnectDelay(
10153
10189
  this.reconnectAttempts,
10154
10190
  this.config.reconnectDelayMs,
10155
10191
  this.config.maxReconnectDelayMs
10156
10192
  );
10157
- this.reconnectTimeoutId = setTimeout(() => {
10158
- this.reconnectTimeoutId = void 0;
10159
- this.connect();
10160
- }, delay);
10193
+ const askedFor = Math.min(chunkSOJDUKY6_cjs.retryAfterMsFromError(failure) ?? 0, chunkSOJDUKY6_cjs.MAX_COOLDOWN_MS);
10194
+ const floor = Math.max(capped / 2, askedFor);
10195
+ const ceiling = Math.max(capped, askedFor * 1.5);
10196
+ return floor + Math.random() * (ceiling - floor);
10161
10197
  }
10162
10198
  /** Replays repository state — only what a sync stored; watch-only scripts poll the indexer. */
10163
10199
  startFailsafePolling() {
@@ -10194,7 +10230,7 @@ var ContractWatcher = class {
10194
10230
  const now = Date.now();
10195
10231
  let current;
10196
10232
  try {
10197
- current = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
10233
+ current = await chunkSOJDUKY6_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
10198
10234
  spendableOnly: true
10199
10235
  });
10200
10236
  } catch (error) {
@@ -10476,14 +10512,14 @@ var ContractWatcher = class {
10476
10512
  const timestamp = Date.now();
10477
10513
  if (update.newVtxos?.length) {
10478
10514
  this.processSubscriptionVtxos(
10479
- update.newVtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo),
10515
+ update.newVtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo),
10480
10516
  "vtxo_received",
10481
10517
  timestamp
10482
10518
  );
10483
10519
  }
10484
10520
  if (update.spentVtxos?.length) {
10485
10521
  this.processSubscriptionVtxos(
10486
- update.spentVtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo),
10522
+ update.spentVtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo),
10487
10523
  "vtxo_spent",
10488
10524
  timestamp
10489
10525
  );
@@ -10508,8 +10544,8 @@ var ContractWatcher = class {
10508
10544
  continue;
10509
10545
  }
10510
10546
  if (target === byWatchedScript && eventType === "vtxo_received") {
10511
- const n = chunkOMPDPBT5_cjs.normalizeVtxo(vtxo);
10512
- if (chunkOMPDPBT5_cjs.isVtxoSpent(n) || n.isSwept || chunkOMPDPBT5_cjs.isPastExpiry(n, now)) continue;
10547
+ const n = chunkSOJDUKY6_cjs.normalizeVtxo(vtxo);
10548
+ if (chunkSOJDUKY6_cjs.isVtxoSpent(n) || n.isSwept || chunkSOJDUKY6_cjs.isPastExpiry(n, now)) continue;
10513
10549
  }
10514
10550
  let bucket = target.get(vtxo.script);
10515
10551
  if (!bucket) {
@@ -10697,7 +10733,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
10697
10733
  if (!contract) continue;
10698
10734
  try {
10699
10735
  const key = contractKey(contract);
10700
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
10736
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
10701
10737
  const hit = memo?.get(script);
10702
10738
  let tapscripts;
10703
10739
  if (hit && hit.key === key && hit.handler === handler) {
@@ -10718,7 +10754,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
10718
10754
  scripts.add(script);
10719
10755
  } catch (err) {
10720
10756
  const reason = `'${contract.type}' at ${script}: ${err instanceof Error ? err.message : String(err)}`;
10721
- if (err instanceof chunkJFJNB7ZH_cjs.UnsupportedProgramVersionError) {
10757
+ if (err instanceof chunk5PWL7WOT_cjs.UnsupportedProgramVersionError) {
10722
10758
  unsupported.set(script, { key: contractKey(contract), reason });
10723
10759
  } else {
10724
10760
  failures.set(script, reason);
@@ -10729,7 +10765,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
10729
10765
  }
10730
10766
  function annotateAgainst(vtxos, byScript, tapscripts = /* @__PURE__ */ new Map()) {
10731
10767
  return vtxos.map(
10732
- (vtxo) => extendVirtualCoinForContract(chunkOMPDPBT5_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
10768
+ (vtxo) => extendVirtualCoinForContract(chunkSOJDUKY6_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
10733
10769
  );
10734
10770
  }
10735
10771
  var SCAN_MAX_INDEX = 1e4;
@@ -10778,8 +10814,8 @@ var ContractManager = class _ContractManager {
10778
10814
  /** Serializes onchain read-modify-writes so a pending spender is never overwritten. */
10779
10815
  onchainChain = Promise.resolve();
10780
10816
  constructor(config) {
10781
- chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
10782
- chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
10817
+ chunkSOJDUKY6_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
10818
+ chunkSOJDUKY6_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
10783
10819
  this.config = { ...config };
10784
10820
  if (config.onchainProvider && config.network) {
10785
10821
  this.onchainWatcher = new OnchainContractWatcher({
@@ -10824,12 +10860,12 @@ var ContractManager = class _ContractManager {
10824
10860
  }
10825
10861
  /** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
10826
10862
  setVtxoSyncMaxAge(maxAgeMs) {
10827
- chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
10863
+ chunkSOJDUKY6_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
10828
10864
  this.config.vtxoSyncMaxAgeMs = maxAgeMs;
10829
10865
  }
10830
10866
  /** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
10831
10867
  setVtxoSyncOverlap(overlapMs) {
10832
- chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
10868
+ chunkSOJDUKY6_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
10833
10869
  this.config.vtxoSyncOverlapMs = overlapMs;
10834
10870
  }
10835
10871
  markSyncOnline() {
@@ -10893,10 +10929,10 @@ var ContractManager = class _ContractManager {
10893
10929
  if (this.unsupportedContracts.get(contract.script) === key) return true;
10894
10930
  if (this.tapscriptMemo.get(contract.script)?.key === key) return false;
10895
10931
  try {
10896
- chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
10932
+ chunkJYQXB7OH_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
10897
10933
  return false;
10898
10934
  } catch (err) {
10899
- if (!(err instanceof chunkJFJNB7ZH_cjs.UnsupportedProgramVersionError)) return false;
10935
+ if (!(err instanceof chunk5PWL7WOT_cjs.UnsupportedProgramVersionError)) return false;
10900
10936
  this.unsupportedContracts.set(contract.script, key);
10901
10937
  return true;
10902
10938
  }
@@ -10909,7 +10945,7 @@ var ContractManager = class _ContractManager {
10909
10945
  this.markSyncOnline();
10910
10946
  return void 0;
10911
10947
  } catch (err) {
10912
- if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
10948
+ if (!chunkSOJDUKY6_cjs.isRetryableProviderError(err)) throw err;
10913
10949
  this.markSyncDegraded(err);
10914
10950
  return err;
10915
10951
  }
@@ -10932,7 +10968,7 @@ var ContractManager = class _ContractManager {
10932
10968
  try {
10933
10969
  await this.scheduleLookAheadDrain();
10934
10970
  } catch (err) {
10935
- if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
10971
+ if (!chunkSOJDUKY6_cjs.isRetryableProviderError(err)) throw err;
10936
10972
  this.lookAheadRefillOwed = true;
10937
10973
  this.markSyncDegraded(err);
10938
10974
  }
@@ -10995,7 +11031,7 @@ var ContractManager = class _ContractManager {
10995
11031
  /** No throw: construction returned long ago, so the state is the channel. */
10996
11032
  reportBackgroundFailure(stage, err) {
10997
11033
  this.markSyncDegraded(err);
10998
- if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) {
11034
+ if (!chunkSOJDUKY6_cjs.isRetryableProviderError(err)) {
10999
11035
  console.error(`[contracts] background ${stage} failed`, err);
11000
11036
  }
11001
11037
  }
@@ -11097,7 +11133,7 @@ var ContractManager = class _ContractManager {
11097
11133
  const from = Math.max(0, watermark - lookAhead.size);
11098
11134
  const to = watermark + lookAhead.size;
11099
11135
  const deps = lookAhead.candidateDeps();
11100
- const handlers = chunkMQUATTIM_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkMQUATTIM_cjs.contractHandlers.get(t)).filter(hasCandidates);
11136
+ const handlers = chunkJYQXB7OH_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkJYQXB7OH_cjs.contractHandlers.get(t)).filter(hasCandidates);
11101
11137
  const band = /* @__PURE__ */ new Map();
11102
11138
  for (let index = from; index <= to; index++) {
11103
11139
  const descriptor = lookAhead.materialize(index);
@@ -11108,7 +11144,7 @@ var ContractManager = class _ContractManager {
11108
11144
  index,
11109
11145
  params: {
11110
11146
  ...candidate,
11111
- ...chunkMQUATTIM_cjs.speculativeReceiveMetadata(descriptor)
11147
+ ...chunkJYQXB7OH_cjs.speculativeReceiveMetadata(descriptor)
11112
11148
  }
11113
11149
  });
11114
11150
  }
@@ -11167,7 +11203,7 @@ var ContractManager = class _ContractManager {
11167
11203
  });
11168
11204
  for (const entry of pending) entry.catchUpPending = false;
11169
11205
  } catch (err) {
11170
- if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
11206
+ if (!chunkSOJDUKY6_cjs.isRetryableProviderError(err)) throw err;
11171
11207
  this.markSyncDegraded(err);
11172
11208
  }
11173
11209
  }
@@ -11258,7 +11294,7 @@ var ContractManager = class _ContractManager {
11258
11294
  return result;
11259
11295
  }
11260
11296
  async upsertContractRow(params) {
11261
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(params.type);
11297
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(params.type);
11262
11298
  if (!handler) {
11263
11299
  throw new Error(`No handler registered for contract type '${params.type}'`);
11264
11300
  }
@@ -11360,7 +11396,7 @@ var ContractManager = class _ContractManager {
11360
11396
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
11361
11397
  );
11362
11398
  }
11363
- const registered = chunkMQUATTIM_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkMQUATTIM_cjs.contractHandlers.get(t)).filter(isDiscoverable);
11399
+ const registered = chunkJYQXB7OH_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkJYQXB7OH_cjs.contractHandlers.get(t)).filter(isDiscoverable);
11364
11400
  const discoverables = [
11365
11401
  ...registered.filter((h) => h.type === "boarding"),
11366
11402
  ...registered.filter((h) => h.type !== "boarding")
@@ -11491,7 +11527,7 @@ var ContractManager = class _ContractManager {
11491
11527
  return contracts.filter((contract) => this.isUnsupported(contract));
11492
11528
  }
11493
11529
  async getContractsWithVtxos(filter, pageSize, options) {
11494
- chunkOMPDPBT5_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
11530
+ chunkSOJDUKY6_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
11495
11531
  const contracts = await this.getContracts(filter);
11496
11532
  if (this.syncedWithin(
11497
11533
  contracts,
@@ -11599,7 +11635,7 @@ var ContractManager = class _ContractManager {
11599
11635
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
11600
11636
  const asking = vtxos.filter((vtxo) => {
11601
11637
  const contract = byScript.get(vtxo.script);
11602
- return contract !== void 0 && chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
11638
+ return contract !== void 0 && chunkJYQXB7OH_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
11603
11639
  });
11604
11640
  if (asking.length === 0) return refused;
11605
11641
  const [tip, walletDescriptorValue] = await Promise.all([
@@ -11608,7 +11644,7 @@ var ContractManager = class _ContractManager {
11608
11644
  ]);
11609
11645
  for (const vtxo of asking) {
11610
11646
  const contract = byScript.get(vtxo.script);
11611
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
11647
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
11612
11648
  if (!handler?.assertSpendableNow) continue;
11613
11649
  const context = {
11614
11650
  collaborative: true,
@@ -11618,7 +11654,7 @@ var ContractManager = class _ContractManager {
11618
11654
  walletDescriptor: walletDescriptorValue,
11619
11655
  // `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
11620
11656
  // reads `vtxo.status.block_time` unguarded, so require `status` too.
11621
- vtxo: chunkOMPDPBT5_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
11657
+ vtxo: chunkSOJDUKY6_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
11622
11658
  };
11623
11659
  try {
11624
11660
  await handler.assertSpendableNow(
@@ -11732,7 +11768,7 @@ var ContractManager = class _ContractManager {
11732
11768
  const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
11733
11769
  const [contract] = await this.getContracts({ script: contractScript });
11734
11770
  if (!contract) return [];
11735
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
11771
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
11736
11772
  if (!handler) return [];
11737
11773
  const script = handler.createScript(contract.params);
11738
11774
  const tip = await this.currentChainTip();
@@ -11754,7 +11790,7 @@ var ContractManager = class _ContractManager {
11754
11790
  const { contractScript, collaborative = true, walletDescriptor } = options;
11755
11791
  const [contract] = await this.getContracts({ script: contractScript });
11756
11792
  if (!contract) return [];
11757
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
11793
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
11758
11794
  if (!handler) return [];
11759
11795
  const script = handler.createScript(contract.params);
11760
11796
  const context = {
@@ -11800,7 +11836,7 @@ var ContractManager = class _ContractManager {
11800
11836
  }
11801
11837
  async refreshOutpoints(outpoints) {
11802
11838
  if (outpoints.length === 0) return;
11803
- const { vtxos } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(this.config.indexerProvider, {
11839
+ const { vtxos } = await chunkSOJDUKY6_cjs.getNormalizedVtxos(this.config.indexerProvider, {
11804
11840
  outpoints
11805
11841
  });
11806
11842
  if (vtxos.length === 0) return;
@@ -11925,7 +11961,7 @@ var ContractManager = class _ContractManager {
11925
11961
  ...Object.values(pending).map((p) => p.script)
11926
11962
  ]);
11927
11963
  const targets = contracts.filter(
11928
- (c) => chunkMQUATTIM_cjs.contractHandlers.has(c.type) && (c.state === "active" && isOnchainScoped(c) || owners.has(c.script))
11964
+ (c) => chunkJYQXB7OH_cjs.contractHandlers.has(c.type) && (c.state === "active" && isOnchainScoped(c) || owners.has(c.script))
11929
11965
  );
11930
11966
  const wanted = scripts && new Set(scripts);
11931
11967
  const settled = [];
@@ -11960,7 +11996,7 @@ var ContractManager = class _ContractManager {
11960
11996
  ).catch((e) => console.warn("[contracts] onchain watch failed", e));
11961
11997
  }
11962
11998
  async syncOnchainContract(contract, onchainProvider, network, pending, tipHeight, prefetched) {
11963
- chunkMQUATTIM_cjs.contractHandlers.get(contract.type).createScript(contract.params);
11999
+ chunkJYQXB7OH_cjs.contractHandlers.get(contract.type).createScript(contract.params);
11964
12000
  const coins = prefetched ?? await onchainProvider.getCoins(onchainAddressOf(contract, network));
11965
12001
  const stored = new Map(
11966
12002
  (await getVtxosForContract(this.config.walletRepository, contract)).map((v) => [
@@ -12058,8 +12094,8 @@ var ContractManager = class _ContractManager {
12058
12094
  const found = /* @__PURE__ */ new Map();
12059
12095
  if (!indexerProvider.getUtxos || rows.length === 0) return found;
12060
12096
  try {
12061
- for (let i = 0; i < rows.length; i += chunkOMPDPBT5_cjs.OUTPOINT_QUERY_CHUNK_SIZE) {
12062
- const outpoints = rows.slice(i, i + chunkOMPDPBT5_cjs.OUTPOINT_QUERY_CHUNK_SIZE).map(({ txid, vout }) => ({ txid, vout }));
12097
+ for (let i = 0; i < rows.length; i += chunkSOJDUKY6_cjs.OUTPOINT_QUERY_CHUNK_SIZE) {
12098
+ const outpoints = rows.slice(i, i + chunkSOJDUKY6_cjs.OUTPOINT_QUERY_CHUNK_SIZE).map(({ txid, vout }) => ({ txid, vout }));
12063
12099
  let pageIndex;
12064
12100
  let pages = 0;
12065
12101
  do {
@@ -12069,7 +12105,7 @@ var ContractManager = class _ContractManager {
12069
12105
  const { utxos, page } = await indexerProvider.getUtxos({
12070
12106
  outpoints,
12071
12107
  pageIndex,
12072
- pageSize: chunkOMPDPBT5_cjs.OUTPOINT_QUERY_CHUNK_SIZE
12108
+ pageSize: chunkSOJDUKY6_cjs.OUTPOINT_QUERY_CHUNK_SIZE
12073
12109
  });
12074
12110
  for (const utxo of utxos) found.set(vtxoOutpoint(utxo), utxo);
12075
12111
  const more = page && page.current < page.total && page.next > page.current;
@@ -12077,7 +12113,7 @@ var ContractManager = class _ContractManager {
12077
12113
  } while (pageIndex !== void 0);
12078
12114
  }
12079
12115
  } catch (e) {
12080
- if (e instanceof chunk3NALVGMJ_cjs.IndexerUtxosUnsupportedError) return found;
12116
+ if (e instanceof chunk4IDCSOP2_cjs.IndexerUtxosUnsupportedError) return found;
12081
12117
  console.warn("[contracts] arkd spend lookup failed; using the explorer", e);
12082
12118
  return void 0;
12083
12119
  }
@@ -12130,7 +12166,7 @@ var ContractManager = class _ContractManager {
12130
12166
  break;
12131
12167
  }
12132
12168
  } catch (err) {
12133
- if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
12169
+ if (!chunkSOJDUKY6_cjs.isRetryableProviderError(err)) throw err;
12134
12170
  this.markSyncDegraded(err);
12135
12171
  synced = false;
12136
12172
  }
@@ -12218,7 +12254,7 @@ var ContractManager = class _ContractManager {
12218
12254
  */
12219
12255
  async reconcilePendingFrontier(contracts) {
12220
12256
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
12221
- const vtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(
12257
+ const vtxos = await chunkSOJDUKY6_cjs.getAllNormalizedVtxos(
12222
12258
  this.config.indexerProvider,
12223
12259
  contracts.map((c) => c.script),
12224
12260
  { pendingOnly: true }
@@ -12293,7 +12329,7 @@ var ContractManager = class _ContractManager {
12293
12329
  }
12294
12330
  return result;
12295
12331
  }
12296
- async fetchContractVtxosBulk(contracts, pageSize = chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
12332
+ async fetchContractVtxosBulk(contracts, pageSize = chunkSOJDUKY6_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
12297
12333
  if (contracts.length === 0) {
12298
12334
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
12299
12335
  }
@@ -12309,7 +12345,7 @@ var ContractManager = class _ContractManager {
12309
12345
  before: syncWindow.before
12310
12346
  }
12311
12347
  } : {};
12312
- const vtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(
12348
+ const vtxos = await chunkSOJDUKY6_cjs.getAllNormalizedVtxos(
12313
12349
  this.config.indexerProvider,
12314
12350
  contracts.map((c) => c.script),
12315
12351
  { ...windowOpts, pageSize }
@@ -12416,7 +12452,7 @@ function parseLegacyExpiry(batchExpiry) {
12416
12452
  if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
12417
12453
  return {};
12418
12454
  }
12419
- if (batchExpiry >= chunkOMPDPBT5_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
12455
+ if (batchExpiry >= chunkSOJDUKY6_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
12420
12456
  return { expiresAtHeight: batchExpiry / 1e3 };
12421
12457
  }
12422
12458
  function legacyVtxoFacts(status) {
@@ -12654,7 +12690,7 @@ function backfillContractWatchState(store) {
12654
12690
  };
12655
12691
  readPage();
12656
12692
  }
12657
- var unspentFlag = (vtxo) => chunkOMPDPBT5_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
12693
+ var unspentFlag = (vtxo) => chunkSOJDUKY6_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
12658
12694
  function backfillVtxoIndexFields(transaction) {
12659
12695
  const store = transaction.objectStore(STORE_VTXOS);
12660
12696
  const pageSize = 1e3;
@@ -12685,7 +12721,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
12685
12721
  var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
12686
12722
  function normalizeOptions2(pathOrOptions) {
12687
12723
  const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
12688
- chunkOMPDPBT5_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
12724
+ chunkSOJDUKY6_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
12689
12725
  return {
12690
12726
  path: o.path,
12691
12727
  activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
@@ -12913,7 +12949,7 @@ var deserializeTapLeaf = (t) => {
12913
12949
  var deserializeVtxo = ({
12914
12950
  intentTapLeafScript,
12915
12951
  ...o
12916
- }) => chunkOMPDPBT5_cjs.normalizeVtxo({
12952
+ }) => chunkSOJDUKY6_cjs.normalizeVtxo({
12917
12953
  ...o,
12918
12954
  createdAt: new Date(o.createdAt),
12919
12955
  tapTree: base.hex.decode(o.tapTree),
@@ -13313,7 +13349,7 @@ var RestEmulatorProvider = class {
13313
13349
  serverUrl;
13314
13350
  async getInfo() {
13315
13351
  const url = `${this.serverUrl}/v1/info`;
13316
- const response = await chunkOMPDPBT5_cjs.baseFetch(url);
13352
+ const response = await chunkSOJDUKY6_cjs.baseFetch(url);
13317
13353
  if (!response.ok) {
13318
13354
  const errorText2 = await response.text();
13319
13355
  throw new Error(`Failed to get emulator info: ${errorText2}`);
@@ -13437,7 +13473,7 @@ function arkadeServiceUrl(service) {
13437
13473
  }
13438
13474
  async function resolveArkadeService(service, opts = {}) {
13439
13475
  const operatorUrl = arkadeServiceUrl(service);
13440
- const arkProvider = opts.arkProvider ?? new chunkOMPDPBT5_cjs.RestOperatorProvider(operatorUrl);
13476
+ const arkProvider = opts.arkProvider ?? new chunkSOJDUKY6_cjs.RestOperatorProvider(operatorUrl);
13441
13477
  const info = opts.info ?? await arkProvider.getInfo();
13442
13478
  if ("network" in service && service.network !== info.network) {
13443
13479
  throw new Error(
@@ -13456,7 +13492,7 @@ async function resolveArkadeService(service, opts = {}) {
13456
13492
  }
13457
13493
  return {
13458
13494
  arkProvider,
13459
- indexerProvider: new chunk3NALVGMJ_cjs.RestIndexerProvider(operatorUrl),
13495
+ indexerProvider: new chunk4IDCSOP2_cjs.RestIndexerProvider(operatorUrl),
13460
13496
  onchainProvider: new EsploraProvider(esploraUrl),
13461
13497
  emulator,
13462
13498
  info
@@ -13540,7 +13576,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
13540
13576
  */
13541
13577
  materializeDescriptorAt(index) {
13542
13578
  const descriptor = this.identity.descriptor;
13543
- const network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
13579
+ const network = chunkJYQXB7OH_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
13544
13580
  const expansion = descriptorsScure.expand({ descriptor, network, index });
13545
13581
  const keyInfo = expansion.expansionMap?.["@0"];
13546
13582
  if (!keyInfo?.keyExpression) {
@@ -13608,7 +13644,7 @@ function signingDescriptorIndex(descriptor) {
13608
13644
  }
13609
13645
  function newestWalletReceiveContract(contracts, serverPubKeyHex) {
13610
13646
  return contracts.filter(
13611
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkMQUATTIM_cjs.WALLET_RECEIVE_SOURCE
13647
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkJYQXB7OH_cjs.WALLET_RECEIVE_SOURCE
13612
13648
  ).sort((a, b) => {
13613
13649
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
13614
13650
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -13659,7 +13695,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
13659
13695
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
13660
13696
  if (!provider) return void 0;
13661
13697
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
13662
- const expectedContractType = setup.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? "delegate" : "default";
13698
+ const expectedContractType = setup.offchainTapscript instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script ? "delegate" : "default";
13663
13699
  const factoryOpts = {
13664
13700
  walletRepository: setup.walletRepository,
13665
13701
  contractRepository: setup.contractRepository,
@@ -13819,7 +13855,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
13819
13855
  };
13820
13856
  function deriveLeafPubkey(descriptor) {
13821
13857
  try {
13822
- return chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor);
13858
+ return chunkJYQXB7OH_cjs.deriveDescriptorLeafPubKey(descriptor);
13823
13859
  } catch (e) {
13824
13860
  throw new NonRangeableDescriptorError(
13825
13861
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -13839,11 +13875,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
13839
13875
  // Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
13840
13876
  // it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
13841
13877
  metadata: {
13842
- ...tagSource && { source: chunkMQUATTIM_cjs.WALLET_RECEIVE_SOURCE },
13878
+ ...tagSource && { source: chunkJYQXB7OH_cjs.WALLET_RECEIVE_SOURCE },
13843
13879
  signingDescriptor: descriptor
13844
13880
  }
13845
13881
  };
13846
- const params = tapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? {
13882
+ const params = tapscript instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script ? {
13847
13883
  ...base$1,
13848
13884
  type: "delegate",
13849
13885
  params: {
@@ -13864,10 +13900,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
13864
13900
  return { tapscript, params };
13865
13901
  }
13866
13902
  function rebuildTapscript(current, pubKey) {
13867
- if (current instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script) {
13868
- return new chunkMQUATTIM_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
13903
+ if (current instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script) {
13904
+ return new chunkJYQXB7OH_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
13869
13905
  }
13870
- return new chunkMQUATTIM_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
13906
+ return new chunkJYQXB7OH_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
13871
13907
  }
13872
13908
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
13873
13909
  const candidates = await collectContracts(contractRepository, {
@@ -13920,7 +13956,7 @@ async function resolvePrevTxs(txids, source, onchain) {
13920
13956
  try {
13921
13957
  const { txs } = await source.getVirtualTxs(wanted);
13922
13958
  for (const psbt of txs) {
13923
- const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
13959
+ const tx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
13924
13960
  resolved.set(tx.id, tx.toBytes());
13925
13961
  }
13926
13962
  } catch (err) {
@@ -13953,7 +13989,7 @@ async function resolvePrevTxs(txids, source, onchain) {
13953
13989
  async function attachPrevArkTxs(tx, txids, source, onchain) {
13954
13990
  const pending = [];
13955
13991
  for (let i = 0; i < tx.inputsLength; i++) {
13956
- if (chunkOMPDPBT5_cjs.getArkPsbtFields(tx, i, chunkOMPDPBT5_cjs.PrevArkTxField).length === 0) pending.push(i);
13992
+ if (chunkSOJDUKY6_cjs.getArkPsbtFields(tx, i, chunkSOJDUKY6_cjs.PrevArkTxField).length === 0) pending.push(i);
13957
13993
  }
13958
13994
  if (pending.length === 0) return;
13959
13995
  const resolved = await resolvePrevTxs(
@@ -13962,13 +13998,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
13962
13998
  onchain
13963
13999
  );
13964
14000
  for (const i of pending) {
13965
- chunkOMPDPBT5_cjs.setArkPsbtField(tx, i, chunkOMPDPBT5_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
14001
+ chunkSOJDUKY6_cjs.setArkPsbtField(tx, i, chunkSOJDUKY6_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
13966
14002
  }
13967
14003
  }
13968
14004
  async function attachPrevoutTxs(tx, source) {
13969
14005
  const pending = [];
13970
14006
  for (let i = 0; i < tx.inputsLength; i++) {
13971
- if (chunkOMPDPBT5_cjs.getArkPsbtFields(tx, i, chunkOMPDPBT5_cjs.PrevoutTxField).length > 0) continue;
14007
+ if (chunkSOJDUKY6_cjs.getArkPsbtFields(tx, i, chunkSOJDUKY6_cjs.PrevoutTxField).length > 0) continue;
13972
14008
  const input = tx.getInput(i);
13973
14009
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
13974
14010
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -13983,7 +14019,7 @@ async function attachPrevoutTxs(tx, source) {
13983
14019
  resolved.set(txids[i], result.value);
13984
14020
  }
13985
14021
  for (const { index, txid } of pending) {
13986
- chunkOMPDPBT5_cjs.setArkPsbtField(tx, index, chunkOMPDPBT5_cjs.PrevoutTxField, resolved.get(txid));
14022
+ chunkSOJDUKY6_cjs.setArkPsbtField(tx, index, chunkSOJDUKY6_cjs.PrevoutTxField, resolved.get(txid));
13987
14023
  }
13988
14024
  }
13989
14025
  async function withPrevTxs(coins, source, onchain) {
@@ -14024,7 +14060,7 @@ function computeOffchainBalance(vtxos, caps) {
14024
14060
  }
14025
14061
  };
14026
14062
  for (const vtxo of vtxos) {
14027
- if (chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) continue;
14063
+ if (chunkSOJDUKY6_cjs.isVtxoSpent(vtxo)) continue;
14028
14064
  addAssets(owned, vtxo);
14029
14065
  if (vtxo.isUnrolled) {
14030
14066
  unrolled += vtxo.value;
@@ -14034,11 +14070,11 @@ function computeOffchainBalance(vtxos, caps) {
14034
14070
  deprecatedSignerLocked += vtxo.value;
14035
14071
  continue;
14036
14072
  }
14037
- if (chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
14073
+ if (chunkSOJDUKY6_cjs.canRecoverOnchain(vtxo, now)) {
14038
14074
  recoverable += vtxo.value;
14039
14075
  continue;
14040
14076
  }
14041
- if (!chunkOMPDPBT5_cjs.canSpendOffchain(vtxo, now)) continue;
14077
+ if (!chunkSOJDUKY6_cjs.canSpendOffchain(vtxo, now)) continue;
14042
14078
  if (vtxo.isPreconfirmed) {
14043
14079
  preconfirmed += vtxo.value;
14044
14080
  } else {
@@ -14313,7 +14349,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
14313
14349
  if (!newest?.params.pubKey) return baseline;
14314
14350
  try {
14315
14351
  const pubKey = base.hex.decode(newest.params.pubKey);
14316
- return new chunkMQUATTIM_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
14352
+ return new chunkJYQXB7OH_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
14317
14353
  } catch (e) {
14318
14354
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
14319
14355
  return baseline;
@@ -14345,21 +14381,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
14345
14381
  if (vtxo.isUnrolled) {
14346
14382
  return !!f.withUnrolled;
14347
14383
  }
14348
- if (chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) {
14384
+ if (chunkSOJDUKY6_cjs.isVtxoSpent(vtxo)) {
14349
14385
  return false;
14350
14386
  }
14351
- if (!f.withRecoverable && chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
14387
+ if (!f.withRecoverable && chunkSOJDUKY6_cjs.canRecoverOnchain(vtxo, now)) {
14352
14388
  return false;
14353
14389
  }
14354
14390
  return true;
14355
14391
  });
14356
14392
  }
14357
14393
  async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
14358
- const candidates = inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin).map(chunkOMPDPBT5_cjs.normalizeVtxo).filter((v) => !v.isSwept);
14394
+ const candidates = inputs.filter(chunkSOJDUKY6_cjs.isVirtualCoin).map(chunkSOJDUKY6_cjs.normalizeVtxo).filter((v) => !v.isSwept);
14359
14395
  if (candidates.length === 0) return inputs;
14360
- const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkOMPDPBT5_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
14396
+ const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkSOJDUKY6_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
14361
14397
  const suspects = candidates.filter(
14362
- (v) => chunkOMPDPBT5_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
14398
+ (v) => chunkSOJDUKY6_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
14363
14399
  );
14364
14400
  if (suspects.length === 0) return inputs;
14365
14401
  let sweptNow;
@@ -14373,12 +14409,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
14373
14409
  );
14374
14410
  } catch (e) {
14375
14411
  const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
14376
- throw chunkOMPDPBT5_cjs.isRetryableProviderError(e) ? new chunkOMPDPBT5_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
14412
+ throw chunkSOJDUKY6_cjs.isRetryableProviderError(e) ? new chunkSOJDUKY6_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
14377
14413
  }
14378
14414
  if (sweptNow.size === 0) return inputs;
14379
14415
  return inputs.map((input) => {
14380
- if (!chunkOMPDPBT5_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
14381
- return { ...chunkOMPDPBT5_cjs.normalizeVtxo(input), isSwept: true };
14416
+ if (!chunkSOJDUKY6_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
14417
+ return { ...chunkSOJDUKY6_cjs.normalizeVtxo(input), isSwept: true };
14382
14418
  });
14383
14419
  }
14384
14420
  var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
@@ -14677,7 +14713,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14677
14713
  async getArkadeReader() {
14678
14714
  const indexer = this.indexerProvider;
14679
14715
  return {
14680
- getVtxos: (opts) => chunkOMPDPBT5_cjs.getNormalizedVtxos(indexer, opts),
14716
+ getVtxos: (opts) => chunkSOJDUKY6_cjs.getNormalizedVtxos(indexer, opts),
14681
14717
  getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
14682
14718
  };
14683
14719
  }
@@ -14727,7 +14763,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14727
14763
  "Pass either `service` or `operatorProvider`/`indexerProvider`/`onchainProvider`, not both"
14728
14764
  );
14729
14765
  }
14730
- const arkProvider = callerProvider || new chunkOMPDPBT5_cjs.RestOperatorProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
14766
+ const arkProvider = callerProvider || new chunkSOJDUKY6_cjs.RestOperatorProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
14731
14767
  let indexerProvider = config.indexerProvider;
14732
14768
  if (!indexerProvider && !config.service) {
14733
14769
  const derived = extractOperatorProviderUrl(arkProvider);
@@ -14736,11 +14772,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
14736
14772
  "indexerProvider is required when operatorProvider is provided without a discoverable serverUrl"
14737
14773
  );
14738
14774
  }
14739
- indexerProvider = new chunk3NALVGMJ_cjs.RestIndexerProvider(derived ?? chunkFLPWNMX3_cjs.DEFAULT_ARKADE_SERVER_URL);
14775
+ indexerProvider = new chunk4IDCSOP2_cjs.RestIndexerProvider(derived ?? chunkFLPWNMX3_cjs.DEFAULT_ARKADE_SERVER_URL);
14740
14776
  }
14741
14777
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
14742
14778
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
14743
- const delegatePubKeyPromise = config.delegateProvider?.getDelegateInfo().then((info2) => chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0);
14779
+ const delegatePubKeyPromise = config.delegateProvider?.getDelegateInfo().then((info2) => chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0);
14744
14780
  const {
14745
14781
  info,
14746
14782
  source: serverInfoSource,
@@ -14787,15 +14823,15 @@ var ReadonlyWallet = class _ReadonlyWallet {
14787
14823
  }
14788
14824
  }
14789
14825
  const boardingTimelock = config.boardingTimelock ?? toTimelock(info.boardingExitDelay);
14790
- const serverPubKey = chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
14826
+ const serverPubKey = chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
14791
14827
  const delegatePubKey = await delegatePubKeyPromise;
14792
14828
  const offchainOptions = {
14793
14829
  pubKey,
14794
14830
  serverPubKey,
14795
14831
  csvTimelock: exitTimelock
14796
14832
  };
14797
- const offchainTapscript = !delegatePubKey ? new chunkMQUATTIM_cjs.DefaultVtxo.Script(offchainOptions) : new chunkMQUATTIM_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
14798
- const boardingTapscript = chunkMQUATTIM_cjs.BoardingContractHandler.createScript({
14833
+ const offchainTapscript = !delegatePubKey ? new chunkJYQXB7OH_cjs.DefaultVtxo.Script(offchainOptions) : new chunkJYQXB7OH_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
14834
+ const boardingTapscript = chunkJYQXB7OH_cjs.BoardingContractHandler.createScript({
14799
14835
  pubKey: base.hex.encode(pubKey),
14800
14836
  serverPubKey: base.hex.encode(serverPubKey),
14801
14837
  csvTimelock: chunkFLPWNMX3_cjs.timelockToSequence(boardingTimelock).toString()
@@ -14964,7 +15000,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14964
15000
  if (!filter?.withUnrolled) {
14965
15001
  logExcludedVtxos(
14966
15002
  "getSpendableVtxos",
14967
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)),
15003
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkSOJDUKY6_cjs.isVtxoSpent(vtxo)),
14968
15004
  [() => UNROLLED_REASON]
14969
15005
  );
14970
15006
  }
@@ -15110,7 +15146,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15110
15146
  ]);
15111
15147
  const snapshot = fullSnapshot.filter(({ contract }) => !isRecoveryOnlyContract(contract));
15112
15148
  const allVtxos = snapshot.flatMap((_) => _.vtxos);
15113
- const resolveTxCreatedAt = (txids) => chunkOMPDPBT5_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
15149
+ const resolveTxCreatedAt = (txids) => chunkSOJDUKY6_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
15114
15150
  return buildTransactionHistory(
15115
15151
  allVtxos,
15116
15152
  boardingTxs,
@@ -15310,11 +15346,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
15310
15346
  const currentServerPubKey = this.boardingTapscript.options.serverPubKey;
15311
15347
  const currentServerSigner = toXOnlySignerHex(base.hex.encode(currentServerPubKey));
15312
15348
  const signers = /* @__PURE__ */ new Set([currentServerSigner, ...allowedSigners ?? []]);
15313
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
15349
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkJYQXB7OH_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
15314
15350
  const baselinePubkey = await this.identity.xOnlyPublicKey();
15315
15351
  for (const signer of signers) {
15316
15352
  add(
15317
- new chunkMQUATTIM_cjs.DefaultVtxo.Script({
15353
+ new chunkJYQXB7OH_cjs.DefaultVtxo.Script({
15318
15354
  pubKey: baselinePubkey,
15319
15355
  serverPubKey: base.hex.decode(signer),
15320
15356
  csvTimelock: boardingCsv
@@ -15335,7 +15371,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15335
15371
  continue;
15336
15372
  }
15337
15373
  add(
15338
- c.type === "default" ? chunkMQUATTIM_cjs.DefaultContractHandler.createScript(c.params) : chunkMQUATTIM_cjs.BoardingContractHandler.createScript(c.params)
15374
+ c.type === "default" ? chunkJYQXB7OH_cjs.DefaultContractHandler.createScript(c.params) : chunkJYQXB7OH_cjs.BoardingContractHandler.createScript(c.params)
15339
15375
  );
15340
15376
  } catch (e) {
15341
15377
  console.warn("Skipping malformed boarding contract", c.script, e);
@@ -15384,7 +15420,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15384
15420
  tapscripts.map(async (tapscript, i) => {
15385
15421
  const contract = contracts.get(scripts[i]);
15386
15422
  const spent = new Set(
15387
- contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(chunkOMPDPBT5_cjs.isVtxoSpent).map(vtxoOutpoint) : []
15423
+ contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(chunkSOJDUKY6_cjs.isVtxoSpent).map(vtxoOutpoint) : []
15388
15424
  );
15389
15425
  const utxos = fetched[i].filter((c) => !spent.has(vtxoOutpoint(c))).map((utxo) => extendCoinWithTapscript(tapscript, utxo));
15390
15426
  return {
@@ -15413,10 +15449,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
15413
15449
  timer = setTimeout(
15414
15450
  () => reject(
15415
15451
  new Error(
15416
- `Boarding address lookup timed out after ${chunkOMPDPBT5_cjs.READ_TIMEOUT_MS}ms`
15452
+ `Boarding address lookup timed out after ${chunkSOJDUKY6_cjs.READ_TIMEOUT_MS}ms`
15417
15453
  )
15418
15454
  ),
15419
- chunkOMPDPBT5_cjs.READ_TIMEOUT_MS
15455
+ chunkSOJDUKY6_cjs.READ_TIMEOUT_MS
15420
15456
  );
15421
15457
  })
15422
15458
  ]);
@@ -15602,7 +15638,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15602
15638
  /** Fetch Arkade transaction ids that are still pending final settlement. */
15603
15639
  async fetchPendingTxs() {
15604
15640
  const scripts = await this.getWalletScripts();
15605
- const vtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
15641
+ const vtxos = await chunkSOJDUKY6_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
15606
15642
  return vtxos.filter(
15607
15643
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
15608
15644
  ).map((_) => _.arkTxId);
@@ -15633,7 +15669,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15633
15669
  });
15634
15670
  for (const contract of contracts) {
15635
15671
  if (map.has(contract.script)) continue;
15636
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
15672
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
15637
15673
  if (handler) {
15638
15674
  const script = handler.createScript(contract.params);
15639
15675
  map.set(contract.script, script);
@@ -15752,7 +15788,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15752
15788
  });
15753
15789
  try {
15754
15790
  const baselinePubkey = await baselinePubkeyPromise;
15755
- const delegatePubKey = this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
15791
+ const delegatePubKey = this.offchainTapscript instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
15756
15792
  const baselineSigners = [
15757
15793
  this.offchainTapscript.options.serverPubKey,
15758
15794
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
@@ -15762,7 +15798,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15762
15798
  for (const serverPubKey of baselineSigners) {
15763
15799
  for (const csvTimelock of this.walletContractTimelocks) {
15764
15800
  const csvTimelockStr = chunkFLPWNMX3_cjs.timelockToSequence(csvTimelock).toString();
15765
- const defaultScript = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
15801
+ const defaultScript = new chunkJYQXB7OH_cjs.DefaultVtxo.Script({
15766
15802
  pubKey: baselinePubkey,
15767
15803
  serverPubKey,
15768
15804
  csvTimelock
@@ -15783,7 +15819,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
15783
15819
  });
15784
15820
  }
15785
15821
  if (delegatePubKey) {
15786
- const delegateScript = new chunkMQUATTIM_cjs.DelegateVtxo.Script({
15822
+ const delegateScript = new chunkJYQXB7OH_cjs.DelegateVtxo.Script({
15787
15823
  pubKey: baselinePubkey,
15788
15824
  serverPubKey,
15789
15825
  delegatePubKey,
@@ -15807,9 +15843,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
15807
15843
  }
15808
15844
  }
15809
15845
  }
15810
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
15846
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkJYQXB7OH_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
15811
15847
  for (const serverPubKey of baselineSigners) {
15812
- const baselineBoarding = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
15848
+ const baselineBoarding = new chunkJYQXB7OH_cjs.DefaultVtxo.Script({
15813
15849
  pubKey: baselinePubkey,
15814
15850
  serverPubKey,
15815
15851
  csvTimelock: boardingCsvTimelock
@@ -16026,7 +16062,7 @@ var Wallet2 = class extends ReadonlyWallet {
16026
16062
  serverPubKey: this.offchainTapscript.options.serverPubKey,
16027
16063
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
16028
16064
  csvTimelocks: this.walletContractTimelocks,
16029
- delegatePubKey: this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
16065
+ delegatePubKey: this.offchainTapscript instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
16030
16066
  };
16031
16067
  }
16032
16068
  _signerRouter;
@@ -16188,7 +16224,7 @@ var Wallet2 = class extends ReadonlyWallet {
16188
16224
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
16189
16225
  const persisted = row?.metadata?.signingDescriptor;
16190
16226
  if (typeof persisted === "string") return persisted;
16191
- return chunkMQUATTIM_cjs.identityDescriptor(this.identity);
16227
+ return chunkJYQXB7OH_cjs.identityDescriptor(this.identity);
16192
16228
  }
16193
16229
  /**
16194
16230
  * Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
@@ -16198,7 +16234,7 @@ var Wallet2 = class extends ReadonlyWallet {
16198
16234
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
16199
16235
  if (type === "boarding") {
16200
16236
  const built2 = this.buildBoardingContract(
16201
- chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor),
16237
+ chunkJYQXB7OH_cjs.deriveDescriptorLeafPubKey(descriptor),
16202
16238
  descriptor,
16203
16239
  tagSource
16204
16240
  );
@@ -16235,11 +16271,11 @@ var Wallet2 = class extends ReadonlyWallet {
16235
16271
  * (offchain analogue: {@link buildReceiveContract}).
16236
16272
  */
16237
16273
  buildBoardingContract(pubKey, descriptor, tagSource) {
16238
- const tapscript = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
16274
+ const tapscript = new chunkJYQXB7OH_cjs.DefaultVtxo.Script({
16239
16275
  ...this._boardingTapscript.options,
16240
16276
  pubKey
16241
16277
  });
16242
- const csvTimelock = tapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16278
+ const csvTimelock = tapscript.options.csvTimelock ?? chunkJYQXB7OH_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16243
16279
  return {
16244
16280
  tapscript,
16245
16281
  params: {
@@ -16253,7 +16289,7 @@ var Wallet2 = class extends ReadonlyWallet {
16253
16289
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
16254
16290
  state: "active",
16255
16291
  metadata: {
16256
- ...tagSource && { source: chunkMQUATTIM_cjs.WALLET_RECEIVE_SOURCE },
16292
+ ...tagSource && { source: chunkJYQXB7OH_cjs.WALLET_RECEIVE_SOURCE },
16257
16293
  signingDescriptor: descriptor
16258
16294
  }
16259
16295
  }
@@ -16275,7 +16311,7 @@ var Wallet2 = class extends ReadonlyWallet {
16275
16311
  if (this._hdProvider) {
16276
16312
  return (await this.getContractManager()).getNextSigningDescriptor();
16277
16313
  }
16278
- return chunkMQUATTIM_cjs.identityDescriptor(this.identity);
16314
+ return chunkJYQXB7OH_cjs.identityDescriptor(this.identity);
16279
16315
  }
16280
16316
  /**
16281
16317
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -16351,7 +16387,7 @@ var Wallet2 = class extends ReadonlyWallet {
16351
16387
  * the stable public API.
16352
16388
  */
16353
16389
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
16354
- const xonly = chunkJFJNB7ZH_cjs.toXOnly(newServerPubKey, "ark signer key");
16390
+ const xonly = chunk5PWL7WOT_cjs.toXOnly(newServerPubKey, "ark signer key");
16355
16391
  const newServerUnrollScript = assertValidServerUnrollScript(
16356
16392
  checkpointTapscript,
16357
16393
  this.network,
@@ -16381,21 +16417,21 @@ var Wallet2 = class extends ReadonlyWallet {
16381
16417
  ]);
16382
16418
  const [currentOffchainRow] = offchainRows2;
16383
16419
  const [currentBoardingRow] = boardingRows;
16384
- const newOffchain = this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? new chunkMQUATTIM_cjs.DelegateVtxo.Script({
16420
+ const newOffchain = this.offchainTapscript instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script ? new chunkJYQXB7OH_cjs.DelegateVtxo.Script({
16385
16421
  ...this.offchainTapscript.options,
16386
16422
  serverPubKey: xonly
16387
- }) : new chunkMQUATTIM_cjs.DefaultVtxo.Script({
16423
+ }) : new chunkJYQXB7OH_cjs.DefaultVtxo.Script({
16388
16424
  ...this.offchainTapscript.options,
16389
16425
  serverPubKey: xonly
16390
16426
  });
16391
- const newBoarding = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
16427
+ const newBoarding = new chunkJYQXB7OH_cjs.DefaultVtxo.Script({
16392
16428
  ...this._boardingTapscript.options,
16393
16429
  serverPubKey: xonly
16394
16430
  });
16395
16431
  const offchainCsv = chunkFLPWNMX3_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
16396
16432
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
16397
16433
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
16398
- if (newOffchain instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script) {
16434
+ if (newOffchain instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script) {
16399
16435
  await manager.createContract({
16400
16436
  type: "delegate",
16401
16437
  params: {
@@ -16423,7 +16459,7 @@ var Wallet2 = class extends ReadonlyWallet {
16423
16459
  metadata: currentOffchainRow?.metadata
16424
16460
  });
16425
16461
  }
16426
- const boardingCsv = newBoarding.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16462
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkJYQXB7OH_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
16427
16463
  await manager.createContract({
16428
16464
  type: "boarding",
16429
16465
  params: {
@@ -16457,14 +16493,14 @@ var Wallet2 = class extends ReadonlyWallet {
16457
16493
  _restoreInFlight;
16458
16494
  _addPendingSpends(inputs) {
16459
16495
  for (const input of inputs) {
16460
- if (chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
16496
+ if (chunkSOJDUKY6_cjs.isVirtualCoin(input)) {
16461
16497
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
16462
16498
  }
16463
16499
  }
16464
16500
  }
16465
16501
  _removePendingSpends(inputs) {
16466
16502
  for (const input of inputs) {
16467
- if (chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
16503
+ if (chunkSOJDUKY6_cjs.isVirtualCoin(input)) {
16468
16504
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
16469
16505
  }
16470
16506
  }
@@ -16528,7 +16564,7 @@ var Wallet2 = class extends ReadonlyWallet {
16528
16564
  if (clashing.length > 0) throw new VtxoReservedError(clashing, "in-flight");
16529
16565
  }
16530
16566
  _assertNotHeld(inputs) {
16531
- const held = coinKeys(inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin)).filter(
16567
+ const held = coinKeys(inputs.filter(chunkSOJDUKY6_cjs.isVirtualCoin)).filter(
16532
16568
  (key) => this._heldOutpoints.has(key)
16533
16569
  );
16534
16570
  if (held.length > 0) throw new VtxoReservedError(held, "held");
@@ -16567,14 +16603,14 @@ var Wallet2 = class extends ReadonlyWallet {
16567
16603
  const hd = provider !== void 0;
16568
16604
  const [manager, staticDescriptor, arkInfo] = await Promise.all([
16569
16605
  this.getContractManager(),
16570
- hd ? void 0 : chunkMQUATTIM_cjs.identityDescriptor(this.identity),
16606
+ hd ? void 0 : chunkJYQXB7OH_cjs.identityDescriptor(this.identity),
16571
16607
  this.arkProvider.getInfo()
16572
16608
  ]);
16573
16609
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
16574
- const delegatePubKey = this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
16575
- const currentSignerPubKey = chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
16610
+ const delegatePubKey = this.offchainTapscript instanceof chunkJYQXB7OH_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
16611
+ const currentSignerPubKey = chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
16576
16612
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
16577
- (s) => chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
16613
+ (s) => chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
16578
16614
  );
16579
16615
  const deps = {
16580
16616
  indexerProvider: this.indexerProvider,
@@ -16586,7 +16622,7 @@ var Wallet2 = class extends ReadonlyWallet {
16586
16622
  deprecatedSignerPubKeys,
16587
16623
  csvTimelocks: this.walletContractTimelocks,
16588
16624
  // Boarding-exit CSV, distinct from the unilateral-exit matrix.
16589
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
16625
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkJYQXB7OH_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
16590
16626
  delegatePubKey
16591
16627
  };
16592
16628
  const result = await manager.scanContracts({
@@ -16708,7 +16744,7 @@ var Wallet2 = class extends ReadonlyWallet {
16708
16744
  throw new Error("Invalid configured public key");
16709
16745
  }
16710
16746
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
16711
- const forfeitPubkey = chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
16747
+ const forfeitPubkey = chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
16712
16748
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
16713
16749
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
16714
16750
  const serverUnrollScript = assertValidServerUnrollScript(
@@ -16919,7 +16955,7 @@ var Wallet2 = class extends ReadonlyWallet {
16919
16955
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
16920
16956
  break;
16921
16957
  }
16922
- const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo));
16958
+ const inputFee = estimator.evalOffchainInput(chunkSOJDUKY6_cjs.toOffchainInputFeeParams(vtxo));
16923
16959
  if (inputFee.satoshis >= vtxo.value) {
16924
16960
  continue;
16925
16961
  }
@@ -17043,11 +17079,11 @@ var Wallet2 = class extends ReadonlyWallet {
17043
17079
  ]);
17044
17080
  let intentTxId;
17045
17081
  try {
17046
- intentTxId = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
17082
+ intentTxId = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
17047
17083
  } catch {
17048
17084
  intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
17049
17085
  }
17050
- const settleInputVtxos = params.inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin);
17086
+ const settleInputVtxos = params.inputs.filter(chunkSOJDUKY6_cjs.isVirtualCoin);
17051
17087
  const contractManager = await this.getContractManager();
17052
17088
  await contractManager.assertAnnotatable(settleInputVtxos);
17053
17089
  await contractManager.assertSpendableNow?.(
@@ -17056,7 +17092,7 @@ var Wallet2 = class extends ReadonlyWallet {
17056
17092
  );
17057
17093
  if (picked) this._assertNotHeld(params.inputs);
17058
17094
  this._addPendingSpends(params.inputs);
17059
- const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkOMPDPBT5_cjs.isVirtualCoin(i))) : [];
17095
+ const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkSOJDUKY6_cjs.isVirtualCoin(i))) : [];
17060
17096
  for (const key of boardingKeys) this._pendingSpendOutpoints.add(key);
17061
17097
  const settlingKeys = params.inputs.map((i) => `${i.txid}:${i.vout}`);
17062
17098
  for (const key of settlingKeys) this._settlingOutpoints.add(key);
@@ -17166,7 +17202,7 @@ var Wallet2 = class extends ReadonlyWallet {
17166
17202
  async maybeRotateBoardingAfterBoard(inputs) {
17167
17203
  if (!this._descriptorProvider) return;
17168
17204
  const consumedBoarding = inputs.some(
17169
- (input) => typeof input !== "string" && !chunkOMPDPBT5_cjs.isVirtualCoin(input)
17205
+ (input) => typeof input !== "string" && !chunkSOJDUKY6_cjs.isVirtualCoin(input)
17170
17206
  );
17171
17207
  if (!consumedBoarding) return;
17172
17208
  try {
@@ -17177,7 +17213,7 @@ var Wallet2 = class extends ReadonlyWallet {
17177
17213
  }
17178
17214
  async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
17179
17215
  const signedForfeits = [];
17180
- let settlementPsbt = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
17216
+ let settlementPsbt = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
17181
17217
  assertFinalCommitmentMatchesValidated(
17182
17218
  settlementPsbt,
17183
17219
  validatedCommitmentTxid,
@@ -17190,7 +17226,7 @@ var Wallet2 = class extends ReadonlyWallet {
17190
17226
  let connectorIndex = 0;
17191
17227
  const connectorsLeaves = connectorsGraph?.leaves() || [];
17192
17228
  for (const input of inputs) {
17193
- if (!chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
17229
+ if (!chunkSOJDUKY6_cjs.isVirtualCoin(input)) {
17194
17230
  let matched = false;
17195
17231
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
17196
17232
  const settlementInput = settlementPsbt.getInput(i);
@@ -17228,7 +17264,7 @@ var Wallet2 = class extends ReadonlyWallet {
17228
17264
  }
17229
17265
  continue;
17230
17266
  }
17231
- if (!chunkOMPDPBT5_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
17267
+ if (!chunkSOJDUKY6_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
17232
17268
  continue;
17233
17269
  }
17234
17270
  if (connectorsLeaves.length === 0) {
@@ -17348,14 +17384,14 @@ var Wallet2 = class extends ReadonlyWallet {
17348
17384
  throw new Error("Sweep tap tree root not set");
17349
17385
  }
17350
17386
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
17351
- (k) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
17387
+ (k) => base.hex.encode(chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
17352
17388
  );
17353
17389
  const signerPublicKey = await session.getPublicKey();
17354
- const xonlySignerPublicKey = chunkJFJNB7ZH_cjs.toXOnly(signerPublicKey, "signer key");
17390
+ const xonlySignerPublicKey = chunk5PWL7WOT_cjs.toXOnly(signerPublicKey, "signer key");
17355
17391
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
17356
17392
  return { skip: true };
17357
17393
  }
17358
- const commitmentTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(
17394
+ const commitmentTx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(
17359
17395
  base.base64.decode(event.unsignedCommitmentTx)
17360
17396
  );
17361
17397
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
@@ -17437,9 +17473,9 @@ var Wallet2 = class extends ReadonlyWallet {
17437
17473
  ...existing ?? {},
17438
17474
  proofTxId: intentTxId,
17439
17475
  registerProof: intent.proof,
17440
- registerProofMessage: chunkOMPDPBT5_cjs.Proof.encodeMessage(intent.message),
17476
+ registerProofMessage: chunkSOJDUKY6_cjs.Proof.encodeMessage(intent.message),
17441
17477
  deleteProof: deleteIntent.proof,
17442
- deleteProofMessage: chunkOMPDPBT5_cjs.Proof.encodeMessage(deleteIntent.message),
17478
+ deleteProofMessage: chunkSOJDUKY6_cjs.Proof.encodeMessage(deleteIntent.message),
17443
17479
  proofInputs: inputs.map((i) => ({
17444
17480
  txid: i.txid,
17445
17481
  vout: i.vout
@@ -17470,7 +17506,7 @@ var Wallet2 = class extends ReadonlyWallet {
17470
17506
  }
17471
17507
  /** @see IWallet.cosignOnchainTx */
17472
17508
  async cosignOnchainTx(psbt) {
17473
- const tx = typeof psbt === "string" ? chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)) : psbt;
17509
+ const tx = typeof psbt === "string" ? chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)) : psbt;
17474
17510
  return this._withTxLock(async () => {
17475
17511
  await (await this.getContractManager()).syncOnchain();
17476
17512
  return this._cosignOnchainTxImpl(tx);
@@ -17535,7 +17571,7 @@ var Wallet2 = class extends ReadonlyWallet {
17535
17571
  if (reasons.length > 0) throw new OnchainCosignPreflightError(reasons.join("; "));
17536
17572
  }
17537
17573
  const feeRate = await this.onchainProvider.getFeeRate() ?? 1;
17538
- const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
17574
+ const tx = new chunkSOJDUKY6_cjs.Transaction({ version: 2 });
17539
17575
  if (sweepTo) {
17540
17576
  const swept = candidates.slice(0, MAX_COSIGN_INPUTS);
17541
17577
  for (const { coin } of swept) {
@@ -17596,7 +17632,7 @@ var Wallet2 = class extends ReadonlyWallet {
17596
17632
  continue;
17597
17633
  }
17598
17634
  const { coin, contract, script } = mine;
17599
- const path = chunkMQUATTIM_cjs.contractHandlers.get(contract.type).selectPath(script, contract, {
17635
+ const path = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type).selectPath(script, contract, {
17600
17636
  collaborative: true,
17601
17637
  currentTime: Date.now(),
17602
17638
  blockHeight: tip.height,
@@ -17646,7 +17682,7 @@ var Wallet2 = class extends ReadonlyWallet {
17646
17682
  onchainProvider: this.onchainProvider
17647
17683
  });
17648
17684
  } catch (e) {
17649
- if (e instanceof chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError || isCosignRejectedAfterSigning(e)) {
17685
+ if (e instanceof chunkSOJDUKY6_cjs.OnchainCosignAmbiguousError || isCosignRejectedAfterSigning(e)) {
17650
17686
  await markPending(signed.id);
17651
17687
  }
17652
17688
  throw e;
@@ -17666,7 +17702,7 @@ var Wallet2 = class extends ReadonlyWallet {
17666
17702
  this.lockedOutpoints(),
17667
17703
  this.onchainCoins(manager)
17668
17704
  ]);
17669
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
17705
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkJYQXB7OH_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
17670
17706
  return coins.filter(
17671
17707
  ({ coin, contract }) => !locked.has(vtxoOutpoint(coin)) && needsOnchainSweep(coin, contract, boardingCsv, tip, this._cosignMarginBlocks)
17672
17708
  ).slice(0, MAX_COSIGN_INPUTS).map(({ coin }) => ({ txid: coin.txid, vout: coin.vout }));
@@ -17678,8 +17714,8 @@ var Wallet2 = class extends ReadonlyWallet {
17678
17714
  unspentOnly: true
17679
17715
  });
17680
17716
  return snapshot.flatMap(({ contract, vtxos }) => {
17681
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
17682
- const coins = vtxos.filter((v) => v.isUnrolled && !chunkOMPDPBT5_cjs.isVtxoSpent(v));
17717
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
17718
+ const coins = vtxos.filter((v) => v.isUnrolled && !chunkSOJDUKY6_cjs.isVtxoSpent(v));
17683
17719
  if (!handler || coins.length === 0) return [];
17684
17720
  const script = handler.createScript(contract.params);
17685
17721
  return coins.map((coin) => ({ coin, contract, script }));
@@ -17689,7 +17725,7 @@ var Wallet2 = class extends ReadonlyWallet {
17689
17725
  try {
17690
17726
  return await this.arkProvider.registerIntent(intent);
17691
17727
  } catch (error) {
17692
- if (error instanceof chunkOMPDPBT5_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
17728
+ if (error instanceof chunkSOJDUKY6_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
17693
17729
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
17694
17730
  await this.arkProvider.deleteIntent(deleteIntent);
17695
17731
  return this.arkProvider.registerIntent(intent);
@@ -17705,7 +17741,7 @@ var Wallet2 = class extends ReadonlyWallet {
17705
17741
  expire_at: 0,
17706
17742
  cosigners_public_keys: cosignerPubKeys
17707
17743
  };
17708
- const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, outputs);
17744
+ const proof = chunkSOJDUKY6_cjs.Proof.create(message, coins, outputs);
17709
17745
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
17710
17746
  return {
17711
17747
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -17717,7 +17753,7 @@ var Wallet2 = class extends ReadonlyWallet {
17717
17753
  type: "delete",
17718
17754
  expire_at: 0
17719
17755
  };
17720
- const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, []);
17756
+ const proof = chunkSOJDUKY6_cjs.Proof.create(message, coins, []);
17721
17757
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
17722
17758
  return {
17723
17759
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -17729,7 +17765,7 @@ var Wallet2 = class extends ReadonlyWallet {
17729
17765
  type: "get-pending-tx",
17730
17766
  expire_at: 0
17731
17767
  };
17732
- const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, []);
17768
+ const proof = chunkSOJDUKY6_cjs.Proof.create(message, coins, []);
17733
17769
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
17734
17770
  return {
17735
17771
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -17750,7 +17786,7 @@ var Wallet2 = class extends ReadonlyWallet {
17750
17786
  if (!vtxos || vtxos.length === 0) {
17751
17787
  const scriptMap = await this.getScriptMap();
17752
17788
  const allExtended = [];
17753
- const fetchedVtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(this.indexerProvider, [
17789
+ const fetchedVtxos = await chunkSOJDUKY6_cjs.getAllNormalizedVtxos(this.indexerProvider, [
17754
17790
  ...scriptMap.keys()
17755
17791
  ]);
17756
17792
  for (const vtxo of fetchedVtxos) {
@@ -17793,8 +17829,8 @@ var Wallet2 = class extends ReadonlyWallet {
17793
17829
  batchPending.push(pendingTx.arkTxid);
17794
17830
  try {
17795
17831
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
17796
- const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(c));
17797
- chunkOMPDPBT5_cjs.assertAllowedSighashTypes(tx);
17832
+ const tx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(c));
17833
+ chunkSOJDUKY6_cjs.assertAllowedSighashTypes(tx);
17798
17834
  return tx;
17799
17835
  });
17800
17836
  assertCheckpointsMatchInputs(
@@ -18210,7 +18246,7 @@ var Wallet2 = class extends ReadonlyWallet {
18210
18246
  const recoverable = [];
18211
18247
  const unclaimed = [];
18212
18248
  for (const vtxo of vtxos) {
18213
- if (chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) {
18249
+ if (chunkSOJDUKY6_cjs.isVtxoSpent(vtxo)) {
18214
18250
  unclaimed.push(cashReport(vtxo, "already-spent"));
18215
18251
  } else if (vtxo.isUnrolled) {
18216
18252
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -18232,7 +18268,7 @@ var Wallet2 = class extends ReadonlyWallet {
18232
18268
  const all = [];
18233
18269
  const seen = /* @__PURE__ */ new Set();
18234
18270
  for (let pageIndex = 0; ; pageIndex++) {
18235
- const { vtxos, page } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(this.indexerProvider, {
18271
+ const { vtxos, page } = await chunkSOJDUKY6_cjs.getNormalizedVtxos(this.indexerProvider, {
18236
18272
  scripts,
18237
18273
  pageIndex,
18238
18274
  pageSize
@@ -18275,7 +18311,7 @@ var Wallet2 = class extends ReadonlyWallet {
18275
18311
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_PROOF) {
18276
18312
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_PROOF);
18277
18313
  const message = { type: "get-pending-tx", expire_at: 0 };
18278
- const proof = chunkOMPDPBT5_cjs.Proof.create(message, batch, []);
18314
+ const proof = chunkSOJDUKY6_cjs.Proof.create(message, batch, []);
18279
18315
  const signedProof = await identity.sign(
18280
18316
  proof,
18281
18317
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -18296,8 +18332,8 @@ var Wallet2 = class extends ReadonlyWallet {
18296
18332
  for (const pendingTx of pendingTxs) {
18297
18333
  try {
18298
18334
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
18299
- const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
18300
- chunkOMPDPBT5_cjs.assertAllowedSighashTypes(tx);
18335
+ const tx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
18336
+ chunkSOJDUKY6_cjs.assertAllowedSighashTypes(tx);
18301
18337
  return tx;
18302
18338
  });
18303
18339
  assertCheckpointsMatchInputs(
@@ -18338,7 +18374,7 @@ var Wallet2 = class extends ReadonlyWallet {
18338
18374
  }
18339
18375
  /** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
18340
18376
  arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
18341
- const arkTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
18377
+ const arkTx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
18342
18378
  let total = 0;
18343
18379
  for (let i = 0; i < arkTx.outputsLength; i++) {
18344
18380
  const output = arkTx.getOutput(i);
@@ -18397,7 +18433,7 @@ var Wallet2 = class extends ReadonlyWallet {
18397
18433
  throw new Error("send({ maxChangeFee }): expected a non-negative safe integer");
18398
18434
  }
18399
18435
  if (selectedVtxos) {
18400
- if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
18436
+ if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo);
18401
18437
  if (inputExpiryFloor && selectedVtxos.some((coin) => !meetsInputExpiryFloor(coin, inputExpiryFloor))) {
18402
18438
  throw new Error("send({ selectedVtxos }): input expiry floor not met");
18403
18439
  }
@@ -18724,10 +18760,10 @@ var Wallet2 = class extends ReadonlyWallet {
18724
18760
  const serverPubKey = this.arkServerPublicKey;
18725
18761
  const serverUnrollScript = this.serverUnrollScript;
18726
18762
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
18727
- const normalizedInputs = inputs.map(chunkOMPDPBT5_cjs.normalizeVtxo);
18728
- const at = now ?? await chunkOMPDPBT5_cjs.resolveTimeHeight(this.onchainProvider);
18763
+ const normalizedInputs = inputs.map(chunkSOJDUKY6_cjs.normalizeVtxo);
18764
+ const at = now ?? await chunkSOJDUKY6_cjs.resolveTimeHeight(this.onchainProvider);
18729
18765
  for (const input of normalizedInputs) {
18730
- if (!chunkOMPDPBT5_cjs.canSpendOffchain(input, at)) {
18766
+ if (!chunkSOJDUKY6_cjs.canSpendOffchain(input, at)) {
18731
18767
  throw new Error(
18732
18768
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
18733
18769
  );
@@ -18921,7 +18957,7 @@ var Wallet2 = class extends ReadonlyWallet {
18921
18957
  }
18922
18958
  const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
18923
18959
  for (const encoded of signedCheckpointTxs) {
18924
- const checkpoint = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
18960
+ const checkpoint = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
18925
18961
  for (let i = 0; i < checkpoint.inputsLength; i++) {
18926
18962
  const input = checkpoint.getInput(i);
18927
18963
  if (!input.txid) continue;
@@ -19038,12 +19074,12 @@ var Wallet2 = class extends ReadonlyWallet {
19038
19074
  const inputArkTxIds = /* @__PURE__ */ new Set();
19039
19075
  const boardingScripts = /* @__PURE__ */ new Set();
19040
19076
  const boardingOutpoints = [];
19041
- const vtxoInputs = inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin);
19077
+ const vtxoInputs = inputs.filter(chunkSOJDUKY6_cjs.isVirtualCoin);
19042
19078
  const cm = await this.getContractManager();
19043
19079
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
19044
19080
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
19045
19081
  for (const input of inputs) {
19046
- if (chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
19082
+ if (chunkSOJDUKY6_cjs.isVirtualCoin(input)) {
19047
19083
  const outpoint = `${input.txid}:${input.vout}`;
19048
19084
  const vtxo = annotatedByKey.get(outpoint);
19049
19085
  if (!vtxo) {
@@ -19126,7 +19162,7 @@ function bySelectionOrder(a, b) {
19126
19162
  return b.value - a.value;
19127
19163
  }
19128
19164
  function selectVirtualCoins(coins, targetAmount) {
19129
- const sortedCoins = coins.map(chunkOMPDPBT5_cjs.normalizeVtxo).sort(bySelectionOrder);
19165
+ const sortedCoins = coins.map(chunkSOJDUKY6_cjs.normalizeVtxo).sort(bySelectionOrder);
19130
19166
  const selectedCoins = [];
19131
19167
  let selectedAmount = 0;
19132
19168
  for (const coin of sortedCoins) {
@@ -19254,7 +19290,7 @@ function assertTimeoutMap(name, timeouts) {
19254
19290
  if (value === void 0) {
19255
19291
  throw new Error(`${name}.${key} must be a non-negative safe integer`);
19256
19292
  }
19257
- chunkOMPDPBT5_cjs.assertTimerMs(`${name}.${key}`, value);
19293
+ chunkSOJDUKY6_cjs.assertTimerMs(`${name}.${key}`, value);
19258
19294
  }
19259
19295
  }
19260
19296
  var MessageBus = class {
@@ -19271,8 +19307,8 @@ var MessageBus = class {
19271
19307
  }) {
19272
19308
  this.walletRepository = walletRepository;
19273
19309
  this.contractRepository = contractRepository;
19274
- chunkOMPDPBT5_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
19275
- chunkOMPDPBT5_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
19310
+ chunkSOJDUKY6_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
19311
+ chunkSOJDUKY6_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
19276
19312
  assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
19277
19313
  this.intentRepository = intentRepository;
19278
19314
  this.onchainProvider = onchainProvider;
@@ -19528,14 +19564,14 @@ var MessageBus = class {
19528
19564
  this.initialized = true;
19529
19565
  }
19530
19566
  async buildServices(config) {
19531
- const arkProvider = new chunkOMPDPBT5_cjs.RestOperatorProvider(config.arkServer.url);
19567
+ const arkProvider = new chunkSOJDUKY6_cjs.RestOperatorProvider(config.arkServer.url);
19532
19568
  const storage = {
19533
19569
  walletRepository: this.walletRepository,
19534
19570
  contractRepository: this.contractRepository,
19535
19571
  ...this.intentRepository && { intentRepository: this.intentRepository }
19536
19572
  };
19537
19573
  const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
19538
- const indexerProvider = new chunk3NALVGMJ_cjs.RestIndexerProvider(config.arkServer.url);
19574
+ const indexerProvider = new chunk4IDCSOP2_cjs.RestIndexerProvider(config.arkServer.url);
19539
19575
  const serialized = normalizeSerializedIdentity(config.wallet);
19540
19576
  if (isSigningSerialized(serialized)) {
19541
19577
  const identity2 = hydrateIdentity(serialized);
@@ -19918,7 +19954,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
19918
19954
  const inputs = [];
19919
19955
  let subtotal = 0n;
19920
19956
  for (const vtxo of vtxos) {
19921
- const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo));
19957
+ const inputFee = estimator.evalOffchainInput(chunkSOJDUKY6_cjs.toOffchainInputFeeParams(vtxo));
19922
19958
  if (inputFee.satoshis >= vtxo.value) {
19923
19959
  if (named) {
19924
19960
  throw new Error(
@@ -20183,7 +20219,7 @@ var Ramps = class {
20183
20219
  const ordered = [...candidates].sort(bySelectionOrder);
20184
20220
  let covered = 0n;
20185
20221
  for (let i = 0; i < ordered.length && i < MAX_VTXOS_PER_SETTLEMENT; i++) {
20186
- const fee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
20222
+ const fee = estimator.evalOffchainInput(chunkSOJDUKY6_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
20187
20223
  covered += BigInt(ordered[i].value) - BigInt(fee);
20188
20224
  if (covered < needed) continue;
20189
20225
  try {
@@ -20241,11 +20277,11 @@ async function readArkadeCash(token, indexer, info, onchain) {
20241
20277
  if (signer.status === "UNKNOWN_SIGNER") {
20242
20278
  throw new Error("ArkadeCash belongs to another operator");
20243
20279
  }
20244
- const coins = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(indexer, [arkadeCashId(cash)]);
20280
+ const coins = await chunkSOJDUKY6_cjs.getAllNormalizedVtxos(indexer, [arkadeCashId(cash)]);
20245
20281
  return classifyArkadeCash(
20246
20282
  coins,
20247
20283
  info.dust,
20248
- await chunkOMPDPBT5_cjs.resolveTimeHeight(onchain),
20284
+ await chunkSOJDUKY6_cjs.resolveTimeHeight(onchain),
20249
20285
  signer.status === "EXPIRED"
20250
20286
  );
20251
20287
  }
@@ -20253,16 +20289,16 @@ function classifyArkadeCash(coins, dust, now, awaitingSweep = false) {
20253
20289
  const eligible = coins.filter(
20254
20290
  (coin) => coin.value >= Number(dust) && !(coin.assets && coin.assets.length > 0)
20255
20291
  );
20256
- const hasSpent = eligible.some(chunkOMPDPBT5_cjs.isVtxoSpent);
20257
- const hasLive = eligible.some((coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && !coin.isUnrolled);
20258
- const hasExit = eligible.some((coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && coin.isUnrolled);
20259
- const recoverable = eligible.some((coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && coin.isSwept);
20292
+ const hasSpent = eligible.some(chunkSOJDUKY6_cjs.isVtxoSpent);
20293
+ const hasLive = eligible.some((coin) => !chunkSOJDUKY6_cjs.isVtxoSpent(coin) && !coin.isUnrolled);
20294
+ const hasExit = eligible.some((coin) => !chunkSOJDUKY6_cjs.isVtxoSpent(coin) && coin.isUnrolled);
20295
+ const recoverable = eligible.some((coin) => !chunkSOJDUKY6_cjs.isVtxoSpent(coin) && coin.isSwept);
20260
20296
  const elapsedBatch = eligible.some(
20261
- (coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && !coin.isSwept && chunkOMPDPBT5_cjs.isPastExpiry(coin, now)
20297
+ (coin) => !chunkSOJDUKY6_cjs.isVtxoSpent(coin) && !coin.isSwept && chunkSOJDUKY6_cjs.isPastExpiry(coin, now)
20262
20298
  );
20263
20299
  return {
20264
20300
  status: eligible.length === 0 ? "unissued" : hasExit && !hasLive ? "exited" : hasSpent && !hasLive ? "claimed" : recoverable ? "recovering" : elapsedBatch || awaitingSweep ? "expired" : "available",
20265
- amount: eligible.reduce((sum, coin) => sum + (chunkOMPDPBT5_cjs.isVtxoSpent(coin) ? 0 : coin.value), 0),
20301
+ amount: eligible.reduce((sum, coin) => sum + (chunkSOJDUKY6_cjs.isVtxoSpent(coin) ? 0 : coin.value), 0),
20266
20302
  issues: groupByTxid(eligible),
20267
20303
  claims: groupByTxid(
20268
20304
  // `||`: the indexer reports an unset id as an empty string, not as absent.
@@ -21323,7 +21359,7 @@ var WalletMessageHandler = class {
21323
21359
  this.lazyBoardingInit = payload.lazyBoarding ?? false;
21324
21360
  this.boardingEpoch++;
21325
21361
  this.boardingLoaded = false;
21326
- this.indexerProvider = new chunk3NALVGMJ_cjs.RestIndexerProvider(arkServerUrl);
21362
+ this.indexerProvider = new chunk4IDCSOP2_cjs.RestIndexerProvider(arkServerUrl);
21327
21363
  await this.onWalletInitialized();
21328
21364
  }
21329
21365
  /** @see RequestInitWallet.payload.lazyBoarding */
@@ -21767,7 +21803,7 @@ var WalletMessageHandler = class {
21767
21803
  this.readonlyWallet.getBoardingTxs()
21768
21804
  ]);
21769
21805
  const indexerProvider = this.indexerProvider;
21770
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunkOMPDPBT5_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
21806
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunkSOJDUKY6_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
21771
21807
  return buildTransactionHistory(
21772
21808
  vtxos,
21773
21809
  boardingTxs,
@@ -21836,9 +21872,9 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
21836
21872
  // budget so the worker's snapshot fallback stays reachable before this
21837
21873
  // page deadline fires — lowering it below the budget would time the page
21838
21874
  // out while the worker is still seconds from answering from cache.
21839
- GET_OPERATOR_INFO: chunkOMPDPBT5_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
21875
+ GET_OPERATOR_INFO: chunkSOJDUKY6_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
21840
21876
  /** @deprecated Use `GET_OPERATOR_INFO`. */
21841
- GET_ARKADE_INFO: chunkOMPDPBT5_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
21877
+ GET_ARKADE_INFO: chunkSOJDUKY6_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
21842
21878
  INDEXER_GET_VTXOS: 2e4,
21843
21879
  INDEXER_GET_VIRTUAL_TXS: 2e4,
21844
21880
  GET_VTXOS: 2e4,
@@ -21938,10 +21974,10 @@ function getRequestDedupKey(request) {
21938
21974
  }
21939
21975
  function cosignWorkerError(e) {
21940
21976
  if (e instanceof Error && e.message === "Unknown message") {
21941
- return new chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError();
21977
+ return new chunkSOJDUKY6_cjs.OnchainCosignUnsupportedError();
21942
21978
  }
21943
21979
  if (e instanceof ServiceWorkerTimeoutError) {
21944
- return new chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError(e.message, { cause: e });
21980
+ return new chunkSOJDUKY6_cjs.OnchainCosignAmbiguousError(e.message, { cause: e });
21945
21981
  }
21946
21982
  return rehydrateCosignError(e);
21947
21983
  }
@@ -21996,7 +22032,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
21996
22032
  }
21997
22033
  };
21998
22034
  var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
21999
- chunkOMPDPBT5_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
22035
+ chunkSOJDUKY6_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
22000
22036
  const initCmd = {
22001
22037
  tag: "INITIALIZE_MESSAGE_BUS",
22002
22038
  id: getRandomId(),
@@ -22116,7 +22152,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
22116
22152
  Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
22117
22153
  );
22118
22154
  for (const [key, value] of Object.entries(overrides)) {
22119
- chunkOMPDPBT5_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
22155
+ chunkSOJDUKY6_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
22120
22156
  }
22121
22157
  const messageTimeouts = {
22122
22158
  ...DEFAULT_MESSAGE_TIMEOUTS,
@@ -22461,7 +22497,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
22461
22497
  try {
22462
22498
  const response = await this.sendMessage(message);
22463
22499
  const { vtxos, page } = response.payload;
22464
- return { vtxos: vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo), page: page && { ...page } };
22500
+ return { vtxos: vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo), page: page && { ...page } };
22465
22501
  } catch (cause) {
22466
22502
  throw new Error(`Failed to get vtxos: ${cause}`, { cause });
22467
22503
  }
@@ -22570,7 +22606,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
22570
22606
  };
22571
22607
  try {
22572
22608
  const response = await this.sendMessage(message);
22573
- return response.payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
22609
+ return response.payload.vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo);
22574
22610
  } catch (error) {
22575
22611
  throw new Error(`Failed to get vtxos: ${error}`);
22576
22612
  }
@@ -22601,7 +22637,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
22601
22637
  "Service worker does not support the requested contract scope or freshness check"
22602
22638
  );
22603
22639
  }
22604
- return payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
22640
+ return payload.vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo);
22605
22641
  } catch (error) {
22606
22642
  throw new Error(`Failed to get spendable vtxos: ${error}`);
22607
22643
  }
@@ -22796,7 +22832,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
22796
22832
  };
22797
22833
  try {
22798
22834
  const response = await sendContractMessage(message);
22799
- return response.payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
22835
+ return response.payload.vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo);
22800
22836
  } catch (cause) {
22801
22837
  throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
22802
22838
  }
@@ -23468,7 +23504,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
23468
23504
  };
23469
23505
  try {
23470
23506
  const response = await wallet.sendMessage(message);
23471
- return response.payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
23507
+ return response.payload.vtxos.map(chunkSOJDUKY6_cjs.normalizeVtxo);
23472
23508
  } catch (e) {
23473
23509
  throw new Error(`Failed to get expiring vtxos: ${e}`);
23474
23510
  }
@@ -23690,7 +23726,7 @@ var OnchainWallet = class _OnchainWallet {
23690
23726
  feeRate,
23691
23727
  params.address
23692
23728
  );
23693
- let tx = new chunkOMPDPBT5_cjs.Transaction();
23729
+ let tx = new chunkSOJDUKY6_cjs.Transaction();
23694
23730
  for (const input of inputs) {
23695
23731
  tx.addInput({
23696
23732
  txid: input.txid,
@@ -23748,7 +23784,7 @@ var OnchainWallet = class _OnchainWallet {
23748
23784
  * @throws If the parent has no anchor, or funding cannot be selected/signed
23749
23785
  */
23750
23786
  async bumpAnchor(parentHex, feeRate) {
23751
- const parent = chunkOMPDPBT5_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
23787
+ const parent = chunkSOJDUKY6_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
23752
23788
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
23753
23789
  const child = await this.buildBumpPackage(parent, feeRate, coins);
23754
23790
  return [parent.hex, child.hex];
@@ -24600,7 +24636,7 @@ var CachingOperatorProvider = class {
24600
24636
  constructor(inner, ttlMs = DEFAULT_TTL_MS) {
24601
24637
  this.inner = inner;
24602
24638
  this.ttlMs = ttlMs;
24603
- chunkOMPDPBT5_cjs.assertNonNegativeMs("ttlMs", ttlMs);
24639
+ chunkSOJDUKY6_cjs.assertNonNegativeMs("ttlMs", ttlMs);
24604
24640
  this.unsubscribe = inner.onServerInfoChanged?.((info) => {
24605
24641
  this.cached = info;
24606
24642
  this.expiresAt = Date.now() + this.ttlMs;
@@ -24687,7 +24723,7 @@ exports.BIP322 = void 0;
24687
24723
  async function sign2(message, identity, network) {
24688
24724
  const xOnlyPubKey = await identity.xOnlyPublicKey();
24689
24725
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
24690
- const toSpend = chunkOMPDPBT5_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
24726
+ const toSpend = chunkSOJDUKY6_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
24691
24727
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
24692
24728
  const signed = await identity.sign(toSign, [0]);
24693
24729
  signed.finalizeIdx(0);
@@ -24745,7 +24781,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
24745
24781
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
24746
24782
  return false;
24747
24783
  }
24748
- const toSpend = chunkOMPDPBT5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
24784
+ const toSpend = chunkSOJDUKY6_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
24749
24785
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
24750
24786
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
24751
24787
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -24766,7 +24802,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
24766
24802
  }
24767
24803
  const sighashType = sigWithHash[sigWithHash.length - 1];
24768
24804
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
24769
- const toSpend = chunkOMPDPBT5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
24805
+ const toSpend = chunkSOJDUKY6_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
24770
24806
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
24771
24807
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
24772
24808
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -24819,7 +24855,7 @@ function encodeCompactSize(n) {
24819
24855
  return buf;
24820
24856
  }
24821
24857
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
24822
- const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 0 });
24858
+ const tx = new chunkSOJDUKY6_cjs.Transaction({ version: 0 });
24823
24859
  tx.addInput({
24824
24860
  txid: toSpend.id,
24825
24861
  index: 0,
@@ -24833,12 +24869,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
24833
24869
  });
24834
24870
  tx.addOutput({
24835
24871
  amount: 0n,
24836
- script: chunkOMPDPBT5_cjs.OP_RETURN_EMPTY_PKSCRIPT
24872
+ script: chunkSOJDUKY6_cjs.OP_RETURN_EMPTY_PKSCRIPT
24837
24873
  });
24838
24874
  return tx;
24839
24875
  }
24840
24876
  function craftBIP322ToSignSimple(toSpend, pkScript) {
24841
- const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 0 });
24877
+ const tx = new chunkSOJDUKY6_cjs.Transaction({ version: 0 });
24842
24878
  tx.addInput({
24843
24879
  txid: toSpend.id,
24844
24880
  index: 0,
@@ -24850,12 +24886,12 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
24850
24886
  });
24851
24887
  tx.addOutput({
24852
24888
  amount: 0n,
24853
- script: chunkOMPDPBT5_cjs.OP_RETURN_EMPTY_PKSCRIPT
24889
+ script: chunkSOJDUKY6_cjs.OP_RETURN_EMPTY_PKSCRIPT
24854
24890
  });
24855
24891
  return tx;
24856
24892
  }
24857
24893
  function finalizeVirtualTx(type, psbtBase64) {
24858
- const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
24894
+ const tx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
24859
24895
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
24860
24896
  const input = tx.getInput(0);
24861
24897
  if (!input) {
@@ -24889,7 +24925,7 @@ async function resolveUnilateralPath(params) {
24889
24925
  const { vtxo, scriptHex, contractRepository } = params;
24890
24926
  const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
24891
24927
  if (contract) {
24892
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
24928
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
24893
24929
  if (!handler) {
24894
24930
  throw new ExitPathError(
24895
24931
  "no-handler",
@@ -25125,7 +25161,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
25125
25161
  let totalAmount = 0n;
25126
25162
  const txWeightEstimator = TxWeightEstimator.create();
25127
25163
  for (const vtxo of vtxos) {
25128
- if (!chunkOMPDPBT5_cjs.canSweepOnchain(vtxo)) {
25164
+ if (!chunkSOJDUKY6_cjs.canSweepOnchain(vtxo)) {
25129
25165
  throw new Error(
25130
25166
  `Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
25131
25167
  );
@@ -25177,7 +25213,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
25177
25213
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
25178
25214
  );
25179
25215
  }
25180
- const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
25216
+ const tx = new chunkSOJDUKY6_cjs.Transaction({ version: 2 });
25181
25217
  for (const input of inputs) {
25182
25218
  tx.addInput(input);
25183
25219
  }
@@ -25260,7 +25296,7 @@ async function buildSignedSweep(params) {
25260
25296
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
25261
25297
  );
25262
25298
  }
25263
- const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
25299
+ const tx = new chunkSOJDUKY6_cjs.Transaction({ version: 2 });
25264
25300
  tx.addInput({
25265
25301
  txid: vtxo.txid,
25266
25302
  index: vtxo.vout,
@@ -25315,7 +25351,7 @@ async function resolveFeeRate(opts) {
25315
25351
  }
25316
25352
  async function selectExitVtxos(opts) {
25317
25353
  if (!opts.vtxos) return opts.wallet.getVtxos();
25318
- const res = await chunkOMPDPBT5_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
25354
+ const res = await chunkSOJDUKY6_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
25319
25355
  const scripts = [
25320
25356
  ...new Set(res.vtxos.filter((vtxo) => !vtxo.isSpent).map((vtxo) => vtxo.script))
25321
25357
  ];
@@ -25333,7 +25369,7 @@ async function selectExitVtxos(opts) {
25333
25369
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
25334
25370
  );
25335
25371
  }
25336
- const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
25372
+ const handler = chunkJYQXB7OH_cjs.contractHandlers.get(contract.type);
25337
25373
  if (!handler) {
25338
25374
  throw new Error(`no contract handler registered for type '${contract.type}'`);
25339
25375
  }
@@ -25367,7 +25403,7 @@ async function computeExitLayout(opts, feeRate) {
25367
25403
  if (pendingNodes.length > 0) {
25368
25404
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
25369
25405
  for (const psbt of txs) {
25370
- psbts.set(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
25406
+ psbts.set(chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
25371
25407
  }
25372
25408
  }
25373
25409
  const childVsize = Number(
@@ -25532,7 +25568,7 @@ var Executor = class {
25532
25568
  constructor(pkg, provider, opts) {
25533
25569
  this.pkg = pkg;
25534
25570
  this.provider = provider;
25535
- chunkOMPDPBT5_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
25571
+ chunkSOJDUKY6_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
25536
25572
  this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
25537
25573
  this.feeWallet = opts?.feeWallet;
25538
25574
  this.signal = opts?.signal;
@@ -25916,7 +25952,7 @@ async function prepare(opts) {
25916
25952
  if (newFee <= splitterFee) break;
25917
25953
  splitterFee = newFee;
25918
25954
  }
25919
- const splitter = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
25955
+ const splitter = new chunkSOJDUKY6_cjs.Transaction({ version: 2 });
25920
25956
  for (const coin of selected.inputs) {
25921
25957
  splitter.addInput({
25922
25958
  txid: coin.txid,
@@ -26056,46 +26092,46 @@ var UnilateralExit = {
26056
26092
  // src/arkade/index.ts
26057
26093
  var arkade_exports = {};
26058
26094
  chunkFLPWNMX3_cjs.__export(arkade_exports, {
26059
- ARKADE_OP: () => chunkJFJNB7ZH_cjs.ARKADE_OP,
26060
- ARKADE_OPCODES: () => chunkJFJNB7ZH_cjs.ARKADE_OPCODES,
26061
- ARKADE_OPCODE_NAMES: () => chunkJFJNB7ZH_cjs.ARKADE_OPCODE_NAMES,
26062
- ARKADE_OPCODE_VALUES: () => chunkJFJNB7ZH_cjs.ARKADE_OPCODE_VALUES,
26063
- ARKADE_OPS: () => chunkJFJNB7ZH_cjs.ARKADE_OPS,
26095
+ ARKADE_OP: () => chunk5PWL7WOT_cjs.ARKADE_OP,
26096
+ ARKADE_OPCODES: () => chunk5PWL7WOT_cjs.ARKADE_OPCODES,
26097
+ ARKADE_OPCODE_NAMES: () => chunk5PWL7WOT_cjs.ARKADE_OPCODE_NAMES,
26098
+ ARKADE_OPCODE_VALUES: () => chunk5PWL7WOT_cjs.ARKADE_OPCODE_VALUES,
26099
+ ARKADE_OPS: () => chunk5PWL7WOT_cjs.ARKADE_OPS,
26064
26100
  Arkade: () => Arkade,
26065
26101
  ArkadeContract: () => ArkadeContract,
26066
- ArkadeProgramScript: () => chunkJFJNB7ZH_cjs.ArkadeProgramScript,
26067
- ArkadeScript: () => chunkJFJNB7ZH_cjs.ArkadeScript,
26102
+ ArkadeProgramScript: () => chunk5PWL7WOT_cjs.ArkadeProgramScript,
26103
+ ArkadeScript: () => chunk5PWL7WOT_cjs.ArkadeScript,
26068
26104
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
26069
- BigNum: () => chunkJFJNB7ZH_cjs.bignum_exports,
26105
+ BigNum: () => chunk5PWL7WOT_cjs.bignum_exports,
26070
26106
  OP: () => btcSigner.OP,
26071
- OPCODE_NAMES: () => chunkJFJNB7ZH_cjs.OPCODE_NAMES,
26072
- OPCODE_VALUES: () => chunkJFJNB7ZH_cjs.OPCODE_VALUES,
26073
- SUPPORTED_PROGRAM_VERSION: () => chunkJFJNB7ZH_cjs.SUPPORTED_PROGRAM_VERSION,
26107
+ OPCODE_NAMES: () => chunk5PWL7WOT_cjs.OPCODE_NAMES,
26108
+ OPCODE_VALUES: () => chunk5PWL7WOT_cjs.OPCODE_VALUES,
26109
+ SUPPORTED_PROGRAM_VERSION: () => chunk5PWL7WOT_cjs.SUPPORTED_PROGRAM_VERSION,
26074
26110
  Script: () => btcSigner.Script,
26075
- UnsupportedProgramVersionError: () => chunkJFJNB7ZH_cjs.UnsupportedProgramVersionError,
26076
- arkadeScriptHash: () => chunkJFJNB7ZH_cjs.arkadeScriptHash,
26077
- arkadeWitnessHash: () => chunkJFJNB7ZH_cjs.arkadeWitnessHash,
26078
- asmToBytes: () => chunkJFJNB7ZH_cjs.asmToBytes,
26079
- bytesToASM: () => chunkJFJNB7ZH_cjs.bytesToASM,
26080
- computeArkadeScriptPublicKey: () => chunkJFJNB7ZH_cjs.computeArkadeScriptPublicKey,
26111
+ UnsupportedProgramVersionError: () => chunk5PWL7WOT_cjs.UnsupportedProgramVersionError,
26112
+ arkadeScriptHash: () => chunk5PWL7WOT_cjs.arkadeScriptHash,
26113
+ arkadeWitnessHash: () => chunk5PWL7WOT_cjs.arkadeWitnessHash,
26114
+ asmToBytes: () => chunk5PWL7WOT_cjs.asmToBytes,
26115
+ bytesToASM: () => chunk5PWL7WOT_cjs.bytesToASM,
26116
+ computeArkadeScriptPublicKey: () => chunk5PWL7WOT_cjs.computeArkadeScriptPublicKey,
26081
26117
  createArkadeBatchHandler: () => createArkadeBatchHandler,
26082
- deserializeArkadeContractParams: () => chunkJFJNB7ZH_cjs.deserializeArkadeContractParams,
26083
- fromASM: () => chunkJFJNB7ZH_cjs.fromASM,
26084
- getOpcodeName: () => chunkJFJNB7ZH_cjs.getOpcodeName,
26085
- getOpcodeValue: () => chunkJFJNB7ZH_cjs.getOpcodeValue,
26086
- isContractArtifact: () => chunkX6ZI53DZ_cjs.isContractArtifact,
26087
- parseArtifact: () => chunkJFJNB7ZH_cjs.parseArtifact,
26088
- programFromArtifact: () => chunkX6ZI53DZ_cjs.programFromArtifact,
26118
+ deserializeArkadeContractParams: () => chunk5PWL7WOT_cjs.deserializeArkadeContractParams,
26119
+ fromASM: () => chunk5PWL7WOT_cjs.fromASM,
26120
+ getOpcodeName: () => chunk5PWL7WOT_cjs.getOpcodeName,
26121
+ getOpcodeValue: () => chunk5PWL7WOT_cjs.getOpcodeValue,
26122
+ isContractArtifact: () => chunkL7OOPAUG_cjs.isContractArtifact,
26123
+ parseArtifact: () => chunk5PWL7WOT_cjs.parseArtifact,
26124
+ programFromArtifact: () => chunkL7OOPAUG_cjs.programFromArtifact,
26089
26125
  renewProgramContractOutputs: () => renewProgramContractOutputs,
26090
26126
  resolveArkadeService: () => resolveArkadeService,
26091
- resolveAsm: () => chunkJFJNB7ZH_cjs.resolveAsm,
26092
- serializeArkadeContractParams: () => chunkJFJNB7ZH_cjs.serializeArkadeContractParams,
26093
- stringifyArtifact: () => chunkJFJNB7ZH_cjs.stringifyArtifact,
26094
- toASM: () => chunkJFJNB7ZH_cjs.toASM,
26095
- validateProgram: () => chunkJFJNB7ZH_cjs.validateProgram,
26096
- witnessRefToBytes: () => chunkJFJNB7ZH_cjs.witnessRefToBytes
26127
+ resolveAsm: () => chunk5PWL7WOT_cjs.resolveAsm,
26128
+ serializeArkadeContractParams: () => chunk5PWL7WOT_cjs.serializeArkadeContractParams,
26129
+ stringifyArtifact: () => chunk5PWL7WOT_cjs.stringifyArtifact,
26130
+ toASM: () => chunk5PWL7WOT_cjs.toASM,
26131
+ validateProgram: () => chunk5PWL7WOT_cjs.validateProgram,
26132
+ witnessRefToBytes: () => chunk5PWL7WOT_cjs.witnessRefToBytes
26097
26133
  });
26098
- var isVtxoCoin = (input) => chunkOMPDPBT5_cjs.isVirtualCoin(input);
26134
+ var isVtxoCoin = (input) => chunkSOJDUKY6_cjs.isVirtualCoin(input);
26099
26135
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
26100
26136
  if (!signer && inputs.some((input) => !isVtxoCoin(input))) {
26101
26137
  throw new Error("createArkadeBatchHandler: boarding inputs need a signer");
@@ -26124,21 +26160,21 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
26124
26160
  batchId = event.id;
26125
26161
  const sweepTapscript = chunkFLPWNMX3_cjs.CSVMultisigTapscript.encode({
26126
26162
  timelock,
26127
- pubkeys: [chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
26163
+ pubkeys: [chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
26128
26164
  }).script;
26129
26165
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
26130
26166
  return { skip: false };
26131
26167
  },
26132
26168
  onTreeSigningStarted: async (event, vtxoTree) => {
26133
26169
  const signerPubKey = await session.getPublicKey();
26134
- const xonlySignerPubKey = chunkJFJNB7ZH_cjs.toXOnly(signerPubKey, "signer key");
26170
+ const xonlySignerPubKey = chunk5PWL7WOT_cjs.toXOnly(signerPubKey, "signer key");
26135
26171
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
26136
- (k) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
26172
+ (k) => base.hex.encode(chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
26137
26173
  );
26138
26174
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
26139
26175
  return { skip: true };
26140
26176
  }
26141
- const commitmentTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
26177
+ const commitmentTx = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
26142
26178
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
26143
26179
  if (recipients && recipients.length > 0) {
26144
26180
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -26176,7 +26212,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
26176
26212
  if (connectorTree) {
26177
26213
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
26178
26214
  }
26179
- let commitmentPsbt = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
26215
+ let commitmentPsbt = chunkSOJDUKY6_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
26180
26216
  assertFinalCommitmentMatchesValidated(
26181
26217
  commitmentPsbt,
26182
26218
  validatedCommitmentTxid,
@@ -26218,7 +26254,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
26218
26254
  boardingIndices.push(boardingIdx);
26219
26255
  continue;
26220
26256
  }
26221
- if (!chunkOMPDPBT5_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
26257
+ if (!chunkSOJDUKY6_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
26222
26258
  continue;
26223
26259
  }
26224
26260
  if (connectorIndex >= connectorLeaves.length) {
@@ -26256,7 +26292,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
26256
26292
  forfeitOutputScript
26257
26293
  );
26258
26294
  if (input.extraWitness?.length) {
26259
- chunkOMPDPBT5_cjs.setArkPsbtField(forfeitTx, 0, chunkOMPDPBT5_cjs.ConditionWitness, input.extraWitness);
26295
+ chunkSOJDUKY6_cjs.setArkPsbtField(forfeitTx, 0, chunkSOJDUKY6_cjs.ConditionWitness, input.extraWitness);
26260
26296
  }
26261
26297
  if (signer) forfeitTx = await signer.sign(forfeitTx, [0]);
26262
26298
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -26340,8 +26376,8 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
26340
26376
  if (compiled.def.tapscript.csv) {
26341
26377
  throw new Error(`renewProgramContractOutputs: ${fn} has a CSV timelock`);
26342
26378
  }
26343
- const condition = chunkJFJNB7ZH_cjs.staticWitness(compiled.def.tapscript.witness, contract.args);
26344
- const stack = chunkJFJNB7ZH_cjs.staticWitness(compiled.def.arkadeScript?.witness, contract.args);
26379
+ const condition = chunk5PWL7WOT_cjs.staticWitness(compiled.def.tapscript.witness, contract.args);
26380
+ const stack = chunk5PWL7WOT_cjs.staticWitness(compiled.def.arkadeScript?.witness, contract.args);
26345
26381
  if (!condition || !stack) {
26346
26382
  throw new Error(
26347
26383
  `renewProgramContractOutputs: ${fn} needs call arguments, which a renewal cannot supply`
@@ -26351,7 +26387,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
26351
26387
  });
26352
26388
  const { fees } = await arkProvider.getInfo();
26353
26389
  const fee = new Estimator(fees?.intentFee ?? {}).evaluate(
26354
- legs.map(({ coin }) => chunkOMPDPBT5_cjs.toOffchainInputFeeParams(chunkOMPDPBT5_cjs.normalizeVtxo(coin))),
26390
+ legs.map(({ coin }) => chunkSOJDUKY6_cjs.toOffchainInputFeeParams(chunkSOJDUKY6_cjs.normalizeVtxo(coin))),
26355
26391
  [],
26356
26392
  legs.map(({ contract, coin }) => ({
26357
26393
  amount: BigInt(coin.value),
@@ -26414,7 +26450,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
26414
26450
  const [signedProof, deleteProof] = await Promise.all(
26415
26451
  [message, deleteMessage].map(
26416
26452
  (m) => emulator.submitIntent({
26417
- proof: base.base64.encode(chunkOMPDPBT5_cjs.Proof.create(m, coins, outputs).toPSBT()),
26453
+ proof: base.base64.encode(chunkSOJDUKY6_cjs.Proof.create(m, coins, outputs).toPSBT()),
26418
26454
  message: m
26419
26455
  })
26420
26456
  )
@@ -26566,7 +26602,7 @@ var Arkade = class _Arkade {
26566
26602
  indexer = opts.indexer;
26567
26603
  info = await opts.arkade.getInfo();
26568
26604
  }
26569
- const serverKey = chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
26605
+ const serverKey = chunk5PWL7WOT_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
26570
26606
  const checkpoint = chunkFLPWNMX3_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
26571
26607
  const network = opts.network ?? (Object.hasOwn(chunkFLPWNMX3_cjs.networks, info.network) ? chunkFLPWNMX3_cjs.getNetwork(info.network) : chunkFLPWNMX3_cjs.DEFAULT_NETWORK);
26572
26608
  let emulatorKey;
@@ -26575,7 +26611,7 @@ var Arkade = class _Arkade {
26575
26611
  }
26576
26612
  let userKey;
26577
26613
  if (opts.identity) {
26578
- userKey = chunkJFJNB7ZH_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
26614
+ userKey = chunk5PWL7WOT_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
26579
26615
  }
26580
26616
  let contractManager = opts.contractManager;
26581
26617
  let ownsContractManager = false;
@@ -26726,7 +26762,7 @@ var ArkadeContract = class _ArkadeContract {
26726
26762
  userKey: client.userKey,
26727
26763
  emulatorKey: client.emulatorKey
26728
26764
  };
26729
- this.vtxoScript = new chunkJFJNB7ZH_cjs.ArkadeProgramScript(program, this.args, this.keys);
26765
+ this.vtxoScript = new chunk5PWL7WOT_cjs.ArkadeProgramScript(program, this.args, this.keys);
26730
26766
  this.tapTree = this.vtxoScript.encode();
26731
26767
  this.compiled = this.vtxoScript.compiled;
26732
26768
  }
@@ -26752,7 +26788,7 @@ var ArkadeContract = class _ArkadeContract {
26752
26788
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
26753
26789
  );
26754
26790
  }
26755
- const typed = chunkJFJNB7ZH_cjs.deserializeArkadeContractParams(contract.params);
26791
+ const typed = chunk5PWL7WOT_cjs.deserializeArkadeContractParams(contract.params);
26756
26792
  return new _ArkadeContract(client, typed.program, typed.args, {
26757
26793
  serverKey: typed.serverKey,
26758
26794
  userKey: typed.userKey,
@@ -26773,14 +26809,17 @@ var ArkadeContract = class _ArkadeContract {
26773
26809
  get pkScript() {
26774
26810
  return this.vtxoScript.pkScript;
26775
26811
  }
26776
- /** Callable spending paths: `functions.<name>(...args)` (see {@link ContractFunctions}). */
26812
+ /**
26813
+ * Callable spending paths: `functions.<name>({ tapscript: [...], arkadeScript: [...] })`
26814
+ * (see {@link ContractFunctions}).
26815
+ */
26777
26816
  get functions() {
26778
26817
  const out = /* @__PURE__ */ Object.create(null);
26779
26818
  for (const fn of this.compiled) {
26780
26819
  out[fn.name] = (...callArgs) => new ArkadeTransactionBuilder(this.client, {
26781
26820
  contract: this,
26782
26821
  fn,
26783
- args: bindInputs(fn, callArgs)
26822
+ args: bindCall(fn, callArgs)
26784
26823
  });
26785
26824
  }
26786
26825
  return out;
@@ -26792,7 +26831,7 @@ var ArkadeContract = class _ArkadeContract {
26792
26831
  out[fn.name] = (...callArgs) => ({
26793
26832
  contract: this,
26794
26833
  fn,
26795
- args: bindInputs(fn, callArgs)
26834
+ args: bindCall(fn, callArgs)
26796
26835
  });
26797
26836
  }
26798
26837
  return out;
@@ -26804,7 +26843,7 @@ var ArkadeContract = class _ArkadeContract {
26804
26843
  toContractParams() {
26805
26844
  return {
26806
26845
  type: "arkade",
26807
- params: chunkJFJNB7ZH_cjs.serializeArkadeContractParams({
26846
+ params: chunk5PWL7WOT_cjs.serializeArkadeContractParams({
26808
26847
  program: this.program,
26809
26848
  args: this.args,
26810
26849
  serverKey: this.keys.serverKey,
@@ -26891,17 +26930,17 @@ var ArkadeContract = class _ArkadeContract {
26891
26930
  const [registered] = await manager.getContracts({ script: scriptHex });
26892
26931
  if (registered) {
26893
26932
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
26894
- return (withVtxos?.vtxos ?? []).filter((v) => !chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isUnrolled);
26933
+ return (withVtxos?.vtxos ?? []).filter((v) => !chunkSOJDUKY6_cjs.isVtxoSpent(v) && !v.isUnrolled);
26895
26934
  }
26896
26935
  }
26897
26936
  if (!this.client.indexer) {
26898
26937
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
26899
26938
  }
26900
- const { vtxos } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(this.client.indexer, {
26939
+ const { vtxos } = await chunkSOJDUKY6_cjs.getNormalizedVtxos(this.client.indexer, {
26901
26940
  scripts: [scriptHex],
26902
26941
  spendableOnly: true
26903
26942
  });
26904
- return vtxos.filter((v) => !chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isUnrolled);
26943
+ return vtxos.filter((v) => !chunkSOJDUKY6_cjs.isVtxoSpent(v) && !v.isUnrolled);
26905
26944
  }
26906
26945
  /** Total spendable balance (requires an indexer). */
26907
26946
  async getBalance() {
@@ -27067,7 +27106,7 @@ var ArkadeTransactionBuilder = class {
27067
27106
  this.client.checkpoint
27068
27107
  );
27069
27108
  inputs.forEach(({ coin }, i) => {
27070
- if (coin.sourceTx) chunkOMPDPBT5_cjs.setArkPsbtField(arkTx, i, chunkOMPDPBT5_cjs.PrevArkTxField, coin.sourceTx);
27109
+ if (coin.sourceTx) chunkSOJDUKY6_cjs.setArkPsbtField(arkTx, i, chunkSOJDUKY6_cjs.PrevArkTxField, coin.sourceTx);
27071
27110
  });
27072
27111
  if (inputs.some(({ unlocker }) => unlocker.fn.arkadeScript)) {
27073
27112
  const indexer = this.client.indexer;
@@ -27084,11 +27123,11 @@ var ArkadeTransactionBuilder = class {
27084
27123
  }
27085
27124
  inputs.forEach(({ unlocker }, i) => {
27086
27125
  const condition = (unlocker.fn.def.tapscript.witness ?? []).map(
27087
- (w) => witnessBytes(unlocker, w)
27126
+ (w) => witnessBytes(unlocker, "tapscript", w)
27088
27127
  );
27089
27128
  if (condition.length === 0) return;
27090
- chunkOMPDPBT5_cjs.setArkPsbtField(arkTx, i, chunkOMPDPBT5_cjs.ConditionWitness, condition);
27091
- chunkOMPDPBT5_cjs.setArkPsbtField(checkpoints[i], 0, chunkOMPDPBT5_cjs.ConditionWitness, condition);
27129
+ chunkSOJDUKY6_cjs.setArkPsbtField(arkTx, i, chunkSOJDUKY6_cjs.ConditionWitness, condition);
27130
+ chunkSOJDUKY6_cjs.setArkPsbtField(checkpoints[i], 0, chunkSOJDUKY6_cjs.ConditionWitness, condition);
27092
27131
  });
27093
27132
  const packets = [];
27094
27133
  if (this.assetSpecs.length > 0) {
@@ -27097,7 +27136,9 @@ var ArkadeTransactionBuilder = class {
27097
27136
  const entries = inputs.flatMap(({ unlocker }, vin) => {
27098
27137
  const { arkadeScript, def } = unlocker.fn;
27099
27138
  if (!arkadeScript) return [];
27100
- const stack = (def.arkadeScript?.witness ?? []).map((w) => witnessBytes(unlocker, w));
27139
+ const stack = (def.arkadeScript?.witness ?? []).map(
27140
+ (w) => witnessBytes(unlocker, "arkadeScript", w)
27141
+ );
27101
27142
  return [{ vin, script: arkadeScript, witness: btcSigner.RawWitness.encode(stack) }];
27102
27143
  });
27103
27144
  if (entries.length > 0) {
@@ -27151,10 +27192,12 @@ var ArkadeTransactionBuilder = class {
27151
27192
  );
27152
27193
  }
27153
27194
  const { sequence, lockTime } = this.leafTimelocks(fn);
27154
- const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2, lockTime });
27195
+ const tx = new chunkSOJDUKY6_cjs.Transaction({ version: 2, lockTime });
27155
27196
  tx.addInput({ txid: base.hex.decode(coin.txid), index: coin.vout, sequence });
27156
27197
  for (const o of outputs) tx.addOutput(o);
27157
- const condition = (fn.def.tapscript.witness ?? []).map((w) => witnessBytes(unlocker, w));
27198
+ const condition = (fn.def.tapscript.witness ?? []).map(
27199
+ (w) => witnessBytes(unlocker, "tapscript", w)
27200
+ );
27158
27201
  prepareOwnedInput(tx, {
27159
27202
  index: 0,
27160
27203
  coin: { value: coin.value, script: base.hex.encode(contract.pkScript) },
@@ -27163,7 +27206,7 @@ var ArkadeTransactionBuilder = class {
27163
27206
  });
27164
27207
  if (fn.arkadeScript) {
27165
27208
  const stack = (fn.def.arkadeScript?.witness ?? []).map(
27166
- (w) => witnessBytes(unlocker, w)
27209
+ (w) => witnessBytes(unlocker, "arkadeScript", w)
27167
27210
  );
27168
27211
  attachExtension(tx, [
27169
27212
  EmulatorPacket.create([
@@ -27315,20 +27358,20 @@ var ArkadeTransactionBuilder = class {
27315
27358
  * A caller's packet counts for every input, unread; arkd checks what it actually routes.
27316
27359
  */
27317
27360
  routesAssetsFrom(vin) {
27318
- return this.extraPackets.some((p) => p.type() === chunk3NALVGMJ_cjs.Packet.PACKET_TYPE) || this.assetSpecs.some((spec) => spec.inputs.some((i) => i.vin === vin));
27361
+ return this.extraPackets.some((p) => p.type() === chunk4IDCSOP2_cjs.Packet.PACKET_TYPE) || this.assetSpecs.some((spec) => spec.inputs.some((i) => i.vin === vin));
27319
27362
  }
27320
27363
  buildAssetPacket() {
27321
27364
  const groups = this.assetSpecs.map((s) => {
27322
- const id = typeof s.assetId === "string" ? chunk3NALVGMJ_cjs.AssetId.fromString(s.assetId) : chunk3NALVGMJ_cjs.AssetId.fromBytes(s.assetId);
27323
- return chunk3NALVGMJ_cjs.AssetGroup.create(
27365
+ const id = typeof s.assetId === "string" ? chunk4IDCSOP2_cjs.AssetId.fromString(s.assetId) : chunk4IDCSOP2_cjs.AssetId.fromBytes(s.assetId);
27366
+ return chunk4IDCSOP2_cjs.AssetGroup.create(
27324
27367
  id,
27325
27368
  null,
27326
- s.inputs.map((i) => chunk3NALVGMJ_cjs.AssetInput.create(i.vin, i.amount)),
27327
- s.outputs.map((o) => chunk3NALVGMJ_cjs.AssetOutput.create(o.vout, o.amount)),
27328
- (s.metadata ?? []).map((m) => chunk3NALVGMJ_cjs.Metadata.create(m.key, m.value))
27369
+ s.inputs.map((i) => chunk4IDCSOP2_cjs.AssetInput.create(i.vin, i.amount)),
27370
+ s.outputs.map((o) => chunk4IDCSOP2_cjs.AssetOutput.create(o.vout, o.amount)),
27371
+ (s.metadata ?? []).map((m) => chunk4IDCSOP2_cjs.Metadata.create(m.key, m.value))
27329
27372
  );
27330
27373
  });
27331
- return chunk3NALVGMJ_cjs.Packet.create(groups);
27374
+ return chunk4IDCSOP2_cjs.Packet.create(groups);
27332
27375
  }
27333
27376
  };
27334
27377
  function unspendable(coin, now) {
@@ -27336,8 +27379,8 @@ function unspendable(coin, now) {
27336
27379
  if (coin.expiresAt && now >= new Date(coin.expiresAt).getTime()) return "has expired";
27337
27380
  return void 0;
27338
27381
  }
27339
- function witnessBytes({ contract, args }, ref) {
27340
- return chunkJFJNB7ZH_cjs.witnessRefToBytes(ref, args, contract.args);
27382
+ function witnessBytes({ contract, args }, segment, ref) {
27383
+ return chunk5PWL7WOT_cjs.witnessRefToBytes(ref, args[segment], contract.args);
27341
27384
  }
27342
27385
  function flattenValue(name, value, out, ancestors = /* @__PURE__ */ new Set()) {
27343
27386
  if (typeof value !== "object" || value === null || ArrayBuffer.isView(value)) {
@@ -27363,35 +27406,44 @@ function flattenValue(name, value, out, ancestors = /* @__PURE__ */ new Set()) {
27363
27406
  for (const [key, item] of entries) flattenValue(`${name}.${key}`, item, out, ancestors);
27364
27407
  ancestors.delete(value);
27365
27408
  }
27366
- function bindInputs(fn, callArgs) {
27367
- const inputs = fn.def.inputs ?? [];
27409
+ function bindCall({ name, def }, callArgs) {
27410
+ const [args = {}] = callArgs;
27411
+ const proto = typeof args === "object" && args !== null && Object.getPrototypeOf(args);
27412
+ if (callArgs.length > 1 || proto !== Object.prototype && proto !== null || Object.entries(args).some(
27413
+ ([key, value]) => key !== "tapscript" && key !== "arkadeScript" || value !== void 0 && !Array.isArray(value)
27414
+ )) {
27415
+ throw new Error(
27416
+ `${name}: expected one { arkadeScript?: [...], tapscript?: [...] } argument`
27417
+ );
27418
+ }
27419
+ const { tapscript = [], arkadeScript = [] } = args;
27420
+ return {
27421
+ arkadeScript: bindInputs(
27422
+ `${name} arkadeScript`,
27423
+ def.arkadeScript?.inputs ?? [],
27424
+ arkadeScript
27425
+ ),
27426
+ tapscript: bindInputs(`${name} tapscript`, def.tapscript.inputs ?? [], tapscript)
27427
+ };
27428
+ }
27429
+ function bindInputs(label, inputs, callArgs) {
27368
27430
  const declared = /* @__PURE__ */ new Set();
27369
27431
  for (const def of inputs) {
27370
- if (declared.has(def.name)) throw new Error(`${fn.name}: duplicate input '${def.name}'`);
27432
+ if (declared.has(def.name)) throw new Error(`${label}: duplicate input '${def.name}'`);
27371
27433
  declared.add(def.name);
27372
27434
  }
27373
- const params = [
27374
- ...new Map(
27375
- inputs.map(({ name }) => {
27376
- const root = name.split(".")[0];
27377
- return [name.includes(".") ? `${root}.` : root, root];
27378
- })
27379
- ).values()
27380
- ];
27435
+ const params = [...new Set(inputs.map(({ name }) => name.split(".")[0]))];
27381
27436
  if (callArgs.length !== params.length) {
27382
- throw new Error(
27383
- `${fn.name}: expected ${params.length} argument(s), got ${callArgs.length}`
27384
- );
27437
+ throw new Error(`${label}: expected ${params.length} argument(s), got ${callArgs.length}`);
27385
27438
  }
27386
27439
  const bound = /* @__PURE__ */ Object.create(null);
27387
27440
  params.forEach((param, i) => flattenValue(param, callArgs[i], bound));
27388
27441
  for (const name of Object.keys(bound)) {
27389
- if (!declared.has(name)) throw new Error(`${fn.name}: unexpected input '${name}'`);
27442
+ if (!declared.has(name)) throw new Error(`${label}: unexpected input '${name}'`);
27390
27443
  }
27391
27444
  for (const def of inputs) {
27392
- if (bound[def.name] === void 0)
27393
- throw new Error(`${fn.name}: missing input '${def.name}'`);
27394
- chunkJFJNB7ZH_cjs.validateParamValue(def, bound[def.name]);
27445
+ if (bound[def.name] === void 0) throw new Error(`${label}: missing input '${def.name}'`);
27446
+ chunk5PWL7WOT_cjs.validateParamValue(def, bound[def.name]);
27395
27447
  }
27396
27448
  return bound;
27397
27449
  }
@@ -27801,14 +27853,14 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
27801
27853
  function offchainInputFees(vtxos, fees) {
27802
27854
  const estimator = new Estimator(fees?.intentFee ?? {});
27803
27855
  return vtxos.reduce(
27804
- (total, vtxo) => total + estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
27856
+ (total, vtxo) => total + estimator.evalOffchainInput(chunkSOJDUKY6_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
27805
27857
  0
27806
27858
  );
27807
27859
  }
27808
27860
  async function changeOutputFee(wallet, inputs, needed, fees) {
27809
27861
  const estimator = new Estimator(fees?.intentFee ?? {});
27810
27862
  const net = inputs.reduce(
27811
- (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
27863
+ (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkSOJDUKY6_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
27812
27864
  0n
27813
27865
  );
27814
27866
  const script = base.hex.encode(chunkFLPWNMX3_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
@@ -28139,5 +28191,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
28139
28191
  exports.walletFeeSource = walletFeeSource;
28140
28192
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
28141
28193
  exports.withPrevTxs = withPrevTxs;
28142
- //# sourceMappingURL=chunk-URGVQ5TQ.cjs.map
28143
- //# sourceMappingURL=chunk-URGVQ5TQ.cjs.map
28194
+ //# sourceMappingURL=chunk-EQ3JVVUR.cjs.map
28195
+ //# sourceMappingURL=chunk-EQ3JVVUR.cjs.map