@babylonlabs-io/ts-sdk 0.36.2 → 0.37.1

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 (118) hide show
  1. package/dist/PayoutManager-BxAY2x0g.cjs +2 -0
  2. package/dist/PayoutManager-BxAY2x0g.cjs.map +1 -0
  3. package/dist/{PayoutManager-s_uH8Uuj.js → PayoutManager-sfxuOBGq.js} +51 -43
  4. package/dist/PayoutManager-sfxuOBGq.js.map +1 -0
  5. package/dist/{PeginManager-CB-dVkT2.js → PeginManager-C7-XYrkK.js} +13 -14
  6. package/dist/{PeginManager-CB-dVkT2.js.map → PeginManager-C7-XYrkK.js.map} +1 -1
  7. package/dist/{PeginManager-BPXVXu8t.cjs → PeginManager-CRuwG4I-.cjs} +2 -2
  8. package/dist/{PeginManager-BPXVXu8t.cjs.map → PeginManager-CRuwG4I-.cjs.map} +1 -1
  9. package/dist/assertPsbtUnsignedTxMatches-BoHwgW30.cjs +2 -0
  10. package/dist/assertPsbtUnsignedTxMatches-BoHwgW30.cjs.map +1 -0
  11. package/dist/assertPsbtUnsignedTxMatches-D7RxpR4A.js +263 -0
  12. package/dist/assertPsbtUnsignedTxMatches-D7RxpR4A.js.map +1 -0
  13. package/dist/{bitcoin-B0S8SHCX.js → bitcoin-B5aNKtsk.js} +77 -60
  14. package/dist/{bitcoin-B0S8SHCX.js.map → bitcoin-B5aNKtsk.js.map} +1 -1
  15. package/dist/bitcoin-CHfKAhcI.cjs +2 -0
  16. package/dist/{bitcoin-B3aqjuMP.cjs.map → bitcoin-CHfKAhcI.cjs.map} +1 -1
  17. package/dist/{buildAndBroadcastRefund-C2VqXiOx.js → buildAndBroadcastRefund-C1eOhIdo.js} +322 -322
  18. package/dist/buildAndBroadcastRefund-C1eOhIdo.js.map +1 -0
  19. package/dist/buildAndBroadcastRefund-_CEDUU5H.cjs +2 -0
  20. package/dist/buildAndBroadcastRefund-_CEDUU5H.cjs.map +1 -0
  21. package/dist/{challengeAssert-Yyyj-EdR.cjs → challengeAssert-BKDS_ADt.cjs} +2 -2
  22. package/dist/{challengeAssert-Yyyj-EdR.cjs.map → challengeAssert-BKDS_ADt.cjs.map} +1 -1
  23. package/dist/{challengeAssert-BzxQmdZy.js → challengeAssert-BXESW00N.js} +7 -7
  24. package/dist/{challengeAssert-BzxQmdZy.js.map → challengeAssert-BXESW00N.js.map} +1 -1
  25. package/dist/fundPeginTransaction-BBE3wTjR.cjs +2 -0
  26. package/dist/{fundPeginTransaction-DaWoYCgO.cjs.map → fundPeginTransaction-BBE3wTjR.cjs.map} +1 -1
  27. package/dist/fundPeginTransaction-t-6TsHAY.js +84 -0
  28. package/dist/{fundPeginTransaction-oV-dNJOU.js.map → fundPeginTransaction-t-6TsHAY.js.map} +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +174 -166
  31. package/dist/{noPayout-BXeUw0Qq.cjs → noPayout-B6s8vrW6.cjs} +2 -2
  32. package/dist/{noPayout-BXeUw0Qq.cjs.map → noPayout-B6s8vrW6.cjs.map} +1 -1
  33. package/dist/{noPayout-DBX6G96_.js → noPayout-BhgknZBx.js} +2 -2
  34. package/dist/{noPayout-DBX6G96_.js.map → noPayout-BhgknZBx.js.map} +1 -1
  35. package/dist/{peginInput-tbw9BpZy.cjs → peginInput-57FK2O99.cjs} +2 -2
  36. package/dist/{peginInput-tbw9BpZy.cjs.map → peginInput-57FK2O99.cjs.map} +1 -1
  37. package/dist/{peginInput-C2QPvuhR.js → peginInput-CYJzbuwA.js} +3 -3
  38. package/dist/{peginInput-C2QPvuhR.js.map → peginInput-CYJzbuwA.js.map} +1 -1
  39. package/dist/{reservation-CHUGW0F_.js → reservation-CB-4FBPk.js} +37 -36
  40. package/dist/reservation-CB-4FBPk.js.map +1 -0
  41. package/dist/reservation-hjXStM03.cjs +2 -0
  42. package/dist/reservation-hjXStM03.cjs.map +1 -0
  43. package/dist/tbv/core/clients/index.cjs +1 -1
  44. package/dist/tbv/core/clients/index.js +1 -1
  45. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  46. package/dist/tbv/core/index.cjs +1 -1
  47. package/dist/tbv/core/index.js +172 -164
  48. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  49. package/dist/tbv/core/managers/PeginManager.d.ts +7 -8
  50. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  51. package/dist/tbv/core/managers/index.cjs +1 -1
  52. package/dist/tbv/core/managers/index.js +2 -2
  53. package/dist/tbv/core/primitives/index.cjs +1 -1
  54. package/dist/tbv/core/primitives/index.d.ts +3 -1
  55. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  56. package/dist/tbv/core/primitives/index.js +31 -27
  57. package/dist/tbv/core/primitives/psbt/__tests__/assertPsbtUnsignedTxMatches.test.d.ts +5 -0
  58. package/dist/tbv/core/primitives/psbt/__tests__/assertPsbtUnsignedTxMatches.test.d.ts.map +1 -0
  59. package/dist/tbv/core/primitives/psbt/assertPsbtUnsignedTxMatches.d.ts +31 -0
  60. package/dist/tbv/core/primitives/psbt/assertPsbtUnsignedTxMatches.d.ts.map +1 -0
  61. package/dist/tbv/core/primitives/psbt/index.d.ts +2 -0
  62. package/dist/tbv/core/primitives/psbt/index.d.ts.map +1 -1
  63. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +33 -3
  64. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
  65. package/dist/tbv/core/primitives/utils/index.d.ts +1 -1
  66. package/dist/tbv/core/primitives/utils/index.d.ts.map +1 -1
  67. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  68. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  69. package/dist/tbv/core/services/index.cjs +1 -1
  70. package/dist/tbv/core/services/index.js +2 -2
  71. package/dist/tbv/core/utils/fee/__tests__/peginFeeMath.test.d.ts +19 -0
  72. package/dist/tbv/core/utils/fee/__tests__/peginFeeMath.test.d.ts.map +1 -0
  73. package/dist/tbv/core/utils/fee/index.d.ts +1 -0
  74. package/dist/tbv/core/utils/fee/index.d.ts.map +1 -1
  75. package/dist/tbv/core/utils/fee/peginFeeMath.d.ts +99 -0
  76. package/dist/tbv/core/utils/fee/peginFeeMath.d.ts.map +1 -0
  77. package/dist/tbv/core/utils/index.cjs +1 -1
  78. package/dist/tbv/core/utils/index.js +44 -40
  79. package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -1
  80. package/dist/tbv/core/utils/utxo/reservation.d.ts +4 -1
  81. package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
  82. package/dist/tbv/core/utils/utxo/selectUtxos.d.ts.map +1 -1
  83. package/dist/tbv/index.cjs +1 -1
  84. package/dist/tbv/index.js +172 -164
  85. package/dist/testing/index.cjs +1 -1
  86. package/dist/testing/index.js +1 -1
  87. package/dist/vault-registry-reader-7gOYnrQD.cjs +2 -0
  88. package/dist/vault-registry-reader-7gOYnrQD.cjs.map +1 -0
  89. package/dist/{vault-registry-reader-CrLodprY.js → vault-registry-reader-Blhu9FW2.js} +130 -125
  90. package/dist/vault-registry-reader-Blhu9FW2.js.map +1 -0
  91. package/dist/waitForTransactionReceiptSmartAware-CmgFXFza.js +265 -0
  92. package/dist/waitForTransactionReceiptSmartAware-CmgFXFza.js.map +1 -0
  93. package/dist/waitForTransactionReceiptSmartAware-tv1mtSIY.cjs +2 -0
  94. package/dist/waitForTransactionReceiptSmartAware-tv1mtSIY.cjs.map +1 -0
  95. package/package.json +1 -1
  96. package/dist/PayoutManager-BhJoQZsG.cjs +0 -2
  97. package/dist/PayoutManager-BhJoQZsG.cjs.map +0 -1
  98. package/dist/PayoutManager-s_uH8Uuj.js.map +0 -1
  99. package/dist/bitcoin-B3aqjuMP.cjs +0 -2
  100. package/dist/buildAndBroadcastRefund-C2VqXiOx.js.map +0 -1
  101. package/dist/buildAndBroadcastRefund-CBIfcF47.cjs +0 -2
  102. package/dist/buildAndBroadcastRefund-CBIfcF47.cjs.map +0 -1
  103. package/dist/fundPeginTransaction-DaWoYCgO.cjs +0 -2
  104. package/dist/fundPeginTransaction-oV-dNJOU.js +0 -76
  105. package/dist/payout-BNFMBXS6.js +0 -193
  106. package/dist/payout-BNFMBXS6.js.map +0 -1
  107. package/dist/payout-DQ_fmJUA.cjs +0 -2
  108. package/dist/payout-DQ_fmJUA.cjs.map +0 -1
  109. package/dist/reservation-CHUGW0F_.js.map +0 -1
  110. package/dist/reservation-ho7mjW3X.cjs +0 -2
  111. package/dist/reservation-ho7mjW3X.cjs.map +0 -1
  112. package/dist/vault-registry-reader-CLnhAUN4.cjs +0 -2
  113. package/dist/vault-registry-reader-CLnhAUN4.cjs.map +0 -1
  114. package/dist/vault-registry-reader-CrLodprY.js.map +0 -1
  115. package/dist/waitForTransactionReceiptSmartAware-Cj_DKm0G.js +0 -217
  116. package/dist/waitForTransactionReceiptSmartAware-Cj_DKm0G.js.map +0 -1
  117. package/dist/waitForTransactionReceiptSmartAware-D9ykVriz.cjs +0 -2
  118. package/dist/waitForTransactionReceiptSmartAware-D9ykVriz.cjs.map +0 -1
