@babylonlabs-io/ts-sdk 0.69.1 → 0.70.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 (93) hide show
  1. package/dist/{PeginManager-BI3pacy0.js → PeginManager-BNtg6jgY.js} +5 -5
  2. package/dist/{PeginManager-BI3pacy0.js.map → PeginManager-BNtg6jgY.js.map} +1 -1
  3. package/dist/{PeginManager-DZE2nnjt.cjs → PeginManager-CvI99Uhd.cjs} +2 -2
  4. package/dist/{PeginManager-DZE2nnjt.cjs.map → PeginManager-CvI99Uhd.cjs.map} +1 -1
  5. package/dist/{batchPoll-Bc_UKaTz.js → batchPoll-BM4iQ9jT.js} +3 -3
  6. package/dist/{batchPoll-Bc_UKaTz.js.map → batchPoll-BM4iQ9jT.js.map} +1 -1
  7. package/dist/{batchPoll-C9cZ5usJ.cjs → batchPoll-cqpEfBjr.cjs} +2 -2
  8. package/dist/{batchPoll-C9cZ5usJ.cjs.map → batchPoll-cqpEfBjr.cjs.map} +1 -1
  9. package/dist/buildAndBroadcastReclaim-iNJfx0ZG.cjs +2 -0
  10. package/dist/buildAndBroadcastReclaim-iNJfx0ZG.cjs.map +1 -0
  11. package/dist/{buildAndBroadcastRefund-DY4ZZcFL.js → buildAndBroadcastReclaim-kBHwOL02.js} +692 -598
  12. package/dist/buildAndBroadcastReclaim-kBHwOL02.js.map +1 -0
  13. package/dist/constants-BCdDRd_Y.cjs +2 -0
  14. package/dist/constants-BCdDRd_Y.cjs.map +1 -0
  15. package/dist/constants-DRiWbItj.js +24 -0
  16. package/dist/constants-DRiWbItj.js.map +1 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +256 -244
  19. package/dist/{mempoolApi-71R_CNZa.js → mempoolApi-CfOFmov6.js} +2 -2
  20. package/dist/{mempoolApi-71R_CNZa.js.map → mempoolApi-CfOFmov6.js.map} +1 -1
  21. package/dist/{mempoolApi-BJN9fGEd.cjs → mempoolApi-Q90mz17e.cjs} +2 -2
  22. package/dist/{mempoolApi-BJN9fGEd.cjs.map → mempoolApi-Q90mz17e.cjs.map} +1 -1
  23. package/dist/noPayout-BKP3mRu3.cjs +2 -0
  24. package/dist/noPayout-BKP3mRu3.cjs.map +1 -0
  25. package/dist/noPayout-BdATUPjF.js +280 -0
  26. package/dist/noPayout-BdATUPjF.js.map +1 -0
  27. package/dist/signPsbtsWithFallback-Bo1PJX90.cjs +2 -0
  28. package/dist/signPsbtsWithFallback-Bo1PJX90.cjs.map +1 -0
  29. package/dist/{signPsbtsWithFallback-DCZO2h6i.js → signPsbtsWithFallback-X6ivsbh7.js} +56 -47
  30. package/dist/signPsbtsWithFallback-X6ivsbh7.js.map +1 -0
  31. package/dist/tbv/core/clients/index.cjs +1 -1
  32. package/dist/tbv/core/clients/index.js +2 -2
  33. package/dist/tbv/core/index.cjs +1 -1
  34. package/dist/tbv/core/index.js +255 -243
  35. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  36. package/dist/tbv/core/managers/index.cjs +1 -1
  37. package/dist/tbv/core/managers/index.js +2 -2
  38. package/dist/tbv/core/primitives/index.cjs +1 -1
  39. package/dist/tbv/core/primitives/index.d.ts +4 -0
  40. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  41. package/dist/tbv/core/primitives/index.js +52 -46
  42. package/dist/tbv/core/primitives/psbt/__tests__/depositorClaim.test.d.ts +16 -0
  43. package/dist/tbv/core/primitives/psbt/__tests__/depositorClaim.test.d.ts.map +1 -0
  44. package/dist/tbv/core/primitives/psbt/__tests__/reclaim.test.d.ts +10 -0
  45. package/dist/tbv/core/primitives/psbt/__tests__/reclaim.test.d.ts.map +1 -0
  46. package/dist/tbv/core/primitives/psbt/constants.d.ts +7 -0
  47. package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
  48. package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts +47 -0
  49. package/dist/tbv/core/primitives/psbt/depositorClaim.d.ts.map +1 -0
  50. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  51. package/dist/tbv/core/primitives/psbt/reclaim.d.ts +93 -0
  52. package/dist/tbv/core/primitives/psbt/reclaim.d.ts.map +1 -0
  53. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  54. package/dist/tbv/core/services/index.cjs +1 -1
  55. package/dist/tbv/core/services/index.d.ts +1 -0
  56. package/dist/tbv/core/services/index.d.ts.map +1 -1
  57. package/dist/tbv/core/services/index.js +50 -44
  58. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.test.d.ts +9 -0
  59. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.test.d.ts.map +1 -0
  60. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts +79 -0
  61. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts.map +1 -0
  62. package/dist/tbv/core/services/reclaim/errors.d.ts +22 -0
  63. package/dist/tbv/core/services/reclaim/errors.d.ts.map +1 -0
  64. package/dist/tbv/core/services/reclaim/index.d.ts +9 -0
  65. package/dist/tbv/core/services/reclaim/index.d.ts.map +1 -0
  66. package/dist/tbv/index.cjs +1 -1
  67. package/dist/tbv/index.js +255 -243
  68. package/dist/{toRefundInputs-B62WZ9co.cjs → toRefundInputs-BJojfg3k.cjs} +2 -2
  69. package/dist/{toRefundInputs-B62WZ9co.cjs.map → toRefundInputs-BJojfg3k.cjs.map} +1 -1
  70. package/dist/{toRefundInputs-amYZu79x.js → toRefundInputs-DPNYBFkP.js} +4 -4
  71. package/dist/{toRefundInputs-amYZu79x.js.map → toRefundInputs-DPNYBFkP.js.map} +1 -1
  72. package/dist/{verifyScriptPathSchnorrSignature-Dy9gF5RF.js → verifyScriptPathSchnorrSignature-CQYucnJA.js} +143 -125
  73. package/dist/verifyScriptPathSchnorrSignature-CQYucnJA.js.map +1 -0
  74. package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs +2 -0
  75. package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs.map +1 -0
  76. package/package.json +1 -1
  77. package/dist/buildAndBroadcastRefund-CPPGvzXb.cjs +0 -2
  78. package/dist/buildAndBroadcastRefund-CPPGvzXb.cjs.map +0 -1
  79. package/dist/buildAndBroadcastRefund-DY4ZZcFL.js.map +0 -1
  80. package/dist/constants-DU5CGcqO.cjs +0 -2
  81. package/dist/constants-DU5CGcqO.cjs.map +0 -1
  82. package/dist/constants-GjWXdaqV.js +0 -23
  83. package/dist/constants-GjWXdaqV.js.map +0 -1
  84. package/dist/noPayout-CXn-geIS.js +0 -178
  85. package/dist/noPayout-CXn-geIS.js.map +0 -1
  86. package/dist/noPayout-Ox27Td9x.cjs +0 -2
  87. package/dist/noPayout-Ox27Td9x.cjs.map +0 -1
  88. package/dist/signPsbtsWithFallback-C5cVgYhh.cjs +0 -2
  89. package/dist/signPsbtsWithFallback-C5cVgYhh.cjs.map +0 -1
  90. package/dist/signPsbtsWithFallback-DCZO2h6i.js.map +0 -1
  91. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +0 -1
  92. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +0 -2
  93. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +0 -1
