@babylonlabs-io/ts-sdk 0.79.1 → 1.1.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 (187) hide show
  1. package/README.md +11 -5
  2. package/dist/{signPsbtsWithFallback-f7QLp0q8.js → PayoutManager-CHTOwj0E.js} +26 -26
  3. package/dist/PayoutManager-CHTOwj0E.js.map +1 -0
  4. package/dist/PayoutManager-CpfQjtL0.cjs +2 -0
  5. package/dist/PayoutManager-CpfQjtL0.cjs.map +1 -0
  6. package/dist/PeginManager-6tjlGd0t.cjs +2 -0
  7. package/dist/PeginManager-6tjlGd0t.cjs.map +1 -0
  8. package/dist/{PeginManager-BXlh3ar0.js → PeginManager-DEldv_Ro.js} +23 -22
  9. package/dist/PeginManager-DEldv_Ro.js.map +1 -0
  10. package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs +2 -0
  11. package/dist/buildAndBroadcastReclaim-BwT6Jxp5.cjs.map +1 -0
  12. package/dist/buildAndBroadcastReclaim-CqO2DoP8.js +1919 -0
  13. package/dist/buildAndBroadcastReclaim-CqO2DoP8.js.map +1 -0
  14. package/dist/challengeAssert-Cp_GeRg8.js.map +1 -1
  15. package/dist/challengeAssert-Z7_YULBb.cjs.map +1 -1
  16. package/dist/deriveVaultRoot-BwbXmN0x.js +79 -0
  17. package/dist/deriveVaultRoot-BwbXmN0x.js.map +1 -0
  18. package/dist/deriveVaultRoot-DvhkHzNb.cjs +2 -0
  19. package/dist/deriveVaultRoot-DvhkHzNb.cjs.map +1 -0
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.js +286 -268
  22. package/dist/index.js.map +1 -1
  23. package/dist/noPayout-DAWBQ0eG.cjs +2 -0
  24. package/dist/noPayout-DAWBQ0eG.cjs.map +1 -0
  25. package/dist/{noPayout-DiGr4eas.js → noPayout-qBXWKwav.js} +3 -3
  26. package/dist/noPayout-qBXWKwav.js.map +1 -0
  27. package/dist/onChainBtcPubkey-BXry_CM4.cjs +2 -0
  28. package/dist/onChainBtcPubkey-BXry_CM4.cjs.map +1 -0
  29. package/dist/onChainBtcPubkey-C1WqyxPM.js +159 -0
  30. package/dist/onChainBtcPubkey-C1WqyxPM.js.map +1 -0
  31. package/dist/parseFundingOutpoints-C_-PT9BT.cjs +2 -0
  32. package/dist/parseFundingOutpoints-C_-PT9BT.cjs.map +1 -0
  33. package/dist/parseFundingOutpoints-GSM-IaaK.js +17 -0
  34. package/dist/parseFundingOutpoints-GSM-IaaK.js.map +1 -0
  35. package/dist/{pegin-registration-client-pcczkzMg.js → pegin-registration-client-1sZ-74UC.js} +260 -383
  36. package/dist/pegin-registration-client-1sZ-74UC.js.map +1 -0
  37. package/dist/pegin-registration-client-BNV44jzw.cjs +2 -0
  38. package/dist/pegin-registration-client-BNV44jzw.cjs.map +1 -0
  39. package/dist/shared/index.cjs.map +1 -1
  40. package/dist/shared/index.js.map +1 -1
  41. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +6 -3
  42. package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -1
  43. package/dist/signing-3l5Aqd-H.cjs +2 -0
  44. package/dist/signing-3l5Aqd-H.cjs.map +1 -0
  45. package/dist/signing-Dhr2t0Z6.js +39 -0
  46. package/dist/signing-Dhr2t0Z6.js.map +1 -0
  47. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  48. package/dist/tbv/core/clients/eth/index.js +8 -8
  49. package/dist/tbv/core/clients/index.cjs +1 -1
  50. package/dist/tbv/core/clients/index.js +8 -8
  51. package/dist/tbv/core/index.cjs +1 -1
  52. package/dist/tbv/core/index.d.ts +1 -1
  53. package/dist/tbv/core/index.js +284 -266
  54. package/dist/tbv/core/index.js.map +1 -1
  55. package/dist/tbv/core/managers/PayoutManager.d.ts +1 -1
  56. package/dist/tbv/core/managers/PeginManager.d.ts +1 -1
  57. package/dist/tbv/core/managers/index.cjs +1 -1
  58. package/dist/tbv/core/managers/index.js +2 -2
  59. package/dist/tbv/core/primitives/index.cjs +1 -1
  60. package/dist/tbv/core/primitives/index.d.ts +1 -1
  61. package/dist/tbv/core/primitives/index.js +3 -3
  62. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +5 -3
  63. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -1
  64. package/dist/tbv/core/primitives/psbt/__tests__/deriveExpectedPeginPayoutScriptPubKey.test.d.ts +8 -0
  65. package/dist/tbv/core/primitives/psbt/__tests__/deriveExpectedPeginPayoutScriptPubKey.test.d.ts.map +1 -0
  66. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +6 -0
  67. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  68. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +2 -2
  69. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
  70. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +1 -1
  71. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
  72. package/dist/tbv/core/primitives/psbt/payout.d.ts +13 -7
  73. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  74. package/dist/tbv/core/primitives/psbt/pegin.d.ts +4 -1
  75. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  76. package/dist/tbv/core/recovery/recoveryErrors.d.ts +1 -1
  77. package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifacts.test.d.ts +15 -0
  78. package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifacts.test.d.ts.map +1 -0
  79. package/dist/tbv/core/services/delegated-claim/__tests__/deriveClaimerWotsKeypair.test.d.ts +11 -0
  80. package/dist/tbv/core/services/delegated-claim/__tests__/deriveClaimerWotsKeypair.test.d.ts.map +1 -0
  81. package/dist/tbv/core/services/delegated-claim/__tests__/readWatchtowerArtifacts.test.d.ts +10 -0
  82. package/dist/tbv/core/services/delegated-claim/__tests__/readWatchtowerArtifacts.test.d.ts.map +1 -0
  83. package/dist/tbv/core/services/delegated-claim/__tests__/vaultIdBinding.test.d.ts +10 -0
  84. package/dist/tbv/core/services/delegated-claim/__tests__/vaultIdBinding.test.d.ts.map +1 -0
  85. package/dist/tbv/core/services/delegated-claim/__tests__/wotsKeypair.golden.test.d.ts +11 -0
  86. package/dist/tbv/core/services/delegated-claim/__tests__/wotsKeypair.golden.test.d.ts.map +1 -0
  87. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +46 -0
  88. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -0
  89. package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts +72 -0
  90. package/dist/tbv/core/services/delegated-claim/challengerBinding.d.ts.map +1 -0
  91. package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts +63 -0
  92. package/dist/tbv/core/services/delegated-claim/deriveClaimerWotsKeypair.d.ts.map +1 -0
  93. package/dist/tbv/core/services/delegated-claim/index.d.ts +55 -0
  94. package/dist/tbv/core/services/delegated-claim/index.d.ts.map +1 -0
  95. package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts +65 -0
  96. package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts.map +1 -0
  97. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +70 -0
  98. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -0
  99. package/dist/tbv/core/services/delegated-claim/types.d.ts +105 -0
  100. package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -0
  101. package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts +44 -0
  102. package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts.map +1 -0
  103. package/dist/tbv/core/services/index.cjs +1 -1
  104. package/dist/tbv/core/services/index.d.ts +1 -0
  105. package/dist/tbv/core/services/index.d.ts.map +1 -1
  106. package/dist/tbv/core/services/index.js +73 -56
  107. package/dist/tbv/core/services/index.js.map +1 -1
  108. package/dist/tbv/core/utils/index.cjs +1 -1
  109. package/dist/tbv/core/utils/index.js +44 -43
  110. package/dist/tbv/core/utils/signing.d.ts +24 -0
  111. package/dist/tbv/core/utils/signing.d.ts.map +1 -1
  112. package/dist/tbv/core/vault-secrets/__tests__/context.golden.test.d.ts +4 -4
  113. package/dist/tbv/core/vault-secrets/__tests__/context.test.d.ts +1 -2
  114. package/dist/tbv/core/vault-secrets/__tests__/context.test.d.ts.map +1 -1
  115. package/dist/tbv/core/vault-secrets/__tests__/deriveContextHash.vectors.test.d.ts +40 -0
  116. package/dist/tbv/core/vault-secrets/__tests__/deriveContextHash.vectors.test.d.ts.map +1 -0
  117. package/dist/tbv/core/vault-secrets/context.d.ts +2 -2
  118. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts +5 -6
  119. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -1
  120. package/dist/tbv/core/vault-secrets/index.cjs +1 -1
  121. package/dist/tbv/core/vault-secrets/index.d.ts +2 -2
  122. package/dist/tbv/core/vault-secrets/index.js +9 -8
  123. package/dist/tbv/core/vault-secrets/index.js.map +1 -1
  124. package/dist/tbv/core/wasm/index.cjs +1 -1
  125. package/dist/tbv/core/wasm/index.cjs.map +1 -1
  126. package/dist/tbv/core/wasm/index.d.ts +113 -14
  127. package/dist/tbv/core/wasm/index.d.ts.map +1 -1
  128. package/dist/tbv/core/wasm/index.js +180 -94
  129. package/dist/tbv/core/wasm/index.js.map +1 -1
  130. package/dist/tbv/index.cjs +1 -1
  131. package/dist/tbv/index.js +284 -266
  132. package/dist/tbv/index.js.map +1 -1
  133. package/dist/tbv/integrations/aave/types.d.ts +1 -1
  134. package/dist/testing/MockBitcoinWallet.d.ts +1 -1
  135. package/dist/testing/index.cjs.map +1 -1
  136. package/dist/testing/index.js.map +1 -1
  137. package/dist/toRefundInputs-BaN9XluU.cjs +2 -0
  138. package/dist/toRefundInputs-BaN9XluU.cjs.map +1 -0
  139. package/dist/{toRefundInputs-9inv4Ai4.js → toRefundInputs-mtuuYezp.js} +24 -23
  140. package/dist/toRefundInputs-mtuuYezp.js.map +1 -0
  141. package/dist/{types-B9YhlXe8.js → types-BdCEoANP.js} +2 -2
  142. package/dist/{types-B9YhlXe8.js.map → types-BdCEoANP.js.map} +1 -1
  143. package/dist/{types-C1tpDycc.cjs → types-BuxreSq4.cjs} +2 -2
  144. package/dist/{types-C1tpDycc.cjs.map → types-BuxreSq4.cjs.map} +1 -1
  145. package/dist/{verifyKeyPathSchnorrSignature-BVtNwgK6.js → verifyKeyPathSchnorrSignature-BQHNhRj6.js} +2 -2
  146. package/dist/{verifyKeyPathSchnorrSignature-BVtNwgK6.js.map → verifyKeyPathSchnorrSignature-BQHNhRj6.js.map} +1 -1
  147. package/dist/{verifyKeyPathSchnorrSignature-BjB8Znly.cjs → verifyKeyPathSchnorrSignature-Gm9EmZkx.cjs} +2 -2
  148. package/dist/{verifyKeyPathSchnorrSignature-BjB8Znly.cjs.map → verifyKeyPathSchnorrSignature-Gm9EmZkx.cjs.map} +1 -1
  149. package/dist/verifyScriptPathSchnorrSignature-BKZihCjk.cjs +2 -0
  150. package/dist/verifyScriptPathSchnorrSignature-BKZihCjk.cjs.map +1 -0
  151. package/dist/{verifyScriptPathSchnorrSignature-D_epga4j.js → verifyScriptPathSchnorrSignature-CpjSTfMj.js} +371 -330
  152. package/dist/verifyScriptPathSchnorrSignature-CpjSTfMj.js.map +1 -0
  153. package/package.json +3 -3
  154. package/dist/PeginManager-BXlh3ar0.js.map +0 -1
  155. package/dist/PeginManager-BuVSknB0.cjs +0 -2
  156. package/dist/PeginManager-BuVSknB0.cjs.map +0 -1
  157. package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs +0 -2
  158. package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs.map +0 -1
  159. package/dist/buildAndBroadcastReclaim-O6z9kvc4.js +0 -1545
  160. package/dist/buildAndBroadcastReclaim-O6z9kvc4.js.map +0 -1
  161. package/dist/noPayout-4RZB2g1e.cjs +0 -2
  162. package/dist/noPayout-4RZB2g1e.cjs.map +0 -1
  163. package/dist/noPayout-DiGr4eas.js.map +0 -1
  164. package/dist/onChainBtcPubkey-BbxRrbvg.cjs +0 -2
  165. package/dist/onChainBtcPubkey-BbxRrbvg.cjs.map +0 -1
  166. package/dist/onChainBtcPubkey-C-6UWpD8.js +0 -34
  167. package/dist/onChainBtcPubkey-C-6UWpD8.js.map +0 -1
  168. package/dist/parseFundingOutpoints-B4iQeX6q.cjs +0 -2
  169. package/dist/parseFundingOutpoints-B4iQeX6q.cjs.map +0 -1
  170. package/dist/parseFundingOutpoints-BQWvINfm.js +0 -93
  171. package/dist/parseFundingOutpoints-BQWvINfm.js.map +0 -1
  172. package/dist/pegin-registration-client-CZgcU2_0.cjs +0 -2
  173. package/dist/pegin-registration-client-CZgcU2_0.cjs.map +0 -1
  174. package/dist/pegin-registration-client-pcczkzMg.js.map +0 -1
  175. package/dist/signPsbtsWithFallback-DtwzL5AA.cjs +0 -2
  176. package/dist/signPsbtsWithFallback-DtwzL5AA.cjs.map +0 -1
  177. package/dist/signPsbtsWithFallback-f7QLp0q8.js.map +0 -1
  178. package/dist/signing-BJ3X66b-.cjs +0 -2
  179. package/dist/signing-BJ3X66b-.cjs.map +0 -1
  180. package/dist/signing-Cm-McVR2.js +0 -22
  181. package/dist/signing-Cm-McVR2.js.map +0 -1
  182. package/dist/toRefundInputs-9inv4Ai4.js.map +0 -1
  183. package/dist/toRefundInputs-DitGWAnz.cjs +0 -2
  184. package/dist/toRefundInputs-DitGWAnz.cjs.map +0 -1
  185. package/dist/verifyScriptPathSchnorrSignature-D_epga4j.js.map +0 -1
  186. package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs +0 -2
  187. package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs.map +0 -1
