@babylonlabs-io/ts-sdk 0.51.1 → 0.52.0

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 (63) hide show
  1. package/dist/{PayoutManager-D26nGR-e.js → PayoutManager-BwrV3xFW.js} +2 -2
  2. package/dist/{PayoutManager-D26nGR-e.js.map → PayoutManager-BwrV3xFW.js.map} +1 -1
  3. package/dist/{PayoutManager-BZVEyi10.cjs → PayoutManager-CBfHfLfz.cjs} +2 -2
  4. package/dist/{PayoutManager-BZVEyi10.cjs.map → PayoutManager-CBfHfLfz.cjs.map} +1 -1
  5. package/dist/{PeginManager-COxRVrxa.js → PeginManager-BGWNJYPk.js} +4 -4
  6. package/dist/{PeginManager-COxRVrxa.js.map → PeginManager-BGWNJYPk.js.map} +1 -1
  7. package/dist/{PeginManager-BvxfSwsr.cjs → PeginManager-DDp-ZRIa.cjs} +2 -2
  8. package/dist/{PeginManager-BvxfSwsr.cjs.map → PeginManager-DDp-ZRIa.cjs.map} +1 -1
  9. package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs +2 -0
  10. package/dist/buildAndBroadcastRefund-3MLyCOtv.cjs.map +1 -0
  11. package/dist/{buildAndBroadcastRefund-Bmz9WJuN.js → buildAndBroadcastRefund-BAT5A6MP.js} +111 -110
  12. package/dist/buildAndBroadcastRefund-BAT5A6MP.js.map +1 -0
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.js +191 -189
  15. package/dist/noPayout-ChPNKTbm.cjs +2 -0
  16. package/dist/noPayout-ChPNKTbm.cjs.map +1 -0
  17. package/dist/{noPayout-C1WCsqfd.js → noPayout-DVx3zxUz.js} +24 -22
  18. package/dist/noPayout-DVx3zxUz.js.map +1 -0
  19. package/dist/{peginInput-BPRB9tUi.js → peginInput-B5XDDHpy.js} +17 -15
  20. package/dist/peginInput-B5XDDHpy.js.map +1 -0
  21. package/dist/peginInput-De0C6aSj.cjs +2 -0
  22. package/dist/peginInput-De0C6aSj.cjs.map +1 -0
  23. package/dist/tbv/core/index.cjs +1 -1
  24. package/dist/tbv/core/index.js +189 -187
  25. package/dist/tbv/core/managers/index.cjs +1 -1
  26. package/dist/tbv/core/managers/index.js +2 -2
  27. package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts +7 -0
  28. package/dist/tbv/core/primitives/__tests__/txGraphVersion.test.d.ts.map +1 -0
  29. package/dist/tbv/core/primitives/index.cjs +1 -1
  30. package/dist/tbv/core/primitives/index.d.ts +2 -1
  31. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  32. package/dist/tbv/core/primitives/index.js +34 -32
  33. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  34. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  35. package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
  36. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  37. package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -1
  38. package/dist/tbv/core/primitives/txGraphVersion.d.ts +11 -0
  39. package/dist/tbv/core/primitives/txGraphVersion.d.ts.map +1 -0
  40. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  41. package/dist/tbv/core/services/index.cjs +1 -1
  42. package/dist/tbv/core/services/index.js +2 -2
  43. package/dist/tbv/core/vault-secrets/__tests__/expand.test.d.ts +5 -2
  44. package/dist/tbv/core/vault-secrets/__tests__/expand.test.d.ts.map +1 -1
  45. package/dist/tbv/index.cjs +1 -1
  46. package/dist/tbv/index.js +189 -187
  47. package/dist/{verifyScriptPathSchnorrSignature-CeZp6tMw.js → verifyScriptPathSchnorrSignature-BKECXOpa.js} +108 -97
  48. package/dist/verifyScriptPathSchnorrSignature-BKECXOpa.js.map +1 -0
  49. package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs +2 -0
  50. package/dist/verifyScriptPathSchnorrSignature-CVPh04ZI.cjs.map +1 -0
  51. package/package.json +3 -3
  52. package/dist/buildAndBroadcastRefund-Bmz9WJuN.js.map +0 -1
  53. package/dist/buildAndBroadcastRefund-ob1n2iB3.cjs +0 -2
  54. package/dist/buildAndBroadcastRefund-ob1n2iB3.cjs.map +0 -1
  55. package/dist/noPayout-C1WCsqfd.js.map +0 -1
  56. package/dist/noPayout-lyIRiUyG.cjs +0 -2
  57. package/dist/noPayout-lyIRiUyG.cjs.map +0 -1
  58. package/dist/peginInput-BPRB9tUi.js.map +0 -1
  59. package/dist/peginInput-DH6X4ITS.cjs +0 -2
  60. package/dist/peginInput-DH6X4ITS.cjs.map +0 -1
  61. package/dist/verifyScriptPathSchnorrSignature-CeZp6tMw.js.map +0 -1
  62. package/dist/verifyScriptPathSchnorrSignature-Cl7tu77P.cjs +0 -2
  63. package/dist/verifyScriptPathSchnorrSignature-Cl7tu77P.cjs.map +0 -1