@@ -1,14 +1,14 @@
1
- import { computeMinClaimValue as se, peginP2aAnchorOutput as ue, computeMinPeginFee as pe, buildPeginTxFromPrePegin as Pe, createPrePeginTransaction as fe, validatePeginP2aAnchor as ge, tapInternalPubkey as V, createPayoutConnector as we, computePayoutFeeFloor as ve, getAssertPayoutScriptInfo as $e } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
- import { Buffer as a } from "buffer";
3
- import { Transaction as E, script as ye, opcodes as me, payments as Se, crypto as L, Psbt as _ } from "bitcoinjs-lib";
1
+ import { computeMinClaimValue as se, peginP2aAnchorOutput as ue, computeMinPeginFee as pe, tapInternalPubkey as V, buildPeginTxFromPrePegin as Pe, createPrePeginTransaction as fe, validatePeginP2aAnchor as ge, createPayoutConnector as we, computePayoutFeeFloor as ve, getAssertPayoutScriptInfo as ye } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
+ import { script as $e, opcodes as me, payments as Se, Transaction as E, crypto as L, Psbt as _ } from "bitcoinjs-lib";
4
3
  import { c as K, d as xe } from "./fundPeginTransaction-B2wyjqp0.js";
5
- import { p as Ee, s as p, u as H, h as S, j as Ce, T as C, d as be, S as B, X as N } from "./bitcoin-Ch_jxnDa.js";
6
- import { D as U, P as M, b as F, c as q, M as W, d as X, e as Ae, A as ce, B as ke, V as _e, N as z } from "./constants-GjWXdaqV.js";
4
+ import { p as Ee, s as p, h as S, T as b, u as H, j as be, d as Ce, S as B, X as N } from "./bitcoin-Ch_jxnDa.js";
5
+ import { Buffer as a } from "buffer";
6
+ import { b as U, P as M, c as F, d as q, M as W, e as X, f as ke, A as ce, B as Ae, V as _e, N as z } from "./constants-DRiWbItj.js";
7
7
  import * as ae from "@bitcoin-js/tiny-secp256k1-asmjs";
8
8
  function x(e) {
9
9
  return Ee(e).toLowerCase();
10
10
  }