@@ -1,26 +1,26 @@
1
- var pt = Object.defineProperty;
2
- var gt = (t, e, o) => e in t ? pt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var y = (t, e, o) => gt(t, typeof e != "symbol" ? e + "" : e, o);
4
- import { isAddress as ft, keccak256 as mt, encodeAbiParameters as Pt, getAbiItem as H, encodeFunctionData as K, isAddressEqual as bt, zeroAddress as yt } from "viem";
5
- import { B as g } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
6
- import { B as F, h as v } from "./BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js";
7
- import { M as O, b as M } from "./constants-D5vORbQE.js";
8
- import { waitForTransactionReceiptSmartAware as wt } from "./tbv/core/utils/eth/index.js";
9
- import { a as x } from "./onChainBtcPubkey-C-6UWpD8.js";
10
- import { s as J, b as E, a as Et } from "./secp256k1-D-H9jmd7.js";
11
- import { c as xt, H as Ct, r as C, a as U, h as Z, b as N, s as S } from "./sha2-CLpQd0Rd.js";
12
- const k = 25, It = 9999;
13
- function q(t) {
14
- if (!Number.isInteger(t) || t < 0 || t >= O)
1
+ var dt = Object.defineProperty;
2
+ var pt = (t, e, o) => e in t ? dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var m = (t, e, o) => pt(t, typeof e != "symbol" ? e + "" : e, o);
4
+ import { getAbiItem as _, encodeFunctionData as N, isAddressEqual as gt, zeroAddress as ft } from "viem";
5
+ import { B as h } from "./BTCVaultRegistry.abi-B0x9_Bza.js";
6
+ import { B as K, h as T } from "./BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js";
7
+ import { M as H, b as O } from "./constants-D5vORbQE.js";
8
+ import { waitForTransactionReceiptSmartAware as mt } from "./tbv/core/utils/eth/index.js";
9
+ import { a as C, c as Pt, d as bt } from "./onChainBtcPubkey-C1WqyxPM.js";
10
+ import { s as Y, b as w, a as yt } from "./secp256k1-D-H9jmd7.js";
11
+ import { c as wt, H as Ct, r as E, a as F, h as j, b as R, s as Et } from "./sha2-CLpQd0Rd.js";
12
+ const v = 25, xt = 9999;
13
+ function M(t) {
14
+ if (!Number.isInteger(t) || t < 0 || t >= H)
15
15
  throw new Error(
16
- `Quoted commissionBps must be an integer in [0, ${O}), got ${t}`
16
+ `Quoted commissionBps must be an integer in [0, ${H}), got ${t}`
17
17
  );
18
18
  return Math.min(
19
- t + k,
20
- It
19
+ t + v,
20
+ xt
21
21
  );
22
22
  }
23
- const Bt = /* @__PURE__ */ Uint8Array.from([
23
+ const It = /* @__PURE__ */ Uint8Array.from([
24
24
  7,
25
25
  4,
26
26
  13,
@@ -37,304 +37,183 @@ const Bt = /* @__PURE__ */ Uint8Array.from([
37
37
  14,
38
38
  11,
39
39
  8
40
- ]), tt = Uint8Array.from(new Array(16).fill(0).map((t, e) => e)), $t = tt.map((t) => (9 * t + 5) % 16), et = /* @__PURE__ */ (() => {
41
- const o = [[tt], [$t]];
40
+ ]), Z = Uint8Array.from(new Array(16).fill(0).map((t, e) => e)), Bt = Z.map((t) => (9 * t + 5) % 16), J = /* @__PURE__ */ (() => {
41
+ const o = [[Z], [Bt]];
42
42
  for (let n = 0; n < 4; n++)
43
43
  for (let i of o)
44
- i.push(i[n].map((a) => Bt[a]));
44
+ i.push(i[n].map((s) => It[s]));
45
45
  return o;
46
- })(), ot = et[0], nt = et[1], it = /* @__PURE__ */ [
46
+ })(), tt = J[0], et = J[1], ot = /* @__PURE__ */ [
47
47
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
48
48
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
49
49
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
50
50
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
51
51
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
52
- ].map((t) => Uint8Array.from(t)), vt = /* @__PURE__ */ ot.map((t, e) => t.map((o) => it[e][o])), Tt = /* @__PURE__ */ nt.map((t, e) => t.map((o) => it[e][o])), At = /* @__PURE__ */ Uint32Array.from([
52
+ ].map((t) => Uint8Array.from(t)), Tt = /* @__PURE__ */ tt.map((t, e) => t.map((o) => ot[e][o])), Vt = /* @__PURE__ */ et.map((t, e) => t.map((o) => ot[e][o])), At = /* @__PURE__ */ Uint32Array.from([
53
53
  0,
54
54
  1518500249,
55
55
  1859775393,
56
56
  2400959708,
57
57
  2840853838
58
- ]), Vt = /* @__PURE__ */ Uint32Array.from([
58
+ ]), St = /* @__PURE__ */ Uint32Array.from([
59
59
  1352829926,
60
60
  1548603684,
61
61
  1836072691,
62
62
  2053994217,
63
63
  0
64
64
  ]);
65
- function W(t, e, o, n) {
65
+ function U(t, e, o, n) {
66
66
  return t === 0 ? e ^ o ^ n : t === 1 ? e & o | ~e & n : t === 2 ? (e | ~o) ^ n : t === 3 ? e & n | o & ~n : e ^ (o | ~n);
67
67
  }
68
- const I = /* @__PURE__ */ new Uint32Array(16);
69
- class St extends Ct {
68
+ const x = /* @__PURE__ */ new Uint32Array(16);
69
+ class vt extends Ct {
70
70
  constructor() {
71
71
  super(64, 20, 8, !0);
72
- y(this, "h0", 1732584193);
73
- y(this, "h1", -271733879);
74
- y(this, "h2", -1732584194);
75
- y(this, "h3", 271733878);
76
- y(this, "h4", -1009589776);
72
+ m(this, "h0", 1732584193);
73
+ m(this, "h1", -271733879);
74
+ m(this, "h2", -1732584194);
75
+ m(this, "h3", 271733878);
76
+ m(this, "h4", -1009589776);
77
77
  }
78
78
  get() {
79
- const { h0: o, h1: n, h2: i, h3: a, h4: c } = this;
80
- return [o, n, i, a, c];
79
+ const { h0: o, h1: n, h2: i, h3: s, h4: r } = this;
80
+ return [o, n, i, s, r];
81
81
  }
82
- set(o, n, i, a, c) {
83
- this.h0 = o | 0, this.h1 = n | 0, this.h2 = i | 0, this.h3 = a | 0, this.h4 = c | 0;
82
+ set(o, n, i, s, r) {
83
+ this.h0 = o | 0, this.h1 = n | 0, this.h2 = i | 0, this.h3 = s | 0, this.h4 = r | 0;
84
84
  }
85
85
  process(o, n) {
86
- for (let r = 0; r < 16; r++, n += 4)
87
- I[r] = o.getUint32(n, !0);
88
- let i = this.h0 | 0, a = i, c = this.h1 | 0, h = c, d = this.h2 | 0, p = d, f = this.h3 | 0, P = f, s = this.h4 | 0, l = s;
89
- for (let r = 0; r < 5; r++) {
90
- const u = 4 - r, b = At[r], ct = Vt[r], ut = ot[r], ht = nt[r], lt = vt[r], dt = Tt[r];
91
- for (let m = 0; m < 16; m++) {
92
- const $ = C(i + W(r, c, d, f) + I[ut[m]] + b, lt[m]) + s | 0;
93
- i = s, s = f, f = C(d, 10) | 0, d = c, c = $;
86
+ for (let a = 0; a < 16; a++, n += 4)
87
+ x[a] = o.getUint32(n, !0);
88
+ let i = this.h0 | 0, s = i, r = this.h1 | 0, c = r, u = this.h2 | 0, l = u, g = this.h3 | 0, b = g, f = this.h4 | 0, y = f;
89
+ for (let a = 0; a < 5; a++) {
90
+ const d = 4 - a, rt = At[a], at = St[a], ct = tt[a], ut = et[a], ht = Tt[a], lt = Vt[a];
91
+ for (let p = 0; p < 16; p++) {
92
+ const B = E(i + U(a, r, u, g) + x[ct[p]] + rt, ht[p]) + f | 0;
93
+ i = f, f = g, g = E(u, 10) | 0, u = r, r = B;
94
94
  }
95
- for (let m = 0; m < 16; m++) {
96
- const $ = C(a + W(u, h, p, P) + I[ht[m]] + ct, dt[m]) + l | 0;
97
- a = l, l = P, P = C(p, 10) | 0, p = h, h = $;
95
+ for (let p = 0; p < 16; p++) {
96
+ const B = E(s + U(d, c, l, b) + x[ut[p]] + at, lt[p]) + y | 0;
97
+ s = y, y = b, b = E(l, 10) | 0, l = c, c = B;
98
98
  }
99
99
  }
100
- this.set(this.h1 + d + P | 0, this.h2 + f + l | 0, this.h3 + s + a | 0, this.h4 + i + h | 0, this.h0 + c + p | 0);
100
+ this.set(this.h1 + u + b | 0, this.h2 + g + y | 0, this.h3 + f + s | 0, this.h4 + i + c | 0, this.h0 + r + l | 0);
101
101
  }
102
102
  roundClean() {
103
- U(I);
103
+ F(x);
104
104
  }
105
105
  destroy() {
106
- this.destroyed = !0, U(this.buffer), this.set(0, 0, 0, 0, 0);
106
+ this.destroyed = !0, F(this.buffer), this.set(0, 0, 0, 0, 0);
107
107
  }
108
108
  }
109
- const kt = /* @__PURE__ */ xt(() => new St()), Rt = "5120", R = "0014", _t = 20, D = 33, Nt = 65, Ht = 2, Kt = 3, Ft = 4;
110
- function st(t, e) {
109
+ const $t = /* @__PURE__ */ wt(() => new vt()), kt = "5120", $ = "0014", Rt = 20, q = 33, _t = 65, Nt = 2, Kt = 3, Ht = 4;
110
+ function nt(t, e) {
111
111
  const o = t.startsWith("0x") || t.startsWith("0X") ? t.slice(2) : t;
112
112
  if (!/^(?:[0-9a-fA-F]{2})+$/.test(o))
113
113
  throw new Error(`${e} must be non-empty, even-length hex`);
114
114
  return `0x${o.toLowerCase()}`;
115
115
  }
116
116
  function Ot(t) {
117
- const e = Z(t), o = E.utils.lift_x(BigInt(`0x${t}`)), n = E.utils.bytesToNumberBE(
118
- E.utils.taggedHash("TapTweak", e)
117
+ const e = j(t), o = w.utils.lift_x(BigInt(`0x${t}`)), n = w.utils.bytesToNumberBE(
118
+ w.utils.taggedHash("TapTweak", e)
119
119
  );
120
- if (n >= J.CURVE.n)
120
+ if (n >= Y.CURVE.n)
121
121
  throw new Error("Proof of possession BTC pubkey has an invalid TapTweak");
122
- const i = n === 0n ? o : o.add(E.Point.BASE.multiply(n));
123
- return `0x${Rt}${N(
124
- E.utils.pointToBytes(i)
122
+ const i = n === 0n ? o : o.add(w.Point.BASE.multiply(n));
123
+ return `0x${kt}${R(
124
+ w.utils.pointToBytes(i)
125
125
  )}`;
126
126
  }
127
- function Mt(t) {
128
- const e = st(t, "depositorBtcPubkeyRaw"), o = Z(e.slice(2));
127
+ function Ft(t) {
128
+ const e = nt(t, "depositorBtcPubkeyRaw"), o = j(e.slice(2));
129
129
  if (o.length === 32)
130
130
  return {
131
- xOnlyPubkey: x(e, "Payout BTC pubkey")
131
+ xOnlyPubkey: C(e, "Payout BTC pubkey")
132
132
  };
133
- const n = o.length === D && (o[0] === Ht || o[0] === Kt), i = o.length === Nt && o[0] === Ft;
133
+ const n = o.length === q && (o[0] === Nt || o[0] === Kt), i = o.length === _t && o[0] === Ht;
134
134
  if (!n && !i)
135
135
  throw new Error(
136
136
  "depositorBtcPubkeyRaw must be x-only, compressed, or uncompressed"
137
137
  );
138
138
  try {
139
- J.Point.fromBytes(o);
139
+ Y.Point.fromBytes(o);
140
140
  } catch {
141
141
  throw new Error("depositorBtcPubkeyRaw is not a valid BTC pubkey");
142
142
  }
143
143
  return {
144
- xOnlyPubkey: N(o.subarray(1, D)),
144
+ xOnlyPubkey: R(o.subarray(1, q)),
145
145
  compressedPubkey: n ? o : void 0
146
146
  };
147
147
  }
148
- function Ut(t) {
149
- return `0x${R}${N(kt(S(t)))}`;
148
+ function Mt(t) {
149
+ return `0x${$}${R($t(Et(t)))}`;
150
150
  }
151
- function qt(t, e, o) {
152
- const n = st(
151
+ function Ut(t, e, o) {
152
+ const n = nt(
153
153
  t,
154
154
  "depositorPayoutScriptPubKey"
155
155
  );
156
- if ((n.length - 2) / 2 > M)
156
+ if ((n.length - 2) / 2 > O)
157
157
  throw new Error(
158
- `depositorPayoutScriptPubKey exceeds ${M} bytes`
158
+ `depositorPayoutScriptPubKey exceeds ${O} bytes`
159
159
  );
160
- const i = e.startsWith("0x") || e.startsWith("0X") ? e.slice(2) : e, a = x(
160
+ const i = e.startsWith("0x") || e.startsWith("0X") ? e.slice(2) : e, s = C(
161
161
  `0x${i}`,
162
162
  "Proof of possession BTC pubkey"
163
- ), c = Mt(o);
164
- if (c.xOnlyPubkey !== a)
163
+ ), r = Ft(o);
164
+ if (r.xOnlyPubkey !== s)
165
165
  throw new Error(
166
166
  "depositorBtcPubkeyRaw does not match the proof of possession BTC pubkey"
167
167
  );
168
- if (n === Ot(a))
168
+ if (n === Ot(s))
169
169
  return n;
170
- if (n.startsWith(`0x${R}`) && n.length === 2 + R.length + _t * 2) {
171
- if (!c.compressedPubkey)
170
+ if (n.startsWith(`0x${$}`) && n.length === 2 + $.length + Rt * 2) {
171
+ if (!r.compressedPubkey)
172
172
  throw new Error("A P2WPKH payout requires a compressed BTC pubkey");
173
- if (n === Ut(c.compressedPubkey))
173
+ if (n === Mt(r.compressedPubkey))
174
174
  return n;
175
175
  }
176
176
  throw new Error(
177
177
  "depositorPayoutScriptPubKey does not match the proof of possession BTC pubkey"
178
178
  );
179
179
  }
180
- function Wt(t, e) {
181
- const o = t.startsWith("0x") ? t.slice(2) : t;
182
- if (o.length === 0 || o.length % 2 !== 0)
183
- throw new Error(`${e} must be non-empty, even-length hex`);
184
- if (!/^[0-9a-fA-F]+$/.test(o))
185
- throw new Error(`${e} contains non-hex characters`);
186
- const n = new Uint8Array(o.length / 2);
187
- for (let i = 0; i < n.length; i++)
188
- n[i] = Number.parseInt(o.slice(i * 2, i * 2 + 2), 16);
189
- return n;
190
- }
191
- function Dt(t) {
192
- return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join(
193
- ""
194
- );
195
- }
196
- function Lt(t) {
197
- const e = new Uint8Array(
198
- t.reduce((n, i) => n + i.length, 0)
199
- );
200
- let o = 0;
201
- for (const n of t)
202
- e.set(n, o), o += n.length;
203
- return e;
204
- }
205
- function Xt(t) {
206
- let e = 0;
207
- const o = (s, l) => {
208
- if (!Number.isSafeInteger(s) || s < 0)
209
- throw new Error(`Invalid ${l} length ${s}`);
210
- if (e + s > t.length)
211
- throw new Error(`Truncated Bitcoin transaction while reading ${l}`);
212
- const r = t.slice(e, e + s);
213
- return e += s, r;
214
- }, n = (s, l) => {
215
- const r = o(s, l);
216
- let u = 0n;
217
- for (let b = r.length - 1; b >= 0; b--)
218
- u = u << 8n | BigInt(r[b]);
219
- return u;
220
- }, i = (s) => {
221
- const l = e, r = o(1, s)[0];
222
- let u;
223
- if (r < 253)
224
- u = BigInt(r);
225
- else if (r === 253) {
226
- if (u = n(2, s), u < 0xfdn) throw new Error(`Non-canonical ${s}`);
227
- } else if (r === 254) {
228
- if (u = n(4, s), u <= 0xffffn) throw new Error(`Non-canonical ${s}`);
229
- } else if (u = n(8, s), u <= 0xffffffffn) throw new Error(`Non-canonical ${s}`);
230
- if (u > BigInt(Number.MAX_SAFE_INTEGER))
231
- throw new Error(`${s} exceeds JavaScript's safe integer range`);
232
- return {
233
- encoded: t.slice(l, e),
234
- value: Number(u)
235
- };
236
- }, a = o(4, "version"), c = t[e] === 0 && t[e + 1] === 1;
237
- c && (e += 2);
238
- const h = i("input count"), d = [];
239
- for (let s = 0; s < h.value; s++) {
240
- const l = e;
241
- o(32, `input ${s} previous transaction hash`), o(4, `input ${s} previous output index`);
242
- const r = i(`input ${s} script length`);
243
- o(r.value, `input ${s} script`), o(4, `input ${s} sequence`), d.push(t.slice(l, e));
244
- }
245
- const p = i("output count"), f = [];
246
- for (let s = 0; s < p.value; s++) {
247
- const l = e;
248
- o(8, `output ${s} value`);
249
- const r = i(`output ${s} script length`);
250
- o(r.value, `output ${s} script`), f.push(t.slice(l, e));
251
- }
252
- if (c) {
253
- let s = !1;
254
- for (let l = 0; l < h.value; l++) {
255
- const r = i(`input ${l} witness item count`);
256
- s || (s = r.value > 0);
257
- for (let u = 0; u < r.value; u++) {
258
- const b = i(
259
- `input ${l} witness item ${u} length`
260
- );
261
- o(b.value, `input ${l} witness item ${u}`);
262
- }
263
- }
264
- if (!s)
265
- throw new Error("Bitcoin transaction has superfluous witness marker");
266
- }
267
- const P = o(4, "locktime");
268
- if (e !== t.length)
269
- throw new Error(
270
- `Bitcoin transaction has ${t.length - e} trailing byte(s)`
271
- );
272
- return Lt([
273
- a,
274
- h.encoded,
275
- ...d,
276
- p.encoded,
277
- ...f,
278
- P
279
- ]);
280
- }
281
- function zt(t) {
282
- const e = Xt(
283
- Wt(t, "transactionHex")
284
- ), o = S(S(e));
285
- return o.reverse(), `0x${Dt(o)}`;
286
- }
287
- function Gt(t, e) {
288
- const o = t.startsWith("0x") ? t : `0x${t}`;
289
- if (!/^0x[0-9a-fA-F]{64}$/.test(o))
290
- throw new Error("peginTxHash must be a 32-byte hex value");
291
- const n = e.startsWith("0x") ? e : `0x${e}`;
292
- if (!ft(n, { strict: !0 }))
293
- throw new Error(`Invalid depositor Ethereum address: ${e}`);
294
- return mt(
295
- Pt(
296
- [{ type: "bytes32" }, { type: "address" }],
297
- [o, n]
298
- )
299
- ).slice(2);
300
- }
301
- const T = 65535, L = 1e4, B = 4294967295, X = 255;
302
- function Qt(t) {
303
- if (!Number.isInteger(t) || t < 0 || t > B)
180
+ const V = 65535, D = 1e4, I = 4294967295, W = 255;
181
+ function qt(t) {
182
+ if (!Number.isInteger(t) || t < 0 || t > I)
304
183
  throw new Error(
305
184
  `Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`
306
185
  );
307
186
  }
308
- function Yt(t) {
187
+ function Dt(t) {
309
188
  const e = [];
310
189
  if (t.timelockAssert <= 0n && e.push(
311
190
  `timelockAssert must be positive, got ${t.timelockAssert}`
312
- ), t.timelockAssert > BigInt(T) && e.push(
313
- `timelockAssert ${t.timelockAssert} exceeds uint16 max (${T})`
191
+ ), t.timelockAssert > BigInt(V) && e.push(
192
+ `timelockAssert ${t.timelockAssert} exceeds uint16 max (${V})`
314
193
  ), t.timelockChallengeAssert <= 0n && e.push(
315
194
  `timelockChallengeAssert must be positive, got ${t.timelockChallengeAssert}`
316
195
  ), t.tRefund <= 0 && e.push(`tRefund must be positive, got ${t.tRefund}`), t.tStale <= 0 && e.push(`tStale must be positive, got ${t.tStale}`), t.securityCouncilKeys.length === 0 && e.push("securityCouncilKeys must not be empty"), t.councilQuorum <= 0 && e.push(`councilQuorum must be positive, got ${t.councilQuorum}`), t.councilQuorum > t.securityCouncilKeys.length && e.push(
317
196
  `councilQuorum (${t.councilQuorum}) exceeds securityCouncilKeys count (${t.securityCouncilKeys.length})`
318
197
  ), t.feeRate <= 0n && e.push(`feeRate must be positive, got ${t.feeRate}`), t.minPeginFeeRate <= 0n && e.push(
319
198
  `minPeginFeeRate must be positive, got ${t.minPeginFeeRate}`
320
- ), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion > T) && e.push(
199
+ ), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion > V) && e.push(
321
200
  `proverCircuitVersion must be a uint16, got ${t.proverCircuitVersion}`
322
- ), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > B) && e.push(
323
- `minPrepeginDepth must be a uint32 in [1, ${B}], got ${t.minPrepeginDepth}`
201
+ ), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > I) && e.push(
202
+ `minPrepeginDepth must be a uint32 in [1, ${I}], got ${t.minPrepeginDepth}`
324
203
  ), t.babeTotalInstances <= 0 && e.push(
325
204
  `babeTotalInstances must be positive, got ${t.babeTotalInstances}`
326
205
  ), t.babeInstancesToFinalize <= 0 && e.push(
327
206
  `babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`
328
207
  ), t.babeInstancesToFinalize > t.babeTotalInstances && e.push(
329
208
  `babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`
330
- ), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > L) && e.push(
331
- `minVpCommissionBps must be in [0, ${L}], got ${t.minVpCommissionBps}`
209
+ ), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > D) && e.push(
210
+ `minVpCommissionBps must be in [0, ${D}], got ${t.minVpCommissionBps}`
332
211
  ), e.length > 0)
333
212
  throw new Error(
334
213
  `Invalid offchain protocol parameters: ${e.join("; ")}`
335
214
  );
336
215
  }
337
- function jt(t) {
216
+ function Wt(t) {
338
217
  const e = [];
339
218
  if (t.minimumPegInAmount <= 0n && e.push(
340
219
  `minimumPegInAmount must be positive, got ${t.minimumPegInAmount}`
@@ -344,38 +223,38 @@ function jt(t) {
344
223
  `pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`
345
224
  ), t.pegInActivationTimeout <= 0n && e.push(
346
225
  `pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`
347
- ), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > X) && e.push(
348
- `maxHtlcOutputCount must be an integer in [1, ${X}], got ${t.maxHtlcOutputCount}`
226
+ ), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > W) && e.push(
227
+ `maxHtlcOutputCount must be an integer in [1, ${W}], got ${t.maxHtlcOutputCount}`
349
228
  ), (typeof t.expiredPegInGraceBlocks != "bigint" || t.expiredPegInGraceBlocks <= 0n) && e.push(
350
229
  `expiredPegInGraceBlocks must be a positive bigint, got ${t.expiredPegInGraceBlocks}`
351
230
  ), e.length > 0)
352
231
  throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`);
353
232
  }
354
- function fe(t) {
355
- if (jt(t), Yt(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > B)
233
+ function ce(t) {
234
+ if (Wt(t), Dt(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > I)
356
235
  throw new Error(
357
236
  `Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`
358
237
  );
359
- Et(
238
+ yt(
360
239
  t.activeVaultCoreVersion,
361
240
  "ProtocolParams.activeVaultCoreVersion()"
362
241
  );
363
242
  }
364
- const rt = "RegistrationLogsUnavailableError";
365
- class at extends Error {
243
+ const it = "RegistrationLogsUnavailableError";
244
+ class st extends Error {
366
245
  constructor(o) {
367
246
  super(
368
247
  `The Ethereum node returned no registration logs for block ${o}, which holds a vault registration; the node may not have indexed that block yet. Try again.`
369
248
  );
370
- y(this, "blockNumber");
371
- this.name = rt, this.blockNumber = o;
249
+ m(this, "blockNumber");
250
+ this.name = it, this.blockNumber = o;
372
251
  }
373
252
  }
374
- function me(t) {
375
- return t instanceof at ? !0 : typeof t != "object" || t === null ? !1 : t.name === rt;
253
+ function ue(t) {
254
+ return t instanceof st ? !0 : typeof t != "object" || t === null ? !1 : t.name === it;
376
255
  }
377
- const z = 9999;
378
- function G(t) {
256
+ const L = 9999;
257
+ function X(t) {
379
258
  return {
380
259
  depositor: t.depositor,
381
260
  depositorBtcPubKey: t.depositorBtcPubKey,
@@ -388,7 +267,7 @@ function G(t) {
388
267
  }
389
268
  function A(t) {
390
269
  const e = Number(t.offchainParamsVersion);
391
- return Qt(e), {
270
+ return qt(e), {
392
271
  depositorSignedPeginTx: t.depositorSignedPeginTx,
393
272
  universalChallengersVersion: t.universalChallengersVersion,
394
273
  appVaultKeepersVersion: t.appVaultKeepersVersion,
@@ -403,29 +282,29 @@ function A(t) {
403
282
  vaultCoreVersion: t.vaultCoreVersion
404
283
  };
405
284
  }
406
- const Jt = 1n << 64n, Q = 0n, Zt = [
407
- H({ abi: g, name: "PegInSubmitted" }),
408
- H({ abi: g, name: "PegInSubmittedV2" })
285
+ const Lt = 1n << 64n, z = 0n, Xt = [
286
+ _({ abi: h, name: "PegInSubmitted" }),
287
+ _({ abi: h, name: "PegInSubmittedV2" })
409
288
  ];
410
- function V(t, e, o) {
411
- if (t < 0n || t >= Jt)
289
+ function S(t, e, o) {
290
+ if (t < 0n || t >= Lt)
412
291
  throw new Error(
413
292
  `getBtcVaultProtocolInfo returned ${e}=${t} for vault ${o}, outside the uint64 range — the registry may predate RFC-006`
414
293
  );
415
294
  return t;
416
295
  }
417
- function Y(t, e) {
296
+ function G(t, e) {
418
297
  return {
419
- vpKeyEpoch: V(t.vpKeyEpoch, "vpKeyEpoch", e),
420
- appKeeperKeyEpoch: V(
298
+ vpKeyEpoch: S(t.vpKeyEpoch, "vpKeyEpoch", e),
299
+ appKeeperKeyEpoch: S(
421
300
  t.appKeeperKeyEpoch,
422
301
  "appKeeperKeyEpoch",
423
302
  e
424
303
  ),
425
- ucKeyEpoch: V(t.ucKeyEpoch, "ucKeyEpoch", e)
304
+ ucKeyEpoch: S(t.ucKeyEpoch, "ucKeyEpoch", e)
426
305
  };
427
306
  }
428
- class te {
307
+ class zt {
429
308
  constructor(e, o) {
430
309
  this.publicClient = e, this.contractAddress = o;
431
310
  }
@@ -455,14 +334,14 @@ class te {
455
334
  async getVaultProviderGenesisBtcPubKey(e, o) {
456
335
  const n = await this.publicClient.readContract({
457
336
  address: this.contractAddress,
458
- abi: g,
337
+ abi: h,
459
338
  functionName: "getOperationBtcKeyAtEpoch",
460
- args: [e, Q],
339
+ args: [e, z],
461
340
  blockNumber: o
462
341
  });
463
- return x(
342
+ return C(
464
343
  n,
465
- `getOperationBtcKeyAtEpoch (vp=${e}, epoch=${Q})`
344
+ `getOperationBtcKeyAtEpoch (vp=${e}, epoch=${z})`
466
345
  );
467
346
  }
468
347
  /**
@@ -479,7 +358,7 @@ class te {
479
358
  async getVaultProviderApplication(e, o) {
480
359
  return await this.publicClient.readContract({
481
360
  address: this.contractAddress,
482
- abi: g,
361
+ abi: h,
483
362
  functionName: "getVaultProviderApplication",
484
363
  args: [e],
485
364
  blockNumber: o
@@ -499,11 +378,11 @@ class te {
499
378
  async getCurrentVaultProviderOperationBtcKey(e) {
500
379
  const o = await this.publicClient.readContract({
501
380
  address: this.contractAddress,
502
- abi: g,
381
+ abi: h,
503
382
  functionName: "getCurrentOperationBtcKey",
504
383
  args: [e]
505
384
  });
506
- return x(
385
+ return C(
507
386
  o,
508
387
  `getCurrentOperationBtcKey (vp=${e})`
509
388
  );
@@ -527,38 +406,38 @@ class te {
527
406
  async getVaultKeyEpochs(e) {
528
407
  const o = await this.publicClient.readContract({
529
408
  address: this.contractAddress,
530
- abi: F,
409
+ abi: K,
531
410
  functionName: "getBtcVaultProtocolInfo",
532
411
  args: [e]
533
412
  });
534
- return Y(o, e);
413
+ return G(o, e);
535
414
  }
536
415
  async getVaultKeyEpochsBatch(e) {
537
416
  return e.length === 0 ? [] : (await this.publicClient.multicall({
538
417
  contracts: e.map((n) => ({
539
418
  address: this.contractAddress,
540
- abi: F,
419
+ abi: K,
541
420
  functionName: "getBtcVaultProtocolInfo",
542
421
  args: [n]
543
422
  })),
544
423
  allowFailure: !1
545
424
  })).map(
546
- (n, i) => Y(n, e[i])
425
+ (n, i) => G(n, e[i])
547
426
  );
548
427
  }
549
428
  async getVaultBasicInfo(e) {
550
429
  const o = await this.publicClient.readContract({
551
430
  address: this.contractAddress,
552
- abi: g,
431
+ abi: h,
553
432
  functionName: "getBtcVaultBasicInfo",
554
433
  args: [e]
555
434
  });
556
- return G(o);
435
+ return X(o);
557
436
  }
558
437
  async getVaultProtocolInfo(e) {
559
438
  const o = await this.publicClient.readContract({
560
439
  address: this.contractAddress,
561
- abi: g,
440
+ abi: h,
562
441
  functionName: "getBtcVaultProtocolInfo",
563
442
  args: [e]
564
443
  });
@@ -568,18 +447,18 @@ class te {
568
447
  return e.length === 0 ? [] : (await this.publicClient.multicall({
569
448
  contracts: e.map((n) => ({
570
449
  address: this.contractAddress,
571
- abi: g,
450
+ abi: h,
572
451
  functionName: "getBtcVaultProtocolInfo",
573
452
  args: [n]
574
453
  })),
575
454
  allowFailure: !1
576
455
  })).map((n, i) => {
577
- const a = n;
578
- if (!a.depositorSignedPeginTx || a.depositorSignedPeginTx === "0x")
456
+ const s = n;
457
+ if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
579
458
  throw new Error(
580
459
  `Vault ${e[i]} not found on-chain or has no pegin transaction`
581
460
  );
582
- return A(a);
461
+ return A(s);
583
462
  });
584
463
  }
585
464
  /**
@@ -589,7 +468,7 @@ class te {
589
468
  async getPegInFee(e) {
590
469
  return await this.publicClient.readContract({
591
470
  address: this.contractAddress,
592
- abi: g,
471
+ abi: h,
593
472
  functionName: "getPegInFee",
594
473
  args: [e]
595
474
  });
@@ -604,13 +483,13 @@ class te {
604
483
  async getVaultProviderCommission(e) {
605
484
  const o = await this.publicClient.readContract({
606
485
  address: this.contractAddress,
607
- abi: g,
486
+ abi: h,
608
487
  functionName: "getVaultProviderCommission",
609
488
  args: [e]
610
489
  });
611
- if (!Number.isInteger(o) || o < 0 || o > z)
490
+ if (!Number.isInteger(o) || o < 0 || o > L)
612
491
  throw new Error(
613
- `getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${z}]`
492
+ `getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${L}]`
614
493
  );
615
494
  return o;
616
495
  }
@@ -619,24 +498,24 @@ class te {
619
498
  contracts: [
620
499
  {
621
500
  address: this.contractAddress,
622
- abi: g,
501
+ abi: h,
623
502
  functionName: "getBtcVaultBasicInfo",
624
503
  args: [e]
625
504
  },
626
505
  {
627
506
  address: this.contractAddress,
628
- abi: g,
507
+ abi: h,
629
508
  functionName: "getBtcVaultProtocolInfo",
630
509
  args: [e]
631
510
  }
632
511
  ],
633
512
  allowFailure: !1
634
- }), i = G(o), a = A(n);
635
- if (!a.depositorSignedPeginTx || a.depositorSignedPeginTx === "0x")
513
+ }), i = X(o), s = A(n);
514
+ if (!s.depositorSignedPeginTx || s.depositorSignedPeginTx === "0x")
636
515
  throw new Error(
637
516
  `Vault ${e} not found on-chain or has no pegin transaction`
638
517
  );
639
- return { basic: i, protocol: a };
518
+ return { basic: i, protocol: s };
640
519
  }
641
520
  /**
642
521
  * Read the depositor's commission ceiling (`maxAcceptableCommissionBps`)
@@ -660,23 +539,23 @@ class te {
660
539
  if (e.length === 0) return [];
661
540
  const n = await this.publicClient.getLogs({
662
541
  address: this.contractAddress,
663
- events: Zt,
542
+ events: Xt,
664
543
  fromBlock: o,
665
544
  toBlock: o,
666
545
  strict: !0
667
546
  });
668
547
  if (n.length === 0)
669
- throw new at(o);
548
+ throw new st(o);
670
549
  return e.map((i) => {
671
- const a = i.toLowerCase();
672
- let c = !1;
673
- const h = [];
674
- for (const d of n)
675
- d.args.vaultId.toLowerCase() === a && (c = !0, d.eventName === "PegInSubmittedV2" && h.push(d.args.maxAcceptableCommissionBps));
676
- if (h.length === 1) return h[0];
677
- throw h.length > 1 ? new Error(
678
- `Expected one PegInSubmittedV2 log for vault ${i} at block ${o}, found ${h.length} PegInSubmittedV2 logs`
679
- ) : c ? new Error(
550
+ const s = i.toLowerCase();
551
+ let r = !1;
552
+ const c = [];
553
+ for (const u of n)
554
+ u.args.vaultId.toLowerCase() === s && (r = !0, u.eventName === "PegInSubmittedV2" && c.push(u.args.maxAcceptableCommissionBps));
555
+ if (c.length === 1) return c[0];
556
+ throw c.length > 1 ? new Error(
557
+ `Expected one PegInSubmittedV2 log for vault ${i} at block ${o}, found ${c.length} PegInSubmittedV2 logs`
558
+ ) : r ? new Error(
680
559
  `Vault ${i} was registered before the registry emitted the depositor's commission ceiling (no PegInSubmittedV2 log at block ${o}), so the ceiling cannot be recovered on-chain`
681
560
  ) : new Error(
682
561
  `Vault ${i} has no registration log at its on-chain registration block ${o}`
@@ -684,29 +563,29 @@ class te {
684
563
  });
685
564
  }
686
565
  }
687
- const ee = 0, oe = 255, ne = 12e4;
688
- function w(t, e) {
566
+ const Gt = 0, Qt = 255, Yt = 12e4;
567
+ function P(t, e) {
689
568
  const o = t.startsWith("0x") ? t : t.startsWith("0X") ? `0x${t.slice(2)}` : `0x${t}`;
690
569
  if (!/^0x(?:[0-9a-fA-F]{2})+$/.test(o))
691
570
  throw new Error(`${e} must be non-empty, even-length hex`);
692
571
  return o;
693
572
  }
694
- function _(t, e) {
573
+ function k(t, e) {
695
574
  if (!/^0x[0-9a-fA-F]{64}$/.test(t))
696
575
  throw new Error(`${e} must be a 32-byte hex value`);
697
576
  }
698
- const ie = "0x0000000000000000000000000000000000000000000000000000000000000000";
699
- function j(t) {
700
- if (_(t, "expectedFingerprint"), t.toLowerCase() === ie)
577
+ const jt = "0x0000000000000000000000000000000000000000000000000000000000000000";
578
+ function Q(t) {
579
+ if (k(t, "expectedFingerprint"), t.toLowerCase() === jt)
701
580
  throw new Error(
702
581
  "expectedFingerprint must not be zero: the registry cannot resolve a zero fingerprint, so this submission would always revert"
703
582
  );
704
583
  }
705
- function se(t) {
706
- if (!Number.isInteger(t) || t < 0 || t > oe)
584
+ function Zt(t) {
585
+ if (!Number.isInteger(t) || t < 0 || t > Qt)
707
586
  throw new Error(`htlcVout must be a uint8, got ${t}`);
708
587
  }
709
- class Pe {
588
+ class he {
710
589
  constructor(e) {
711
590
  this.config = e;
712
591
  }
@@ -715,36 +594,36 @@ class Pe {
715
594
  ...e,
716
595
  popSignature: { ...e.popSignature }
717
596
  };
718
- this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps), j(o.expectedFingerprint);
719
- const n = this.assertPopMatchesEthAccount(o.popSignature), i = this.normalizeBtcPubkey(o.popSignature), a = w(
597
+ this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps), Q(o.expectedFingerprint);
598
+ const n = this.assertPopMatchesEthAccount(o.popSignature), i = this.normalizeBtcPubkey(o.popSignature), s = P(
720
599
  o.popSignature.btcPopSignature,
721
600
  "btcPopSignature"
722
- ), c = this.normalizeRequest(
601
+ ), r = this.normalizeRequest(
723
602
  o,
724
603
  n,
725
604
  i
726
605
  );
727
606
  await this.assertVaultDoesNotExist(
728
- c.vaultId,
729
- c.peginTxHash
607
+ r.vaultId,
608
+ r.peginTxHash
730
609
  );
731
- const h = await this.readPeginFee(o.vaultProvider), d = await this.resolveMaxAcceptableCommissionBps(
610
+ const c = await this.readPeginFee(o.vaultProvider), u = await this.resolveMaxAcceptableCommissionBps(
732
611
  o.vaultProvider,
733
612
  o.quotedCommissionBps
734
- ), p = K({
735
- abi: g,
613
+ ), l = N({
614
+ abi: h,
736
615
  functionName: "submitPeginRequest",
737
616
  args: [
738
617
  n,
739
618
  i,
740
- a,
741
- c.unsignedPrePeginTx,
742
- c.depositorSignedPeginTx,
619
+ s,
620
+ r.unsignedPrePeginTx,
621
+ r.depositorSignedPeginTx,
743
622
  o.vaultProvider,
744
- d,
623
+ u,
745
624
  o.hashlock,
746
625
  o.htlcVout,
747
- c.payoutScript,
626
+ r.payoutScript,
748
627
  o.depositorWotsPkHash,
749
628
  // Appended last on the singular overload; the batch takes it at
750
629
  // position 4 instead. Order is the selector, so do not "tidy" either.
@@ -753,83 +632,83 @@ class Pe {
753
632
  });
754
633
  return {
755
634
  ethTxHash: await this.sendAndWait(
756
- p,
757
- h,
635
+ l,
636
+ c,
758
637
  !1,
759
638
  n
760
639
  ),
761
- vaultId: c.vaultId,
762
- peginTxHash: c.peginTxHash
640
+ vaultId: r.vaultId,
641
+ peginTxHash: r.peginTxHash
763
642
  };
764
643
  }
765
644
  async registerPeginBatchOnChain(e) {
766
645
  const o = {
767
646
  ...e,
768
647
  popSignature: { ...e.popSignature },
769
- requests: e.requests.map((r) => ({ ...r }))
648
+ requests: e.requests.map((a) => ({ ...a }))
770
649
  };
771
650
  if (o.requests.length === 0)
772
651
  throw new Error("Batch pegin requires at least one request");
773
- this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps), j(o.expectedFingerprint);
774
- const n = this.assertPopMatchesEthAccount(o.popSignature), i = w(
652
+ this.assertQuotedCommissionPresentWhenRequired(o.quotedCommissionBps), Q(o.expectedFingerprint);
653
+ const n = this.assertPopMatchesEthAccount(o.popSignature), i = P(
775
654
  o.unsignedPrePeginTx,
776
655
  "unsignedPrePeginTx"
777
- ), a = this.normalizeBtcPubkey(o.popSignature), c = w(
656
+ ), s = this.normalizeBtcPubkey(o.popSignature), r = P(
778
657
  o.popSignature.btcPopSignature,
779
658
  "btcPopSignature"
780
- ), h = [], d = [], p = /* @__PURE__ */ new Set();
781
- for (const r of o.requests) {
782
- const u = this.normalizeRequest(
659
+ ), c = [], u = [], l = /* @__PURE__ */ new Set();
660
+ for (const a of o.requests) {
661
+ const d = this.normalizeRequest(
783
662
  {
784
- ...r,
663
+ ...a,
785
664
  unsignedPrePeginTx: o.unsignedPrePeginTx,
786
665
  vaultProvider: o.vaultProvider,
787
666
  depositorBtcPubkeyRaw: o.depositorBtcPubkeyRaw
788
667
  },
789
668
  n,
790
- a
669
+ s
791
670
  );
792
- if (p.has(u.vaultId))
793
- throw new Error(`Duplicate vault in batch: ${u.vaultId}`);
794
- p.add(u.vaultId), h.push({
795
- vaultId: u.vaultId,
796
- peginTxHash: u.peginTxHash
797
- }), d.push({
798
- depositorBtcPubKey: a,
799
- btcPopSignature: c,
671
+ if (l.has(d.vaultId))
672
+ throw new Error(`Duplicate vault in batch: ${d.vaultId}`);
673
+ l.add(d.vaultId), c.push({
674
+ vaultId: d.vaultId,
675
+ peginTxHash: d.peginTxHash
676
+ }), u.push({
677
+ depositorBtcPubKey: s,
678
+ btcPopSignature: r,
800
679
  unsignedPrePeginTx: i,
801
- depositorSignedPeginTx: u.depositorSignedPeginTx,
802
- hashlock: r.hashlock,
803
- htlcVout: r.htlcVout,
804
- referralCode: ee,
805
- depositorPayoutBtcAddress: u.payoutScript,
806
- depositorWotsPkHash: r.depositorWotsPkHash
680
+ depositorSignedPeginTx: d.depositorSignedPeginTx,
681
+ hashlock: a.hashlock,
682
+ htlcVout: a.htlcVout,
683
+ referralCode: Gt,
684
+ depositorPayoutBtcAddress: d.payoutScript,
685
+ depositorWotsPkHash: a.depositorWotsPkHash
807
686
  });
808
687
  }
809
- for (const r of h)
810
- await this.assertVaultDoesNotExist(r.vaultId, r.peginTxHash);
811
- const f = await this.readPeginFee(o.vaultProvider), P = await this.resolveMaxAcceptableCommissionBps(
688
+ for (const a of c)
689
+ await this.assertVaultDoesNotExist(a.vaultId, a.peginTxHash);
690
+ const g = await this.readPeginFee(o.vaultProvider), b = await this.resolveMaxAcceptableCommissionBps(
812
691
  o.vaultProvider,
813
692
  o.quotedCommissionBps
814
- ), s = K({
815
- abi: g,
693
+ ), f = N({
694
+ abi: h,
816
695
  functionName: "submitPeginRequestBatch",
817
696
  // `expectedFingerprint` sits BEFORE `requests`, not appended. Reordering
818
697
  // these five changes the selector and the call stops existing.
819
698
  args: [
820
699
  n,
821
700
  o.vaultProvider,
822
- P,
701
+ b,
823
702
  o.expectedFingerprint,
824
- d
703
+ u
825
704
  ]
826
705
  });
827
706
  return { ethTxHash: await this.sendAndWait(
828
- s,
829
- f * BigInt(o.requests.length),
707
+ f,
708
+ g * BigInt(o.requests.length),
830
709
  !0,
831
710
  n
832
- ), vaults: h };
711
+ ), vaults: c };
833
712
  }
834
713
  assertQuotedCommissionPresentWhenRequired(e) {
835
714
  if (e === void 0 && this.config.requireQuotedCommissionBps)
@@ -843,15 +722,15 @@ class Pe {
843
722
  assertEthAccount(e) {
844
723
  const o = this.config.ethWallet.account;
845
724
  if (!o) throw new Error("Ethereum wallet account not found");
846
- if (!bt(e, o.address))
725
+ if (!gt(e, o.address))
847
726
  throw new Error(
848
727
  `Proof of possession was signed for ${e} but the Ethereum wallet is currently connected to ${o.address}. Reconnect the original account or sign a new proof of possession.`
849
728
  );
850
729
  return o.address;
851
730
  }
852
731
  normalizeBtcPubkey(e) {
853
- return `0x${x(
854
- w(e.depositorBtcPubkey, "Proof of possession BTC pubkey"),
732
+ return `0x${C(
733
+ P(e.depositorBtcPubkey, "Proof of possession BTC pubkey"),
855
734
  "Proof of possession BTC pubkey"
856
735
  )}`;
857
736
  }
@@ -860,33 +739,33 @@ class Pe {
860
739
  // value through a per-request helper that has no use for it. It is validated
861
740
  // once per call, at the top of each public method.
862
741
  normalizeRequest(e, o, n) {
863
- _(e.hashlock, "hashlock"), _(e.depositorWotsPkHash, "depositorWotsPkHash"), se(e.htlcVout);
864
- const i = w(
742
+ k(e.hashlock, "hashlock"), k(e.depositorWotsPkHash, "depositorWotsPkHash"), Zt(e.htlcVout);
743
+ const i = P(
865
744
  e.unsignedPrePeginTx,
866
745
  "unsignedPrePeginTx"
867
- ), a = w(
746
+ ), s = P(
868
747
  e.depositorSignedPeginTx,
869
748
  "depositorSignedPeginTx"
870
- ), c = zt(a);
749
+ ), r = Pt(s);
871
750
  return {
872
751
  unsignedPrePeginTx: i,
873
- depositorSignedPeginTx: a,
874
- payoutScript: qt(
752
+ depositorSignedPeginTx: s,
753
+ payoutScript: Ut(
875
754
  e.depositorPayoutScriptPubKey,
876
755
  n,
877
756
  e.depositorBtcPubkeyRaw
878
757
  ),
879
- peginTxHash: c,
880
- vaultId: w(Gt(c, o), "vaultId")
758
+ peginTxHash: r,
759
+ vaultId: P(bt(r, o), "vaultId")
881
760
  };
882
761
  }
883
762
  async assertVaultDoesNotExist(e, o) {
884
763
  if ((await this.config.publicClient.readContract({
885
764
  address: this.config.btcVaultRegistry,
886
- abi: g,
765
+ abi: h,
887
766
  functionName: "getBtcVaultBasicInfo",
888
767
  args: [e]
889
- })).depositor !== yt)
768
+ })).depositor !== ft)
890
769
  throw new Error(
891
770
  `Vault already exists (ID: ${e}, peginTxHash: ${o}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
892
771
  );
@@ -895,7 +774,7 @@ class Pe {
895
774
  try {
896
775
  return await this.config.publicClient.readContract({
897
776
  address: this.config.btcVaultRegistry,
898
- abi: g,
777
+ abi: h,
899
778
  functionName: "getPegInFee",
900
779
  args: [e]
901
780
  });
@@ -909,7 +788,7 @@ class Pe {
909
788
  async resolveMaxAcceptableCommissionBps(e, o) {
910
789
  let n;
911
790
  try {
912
- n = await new te(
791
+ n = await new zt(
913
792
  this.config.publicClient,
914
793
  this.config.btcVaultRegistry
915
794
  ).getVaultProviderCommission(e);
@@ -920,67 +799,65 @@ class Pe {
920
799
  );
921
800
  }
922
801
  if (o !== void 0) {
923
- if (n > o + k)
802
+ if (n > o + v)
924
803
  throw new Error(
925
- `Vault provider commission changed since quote: quoted ${o} bps, chain currently reports ${n} bps (allowed drift ${k} bps). Please refresh and try again.`
804
+ `Vault provider commission changed since quote: quoted ${o} bps, chain currently reports ${n} bps (allowed drift ${v} bps). Please refresh and try again.`
926
805
  );
927
- return q(o);
806
+ return M(o);
928
807
  }
929
- return q(n);
808
+ return M(n);
930
809
  }
931
810
  async sendAndWait(e, o, n, i) {
932
- let a = this.assertEthAccount(i), c;
811
+ let s = this.assertEthAccount(i), r;
933
812
  try {
934
- c = await this.config.publicClient.estimateGas({
813
+ r = await this.config.publicClient.estimateGas({
935
814
  to: this.config.btcVaultRegistry,
936
815
  data: e,
937
816
  value: o,
938
- account: a
817
+ account: s
939
818
  });
940
- } catch (p) {
941
- v(p);
819
+ } catch (l) {
820
+ T(l);
942
821
  }
943
- a = this.assertEthAccount(i);
944
- let h;
822
+ s = this.assertEthAccount(i);
823
+ let c;
945
824
  try {
946
- h = await this.config.ethWallet.sendTransaction({
825
+ c = await this.config.ethWallet.sendTransaction({
947
826
  to: this.config.btcVaultRegistry,
948
827
  data: e,
949
828
  value: o,
950
- gas: c,
951
- account: a,
829
+ gas: r,
830
+ account: s,
952
831
  chain: this.config.ethChain
953
832
  });
954
- } catch (p) {
955
- v(p);
833
+ } catch (l) {
834
+ T(l);
956
835
  }
957
- const d = await wt({
836
+ const u = await mt({
958
837
  publicClient: this.config.publicClient,
959
838
  walletAddress: i,
960
- hash: h,
961
- timeout: this.config.receiptTimeoutMs ?? ne
839
+ hash: c,
840
+ timeout: this.config.receiptTimeoutMs ?? Yt
962
841
  });
963
- return d.status === "reverted" && v(
842
+ return u.status === "reverted" && T(
964
843
  new Error(
965
- `${n ? "Batch transaction" : "Transaction"} reverted. Hash: ${d.transactionHash}. Check a block explorer for details.`
844
+ `${n ? "Batch transaction" : "Transaction"} reverted. Hash: ${u.transactionHash}. Check a block explorer for details.`
966
845
  )
967
- ), d.transactionHash;
846
+ ), u.transactionHash;
968
847
  }
969
848
  }
970
849
  export {
971
- k as C,
972
- It as M,
973
- at as R,
974
- Pe as V,
975
- fe as a,
976
- jt as b,
977
- te as c,
978
- Gt as d,
979
- q as e,
980
- zt as f,
981
- Qt as g,
982
- me as i,
983
- kt as r,
984
- Yt as v
850
+ v as C,
851
+ xt as M,
852
+ st as R,
853
+ he as V,
854
+ ce as a,
855
+ Wt as b,
856
+ zt as c,
857
+ M as d,
858
+ qt as e,
859
+ ue as i,
860
+ $t as r,
861
+ Dt as v
985
862
  };
986
- //# sourceMappingURL=pegin-registration-client-pcczkzMg.js.map
863
+ //# sourceMappingURL=pegin-registration-client-1sZ-74UC.js.map