@babylonlabs-io/ts-sdk 0.16.0 → 0.16.2

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 (31) hide show
  1. package/README.md +17 -3
  2. package/dist/challengeAssert-CTajvPAY.cjs +2 -0
  3. package/dist/challengeAssert-CTajvPAY.cjs.map +1 -0
  4. package/dist/{challengeAssert-C5DQSUnp.js → challengeAssert-DtrQLG0c.js} +164 -161
  5. package/dist/challengeAssert-DtrQLG0c.js.map +1 -0
  6. package/dist/{errors-BEUjAw2k.js → errors-BeFfs5_J.js} +370 -369
  7. package/dist/errors-BeFfs5_J.js.map +1 -0
  8. package/dist/errors-CAFiRPYI.cjs +2 -0
  9. package/dist/errors-CAFiRPYI.cjs.map +1 -0
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
  13. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +29 -74
  14. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  15. package/dist/tbv/core/index.cjs +1 -1
  16. package/dist/tbv/core/index.js +2 -2
  17. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  18. package/dist/tbv/core/primitives/index.cjs +1 -1
  19. package/dist/tbv/core/primitives/index.js +1 -1
  20. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +0 -11
  21. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
  22. package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -1
  23. package/dist/tbv/index.cjs +1 -1
  24. package/dist/tbv/index.js +2 -2
  25. package/package.json +3 -3
  26. package/dist/challengeAssert-C5DQSUnp.js.map +0 -1
  27. package/dist/challengeAssert-D7SqsNpQ.cjs +0 -2
  28. package/dist/challengeAssert-D7SqsNpQ.cjs.map +0 -1
  29. package/dist/errors-BEUjAw2k.js.map +0 -1
  30. package/dist/errors-DnMc1lLU.cjs +0 -2
  31. package/dist/errors-DnMc1lLU.cjs.map +0 -1
@@ -1,18 +1,17 @@
1
- import { createPrePeginTransaction as W, buildPeginTxFromPrePegin as F, getPrePeginHtlcConnectorInfo as _, tapInternalPubkey as m, initWasm as N, WasmPrePeginTx as q, createPayoutConnector as z, getPeginPayoutScriptInfo as M, getAssertNoPayoutScriptInfo as D, getChallengeAssertScriptInfo as X } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
- import * as B from "bitcoinjs-lib";
3
- import { payments as R, networks as I, initEccLib as G, Transaction as y, Psbt as w } from "bitcoinjs-lib";
4
- import { Buffer as l } from "buffer";
5
- import * as Q from "@bitcoin-js/tiny-secp256k1-asmjs";
1
+ import { createPrePeginTransaction as K, buildPeginTxFromPrePegin as V, getPrePeginHtlcConnectorInfo as _, tapInternalPubkey as m, initWasm as W, WasmPrePeginTx as F, createPayoutConnector as N, getPeginPayoutScriptInfo as q, getAssertNoPayoutScriptInfo as z, getChallengeAssertScriptInfo as M } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
+ import * as L from "bitcoinjs-lib";
3
+ import { payments as A, networks as I, Transaction as y, Psbt as w } from "bitcoinjs-lib";
4
+ import { Buffer as a } from "buffer";
6
5
  const E = 192;
7
6
  function g(t) {
8
7
  return t.startsWith("0x") ? t.slice(2) : t;
9
8
  }