11
- function Et(e, t, o) {
11
+ function bt(e, t, o) {
12
12
  const n = /* @__PURE__ */ new Set();
13
13
  n.add(x(e));
14
14
  for (const i of t)
@@ -124,7 +124,36 @@ function Ve(e, t, o) {
124
124
  );
125
125
  }
126
126
  }
127
- const D = 64, Le = /^[0-9a-fA-F]+$/;
127
+ const Le = 1;
128
+ function Oe(e) {
129
+ const t = p(e);
130
+ if (!/^[0-9a-fA-F]{64}$/.test(t))
131
+ throw new Error(
132
+ "Invalid depositor pubkey for the depositor-claim script: must be an x-only key of 64 hex characters (32 bytes)."
133
+ );
134
+ const o = $e.compile([
135
+ a.from(S(t)),
136
+ me.OP_CHECKSIG
137
+ ]), n = a.from(V), i = { output: o, redeemVersion: b }, { output: r, witness: s } = Se.p2tr({
138
+ internalPubkey: n,
139
+ scriptTree: { output: o },
140
+ redeem: i
141
+ });
142
+ if (!r)
143
+ throw new Error(
144
+ "Failed to derive the depositor-claim P2TR scriptPubKey for PegIn output validation"
145
+ );
146
+ const u = s == null ? void 0 : s[s.length - 1];
147
+ if (!u)
148
+ throw new Error(
149
+ "Failed to derive the depositor-claim tapleaf control block; refusing to build an unspendable input"
150
+ );
151
+ return { scriptPubKey: r, leafScript: o, controlBlock: u, internalKey: n };
152
+ }
153
+ function He(e) {
154
+ return Oe(e).scriptPubKey;
155
+ }
156
+ const D = 64, Re = /^[0-9a-fA-F]+$/;
128
157
  async function Ct(e) {
129
158
  const t = le(e.authAnchorHash), o = await fe({
130
159
  txGraphVersion: e.vaultCoreVersion,
@@ -167,13 +196,13 @@ async function Ct(e) {
167
196
  function le(e) {
168
197
  if (e === void 0) return;
169
198
  const t = e.startsWith("0x") || e.startsWith("0X") ? e.slice(2) : e;
170
- if (t.length !== D || !Le.test(t))
199
+ if (t.length !== D || !Re.test(t))
171
200
  throw new Error(
172
201
  `authAnchorHash must be 32-byte hex (${D} chars, no 0x prefix); got length ${t.length}`
173
202
  );
174
203
  return t.toLowerCase();
175
204
  }
176
- async function bt(e) {
205
+ async function kt(e) {
177
206
  const t = await Pe(
178
207
  {
179
208
  txGraphVersion: e.prePeginParams.vaultCoreVersion,
@@ -198,18 +227,18 @@ async function bt(e) {
198
227
  e.fundedPrePeginTxHex,
199
228
  e.htlcVout
200
229
  );
201
- return await Re(t, e), {
230
+ return await Be(t, e), {
202
231
  txHex: t.txHex,
203
232
  txid: t.txid,
204
233
  vaultScriptPubKey: t.vaultScriptPubKey,
205
234
  vaultValue: t.vaultValue
206
235
  };
207
236
  }
208
- const Oe = 2, He = 1;
209
- async function Re(e, t) {
237
+ const Ke = 2;
238
+ async function Be(e, t) {
210
239
  const o = t.prePeginParams.vaultCoreVersion;
211
240
  await ge(o, e.txHex);
212
- const n = await ue(o), i = Oe + (n ? 1 : 0), r = E.fromHex(p(e.txHex));
241
+ const n = await ue(o), i = Ke + (n ? 1 : 0), r = E.fromHex(p(e.txHex));
213
242
  if (r.ins.length !== 1)
214
243
  throw new Error(
215
244
  `PegIn tx has ${r.ins.length} input(s), expected exactly 1 (the Pre-PegIn HTLC outpoint).`
@@ -260,12 +289,12 @@ async function Re(e, t) {
260
289
  t.prePeginParams.councilQuorum,
261
290
  t.prePeginParams.councilSize,
262
291
  t.prePeginParams.feeRate
263
- ), v = r.outs[He];
292
+ ), v = r.outs[Le];
264
293
  if (BigInt(v.value) !== f)
265
294
  throw new Error(
266
295
  `Encoded PegIn depositor-claim output value ${v.value} does not match the independently computed claim value ${f} for vaultCoreVersion ${o}.`
267
296
  );
268
- const w = Ke(
297
+ const w = He(
269
298
  t.prePeginParams.depositorPubkey
270
299
  );
271
300
  if (!v.script.equals(w))
@@ -273,21 +302,7 @@ async function Re(e, t) {
273
302
  `Encoded PegIn depositor-claim output scriptPubKey ${v.script.toString("hex")} does not pay to the depositor's claim script (expected ${w.toString("hex")}).`
274
303
  );
275
304
  }
276
- function Ke(e) {
277
- const t = ye.compile([
278
- a.from(S(e)),
279
- me.OP_CHECKSIG
280
- ]), { output: o } = Se.p2tr({
281
- internalPubkey: a.from(V),
282
- scriptTree: { output: t }
283
- });
284
- if (!o)
285
- throw new Error(
286
- "Failed to derive the depositor-claim P2TR scriptPubKey for PegIn output validation"
287
- );
288
- return o;
289
- }
290
- async function Be(e) {
305
+ async function Ne(e) {
291
306
  const t = await we(
292
307
  {
293
308
  txGraphVersion: e.vaultCoreVersion,
@@ -307,72 +322,72 @@ async function Be(e) {
307
322
  payoutControlBlock: t.payoutControlBlock
308
323
  };
309
324
  }
310
- const G = 253, Ne = 254, Ue = 65535, Me = 4294967295, Fe = "TapLeaf", qe = "TapBranch", We = "TapTweak", A = 33, k = 32, Y = 128, Xe = 1, ze = 254, De = a.from([81, 32]);
311
- function Ge(e) {
325
+ const G = 253, Ue = 254, Me = 65535, Fe = 4294967295, qe = "TapLeaf", We = "TapBranch", Xe = "TapTweak", k = 33, A = 32, Y = 128, ze = 1, De = 254, Ge = a.from([81, 32]);
326
+ function Ye(e) {
312
327
  if (e < G)
313
328
  return a.from([e]);
314
- if (e <= Ue) {
329
+ if (e <= Me) {
315
330
  const t = a.alloc(2);
316
331
  return t.writeUInt16LE(e), a.concat([a.from([G]), t]);
317
332
  }
318
- if (e <= Me) {
333
+ if (e <= Fe) {
319
334
  const t = a.alloc(4);
320
- return t.writeUInt32LE(e), a.concat([a.from([Ne]), t]);
335
+ return t.writeUInt32LE(e), a.concat([a.from([Ue]), t]);
321
336
  }
322
337
  throw new Error(`Script too large to encode as CompactSize: ${e} bytes`);
323
338
  }
324
339
  function he(e, t) {
325
340
  const o = a.concat([
326
341
  a.from([e]),
327
- Ge(t.length),
342
+ Ye(t.length),
328
343
  a.from(t)
329
344
  ]);
330
- return L.taggedHash(Fe, o);
345
+ return L.taggedHash(qe, o);
331
346
  }
332
- function Ye(e) {
333
- const { leafVersion: t, script: o, controlBlock: n } = e, i = n.length - A;
334
- if (i < 0 || i % k !== 0 || i / k > Y)
347
+ function Qe(e) {
348
+ const { leafVersion: t, script: o, controlBlock: n } = e, i = n.length - k;
349
+ if (i < 0 || i % A !== 0 || i / A > Y)
335
350
  throw new Error(
336
- `Malformed Taproot control block: length ${n.length} must be ${A} + 32*m with 0 <= m <= ${Y}`
351
+ `Malformed Taproot control block: length ${n.length} must be ${k} + 32*m with 0 <= m <= ${Y}`
337
352
  );
338
- const r = n[0] & ze;
353
+ const r = n[0] & De;
339
354
  if (r !== t)
340
355
  throw new Error(
341
356
  `Taproot control block leaf version 0x${r.toString(16)} does not match the tapLeafScript leaf version 0x${t.toString(16)}`
342
357
  );
343
358
  const s = a.from(
344
- n.subarray(1, A)
359
+ n.subarray(1, k)
345
360
  );
346
361
  let u = he(t, o);
347
- for (let l = A; l < n.length; l += k) {
362
+ for (let l = k; l < n.length; l += A) {
348
363
  const P = a.from(
349
- n.subarray(l, l + k)
364
+ n.subarray(l, l + A)
350
365
  );
351
366
  u = L.taggedHash(
352
- qe,
367
+ We,
353
368
  a.compare(u, P) <= 0 ? a.concat([u, P]) : a.concat([P, u])
354
369
  );
355
370
  }
356
371
  const h = L.taggedHash(
357
- We,
372
+ Xe,
358
373
  a.concat([s, u])
359
374
  ), c = ae.xOnlyPointAddTweak(s, h);
360
375
  if (c === null)
361
376
  throw new Error(
362
377
  "Taproot control block does not yield a valid output key (tweak is off-curve)"
363
378
  );
364
- const d = n[0] & Xe;
379
+ const d = n[0] & ze;
365
380
  if (c.parity !== d)
366
381
  throw new Error(
367
382
  `Taproot output key parity ${c.parity} contradicts the control block's parity bit ${d}`
368
383
  );
369
384
  return a.concat([
370
- De,
385
+ Ge,
371
386
  a.from(c.xOnlyPubkey)
372
387
  ]);
373
388
  }
374
- const Qe = 256, Ze = 1500, Q = 256, Z = 0xffffffffn, je = 500, Je = 55, et = 34;
375
- function tt(e) {
389
+ const Ze = 256, je = 1500, Q = 256, Z = 0xffffffffn, Je = 500, et = 55, tt = 34;
390
+ function ot(e) {
376
391
  if (typeof e.protocolFeeRate != "bigint" || e.protocolFeeRate <= 0n || e.protocolFeeRate > Z)
377
392
  throw new Error(
378
393
  `protocolFeeRate must be in [1, ${Z}] sat/vB, got ${e.protocolFeeRate}`
@@ -381,13 +396,13 @@ function tt(e) {
381
396
  [
382
397
  "keepers",
383
398
  e.numVaultKeepers,
384
- Qe,
399
+ Ze,
385
400
  "fee-floor model limit"
386
401
  ],
387
402
  [
388
403
  "challengers",
389
404
  e.numUniversalChallengers,
390
- Ze,
405
+ je,
391
406
  "protocol maximum"
392
407
  ]
393
408
  ])
@@ -400,8 +415,8 @@ function tt(e) {
400
415
  `councilSize must be an integer in [1, ${Q}], got ${e.councilSize}`
401
416
  );
402
417
  }
403
- async function ot(e, t) {
404
- const { implicitFeeSats: o, out0Len: n, out1Len: i } = t, r = e.numVaultKeepers + e.numUniversalChallengers, s = BigInt(o), u = Math.max(0, n - et), h = je + Je * r + u, c = e.protocolFeeRate * BigInt(h);
418
+ async function nt(e, t) {
419
+ const { implicitFeeSats: o, out0Len: n, out1Len: i } = t, r = e.numVaultKeepers + e.numUniversalChallengers, s = BigInt(o), u = Math.max(0, n - tt), h = Je + et * r + u, c = e.protocolFeeRate * BigInt(h);
405
420
  if (s > c)
406
421
  throw new Error(
407
422
  `Payout implicit fee ${o} sats exceeds the safety cap of ${c} sats (${e.protocolFeeRate} sat/vB x ${h} vB for ${r} participants); refusing to sign payout.`
@@ -421,21 +436,21 @@ async function ot(e, t) {
421
436
  `Payout implicit fee ${o} sats is below the floor of ${d} sats (the smallest fee any known vault-provider build produces for this shape); refusing to sign payout.`
422
437
  );
423
438
  }
424
- const nt = 22, rt = 34, it = 34, st = 25, ut = 23;
425
- function ct(e) {
426
- return e.length === nt * 2 && e.startsWith("0014");
427
- }
439
+ const rt = 22, it = 34, st = 34, ut = 25, ct = 23;
428
440
  function at(e) {
429
- return e.length === rt * 2 && e.startsWith("0020");
441
+ return e.length === rt * 2 && e.startsWith("0014");
430
442
  }
431
443
  function lt(e) {
432
- return e.length === it * 2 && e.startsWith("5120");
444
+ return e.length === it * 2 && e.startsWith("0020");
433
445
  }
434
446
  function ht(e) {
435
- return e.length === st * 2 && e.startsWith("76a914") && e.endsWith("88ac");
447
+ return e.length === st * 2 && e.startsWith("5120");
436
448
  }
437
449
  function dt(e) {
438
- return e.length === ut * 2 && e.startsWith("a914") && e.endsWith("87");
450
+ return e.length === ut * 2 && e.startsWith("76a914") && e.endsWith("88ac");
451
+ }
452
+ function pt(e) {
453
+ return e.length === ct * 2 && e.startsWith("a914") && e.endsWith("87");
439
454
  }
440
455
  function j(e, t) {
441
456
  const o = p(e).toLowerCase();
@@ -447,7 +462,7 @@ function j(e, t) {
447
462
  throw new Error(
448
463
  `${t} is an OP_RETURN output, which is provably unspendable`
449
464
  );
450
- if (!lt(o) && !ct(o) && !at(o) && !ht(o) && !dt(o))
465
+ if (!ht(o) && !at(o) && !lt(o) && !dt(o) && !pt(o))
451
466
  throw new Error(
452
467
  `${t} is not a standard scriptPubKey (expected P2TR, P2WPKH, P2WSH, P2PKH, or P2SH; got ${o.length / 2} bytes: ${o})`
453
468
  );
@@ -461,7 +476,7 @@ async function At(e) {
461
476
  councilSize: e.councilMembers.length,
462
477
  protocolFeeRate: e.protocolFeeRate
463
478
  };
464
- tt(t);
479
+ ot(t);
465
480
  const o = E.fromHex(p(e.payoutTxHex)), n = E.fromHex(p(e.peginTxHex)), i = E.fromHex(p(e.assertTxHex));
466
481
  if (o.ins.length !== U)
467
482
  throw new Error(
@@ -480,7 +495,7 @@ async function At(e) {
480
495
  0,
481
496
  n,
482
497
  "PegIn",
483
- Ae
498
+ ke
484
499
  );
485
500
  if (o.ins[0].sequence !== e.timelockPegin)
486
501
  throw new Error(
@@ -497,7 +512,7 @@ async function At(e) {
497
512
  throw new Error(
498
513
  `Payout input 1 sequence ${o.ins[1].sequence} must equal the Assert CSV timelock ${e.timelockAssert}; refusing to sign payout.`
499
514
  );
500
- const { out0Len: u, out1Len: h } = ft(
515
+ const { out0Len: u, out1Len: h } = gt(
501
516
  o,
502
517
  r.value,
503
518
  e
@@ -509,12 +524,12 @@ async function At(e) {
509
524
  `Payout outputs (${d} sats) exceed inputs (${c} sats); invalid transaction.`
510
525
  );
511
526
  const l = c - d;
512
- await ot(t, {
527
+ await nt(t, {
513
528
  implicitFeeSats: l,
514
529
  out0Len: u,
515
530
  out1Len: h
516
531
  });
517
- const P = await Be({
532
+ const P = await Ne({
518
533
  vaultCoreVersion: e.vaultCoreVersion,
519
534
  depositor: e.depositorBtcPubkey,
520
535
  vaultProvider: e.vaultProviderBtcPubkey,
@@ -522,9 +537,9 @@ async function At(e) {
522
537
  universalChallengers: e.universalChallengerBtcPubkeys,
523
538
  timelockPegin: e.timelockPegin,
524
539
  network: e.network
525
- }), f = await pt(e, s);
540
+ }), f = await Pt(e, s);
526
541
  return {
527
- psbtHex: Pt(
542
+ psbtHex: ft(
528
543
  o,
529
544
  r,
530
545
  s,
@@ -533,8 +548,8 @@ async function At(e) {
533
548
  )
534
549
  };
535
550
  }
536
- async function pt(e, t) {
537
- const { payoutScript: o, payoutControlBlock: n } = await $e({
551
+ async function Pt(e, t) {
552
+ const { payoutScript: o, payoutControlBlock: n } = await ye({
538
553
  txGraphVersion: e.vaultCoreVersion,
539
554
  claimer: p(e.claimerBtcPubkey).toLowerCase(),
540
555
  localChallengers: Te({
@@ -551,8 +566,8 @@ async function pt(e, t) {
551
566
  (u) => p(u).toLowerCase()
552
567
  ),
553
568
  councilQuorum: e.councilQuorum
554
- }), i = S(o), r = S(n), s = Ye({
555
- leafVersion: C,
569
+ }), i = S(o), r = S(n), s = Qe({
570
+ leafVersion: b,
556
571
  script: i,
557
572
  controlBlock: r
558
573
  });
@@ -577,7 +592,7 @@ function ee(e, t, o, n, i) {
577
592
  );
578
593
  return u;
579
594
  }
580
- function Pt(e, t, o, n, i) {
595
+ function ft(e, t, o, n, i) {
581
596
  const r = new _();
582
597
  r.setVersion(e.version), r.setLocktime(e.locktime);
583
598
  const [s, u] = e.ins;
@@ -591,7 +606,7 @@ function Pt(e, t, o, n, i) {
591
606
  },
592
607
  tapLeafScript: [
593
608
  {
594
- leafVersion: C,
609
+ leafVersion: b,
595
610
  script: a.from(S(n.payoutScript)),
596
611
  controlBlock: a.from(
597
612
  S(n.payoutControlBlock)
@@ -610,7 +625,7 @@ function Pt(e, t, o, n, i) {
610
625
  },
611
626
  tapLeafScript: [
612
627
  {
613
- leafVersion: C,
628
+ leafVersion: b,
614
629
  script: a.from(i.script),
615
630
  controlBlock: a.from(i.controlBlock)
616
631
  }
@@ -626,14 +641,14 @@ function Pt(e, t, o, n, i) {
626
641
  }
627
642
  function te(e, t) {
628
643
  const o = p(e).toLowerCase(), n = p(
629
- be(t)
644
+ Ce(t)
630
645
  ).toLowerCase();
631
646
  return o === n ? [o] : [o, n];
632
647
  }
633
648
  function oe(e, t) {
634
649
  return t.some((o) => e.equals(a.from(o, "hex")));
635
650
  }
636
- function ft(e, t, o) {
651
+ function gt(e, t, o) {
637
652
  const {
638
653
  claimerBtcPubkey: n,
639
654
  vaultProviderBtcPubkey: i,
@@ -644,16 +659,16 @@ function ft(e, t, o) {
644
659
  vkClaimerPayoutScriptPubKeys: c,
645
660
  vpCommissionScriptPubKey: d
646
661
  } = o;
647
- if (!Ce(u))
662
+ if (!be(u))
648
663
  throw new Error("Invalid registeredPayoutScriptPubKey: not valid hex");
649
664
  const l = p(n).toLowerCase(), P = p(i).toLowerCase(), f = p(r).toLowerCase(), v = s.map(
650
665
  (m) => p(m).toLowerCase()
651
666
  );
652
- let w, g, $;
667
+ let w, g, y;
653
668
  if (l === P)
654
- w = "vp-claimer", g = _e, $ = [p(u)];
669
+ w = "vp-claimer", g = _e, y = [p(u)];
655
670
  else if (l === f)
656
- w = "depositor-as-claimer", g = z, $ = [p(u)];
671
+ w = "depositor-as-claimer", g = z, y = [p(u)];
657
672
  else if (v.includes(l)) {
658
673
  w = "vk-claimer", g = z;
659
674
  const m = c[l];
@@ -664,7 +679,7 @@ function ft(e, t, o) {
664
679
  j(
665
680
  m,
666
681
  `Vault keeper payout script for claimer ${l}`
667
- ), $ = te(m, l);
682
+ ), y = te(m, l);
668
683
  } else
669
684
  throw new Error(
670
685
  `Unknown claimer pubkey ${l}: not VP, depositor, or a registered vault keeper`
@@ -673,9 +688,9 @@ function ft(e, t, o) {
673
688
  throw new Error(
674
689
  `Payout transaction has ${e.outs.length} output(s), expected exactly ${g} for role ${w}.`
675
690
  );
676
- if (!oe(e.outs[0].script, $))
691
+ if (!oe(e.outs[0].script, y))
677
692
  throw new Error(
678
- `Payout transaction output 0 does not pay the expected scriptPubKey for role ${w}. Accepted: ${$.join(" or ")}; got ${e.outs[0].script.toString("hex")}`
693
+ `Payout transaction output 0 does not pay the expected scriptPubKey for role ${w}. Accepted: ${y.join(" or ")}; got ${e.outs[0].script.toString("hex")}`
679
694
  );
680
695
  const T = g - 1;
681
696
  if (e.outs[T].value !== q)
@@ -700,22 +715,22 @@ function ft(e, t, o) {
700
715
  `commissionBps must be an integer in [0, ${W}), got ${h}`
701
716
  );
702
717
  const R = Math.floor(
703
- t * h / ke
718
+ t * h / Ae
704
719
  );
705
720
  if (e.outs[1].value > R)
706
721
  throw new Error(
707
722
  `Payout VP commission (out 1) value ${e.outs[1].value} sats exceeds cap ${R} sats (${h} bps of peginValue=${t})`
708
723
  );
709
724
  }
710
- const b = e.outs[0].script.length;
711
- if (b === 0 || b > X)
725
+ const C = e.outs[0].script.length;
726
+ if (C === 0 || C > X)
712
727
  throw new Error(
713
- `Payout receiver scriptPubKey length ${b} is outside the contract's registration cap [1, ${X}]; refusing to sign payout.`
728
+ `Payout receiver scriptPubKey length ${C} is outside the contract's registration cap [1, ${X}]; refusing to sign payout.`
714
729
  );
715
730
  const de = w === "vp-claimer" ? e.outs[1].script.length : void 0;
716
- return { out0Len: b, out1Len: de };
731
+ return { out0Len: C, out1Len: de };
717
732
  }
718
- function kt(e, t, o = 0) {
733
+ function _t(e, t, o = 0) {
719
734
  const n = _.fromHex(e);
720
735
  if (o >= n.data.inputs.length)
721
736
  throw new Error(
@@ -732,7 +747,7 @@ function kt(e, t, o = 0) {
732
747
  );
733
748
  }
734
749
  if (i.finalScriptWitness && i.finalScriptWitness.length > 0) {
735
- const r = gt(i.finalScriptWitness);
750
+ const r = wt(i.finalScriptWitness);
736
751
  if (r.length !== J)
737
752
  throw new Error(
738
753
  `Unexpected finalized witness stack size at input ${o}: expected ${J} items (signature, script, controlBlock), got ${r.length}`
@@ -752,7 +767,7 @@ function ne(e, t) {
752
767
  `Unexpected signature length at input ${t}: ${e.length}`
753
768
  );
754
769
  }
755
- function gt(e) {
770
+ function wt(e) {
756
771
  const t = [];
757
772
  let o = 0;
758
773
  const n = (s) => {
@@ -788,7 +803,7 @@ function gt(e) {
788
803
  );
789
804
  return t;
790
805
  }
791
- class y extends Error {
806
+ class $ extends Error {
792
807
  constructor(t) {
793
808
  super(
794
809
  `Wallet returned a PSBT for a different transaction: ${t}`
@@ -803,60 +818,60 @@ function re(e, t) {
803
818
  throw new Error(`Failed to parse ${e} PSBT: ${n}`);
804
819
  }
805
820
  }
806
- const wt = 8;
821
+ const vt = 8;
807
822
  function O(e) {
808
- return `${e.toString("hex").slice(0, wt)}…`;
823
+ return `${e.toString("hex").slice(0, vt)}…`;
809
824
  }
810
825
  function ie(e) {
811
826
  const t = a.from(e).reverse();
812
827
  return O(t);
813
828
  }
814
- function _t(e) {
829
+ function Tt(e) {
815
830
  const t = re("requested", e.requestedPsbtHex), o = re("returned", e.returnedPsbtHex);
816
831
  if (t.version !== o.version)
817
- throw new y(
832
+ throw new $(
818
833
  `tx version differs (requested=${t.version}, returned=${o.version})`
819
834
  );
820
835
  if (t.locktime !== o.locktime)
821
- throw new y(
836
+ throw new $(
822
837
  `tx locktime differs (requested=${t.locktime}, returned=${o.locktime})`
823
838
  );
824
839
  if (t.txInputs.length !== o.txInputs.length)
825
- throw new y(
840
+ throw new $(
826
841
  `input count differs (requested=${t.txInputs.length}, returned=${o.txInputs.length})`
827
842
  );
828
843
  if (t.txOutputs.length !== o.txOutputs.length)
829
- throw new y(
844
+ throw new $(
830
845
  `output count differs (requested=${t.txOutputs.length}, returned=${o.txOutputs.length})`
831
846
  );
832
847
  for (let n = 0; n < t.txInputs.length; n++) {
833
848
  const i = t.txInputs[n], r = o.txInputs[n];
834
849
  if (!i.hash.equals(r.hash))
835
- throw new y(
850
+ throw new $(
836
851
  `input ${n} prevout txid differs (requested=${ie(i.hash)}, returned=${ie(r.hash)})`
837
852
  );
838
853
  if (i.index !== r.index)
839
- throw new y(
854
+ throw new $(
840
855
  `input ${n} prevout vout differs (requested=${i.index}, returned=${r.index})`
841
856
  );
842
857
  if (i.sequence !== r.sequence)
843
- throw new y(
858
+ throw new $(
844
859
  `input ${n} sequence differs (requested=${i.sequence}, returned=${r.sequence})`
845
860
  );
846
861
  }
847
862
  for (let n = 0; n < t.txOutputs.length; n++) {
848
863
  const i = t.txOutputs[n], r = o.txOutputs[n];
849
864
  if (!i.script.equals(r.script))
850
- throw new y(
865
+ throw new $(
851
866
  `output ${n} scriptPubKey differs (requested=${O(i.script)}, returned=${O(r.script)})`
852
867
  );
853
868
  if (i.value !== r.value)
854
- throw new y(
869
+ throw new $(
855
870
  `output ${n} value differs (requested=${i.value}, returned=${r.value})`
856
871
  );
857
872
  }
858
873
  }
859
- function Tt(e) {
874
+ function It(e) {
860
875
  const { requestedPsbtHex: t, signatureHex: o, signerXOnlyPubkeyHex: n, inputIndex: i } = e, r = p(o);
861
876
  if (r.length !== B)
862
877
  throw new Error(
@@ -874,12 +889,12 @@ function Tt(e) {
874
889
  );
875
890
  const h = [], c = [];
876
891
  for (let g = 0; g < u.data.inputs.length; g++) {
877
- const $ = u.data.inputs[g].witnessUtxo;
878
- if (!$)
892
+ const y = u.data.inputs[g].witnessUtxo;
893
+ if (!y)
879
894
  throw new Error(
880
895
  `Cannot verify signature: input ${g} of the requested PSBT has no witnessUtxo (required to recompute the Taproot sighash).`
881
896
  );
882
- h.push($.script), c.push($.value);
897
+ h.push(y.script), c.push(y.value);
883
898
  }
884
899
  const d = u.data.inputs[i].tapLeafScript;
885
900
  if (!d || d.length !== 1)
@@ -887,9 +902,9 @@ function Tt(e) {
887
902
  `Cannot verify signature: input ${i} of the requested PSBT must have exactly one tapLeafScript, got ${(d == null ? void 0 : d.length) ?? 0}.`
888
903
  );
889
904
  const l = d[0];
890
- if (l.leafVersion !== C)
905
+ if (l.leafVersion !== b)
891
906
  throw new Error(
892
- `Cannot verify signature: input ${i} tapLeafScript has leaf version 0x${l.leafVersion.toString(16)}, expected 0x${C.toString(16)}.`
907
+ `Cannot verify signature: input ${i} tapLeafScript has leaf version 0x${l.leafVersion.toString(16)}, expected 0x${b.toString(16)}.`
893
908
  );
894
909
  const P = he(l.leafVersion, l.script), f = new E();
895
910
  f.version = u.version, f.locktime = u.locktime;
@@ -915,17 +930,20 @@ function Tt(e) {
915
930
  }
916
931
  export {
917
932
  I as H,
918
- y as P,
933
+ Le as P,
919
934
  Ct as a,
920
- bt as b,
921
- Et as c,
922
- At as d,
923
- kt as e,
924
- _t as f,
925
- Tt as g,
926
- Be as h,
927
- Ve as i,
928
- Te as j,
935
+ kt as b,
936
+ bt as c,
937
+ Oe as d,
938
+ He as e,
939
+ At as f,
940
+ _t as g,
941
+ $ as h,
942
+ Tt as i,
943
+ It as j,
944
+ Ne as k,
945
+ Ve as l,
946
+ Te as m,
929
947
  le as n
930
948
  };
931
- //# sourceMappingURL=verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map
949
+ //# sourceMappingURL=verifyScriptPathSchnorrSignature-CQYucnJA.js.map