@@ -1,16 +1,16 @@
1
1
  var fe = Object.defineProperty;
2
2
  var me = (t, e, n) => e in t ? fe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
3
  var p = (t, e, n) => me(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { D as be, J as re, e as _e } from "./types-TiIjyo2b.js";
5
- import { X as R, C as L, s as C, S as ye, h as Pe } from "./bitcoin-B0S8SHCX.js";
4
+ import { D as be, J as se, e as _e } from "./types-TiIjyo2b.js";
5
+ import { X as R, C as L, s as C, S as ye, h as Pe } from "./bitcoin-B5aNKtsk.js";
6
6
  import { H as T } from "./validation-CxqROCno.js";
7
7
  import * as j from "@bitcoin-js/tiny-secp256k1-asmjs";
8
8
  import { payments as we, Transaction as U } from "bitcoinjs-lib";
9
9
  import { Buffer as A } from "buffer";
10
- import { s as z } from "./sha2-BYVxyZzX.js";
10
+ import { s as W } from "./sha2-BYVxyZzX.js";
11
11
  import { B as w } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
12
12
  import { P as _, A as F } from "./ProtocolParams.abi-DXu8L0Fn.js";
13
- const W = new Set(Object.values(be)), ve = 200;
13
+ const Q = new Set(Object.values(be)), ve = 200;
14
14
  function l(t) {
15
15
  var e;
16
16
  return ((e = JSON.stringify(t)) == null ? void 0 : e.slice(0, ve)) ?? "undefined";
@@ -30,7 +30,7 @@ function v(t) {
30
30
  function ie(t) {
31
31
  return typeof t == "string" && t.length > 0;
32
32
  }
33
- function se(t, e) {
33
+ function oe(t, e) {
34
34
  if (!v(t))
35
35
  throw new o(
36
36
  `VP response validation failed: "${e}" must be a non-empty hex string, got ${l(t)}`
@@ -42,7 +42,7 @@ function m(t, e) {
42
42
  `VP response validation failed: "${e}" must be a non-empty string, got ${l(t)}`
43
43
  );
44
44
  }
45
- function oe(t, e) {
45
+ function q(t, e) {
46
46
  if (!v(t) || t.length !== R && t.length !== L)
47
47
  throw new o(
48
48
  `VP response validation failed: "${e}" must be a ${R} or ${L}-char hex string (BTC pubkey), got ${l(t)}`
@@ -83,9 +83,9 @@ function ae(t) {
83
83
  throw new o(
84
84
  'VP response validation failed: "status" must be a string'
85
85
  );
86
- if (!W.has(e.status))
86
+ if (!Q.has(e.status))
87
87
  throw new o(
88
- `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...W].join(", ")}`
88
+ `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...Q].join(", ")}`
89
89
  );
90
90
  if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
91
91
  throw new o(
@@ -125,7 +125,7 @@ function y(t, e) {
125
125
  throw new o(
126
126
  `VP response validation failed: "${e}" must be an object`
127
127
  );
128
- se(t.tx_hex, `${e}.tx_hex`);
128
+ oe(t.tx_hex, `${e}.tx_hex`);
129
129
  }
130
130
  function $e(t, e) {
131
131
  if (t === null || typeof t != "object")
@@ -133,7 +133,7 @@ function $e(t, e) {
133
133
  `VP response validation failed: "${e}" must be an object`
134
134
  );
135
135
  const n = t;
136
- oe(n.claimer_pubkey, `${e}.claimer_pubkey`), y(n.claim_tx, `${e}.claim_tx`), y(n.assert_tx, `${e}.assert_tx`), y(n.payout_tx, `${e}.payout_tx`), m(n.payout_psbt, `${e}.payout_psbt`);
136
+ q(n.claimer_pubkey, `${e}.claimer_pubkey`), y(n.claim_tx, `${e}.claim_tx`), y(n.assert_tx, `${e}.assert_tx`), y(n.payout_tx, `${e}.payout_tx`), m(n.payout_psbt, `${e}.payout_psbt`);
137
137
  }
138
138
  function Te(t, e) {
139
139
  if (t === null || typeof t != "object")
@@ -149,7 +149,7 @@ function Se(t, e) {
149
149
  `VP response validation failed: "${e}" must be an object`
150
150
  );
151
151
  const n = t;
152
- if (oe(n.challenger_pubkey, `${e}.challenger_pubkey`), y(
152
+ if (q(n.challenger_pubkey, `${e}.challenger_pubkey`), y(
153
153
  n.challenge_assert_x_tx,
154
154
  `${e}.challenge_assert_x_tx`
155
155
  ), y(
@@ -169,7 +169,7 @@ function Se(t, e) {
169
169
  `VP response validation failed: "${e}.output_label_hashes" must be an array`
170
170
  );
171
171
  for (let r = 0; r < n.output_label_hashes.length; r++)
172
- se(
172
+ oe(
173
173
  n.output_label_hashes[r],
174
174
  `${e}.output_label_hashes[${r}]`
175
175
  );
@@ -188,21 +188,26 @@ function ke(t) {
188
188
  throw new o(
189
189
  `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${l(e.verifying_key_hex)}`
190
190
  );
191
- if (e.babe_sessions === null || typeof e.babe_sessions != "object")
191
+ if (e.babe_sessions === null || typeof e.babe_sessions != "object" || Array.isArray(e.babe_sessions))
192
192
  throw new o(
193
193
  'VP response validation failed: "babe_sessions" must be an object'
194
194
  );
195
- for (const [n, r] of Object.entries(
195
+ const n = Object.entries(
196
196
  e.babe_sessions
197
- )) {
198
- if (r === null || typeof r != "object")
197
+ );
198
+ if (n.length === 0)
199
+ throw new o(
200
+ 'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
201
+ );
202
+ for (const [r, i] of n) {
203
+ if (q(r, `babe_sessions["${r}"]`), i === null || typeof i != "object")
199
204
  throw new o(
200
- `VP response validation failed: "babe_sessions.${n}" must be an object`
205
+ `VP response validation failed: "babe_sessions.${r}" must be an object`
201
206
  );
202
- const s = r;
207
+ const s = i;
203
208
  if (!v(s.decryptor_artifacts_hex))
204
209
  throw new o(
205
- `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(s.decryptor_artifacts_hex)}`
210
+ `VP response validation failed: "babe_sessions.${r}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(s.decryptor_artifacts_hex)}`
206
211
  );
207
212
  }
208
213
  }
@@ -299,30 +304,30 @@ function ce(t, e, n) {
299
304
  throw new o(
300
305
  `VP response validation failed: "${e}.results" must be an array, got ${l(r.results)}`
301
306
  );
302
- for (let s = 0; s < r.results.length; s++) {
303
- const i = r.results[s];
304
- if (i === null || typeof i != "object")
307
+ for (let i = 0; i < r.results.length; i++) {
308
+ const s = r.results[i];
309
+ if (s === null || typeof s != "object")
305
310
  throw new o(
306
- `VP response validation failed: "${e}.results[${s}]" must be an object, got ${l(i)}`
311
+ `VP response validation failed: "${e}.results[${i}]" must be an object, got ${l(s)}`
307
312
  );
308
- const a = i;
313
+ const a = s;
309
314
  if (!v(a.pegin_txid) || a.pegin_txid.length !== $)
310
315
  throw new o(
311
- `VP response validation failed: "${e}.results[${s}].pegin_txid" must be a ${$}-char hex string, got ${l(a.pegin_txid)}`
316
+ `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${$}-char hex string, got ${l(a.pegin_txid)}`
312
317
  );
313
318
  if (a.error !== null && typeof a.error != "string")
314
319
  throw new o(
315
- `VP response validation failed: "${e}.results[${s}].error" must be a string or null, got ${l(a.error)}`
320
+ `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${l(a.error)}`
316
321
  );
317
322
  if (a.result === null && a.error === null)
318
323
  throw new o(
319
- `VP response validation failed: "${e}.results[${s}]" has neither "result" nor "error" populated`
324
+ `VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
320
325
  );
321
326
  if (a.result !== null && a.error !== null)
322
327
  throw new o(
323
- `VP response validation failed: "${e}.results[${s}]" has both "result" and "error" populated`
328
+ `VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
324
329
  );
325
- n(a, s);
330
+ n(a, i);
326
331
  }
327
332
  }
328
333
  function Re(t) {
@@ -354,7 +359,7 @@ class Oe {
354
359
  tokenProvider: n == null ? void 0 : n.tokenProvider,
355
360
  maxResponseBytes: n == null ? void 0 : n.maxResponseBytes
356
361
  };
357
- this.client = new re(r);
362
+ this.client = new se(r);
358
363
  }
359
364
  /**
360
365
  * Request the payout/claim/assert transactions that the depositor
@@ -426,31 +431,31 @@ function De(t, e) {
426
431
  const n = /* @__PURE__ */ new Set();
427
432
  for (const u of t)
428
433
  n.add(u.toLowerCase());
429
- const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), i = [], a = [];
434
+ const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
430
435
  for (const u of e) {
431
436
  const h = u.pegin_txid.toLowerCase();
432
437
  if (!n.has(h)) {
433
438
  a.push(h);
434
439
  continue;
435
440
  }
436
- if (s.has(h)) {
437
- i.push(h);
441
+ if (i.has(h)) {
442
+ s.push(h);
438
443
  continue;
439
444
  }
440
- s.add(h), r.set(h, { result: u.result, error: u.error });
445
+ i.add(h), r.set(h, { result: u.result, error: u.error });
441
446
  }
442
447
  const c = [];
443
448
  for (const u of n)
444
- s.has(u) || c.push(u);
445
- return { byTxid: r, missing: c, unexpected: a, duplicate: i };
449
+ i.has(u) || c.push(u);
450
+ return { byTxid: r, missing: c, unexpected: a, duplicate: s };
446
451
  }
447
452
  async function lt(t) {
448
453
  const {
449
454
  items: e,
450
455
  getTxid: n,
451
456
  batchCall: r,
452
- onItem: s,
453
- onMissing: i,
457
+ onItem: i,
458
+ onMissing: s,
454
459
  onDuplicate: a,
455
460
  onDuplicateBatch: c,
456
461
  onWholeBatchError: u,
@@ -484,12 +489,12 @@ async function lt(t) {
484
489
  c && k.size > 0 && c(k.size);
485
490
  for (const d of V.missing) {
486
491
  const b = S.get(d);
487
- b && i(b);
492
+ b && s(b);
488
493
  }
489
494
  for (const [d, b] of V.byTxid) {
490
495
  if (k.has(d)) continue;
491
- const q = S.get(d);
492
- q && s(q, {
496
+ const z = S.get(d);
497
+ z && i(z, {
493
498
  pegin_txid: d,
494
499
  result: b.result,
495
500
  error: b.error
@@ -499,8 +504,8 @@ async function lt(t) {
499
504
  }
500
505
  const je = "BIP0322-signed-message", Ke = "TapTweak", le = 32, Ue = 64;
501
506
  function ue(t, e) {
502
- const n = new TextEncoder().encode(t), r = z(n), s = new Uint8Array(r.length * 2 + e.length);
503
- return s.set(r, 0), s.set(r, r.length), s.set(e, r.length * 2), z(s);
507
+ const n = new TextEncoder().encode(t), r = W(n), i = new Uint8Array(r.length * 2 + e.length);
508
+ return i.set(r, 0), i.set(r, r.length), i.set(e, r.length * 2), W(i);
504
509
  }
505
510
  function Fe(t) {
506
511
  if (t.length !== le) return null;
@@ -510,11 +515,11 @@ function Fe(t) {
510
515
  function Me(t, e, n) {
511
516
  if (e.length !== le || n.length !== Ue) return !1;
512
517
  try {
513
- const r = ue(je, t), s = we.p2tr({
518
+ const r = ue(je, t), i = we.p2tr({
514
519
  internalPubkey: A.from(e)
515
520
  });
516
- if (!s.output) return !1;
517
- const i = s.output, a = 0, c = new U();
521
+ if (!i.output) return !1;
522
+ const s = i.output, a = 0, c = new U();
518
523
  c.version = 0, c.locktime = 0;
519
524
  const u = A.concat([
520
525
  A.from([0, 32]),
@@ -528,14 +533,14 @@ function Me(t, e, n) {
528
533
  0,
529
534
  // sequence = 0
530
535
  u
531
- ), c.addOutput(i, a);
536
+ ), c.addOutput(s, a);
532
537
  const h = new U();
533
538
  h.version = 0, h.locktime = 0;
534
539
  const f = c.getHash();
535
540
  h.addInput(f, 0, 0), h.addOutput(A.from([106]), a);
536
541
  const P = h.hashForWitnessV1(
537
542
  0,
538
- [i],
543
+ [s],
539
544
  [a],
540
545
  U.SIGHASH_DEFAULT
541
546
  ), x = Fe(e);
@@ -550,33 +555,33 @@ function H(t, e) {
550
555
  if (r < 24n) return new Uint8Array([n | Number(r)]);
551
556
  if (r < 0x100n) return new Uint8Array([n | 24, Number(r)]);
552
557
  if (r < 0x10000n) {
553
- const i = Number(r);
554
- return new Uint8Array([n | 25, i >>> 8 & 255, i & 255]);
558
+ const s = Number(r);
559
+ return new Uint8Array([n | 25, s >>> 8 & 255, s & 255]);
555
560
  }
556
561
  if (r < 0x100000000n) {
557
- const i = Number(r);
562
+ const s = Number(r);
558
563
  return new Uint8Array([
559
564
  n | 26,
560
- i >>> 24 & 255,
561
- i >>> 16 & 255,
562
- i >>> 8 & 255,
563
- i & 255
565
+ s >>> 24 & 255,
566
+ s >>> 16 & 255,
567
+ s >>> 8 & 255,
568
+ s & 255
564
569
  ]);
565
570
  }
566
- const s = new Uint8Array(9);
567
- s[0] = n | 27;
568
- for (let i = 7; i >= 0; i--)
569
- s[1 + i] = Number(r >> BigInt((7 - i) * 8)) & 255;
570
- return s;
571
+ const i = new Uint8Array(9);
572
+ i[0] = n | 27;
573
+ for (let s = 7; s >= 0; s--)
574
+ i[1 + s] = Number(r >> BigInt((7 - s) * 8)) & 255;
575
+ return i;
571
576
  }
572
577
  function he(...t) {
573
- const e = t.reduce((s, i) => s + i.length, 0), n = new Uint8Array(e);
578
+ const e = t.reduce((i, s) => i + s.length, 0), n = new Uint8Array(e);
574
579
  let r = 0;
575
- for (const s of t)
576
- n.set(s, r), r += s.length;
580
+ for (const i of t)
581
+ n.set(i, r), r += i.length;
577
582
  return n;
578
583
  }
579
- function Q(t) {
584
+ function J(t) {
580
585
  const n = [H(4, t.length)];
581
586
  for (const r of t)
582
587
  n.push(H(0, r));
@@ -587,8 +592,8 @@ function Le(t, e, n) {
587
592
  throw new Error(
588
593
  `encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${n}`
589
594
  );
590
- const r = H(4, 3), s = Q(t), i = Q(e), a = H(0, n);
591
- return he(r, s, i, a);
595
+ const r = H(4, 3), i = J(t), s = J(e), a = H(0, n);
596
+ return he(r, i, s, a);
592
597
  }
593
598
  const Ge = new TextEncoder().encode(
594
599
  "btc-auth.server-identity.v1"
@@ -605,10 +610,10 @@ function E(t) {
605
610
  return e;
606
611
  }
607
612
  function qe(t) {
608
- const { proof: e, pinnedServerPubkey: n, now: r } = t, s = t.maxLifetimeSecs ?? Xe, i = C(n).toLowerCase();
609
- if (i.length !== R || !T.test(i))
613
+ const { proof: e, pinnedServerPubkey: n, now: r } = t, i = t.maxLifetimeSecs ?? Xe, s = C(n).toLowerCase();
614
+ if (s.length !== R || !T.test(s))
610
615
  throw new g(
611
- `pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,
616
+ `pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
612
617
  "invalid_pubkey_encoding"
613
618
  );
614
619
  const a = C(e.server_pubkey).toLowerCase();
@@ -617,9 +622,9 @@ function qe(t) {
617
622
  `server_pubkey must be 32-byte hex; got ${a.length} chars`,
618
623
  "invalid_pubkey_encoding"
619
624
  );
620
- if (a !== i)
625
+ if (a !== s)
621
626
  throw new g(
622
- `server_pubkey does not match pinned value: expected ${i}, got ${a}`,
627
+ `server_pubkey does not match pinned value: expected ${s}, got ${a}`,
623
628
  "pinned_pubkey_mismatch"
624
629
  );
625
630
  if (!Number.isSafeInteger(e.expires_at))
@@ -637,14 +642,14 @@ function qe(t) {
637
642
  `server identity proof expired at ${e.expires_at}, now ${r}`,
638
643
  "expired"
639
644
  );
640
- if (!Number.isSafeInteger(s) || s <= 0)
645
+ if (!Number.isSafeInteger(i) || i <= 0)
641
646
  throw new g(
642
- `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,
647
+ `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
643
648
  "invalid_max_lifetime"
644
649
  );
645
- if (e.expires_at - r > s)
650
+ if (e.expires_at - r > i)
646
651
  throw new g(
647
- `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${s}s`,
652
+ `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${i}s`,
648
653
  "expires_too_far"
649
654
  );
650
655
  const c = C(e.ephemeral_pubkey).toLowerCase();
@@ -689,14 +694,14 @@ const ze = /* @__PURE__ */ new Set([
689
694
  "vaultProvider_requestDepositorClaimerArtifacts"
690
695
  ]), We = 6e4, G = "auth_createDepositorToken";
691
696
  function de(t, e) {
692
- return new re({
697
+ return new se({
693
698
  baseUrl: t,
694
699
  timeout: We,
695
700
  headers: e,
696
701
  retryableFor: (n) => n === G
697
702
  });
698
703
  }
699
- const J = 4102444800, Qe = 30;
704
+ const Y = 4102444800, Qe = 30;
700
705
  class Je {
701
706
  constructor(e) {
702
707
  // `client` is the only mutable field — see `setClient`. The
@@ -766,16 +771,16 @@ class Je {
766
771
  throw new Error(
767
772
  `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`
768
773
  );
769
- const s = this.now();
770
- if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= s || r.expires_at > J)
774
+ const i = this.now();
775
+ if (!Number.isSafeInteger(r.expires_at) || r.expires_at <= i || r.expires_at > Y)
771
776
  throw new Error(
772
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${s}, ${J}])`
777
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${i}, ${Y}])`
773
778
  );
774
- const i = {
779
+ const s = {
775
780
  token: r.token,
776
781
  expiresAt: r.expires_at
777
782
  };
778
- return this.cached = i, i;
783
+ return this.cached = s, s;
779
784
  } finally {
780
785
  this.inFlight = null;
781
786
  }
@@ -892,7 +897,7 @@ async function dt(t, e) {
892
897
  applicationRegistry: r
893
898
  };
894
899
  }
895
- const M = 65535, Y = 1e4, O = 4294967295, Z = 255;
900
+ const M = 65535, Z = 1e4, O = 4294967295, ee = 255;
896
901
  function X(t) {
897
902
  if (!Number.isInteger(t) || t < 0 || t > O)
898
903
  throw new Error(
@@ -921,8 +926,8 @@ function N(t) {
921
926
  `babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`
922
927
  ), t.babeInstancesToFinalize > t.babeTotalInstances && e.push(
923
928
  `babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`
924
- ), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > Y) && e.push(
925
- `minVpCommissionBps must be in [0, ${Y}], got ${t.minVpCommissionBps}`
929
+ ), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > Z) && e.push(
930
+ `minVpCommissionBps must be in [0, ${Z}], got ${t.minVpCommissionBps}`
926
931
  ), e.length > 0)
927
932
  throw new Error(
928
933
  `Invalid offchain protocol parameters: ${e.join("; ")}`
@@ -938,8 +943,8 @@ function ge(t) {
938
943
  `pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`
939
944
  ), t.pegInActivationTimeout <= 0n && e.push(
940
945
  `pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`
941
- ), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > Z) && e.push(
942
- `maxHtlcOutputCount must be an integer in [1, ${Z}], got ${t.maxHtlcOutputCount}`
946
+ ), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > ee) && e.push(
947
+ `maxHtlcOutputCount must be an integer in [1, ${ee}], got ${t.maxHtlcOutputCount}`
943
948
  ), e.length > 0)
944
949
  throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`);
945
950
  }
@@ -949,7 +954,7 @@ function Ze(t) {
949
954
  `Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`
950
955
  );
951
956
  }
952
- const ee = 65535;
957
+ const te = 65535;
953
958
  function B(t) {
954
959
  return {
955
960
  timelockAssert: t.timelockAssert,
@@ -967,7 +972,7 @@ function B(t) {
967
972
  minPrepeginDepth: t.minPrepeginDepth
968
973
  };
969
974
  }
970
- function te(t) {
975
+ function ne(t) {
971
976
  return {
972
977
  minimumPegInAmount: t.minimumPegInAmount,
973
978
  maxPegInAmount: t.maxPegInAmount,
@@ -976,10 +981,10 @@ function te(t) {
976
981
  maxHtlcOutputCount: t.maxHtlcOutputCount
977
982
  };
978
983
  }
979
- function ne(t) {
980
- if (t > BigInt(ee))
984
+ function re(t) {
985
+ if (t > BigInt(te))
981
986
  throw new Error(
982
- `timelockAssert value ${t} exceeds uint16 max (${ee})`
987
+ `timelockAssert value ${t} exceeds uint16 max (${te})`
983
988
  );
984
989
  return Number(t);
985
990
  }
@@ -992,7 +997,7 @@ class pt {
992
997
  address: this.contractAddress,
993
998
  abi: _,
994
999
  functionName: "getTBVProtocolParams"
995
- }), n = te(e);
1000
+ }), n = ne(e);
996
1001
  return ge(n), n;
997
1002
  }
998
1003
  async getLatestOffchainParams() {
@@ -1022,7 +1027,7 @@ class pt {
1022
1027
  }
1023
1028
  async getTimelockPeginByVersion(e) {
1024
1029
  const n = await this.getOffchainParamsByVersion(e);
1025
- return ne(n.timelockAssert);
1030
+ return re(n.timelockAssert);
1026
1031
  }
1027
1032
  /**
1028
1033
  * Read TBV protocol params, latest offchain params, and the latest version
@@ -1051,19 +1056,19 @@ class pt {
1051
1056
  }
1052
1057
  ],
1053
1058
  allowFailure: !1
1054
- }), n = te(e[0]), r = B(e[1]), s = Number(e[2]), i = {
1059
+ }), n = ne(e[0]), r = B(e[1]), i = Number(e[2]), s = {
1055
1060
  minimumPegInAmount: n.minimumPegInAmount,
1056
1061
  maxPegInAmount: n.maxPegInAmount,
1057
1062
  pegInAckTimeout: n.pegInAckTimeout,
1058
1063
  pegInActivationTimeout: n.pegInActivationTimeout,
1059
1064
  maxHtlcOutputCount: n.maxHtlcOutputCount,
1060
- timelockPegin: ne(r.timelockAssert),
1065
+ timelockPegin: re(r.timelockAssert),
1061
1066
  timelockRefund: r.tRefund,
1062
1067
  minVpCommissionBps: r.minVpCommissionBps,
1063
1068
  offchainParams: r,
1064
- offchainParamsVersion: s
1069
+ offchainParamsVersion: i
1065
1070
  };
1066
- return Ze(i), i;
1071
+ return Ze(s), s;
1067
1072
  }
1068
1073
  /**
1069
1074
  * Fetch every historical offchain params version in a single multicall.
@@ -1079,17 +1084,17 @@ class pt {
1079
1084
  const n = await this.getLatestOffchainParamsVersion();
1080
1085
  if (n === 0)
1081
1086
  return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
1082
- const r = Array.from({ length: n }, (c, u) => u + 1), s = r.map((c) => ({
1087
+ const r = Array.from({ length: n }, (c, u) => u + 1), i = r.map((c) => ({
1083
1088
  address: this.contractAddress,
1084
1089
  abi: _,
1085
1090
  functionName: "getOffchainParamsByVersion",
1086
1091
  args: [c]
1087
- })), i = await this.publicClient.multicall({
1088
- contracts: s,
1092
+ })), s = await this.publicClient.multicall({
1093
+ contracts: i,
1089
1094
  allowFailure: !1
1090
1095
  }), a = /* @__PURE__ */ new Map();
1091
1096
  for (let c = 0; c < r.length; c++) {
1092
- const u = B(i[c]);
1097
+ const u = B(s[c]);
1093
1098
  try {
1094
1099
  N(u), a.set(r[c], u);
1095
1100
  } catch (h) {
@@ -1189,12 +1194,12 @@ class mt {
1189
1194
  throw new Error(
1190
1195
  `getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0, 2)}")`
1191
1196
  );
1192
- const s = r.slice(2);
1193
- if (!j.isXOnlyPoint(Pe(s)))
1197
+ const i = r.slice(2);
1198
+ if (!j.isXOnlyPoint(Pe(i)))
1194
1199
  throw new Error(
1195
1200
  `getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`
1196
1201
  );
1197
- return s;
1202
+ return i;
1198
1203
  }
1199
1204
  async getVaultBasicInfo(e) {
1200
1205
  const n = await this.publicClient.readContract({
@@ -1243,24 +1248,24 @@ class mt {
1243
1248
  args: [r]
1244
1249
  })),
1245
1250
  allowFailure: !1
1246
- })).map((r, s) => {
1247
- const i = r;
1248
- if (!i.depositorSignedPeginTx || i.depositorSignedPeginTx === "0x")
1251
+ })).map((r, i) => {
1252
+ const s = r;
1253
+ if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
1249
1254
  throw new Error(
1250
- `Vault ${e[s]} not found on-chain or has no pegin transaction`
1255
+ `Vault ${e[i]} not found on-chain or has no pegin transaction`
1251
1256
  );
1252
1257
  return {
1253
- depositorSignedPeginTx: i.depositorSignedPeginTx,
1254
- universalChallengersVersion: i.universalChallengersVersion,
1255
- appVaultKeepersVersion: i.appVaultKeepersVersion,
1256
- offchainParamsVersion: i.offchainParamsVersion,
1257
- verifiedAt: i.verifiedAt,
1258
- depositorWotsPkHash: i.depositorWotsPkHash,
1259
- hashlock: i.hashlock,
1260
- htlcVout: i.htlcVout,
1261
- depositorPopSignature: i.depositorPopSignature,
1262
- prePeginTxHash: i.prePeginTxHash,
1263
- vaultProviderCommissionBps: i.vaultProviderCommissionBps
1258
+ depositorSignedPeginTx: s.depositorSignedPeginTx,
1259
+ universalChallengersVersion: s.universalChallengersVersion,
1260
+ appVaultKeepersVersion: s.appVaultKeepersVersion,
1261
+ offchainParamsVersion: s.offchainParamsVersion,
1262
+ verifiedAt: s.verifiedAt,
1263
+ depositorWotsPkHash: s.depositorWotsPkHash,
1264
+ hashlock: s.hashlock,
1265
+ htlcVout: s.htlcVout,
1266
+ depositorPopSignature: s.depositorPopSignature,
1267
+ prePeginTxHash: s.prePeginTxHash,
1268
+ vaultProviderCommissionBps: s.vaultProviderCommissionBps
1264
1269
  };
1265
1270
  });
1266
1271
  }
@@ -1290,13 +1295,13 @@ class mt {
1290
1295
  })),
1291
1296
  allowFailure: !1
1292
1297
  })).map((r) => {
1293
- const s = r;
1294
- if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
1298
+ const i = r;
1299
+ if (!i.depositorSignedPeginTx || i.depositorSignedPeginTx === "0x")
1295
1300
  throw new Error(
1296
1301
  "Vault not found on-chain or has no pegin transaction while reading offchain params version"
1297
1302
  );
1298
- const i = Number(s.offchainParamsVersion);
1299
- return X(i), i;
1303
+ const s = Number(i.offchainParamsVersion);
1304
+ return X(s), s;
1300
1305
  });
1301
1306
  }
1302
1307
  }
@@ -1320,4 +1325,4 @@ export {
1320
1325
  dt as r,
1321
1326
  ke as v
1322
1327
  };
1323
- //# sourceMappingURL=vault-registry-reader-CrLodprY.js.map
1328
+ //# sourceMappingURL=vault-registry-reader-Blhu9FW2.js.map