10
- function lt(t) {
9
+ function ut(t) {
11
10
  return t.startsWith("0x") ? t : `0x${t}`;
12
11
  }
13
12
  function d(t) {
14
13
  const e = g(t);
15
- if (!A(e))
14
+ if (!C(e))
16
15
  throw new Error(`Invalid hex string: ${t}`);
17
16
  const n = new Uint8Array(e.length / 2);
18
17
  for (let r = 0; r < e.length; r += 2)
@@ -22,15 +21,15 @@ function d(t) {
22
21
  function v(t) {
23
22
  return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
24
23
  }
25
- function Y(t) {
24
+ function D(t) {
26
25
  return t.length === 32 ? t : t.slice(1, 33);
27
26
  }
28
- function A(t) {
27
+ function C(t) {
29
28
  return /^[0-9a-fA-F]*$/.test(t) && t.length % 2 === 0;
30
29
  }
31
- function C(t) {
30
+ function $(t) {
32
31
  const e = g(t);
33
- if (!A(e))
32
+ if (!C(e))
34
33
  throw new Error(`Invalid hex characters in public key: ${t}`);
35
34
  if (e.length === 64)
36
35
  return e;
@@ -39,25 +38,31 @@ function C(t) {
39
38
  `Invalid public key length: ${e.length} (expected 64, 66, or 130 hex chars)`
40
39
  );
41
40
  const n = d(e);
42
- return v(Y(n));
41
+ return v(D(n));
43
42
  }
44
- function pt(t) {
43
+ function ct(t) {
45
44
  const e = g(t);
46
- return A(e);
45
+ return C(e);
47
46
  }
48
- function ft(t, e) {
49
- const n = C(t), r = e ?? n;
47
+ function at(t, e) {
48
+ const n = $(t), r = e ?? n;
50
49
  if (n.toLowerCase() !== r.toLowerCase())
51
50
  throw new Error(
52
51
  `Wallet public key does not match vault depositor. Expected: ${r}, Got: ${n}. Please connect the wallet that was used to create this vault.`
53
52
  );
54
53
  return { walletPubkeyRaw: t, walletPubkeyXOnly: n, depositorPubkey: r };
55
54
  }
56
- let L = !1;
57
- function O() {
58
- L || (G(Q), L = !0);
55
+ function X() {
56
+ try {
57
+ A.p2tr({ internalPubkey: a.alloc(32, 1) });
58
+ } catch (t) {
59
+ if (t instanceof Error && t.message.includes("No ECC Library provided"))
60
+ throw new Error(
61
+ 'ECC library not initialized. You must call initEccLib(ecc) from "bitcoinjs-lib" before using the SDK. See the ts-sdk README for setup instructions.'
62
+ );
63
+ }
59
64
  }
60
- function V(t) {
65
+ function R(t) {
61
66
  switch (t) {
62
67
  case "bitcoin":
63
68
  return I.bitcoin;
@@ -70,25 +75,25 @@ function V(t) {
70
75
  throw new Error(`Unknown network: ${t}`);
71
76
  }
72
77
  }
73
- function Z(t, e) {
74
- O();
75
- const n = d(C(t)), { address: r } = R.p2tr({
76
- internalPubkey: l.from(n),
77
- network: V(e)
78
+ function G(t, e) {
79
+ X();
80
+ const n = d($(t)), { address: r } = A.p2tr({
81
+ internalPubkey: a.from(n),
82
+ network: R(e)
78
83
  });
79
84
  if (!r)
80
85
  throw new Error("Failed to derive taproot address from public key");
81
86
  return r;
82
87
  }
83
- function j(t, e) {
88
+ function Y(t, e) {
84
89
  const n = g(t);
85
90
  if (n.length !== 66)
86
91
  throw new Error(
87
92
  `Native SegWit requires a compressed public key (66 hex chars), got ${n.length}`
88
93
  );
89
- const { address: r } = R.p2wpkh({
90
- pubkey: l.from(d(n)),
91
- network: V(e)
94
+ const { address: r } = A.p2wpkh({
95
+ pubkey: a.from(d(n)),
96
+ network: R(e)
92
97
  });
93
98
  if (!r)
94
99
  throw new Error(
@@ -96,10 +101,10 @@ function j(t, e) {
96
101
  );
97
102
  return r;
98
103
  }
99
- function dt(t, e, n) {
104
+ function lt(t, e, n) {
100
105
  const r = g(e);
101
106
  try {
102
- if (t === Z(r, n))
107
+ if (t === G(r, n))
103
108
  return !0;
104
109
  } catch {
105
110
  }
@@ -107,32 +112,32 @@ function dt(t, e, n) {
107
112
  r.length === 66 ? o.push(r) : r.length === 64 && o.push(`02${r}`, `03${r}`);
108
113
  for (const s of o)
109
114
  try {
110
- if (t === j(s, n))
115
+ if (t === Y(s, n))
111
116
  return !0;
112
117
  } catch {
113
118
  }
114
119
  return !1;
115
120
  }
116
121
  function H(t) {
117
- return C(t).toLowerCase();
122
+ return $(t).toLowerCase();
118
123
  }
119
- function ht(t, e, n) {
124
+ function pt(t, e, n) {
120
125
  const r = /* @__PURE__ */ new Set();
121
126
  r.add(H(t));
122
127
  for (const o of e)
123
128
  r.add(H(o));
124
129
  return r.delete(H(n)), r.size;
125
130
  }
126
- const gt = 58, Pt = 43, xt = 11, J = 546, tt = BigInt(J), et = 30, nt = 2, yt = 1.1;
127
- function kt(t) {
128
- return t <= nt ? et : 0;
131
+ const ft = 58, dt = 43, ht = 11, Q = 546, j = BigInt(Q), Z = 30, J = 2, gt = 1.1;
132
+ function Pt(t) {
133
+ return t <= J ? Z : 0;
129
134
  }
130
- const rt = 1;
131
- function vt(t) {
132
- return t + rt;
135
+ const tt = 1;
136
+ function xt(t) {
137
+ return t + tt;
133
138
  }
134
- const wt = 5;
135
- function K(t) {
139
+ const yt = 5;
140
+ function O(t) {
136
141
  const n = t.substring(8, 12) === "0001" ? 12 : 8, r = parseInt(
137
142
  t.substring(n, n + 2),
138
143
  16
@@ -144,39 +149,38 @@ function K(t) {
144
149
  throw new Error(`Expected 0 inputs from WASM, got ${r}`);
145
150
  if (o === 0)
146
151
  throw new Error("Expected at least 1 output from WASM, got 0");
147
- const s = l.from(t.substring(0, 8), "hex").readUInt32LE(0), c = l.from(
152
+ const s = a.from(t.substring(0, 8), "hex").readUInt32LE(0), c = a.from(
148
153
  t.substring(t.length - 8),
149
154
  "hex"
150
155
  ).readUInt32LE(0), u = [];
151
156
  let i = n + 4;
152
157
  for (let p = 0; p < o; p++) {
153
- const a = t.substring(i, i + 16), f = Number(l.from(a, "hex").readBigUInt64LE(0));
158
+ const l = t.substring(i, i + 16), f = Number(a.from(l, "hex").readBigUInt64LE(0));
154
159
  i += 16;
155
160
  const h = parseInt(t.substring(i, i + 2), 16);
156
161
  i += 2;
157
- const P = t.substring(i, i + h * 2), x = l.from(P, "hex");
162
+ const P = t.substring(i, i + h * 2), x = a.from(P, "hex");
158
163
  i += h * 2, u.push({ value: f, script: x });
159
164
  }
160
165
  return { version: s, locktime: c, outputs: u };
161
166
  }
162
- function bt(t) {
163
- O();
164
- const { unfundedTxHex: e, selectedUTXOs: n, changeAddress: r, changeAmount: o, network: s } = t, { version: c, locktime: u, outputs: i } = K(e), p = new B.Transaction();
167
+ function kt(t) {
168
+ const { unfundedTxHex: e, selectedUTXOs: n, changeAddress: r, changeAmount: o, network: s } = t, { version: c, locktime: u, outputs: i } = O(e), p = new L.Transaction();
165
169
  p.version = c, p.locktime = u;
166
- for (const a of n) {
167
- const f = l.from(a.txid, "hex").reverse();
168
- p.addInput(f, a.vout);
170
+ for (const l of n) {
171
+ const f = a.from(l.txid, "hex").reverse();
172
+ p.addInput(f, l.vout);
169
173
  }
170
- for (const a of i)
171
- p.addOutput(a.script, a.value);
172
- if (o > tt) {
173
- const a = B.address.toOutputScript(r, s);
174
- p.addOutput(a, Number(o));
174
+ for (const l of i)
175
+ p.addOutput(l.script, l.value);
176
+ if (o > j) {
177
+ const l = L.address.toOutputScript(r, s);
178
+ p.addOutput(l, Number(o));
175
179
  }
176
180
  return p.toHex();
177
181
  }
178
- async function St(t) {
179
- const e = await W({
182
+ async function vt(t) {
183
+ const e = await K({
180
184
  depositorPubkey: t.depositorPubkey,
181
185
  vaultProviderPubkey: t.vaultProviderPubkey,
182
186
  vaultKeeperPubkeys: t.vaultKeeperPubkeys,
@@ -189,7 +193,7 @@ async function St(t) {
189
193
  councilQuorum: t.councilQuorum,
190
194
  councilSize: t.councilSize,
191
195
  network: t.network
192
- }), r = K(e.txHex).outputs.reduce(
196
+ }), r = O(e.txHex).outputs.reduce(
193
197
  (o, s) => o + BigInt(s.value),
194
198
  0n
195
199
  );
@@ -203,8 +207,8 @@ async function St(t) {
203
207
  depositorClaimValue: e.depositorClaimValue
204
208
  };
205
209
  }
206
- async function mt(t) {
207
- const e = await F(
210
+ async function wt(t) {
211
+ const e = await V(
208
212
  {
209
213
  depositorPubkey: t.prePeginParams.depositorPubkey,
210
214
  vaultProviderPubkey: t.prePeginParams.vaultProviderPubkey,
@@ -230,7 +234,7 @@ async function mt(t) {
230
234
  vaultValue: e.vaultValue
231
235
  };
232
236
  }
233
- async function Et(t) {
237
+ async function bt(t) {
234
238
  const e = g(t.peginTxHex), n = g(t.fundedPrePeginTxHex), r = await _({
235
239
  depositorPubkey: t.depositorPubkey,
236
240
  vaultProviderPubkey: t.vaultProviderPubkey,
@@ -256,7 +260,7 @@ async function Et(t) {
256
260
  throw new Error(
257
261
  `Pre-PegIn output ${c.index} not found (Pre-PegIn has ${s.outs.length} outputs)`
258
262
  );
259
- const a = d(r.hashlockScript), f = d(r.hashlockControlBlock), h = new w();
263
+ const l = d(r.hashlockScript), f = d(r.hashlockControlBlock), h = new w();
260
264
  h.setVersion(o.version), h.setLocktime(o.locktime), h.addInput({
261
265
  hash: c.hash,
262
266
  index: c.index,
@@ -268,11 +272,11 @@ async function Et(t) {
268
272
  tapLeafScript: [
269
273
  {
270
274
  leafVersion: E,
271
- script: l.from(a),
272
- controlBlock: l.from(f)
275
+ script: a.from(l),
276
+ controlBlock: a.from(f)
273
277
  }
274
278
  ],
275
- tapInternalKey: l.from(m)
279
+ tapInternalKey: a.from(m)
276
280
  // sighashType omitted — defaults to SIGHASH_DEFAULT (0x00) for Taproot
277
281
  });
278
282
  for (const P of o.outs)
@@ -282,17 +286,17 @@ async function Et(t) {
282
286
  });
283
287
  return { psbtHex: h.toHex() };
284
288
  }
285
- function Tt(t, e) {
289
+ function St(t, e) {
286
290
  const r = w.fromHex(t).data.inputs[0];
287
291
  if (!r)
288
292
  throw new Error("PegIn PSBT has no inputs");
289
293
  if (r.tapScriptSig && r.tapScriptSig.length > 0) {
290
- const o = l.from(
294
+ const o = a.from(
291
295
  d(e)
292
296
  );
293
297
  for (const s of r.tapScriptSig)
294
298
  if (s.pubkey.equals(o))
295
- return ot(s.signature);
299
+ return et(s.signature);
296
300
  throw new Error(
297
301
  `No PegIn input signature found for depositor pubkey: ${e}`
298
302
  );
@@ -303,7 +307,7 @@ function Tt(t, e) {
303
307
  "No tapScriptSig or finalScriptWitness found in signed PegIn input PSBT"
304
308
  );
305
309
  }
306
- function It(t) {
310
+ function mt(t) {
307
311
  const e = w.fromHex(t);
308
312
  try {
309
313
  e.finalizeAllInputs();
@@ -317,16 +321,16 @@ function It(t) {
317
321
  }
318
322
  return e.extractTransaction().toHex();
319
323
  }
320
- function ot(t) {
324
+ function et(t) {
321
325
  if (t.length === 64)
322
326
  return v(new Uint8Array(t));
323
327
  if (t.length === 65)
324
328
  return v(new Uint8Array(t.subarray(0, 64)));
325
329
  throw new Error(`Unexpected PegIn input signature length: ${t.length}`);
326
330
  }
327
- async function Ht(t) {
328
- await N();
329
- const { prePeginParams: e, fundedPrePeginTxHex: n, htlcVout: r, refundFee: o, hashlock: s } = t, c = new q(
331
+ async function Et(t) {
332
+ await W();
333
+ const { prePeginParams: e, fundedPrePeginTxHex: n, htlcVout: r, refundFee: o, hashlock: s } = t, c = new F(
330
334
  e.depositorPubkey,
331
335
  e.vaultProviderPubkey,
332
336
  e.vaultKeeperPubkeys,
@@ -351,7 +355,7 @@ async function Ht(t) {
351
355
  hashlock: s,
352
356
  timelockRefund: e.timelockRefund,
353
357
  network: e.network
354
- }), a = n.startsWith("0x") ? n.slice(2) : n, f = y.fromHex(a), h = f.outs[r];
358
+ }), l = n.startsWith("0x") ? n.slice(2) : n, f = y.fromHex(l), h = f.outs[r];
355
359
  if (!h)
356
360
  throw new Error(
357
361
  `HTLC output at vout ${r} not found in funded Pre-PegIn tx (tx has ${f.outs.length} outputs)`
@@ -384,13 +388,13 @@ async function Ht(t) {
384
388
  tapLeafScript: [
385
389
  {
386
390
  leafVersion: E,
387
- script: l.from(d(p.refundScript)),
388
- controlBlock: l.from(
391
+ script: a.from(d(p.refundScript)),
392
+ controlBlock: a.from(
389
393
  d(p.refundControlBlock)
390
394
  )
391
395
  }
392
396
  ],
393
- tapInternalKey: l.from(m)
397
+ tapInternalKey: a.from(m)
394
398
  });
395
399
  for (const S of P.outs)
396
400
  k.addOutput({
@@ -402,8 +406,8 @@ async function Ht(t) {
402
406
  u == null || u.free(), c.free();
403
407
  }
404
408
  }
405
- async function st(t) {
406
- const e = await z(
409
+ async function nt(t) {
410
+ const e = await N(
407
411
  {
408
412
  depositor: t.depositor,
409
413
  vaultProvider: t.vaultProvider,
@@ -421,16 +425,16 @@ async function st(t) {
421
425
  payoutControlBlock: e.payoutControlBlock
422
426
  };
423
427
  }
424
- async function At(t) {
425
- const e = g(t.payoutTxHex), n = g(t.peginTxHex), r = g(t.assertTxHex), o = await st({
428
+ async function Tt(t) {
429
+ const e = g(t.payoutTxHex), n = g(t.peginTxHex), r = g(t.assertTxHex), o = await nt({
426
430
  depositor: t.depositorBtcPubkey,
427
431
  vaultProvider: t.vaultProviderBtcPubkey,
428
432
  vaultKeepers: t.vaultKeeperBtcPubkeys,
429
433
  universalChallengers: t.universalChallengerBtcPubkeys,
430
434
  timelockPegin: t.timelockPegin,
431
435
  network: t.network
432
- }), s = d(o.payoutScript), c = d(o.payoutControlBlock), u = y.fromHex(e), i = y.fromHex(n), p = y.fromHex(r), a = new w();
433
- if (a.setVersion(u.version), a.setLocktime(u.locktime), u.ins.length !== 2)
436
+ }), s = d(o.payoutScript), c = d(o.payoutControlBlock), u = y.fromHex(e), i = y.fromHex(n), p = y.fromHex(r), l = new w();
437
+ if (l.setVersion(u.version), l.setLocktime(u.locktime), u.ins.length !== 2)
434
438
  throw new Error(
435
439
  `Payout transaction must have exactly 2 inputs, got ${u.ins.length}`
436
440
  );
@@ -458,7 +462,7 @@ async function At(t) {
458
462
  throw new Error(
459
463
  `Previous output not found for input 1 (txid: ${b}, index: ${h.index})`
460
464
  );
461
- a.addInput({
465
+ l.addInput({
462
466
  hash: f.hash,
463
467
  index: f.index,
464
468
  sequence: f.sequence,
@@ -469,13 +473,13 @@ async function At(t) {
469
473
  tapLeafScript: [
470
474
  {
471
475
  leafVersion: E,
472
- script: l.from(s),
473
- controlBlock: l.from(c)
476
+ script: a.from(s),
477
+ controlBlock: a.from(c)
474
478
  }
475
479
  ],
476
- tapInternalKey: l.from(m)
480
+ tapInternalKey: a.from(m)
477
481
  // sighashType omitted - defaults to SIGHASH_DEFAULT (0x00) for Taproot
478
- }), a.addInput({
482
+ }), l.addInput({
479
483
  hash: h.hash,
480
484
  index: h.index,
481
485
  sequence: h.sequence,
@@ -485,16 +489,16 @@ async function At(t) {
485
489
  }
486
490
  // No tapLeafScript - depositor doesn't sign this input
487
491
  });
488
- for (const $ of u.outs)
489
- a.addOutput({
490
- script: $.script,
491
- value: $.value
492
+ for (const B of u.outs)
493
+ l.addOutput({
494
+ script: B.script,
495
+ value: B.value
492
496
  });
493
497
  return {
494
- psbtHex: a.toHex()
498
+ psbtHex: l.toHex()
495
499
  };
496
500
  }
497
- function Ct(t, e, n = 0) {
501
+ function It(t, e, n = 0) {
498
502
  const r = w.fromHex(t);
499
503
  if (n >= r.data.inputs.length)
500
504
  throw new Error(
@@ -504,14 +508,14 @@ function Ct(t, e, n = 0) {
504
508
  if (o.tapScriptSig && o.tapScriptSig.length > 0) {
505
509
  const s = d(e);
506
510
  for (const c of o.tapScriptSig)
507
- if (c.pubkey.equals(l.from(s)))
511
+ if (c.pubkey.equals(a.from(s)))
508
512
  return U(c.signature, n);
509
513
  throw new Error(
510
514
  `No signature found for depositor pubkey: ${e} at input ${n}`
511
515
  );
512
516
  }
513
517
  if (o.finalScriptWitness && o.finalScriptWitness.length > 0) {
514
- const s = it(o.finalScriptWitness);
518
+ const s = rt(o.finalScriptWitness);
515
519
  if (s.length >= 1)
516
520
  return U(s[0], n);
517
521
  }
@@ -534,7 +538,7 @@ function U(t, e) {
534
538
  `Unexpected signature length at input ${e}: ${t.length}`
535
539
  );
536
540
  }
537
- function it(t) {
541
+ function rt(t) {
538
542
  const e = [];
539
543
  let n = 0;
540
544
  const r = () => {
@@ -556,31 +560,31 @@ function it(t) {
556
560
  }
557
561
  return e;
558
562
  }
559
- async function $t(t) {
560
- const e = g(t.payoutTxHex), n = y.fromHex(e), { payoutScript: r, payoutControlBlock: o } = await M(
563
+ async function Ht(t) {
564
+ const e = g(t.payoutTxHex), n = y.fromHex(e), { payoutScript: r, payoutControlBlock: o } = await q(
561
565
  t.connectorParams
562
566
  ), s = d(r), c = d(o), u = new w();
563
567
  u.setVersion(n.version), u.setLocktime(n.locktime);
564
568
  for (let i = 0; i < n.ins.length; i++) {
565
- const p = n.ins[i], a = t.prevouts[i];
566
- if (!a)
569
+ const p = n.ins[i], l = t.prevouts[i];
570
+ if (!l)
567
571
  throw new Error(`Missing prevout data for input ${i}`);
568
572
  const f = {
569
573
  hash: p.hash,
570
574
  index: p.index,
571
575
  sequence: p.sequence,
572
576
  witnessUtxo: {
573
- script: l.from(d(g(a.script_pubkey))),
574
- value: a.value
577
+ script: a.from(d(g(l.script_pubkey))),
578
+ value: l.value
575
579
  }
576
580
  };
577
581
  i === 0 && (f.tapLeafScript = [
578
582
  {
579
583
  leafVersion: E,
580
- script: l.from(s),
581
- controlBlock: l.from(c)
584
+ script: a.from(s),
585
+ controlBlock: a.from(c)
582
586
  }
583
- ], f.tapInternalKey = l.from(m)), u.addInput(f);
587
+ ], f.tapInternalKey = a.from(m)), u.addInput(f);
584
588
  }
585
589
  for (const i of n.outs)
586
590
  u.addOutput({
@@ -589,32 +593,32 @@ async function $t(t) {
589
593
  });
590
594
  return u.toHex();
591
595
  }
592
- async function Bt(t) {
593
- const e = g(t.noPayoutTxHex), n = y.fromHex(e), { noPayoutScript: r, noPayoutControlBlock: o } = await D(
596
+ async function At(t) {
597
+ const e = g(t.noPayoutTxHex), n = y.fromHex(e), { noPayoutScript: r, noPayoutControlBlock: o } = await z(
594
598
  t.connectorParams,
595
599
  t.challengerPubkey
596
600
  ), s = d(r), c = d(o), u = new w();
597
601
  u.setVersion(n.version), u.setLocktime(n.locktime);
598
602
  for (let i = 0; i < n.ins.length; i++) {
599
- const p = n.ins[i], a = t.prevouts[i];
600
- if (!a)
603
+ const p = n.ins[i], l = t.prevouts[i];
604
+ if (!l)
601
605
  throw new Error(`Missing prevout data for input ${i}`);
602
606
  const f = {
603
607
  hash: p.hash,
604
608
  index: p.index,
605
609
  sequence: p.sequence,
606
610
  witnessUtxo: {
607
- script: l.from(d(g(a.script_pubkey))),
608
- value: a.value
611
+ script: a.from(d(g(l.script_pubkey))),
612
+ value: l.value
609
613
  }
610
614
  };
611
615
  i === 0 && (f.tapLeafScript = [
612
616
  {
613
617
  leafVersion: E,
614
- script: l.from(s),
615
- controlBlock: l.from(c)
618
+ script: a.from(s),
619
+ controlBlock: a.from(c)
616
620
  }
617
- ], f.tapInternalKey = l.from(m)), u.addInput(f);
621
+ ], f.tapInternalKey = a.from(m)), u.addInput(f);
618
622
  }
619
623
  for (const i of n.outs)
620
624
  u.addOutput({
@@ -623,37 +627,37 @@ async function Bt(t) {
623
627
  });
624
628
  return u.toHex();
625
629
  }
626
- async function Lt(t) {
630
+ async function Ct(t) {
627
631
  const e = g(t.challengeAssertTxHex), n = y.fromHex(e);
628
632
  if (t.connectorParamsPerInput.length !== n.ins.length)
629
633
  throw new Error(
630
634
  `Expected ${n.ins.length} connector params, got ${t.connectorParamsPerInput.length}`
631
635
  );
632
636
  const r = await Promise.all(
633
- t.connectorParamsPerInput.map((s) => X(s))
637
+ t.connectorParamsPerInput.map((s) => M(s))
634
638
  ), o = new w();
635
639
  o.setVersion(n.version), o.setLocktime(n.locktime);
636
640
  for (let s = 0; s < n.ins.length; s++) {
637
641
  const c = n.ins[s], u = t.prevouts[s];
638
642
  if (!u)
639
643
  throw new Error(`Missing prevout data for input ${s}`);
640
- const { script: i, controlBlock: p } = r[s], a = d(i), f = d(p);
644
+ const { script: i, controlBlock: p } = r[s], l = d(i), f = d(p);
641
645
  o.addInput({
642
646
  hash: c.hash,
643
647
  index: c.index,
644
648
  sequence: c.sequence,
645
649
  witnessUtxo: {
646
- script: l.from(d(g(u.script_pubkey))),
650
+ script: a.from(d(g(u.script_pubkey))),
647
651
  value: u.value
648
652
  },
649
653
  tapLeafScript: [
650
654
  {
651
655
  leafVersion: E,
652
- script: l.from(a),
653
- controlBlock: l.from(f)
656
+ script: a.from(l),
657
+ controlBlock: a.from(f)
654
658
  }
655
659
  ],
656
- tapInternalKey: l.from(m)
660
+ tapInternalKey: a.from(m)
657
661
  });
658
662
  }
659
663
  for (const s of n.outs)
@@ -664,45 +668,44 @@ async function Lt(t) {
664
668
  return o.toHex();
665
669
  }
666
670
  export {
667
- vt as A,
668
- J as B,
669
- K as C,
670
- tt as D,
671
- bt as E,
672
- yt as F,
673
- V as G,
674
- O as H,
675
- et as L,
676
- Pt as M,
677
- gt as P,
678
- wt as S,
679
- xt as T,
680
- nt as W,
681
- mt as a,
682
- St as b,
683
- ht as c,
684
- Et as d,
685
- Tt as e,
686
- It as f,
687
- Ht as g,
688
- At as h,
689
- Ct as i,
690
- $t as j,
691
- Bt as k,
692
- Lt as l,
693
- st as m,
694
- j as n,
695
- Z as o,
671
+ xt as A,
672
+ Q as B,
673
+ O as C,
674
+ j as D,
675
+ kt as E,
676
+ gt as F,
677
+ R as G,
678
+ Z as L,
679
+ dt as M,
680
+ ft as P,
681
+ yt as S,
682
+ ht as T,
683
+ J as W,
684
+ wt as a,
685
+ vt as b,
686
+ pt as c,
687
+ bt as d,
688
+ St as e,
689
+ mt as f,
690
+ Et as g,
691
+ Tt as h,
692
+ It as i,
693
+ Ht as j,
694
+ At as k,
695
+ Ct as l,
696
+ nt as m,
697
+ Y as n,
698
+ G as o,
696
699
  d as p,
697
- dt as q,
698
- pt as r,
699
- lt as s,
700
- C as t,
700
+ lt as q,
701
+ ct as r,
702
+ ut as s,
703
+ $ as t,
701
704
  g as u,
702
- Y as v,
705
+ D as v,
703
706
  v as w,
704
- ft as x,
705
- kt as y,
706
- rt as z
707
+ at as x,
708
+ Pt as y,
709
+ tt as z
707
710
  };
708
- //# sourceMappingURL=challengeAssert-C5DQSUnp.js.map
711
+ //# sourceMappingURL=challengeAssert-DtrQLG0c.js.map