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