@@ -1,11 +1,12 @@
1
- import { computeMinClaimValue as Q, buildPeginTxFromPrePegin as Z, createPrePeginTransaction as j, createPayoutConnector as J, tapInternalPubkey as ee } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
- import { c as L, d as te } from "./fundPeginTransaction-96FxwYYJ.js";
1
+ import { computeMinClaimValue as Z, buildPeginTxFromPrePegin as j, createPrePeginTransaction as J, createPayoutConnector as ee, tapInternalPubkey as te } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
+ import { c as B, d as ne } from "./fundPeginTransaction-96FxwYYJ.js";
3
3
  import { Buffer as c } from "buffer";
4
- import { Transaction as S, Psbt as k, crypto as ne } from "bitcoinjs-lib";
5
- import { s as x, h as E, u as _, T as H, c as re, d as oe, S as B, X as R } from "./bitcoin-B5aNKtsk.js";
6
- import { P as T, A as C, a as q, M as I, V as ie, N } from "./constants-Cd_fN8VT.js";
7
- import * as se from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- async function ue(e, t) {
4
+ import { Transaction as S, Psbt as T, crypto as re } from "bitcoinjs-lib";
5
+ import { s as x, h as E, u as H, T as V, c as oe, d as ie, S as R, X as q } from "./bitcoin-B5aNKtsk.js";
6
+ import { P as C, A as I, a as N, M as _, V as se, N as M } from "./constants-Cd_fN8VT.js";
7
+ import * as ue from "@bitcoin-js/tiny-secp256k1-asmjs";
8
+ const k = 1;
9
+ async function ae(e, t) {
9
10
  const n = t.pegInAmounts.length;
10
11
  if (e.htlcValues.length !== n)
11
12
  throw new Error(
@@ -19,7 +20,10 @@ async function ue(e, t) {
19
20
  throw new Error(
20
21
  `WASM Pre-PegIn returned non-positive depositorClaimValue ${e.depositorClaimValue}; expected > 0.`
21
22
  );
22
- const r = await Q(
23
+ const r = await Z(
24
+ // Phase-1 pin: the builder constructs the v1 graph, so the cross-check
25
+ // must price the same version's claim value.
26
+ k,
23
27
  t.numLocalChallengers,
24
28
  t.universalChallengerPubkeys.length,
25
29
  t.councilQuorum,
@@ -30,7 +34,7 @@ async function ue(e, t) {
30
34
  throw new Error(
31
35
  `WASM Pre-PegIn depositorClaimValue ${e.depositorClaimValue} does not match the independently computed minimum claim value ${r} (numLocalChallengers=${t.numLocalChallengers}, numUniversalChallengers=${t.universalChallengerPubkeys.length}, councilQuorum=${t.councilQuorum}, councilSize=${t.councilSize}, feeRate=${t.feeRate}).`
32
36
  );
33
- const o = t.minPeginFeeRate * L;
37
+ const o = t.minPeginFeeRate * B;
34
38
  for (let i = 0; i < n; i++) {
35
39
  const u = t.pegInAmounts[i], s = e.peginAmounts[i], a = e.htlcValues[i];
36
40
  if (s !== u)
@@ -52,11 +56,11 @@ async function ue(e, t) {
52
56
  );
53
57
  if (l > o)
54
58
  throw new Error(
55
- `WASM Pre-PegIn implied PegIn fee for HTLC[${i}] (${l} sat) exceeds the plausibility cap ${o} sat (minPeginFeeRate=${t.minPeginFeeRate} × ${L} vbytes); htlcValue ${a} appears grossly inflated.`
59
+ `WASM Pre-PegIn implied PegIn fee for HTLC[${i}] (${l} sat) exceeds the plausibility cap ${o} sat (minPeginFeeRate=${t.minPeginFeeRate} × ${B} vbytes); htlcValue ${a} appears grossly inflated.`
56
60
  );
57
61
  }
58
62
  }
59
- function ae(e, t, n) {
63
+ function ce(e, t, n) {
60
64
  if (e.length < t.length)
61
65
  throw new Error(
62
66
  `Encoded Pre-PegIn tx has ${e.length} output(s), fewer than the ${t.length} HTLC output(s) the cross-check validated.`
@@ -74,9 +78,13 @@ function ae(e, t, n) {
74
78
  );
75
79
  }
76
80
  }
77
- const M = 64, ce = /^[0-9a-fA-F]+$/;
78
- async function Ae(e) {
79
- const t = G(e.authAnchorHash), n = await j({
81
+ const K = 64, le = /^[0-9a-fA-F]+$/;
82
+ async function Te(e) {
83
+ const t = Q(e.authAnchorHash), n = await J({
84
+ // Phase-1 pin: every deposit builds the v1 graph until fresh/resume
85
+ // version resolution lands (fresh: activeVaultCoreVersion; resume: the
86
+ // vault's stamped vaultCoreVersion).
87
+ txGraphVersion: k,
80
88
  depositorPubkey: e.depositorPubkey,
81
89
  vaultProviderPubkey: e.vaultProviderPubkey,
82
90
  vaultKeeperPubkeys: e.vaultKeeperPubkeys,
@@ -92,9 +100,9 @@ async function Ae(e) {
92
100
  network: e.network,
93
101
  authAnchorHash: t
94
102
  });
95
- await ue(n, e);
96
- const r = te(n.txHex);
97
- ae(
103
+ await ae(n, e);
104
+ const r = ne(n.txHex);
105
+ ce(
98
106
  r.outputs,
99
107
  n.htlcValues,
100
108
  n.htlcScriptPubKeys
@@ -114,18 +122,19 @@ async function Ae(e) {
114
122
  authAnchorVout: i
115
123
  };
116
124
  }
117
- function G(e) {
125
+ function Q(e) {
118
126
  if (e === void 0) return;
119
127
  const t = e.startsWith("0x") || e.startsWith("0X") ? e.slice(2) : e;
120
- if (t.length !== M || !ce.test(t))
128
+ if (t.length !== K || !le.test(t))
121
129
  throw new Error(
122
- `authAnchorHash must be 32-byte hex (${M} chars, no 0x prefix); got length ${t.length}`
130
+ `authAnchorHash must be 32-byte hex (${K} chars, no 0x prefix); got length ${t.length}`
123
131
  );
124
132
  return t.toLowerCase();
125
133
  }
126
134
  async function ke(e) {
127
- const t = await Z(
135
+ const t = await j(
128
136
  {
137
+ txGraphVersion: k,
129
138
  depositorPubkey: e.prePeginParams.depositorPubkey,
130
139
  vaultProviderPubkey: e.prePeginParams.vaultProviderPubkey,
131
140
  vaultKeeperPubkeys: e.prePeginParams.vaultKeeperPubkeys,
@@ -139,7 +148,7 @@ async function ke(e) {
139
148
  councilQuorum: e.prePeginParams.councilQuorum,
140
149
  councilSize: e.prePeginParams.councilSize,
141
150
  network: e.prePeginParams.network,
142
- authAnchorHash: G(
151
+ authAnchorHash: Q(
143
152
  e.prePeginParams.authAnchorHash
144
153
  )
145
154
  },
@@ -154,9 +163,10 @@ async function ke(e) {
154
163
  vaultValue: t.vaultValue
155
164
  };
156
165
  }
157
- async function le(e) {
158
- const t = await J(
166
+ async function he(e) {
167
+ const t = await ee(
159
168
  {
169
+ txGraphVersion: k,
160
170
  depositor: e.depositor,
161
171
  vaultProvider: e.vaultProvider,
162
172
  vaultKeepers: e.vaultKeepers,
@@ -173,33 +183,33 @@ async function le(e) {
173
183
  payoutControlBlock: t.payoutControlBlock
174
184
  };
175
185
  }
176
- const K = 3, F = 10, X = 100;
177
- async function Te(e) {
178
- const t = x(e.payoutTxHex), n = x(e.peginTxHex), r = x(e.assertTxHex), o = await le({
186
+ const F = 3, X = 10, W = 100;
187
+ async function Ce(e) {
188
+ const t = x(e.payoutTxHex), n = x(e.peginTxHex), r = x(e.assertTxHex), o = await he({
179
189
  depositor: e.depositorBtcPubkey,
180
190
  vaultProvider: e.vaultProviderBtcPubkey,
181
191
  vaultKeepers: e.vaultKeeperBtcPubkeys,
182
192
  universalChallengers: e.universalChallengerBtcPubkeys,
183
193
  timelockPegin: e.timelockPegin,
184
194
  network: e.network
185
- }), i = E(o.payoutScript), u = E(o.payoutControlBlock), s = S.fromHex(t), a = S.fromHex(n), l = S.fromHex(r), p = new k();
195
+ }), i = E(o.payoutScript), u = E(o.payoutControlBlock), s = S.fromHex(t), a = S.fromHex(n), l = S.fromHex(r), p = new T();
186
196
  if (p.setVersion(s.version), p.setLocktime(s.locktime), s.ins.length !== 2)
187
197
  throw new Error(
188
198
  `Payout transaction must have exactly 2 inputs, got ${s.ins.length}`
189
199
  );
190
- const f = s.ins[0], P = s.ins[1], h = _(
200
+ const f = s.ins[0], P = s.ins[1], h = H(
191
201
  new Uint8Array(f.hash).slice().reverse()
192
202
  ), w = a.getId();
193
- if (h !== w || f.index !== T)
203
+ if (h !== w || f.index !== C)
194
204
  throw new Error(
195
- `Input 0 must spend PegIn:${T}. Expected ${w}:${T}, got ${h}:${f.index}`
205
+ `Input 0 must spend PegIn:${C}. Expected ${w}:${C}, got ${h}:${f.index}`
196
206
  );
197
- const $ = _(
207
+ const $ = H(
198
208
  new Uint8Array(P.hash).slice().reverse()
199
209
  ), d = l.getId();
200
- if ($ !== d || P.index !== C)
210
+ if ($ !== d || P.index !== I)
201
211
  throw new Error(
202
- `Input 1 must spend Assert:${C}. Expected ${d}:${C}, got ${$}:${P.index}`
212
+ `Input 1 must spend Assert:${I}. Expected ${d}:${I}, got ${$}:${P.index}`
203
213
  );
204
214
  const g = a.outs[f.index];
205
215
  if (!g)
@@ -211,7 +221,7 @@ async function Te(e) {
211
221
  throw new Error(
212
222
  `Previous output not found for input 1 (txid: ${$}, index: ${P.index})`
213
223
  );
214
- he({
224
+ de({
215
225
  payoutTx: s,
216
226
  peginValueSats: g.value,
217
227
  claimerBtcPubkey: e.claimerBtcPubkey,
@@ -228,12 +238,12 @@ async function Te(e) {
228
238
  throw new Error(
229
239
  `Payout outputs (${b} sats) exceed inputs (${v} sats); invalid transaction.`
230
240
  );
231
- const O = v - b, U = Math.floor(
232
- v * F / X
241
+ const U = v - b, L = Math.floor(
242
+ v * X / W
233
243
  );
234
- if (O > U)
244
+ if (U > L)
235
245
  throw new Error(
236
- `Payout implicit fee ${O} sats exceeds the safety cap of ${U} sats (${F}/${X} of inputs=${v}); refusing to sign payout.`
246
+ `Payout implicit fee ${U} sats exceeds the safety cap of ${L} sats (${X}/${W} of inputs=${v}); refusing to sign payout.`
237
247
  );
238
248
  p.addInput({
239
249
  hash: f.hash,
@@ -245,12 +255,12 @@ async function Te(e) {
245
255
  },
246
256
  tapLeafScript: [
247
257
  {
248
- leafVersion: H,
258
+ leafVersion: V,
249
259
  script: c.from(i),
250
260
  controlBlock: c.from(u)
251
261
  }
252
262
  ],
253
- tapInternalKey: c.from(ee)
263
+ tapInternalKey: c.from(te)
254
264
  // sighashType omitted - defaults to SIGHASH_DEFAULT (0x00) for Taproot
255
265
  }), p.addInput({
256
266
  hash: P.hash,
@@ -271,7 +281,7 @@ async function Te(e) {
271
281
  psbtHex: p.toHex()
272
282
  };
273
283
  }
274
- function he(e) {
284
+ function de(e) {
275
285
  const {
276
286
  payoutTx: t,
277
287
  peginValueSats: n,
@@ -282,18 +292,18 @@ function he(e) {
282
292
  registeredPayoutScriptPubKey: s,
283
293
  commissionBps: a
284
294
  } = e;
285
- if (!re(s))
295
+ if (!oe(s))
286
296
  throw new Error("Invalid registeredPayoutScriptPubKey: not valid hex");
287
297
  const l = x(r).toLowerCase(), p = x(o).toLowerCase(), f = x(i).toLowerCase(), P = u.map(
288
298
  (y) => x(y).toLowerCase()
289
299
  );
290
300
  let h, w, $;
291
301
  if (l === p)
292
- h = "vp-claimer", w = ie, $ = x(s);
302
+ h = "vp-claimer", w = se, $ = x(s);
293
303
  else if (l === f)
294
- h = "depositor-as-claimer", w = N, $ = x(s);
304
+ h = "depositor-as-claimer", w = M, $ = x(s);
295
305
  else if (P.includes(l))
296
- h = "vk-claimer", w = N, $ = x(oe(l));
306
+ h = "vk-claimer", w = M, $ = x(ie(l));
297
307
  else
298
308
  throw new Error(
299
309
  `Unknown claimer pubkey ${l}: not VP, depositor, or a registered vault keeper`
@@ -308,17 +318,17 @@ function he(e) {
308
318
  `Payout transaction output 0 does not pay the expected scriptPubKey for role ${h}`
309
319
  );
310
320
  const g = w - 1;
311
- if (t.outs[g].value !== q)
321
+ if (t.outs[g].value !== N)
312
322
  throw new Error(
313
- `Payout CPFP anchor (out ${g}) value ${t.outs[g].value} sats must equal ${q} sats`
323
+ `Payout CPFP anchor (out ${g}) value ${t.outs[g].value} sats must equal ${N} sats`
314
324
  );
315
325
  if (h === "vp-claimer") {
316
- if (!Number.isInteger(a) || a < 0 || a >= I)
326
+ if (!Number.isInteger(a) || a < 0 || a >= _)
317
327
  throw new Error(
318
- `commissionBps must be an integer in [0, ${I}), got ${a}`
328
+ `commissionBps must be an integer in [0, ${_}), got ${a}`
319
329
  );
320
330
  const y = Math.floor(
321
- n * a / I
331
+ n * a / _
322
332
  );
323
333
  if (t.outs[1].value > y)
324
334
  throw new Error(
@@ -326,8 +336,8 @@ function he(e) {
326
336
  );
327
337
  }
328
338
  }
329
- function Ce(e, t, n = 0) {
330
- const r = k.fromHex(e);
339
+ function Ie(e, t, n = 0) {
340
+ const r = T.fromHex(e);
331
341
  if (n >= r.data.inputs.length)
332
342
  throw new Error(
333
343
  `Input index ${n} out of range (${r.data.inputs.length} inputs)`
@@ -337,33 +347,33 @@ function Ce(e, t, n = 0) {
337
347
  const i = E(t);
338
348
  for (const u of o.tapScriptSig)
339
349
  if (u.pubkey.equals(c.from(i)))
340
- return W(u.signature, n);
350
+ return z(u.signature, n);
341
351
  throw new Error(
342
352
  `No signature found for depositor pubkey: ${t} at input ${n}`
343
353
  );
344
354
  }
345
355
  if (o.finalScriptWitness && o.finalScriptWitness.length > 0) {
346
- const i = de(o.finalScriptWitness);
347
- if (i.length !== K)
356
+ const i = pe(o.finalScriptWitness);
357
+ if (i.length !== F)
348
358
  throw new Error(
349
- `Unexpected finalized witness stack size at input ${n}: expected ${K} items (signature, script, controlBlock), got ${i.length}`
359
+ `Unexpected finalized witness stack size at input ${n}: expected ${F} items (signature, script, controlBlock), got ${i.length}`
350
360
  );
351
- return W(i[0], n);
361
+ return z(i[0], n);
352
362
  }
353
363
  throw new Error(
354
364
  `No tapScriptSig or finalScriptWitness found in signed PSBT at input ${n}`
355
365
  );
356
366
  }
357
- function W(e, t) {
367
+ function z(e, t) {
358
368
  if (e.length === 64)
359
- return _(new Uint8Array(e));
369
+ return H(new Uint8Array(e));
360
370
  throw e.length === 65 ? new Error(
361
371
  `Unexpected sighash byte 0x${e[64].toString(16).padStart(2, "0")} at input ${t}. Expected implicit SIGHASH_DEFAULT as a 64-byte signature.`
362
372
  ) : new Error(
363
373
  `Unexpected signature length at input ${t}: ${e.length}`
364
374
  );
365
375
  }
366
- function de(e) {
376
+ function pe(e) {
367
377
  const t = [];
368
378
  let n = 0;
369
379
  const r = (u) => {
@@ -406,24 +416,24 @@ class m extends Error {
406
416
  ), this.name = "PsbtSubstitutionError";
407
417
  }
408
418
  }
409
- function z(e, t) {
419
+ function G(e, t) {
410
420
  try {
411
- return k.fromHex(t);
421
+ return T.fromHex(t);
412
422
  } catch (n) {
413
423
  const r = n instanceof Error ? n.message : String(n);
414
424
  throw new Error(`Failed to parse ${e} PSBT: ${r}`);
415
425
  }
416
426
  }
417
- const pe = 8;
418
- function V(e) {
419
- return `${e.toString("hex").slice(0, pe)}…`;
427
+ const fe = 8;
428
+ function O(e) {
429
+ return `${e.toString("hex").slice(0, fe)}…`;
420
430
  }
421
431
  function Y(e) {
422
432
  const t = c.from(e).reverse();
423
- return V(t);
433
+ return O(t);
424
434
  }
425
- function Ie(e) {
426
- const t = z("requested", e.requestedPsbtHex), n = z("returned", e.returnedPsbtHex);
435
+ function _e(e) {
436
+ const t = G("requested", e.requestedPsbtHex), n = G("returned", e.returnedPsbtHex);
427
437
  if (t.version !== n.version)
428
438
  throw new m(
429
439
  `tx version differs (requested=${t.version}, returned=${n.version})`
@@ -459,7 +469,7 @@ function Ie(e) {
459
469
  const o = t.txOutputs[r], i = n.txOutputs[r];
460
470
  if (!o.script.equals(i.script))
461
471
  throw new m(
462
- `output ${r} scriptPubKey differs (requested=${V(o.script)}, returned=${V(i.script)})`
472
+ `output ${r} scriptPubKey differs (requested=${O(o.script)}, returned=${O(i.script)})`
463
473
  );
464
474
  if (o.value !== i.value)
465
475
  throw new m(
@@ -467,41 +477,41 @@ function Ie(e) {
467
477
  );
468
478
  }
469
479
  }
470
- const D = 253, fe = 254, ge = 65535, Pe = 4294967295;
471
- function xe(e) {
480
+ const D = 253, ge = 254, Pe = 65535, xe = 4294967295;
481
+ function we(e) {
472
482
  if (e < D)
473
483
  return c.from([e]);
474
- if (e <= ge) {
484
+ if (e <= Pe) {
475
485
  const t = c.alloc(2);
476
486
  return t.writeUInt16LE(e), c.concat([c.from([D]), t]);
477
487
  }
478
- if (e <= Pe) {
488
+ if (e <= xe) {
479
489
  const t = c.alloc(4);
480
- return t.writeUInt32LE(e), c.concat([c.from([fe]), t]);
490
+ return t.writeUInt32LE(e), c.concat([c.from([ge]), t]);
481
491
  }
482
492
  throw new Error(`Script too large to encode as CompactSize: ${e} bytes`);
483
493
  }
484
- const we = "TapLeaf";
485
- function $e(e, t) {
494
+ const $e = "TapLeaf";
495
+ function ye(e, t) {
486
496
  const n = c.concat([
487
497
  c.from([e]),
488
- xe(t.length),
498
+ we(t.length),
489
499
  c.from(t)
490
500
  ]);
491
- return ne.taggedHash(we, n);
501
+ return re.taggedHash($e, n);
492
502
  }
493
- function _e(e) {
503
+ function He(e) {
494
504
  const { requestedPsbtHex: t, signatureHex: n, signerXOnlyPubkeyHex: r, inputIndex: o } = e, i = x(n);
495
- if (i.length !== B)
505
+ if (i.length !== R)
496
506
  throw new Error(
497
- `Schnorr signature for input ${o} must be ${B} hex chars (64 bytes), got ${i.length}.`
507
+ `Schnorr signature for input ${o} must be ${R} hex chars (64 bytes), got ${i.length}.`
498
508
  );
499
509
  const u = x(r);
500
- if (u.length !== R)
510
+ if (u.length !== q)
501
511
  throw new Error(
502
- `Signer x-only pubkey for input ${o} must be ${R} hex chars (32 bytes), got ${u.length}.`
512
+ `Signer x-only pubkey for input ${o} must be ${q} hex chars (32 bytes), got ${u.length}.`
503
513
  );
504
- const s = k.fromHex(t);
514
+ const s = T.fromHex(t);
505
515
  if (o < 0 || o >= s.data.inputs.length)
506
516
  throw new Error(
507
517
  `Input index ${o} out of range (${s.data.inputs.length} inputs).`
@@ -521,11 +531,11 @@ function _e(e) {
521
531
  `Cannot verify signature: input ${o} of the requested PSBT must have exactly one tapLeafScript, got ${(p == null ? void 0 : p.length) ?? 0}.`
522
532
  );
523
533
  const f = p[0];
524
- if (f.leafVersion !== H)
534
+ if (f.leafVersion !== V)
525
535
  throw new Error(
526
- `Cannot verify signature: input ${o} tapLeafScript has leaf version 0x${f.leafVersion.toString(16)}, expected 0x${H.toString(16)}.`
536
+ `Cannot verify signature: input ${o} tapLeafScript has leaf version 0x${f.leafVersion.toString(16)}, expected 0x${V.toString(16)}.`
527
537
  );
528
- const P = $e(f.leafVersion, f.script), h = new S();
538
+ const P = ye(f.leafVersion, f.script), h = new S();
529
539
  h.version = s.version, h.locktime = s.locktime;
530
540
  for (const d of s.txInputs)
531
541
  h.addInput(d.hash, d.index, d.sequence);
@@ -538,7 +548,7 @@ function _e(e) {
538
548
  S.SIGHASH_DEFAULT,
539
549
  P
540
550
  );
541
- if (!se.verifySchnorr(
551
+ if (!ue.verifySchnorr(
542
552
  w,
543
553
  E(u),
544
554
  E(i)
@@ -549,13 +559,14 @@ function _e(e) {
549
559
  }
550
560
  export {
551
561
  m as P,
552
- Ae as a,
562
+ k as T,
563
+ Te as a,
553
564
  ke as b,
554
- Te as c,
555
- Ie as d,
556
- Ce as e,
557
- _e as f,
558
- le as g,
559
- G as n
565
+ Ce as c,
566
+ _e as d,
567
+ Ie as e,
568
+ He as f,
569
+ he as g,
570
+ Q as n
560
571
  };
561
- //# sourceMappingURL=verifyScriptPathSchnorrSignature-CeZp6tMw.js.map
572
+ //# sourceMappingURL=verifyScriptPathSchnorrSignature-BKECXOpa.js.map