@babylonlabs-io/ts-sdk 0.33.3 → 0.33.5

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 (153) hide show
  1. package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js +417 -0
  2. package/dist/BTCVaultRegistry.abi-DbJ5lsFJ.js.map +1 -0
  3. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs +2 -0
  4. package/dist/BTCVaultRegistry.abi-ZdPpION2.cjs.map +1 -0
  5. package/dist/PayoutManager-C9XHKZ5j.js +200 -0
  6. package/dist/PayoutManager-C9XHKZ5j.js.map +1 -0
  7. package/dist/PayoutManager-DDnNB0mj.cjs +2 -0
  8. package/dist/PayoutManager-DDnNB0mj.cjs.map +1 -0
  9. package/dist/PeginManager-BXg2S1mH.cjs +2 -0
  10. package/dist/PeginManager-BXg2S1mH.cjs.map +1 -0
  11. package/dist/{PeginManager-C-L3huRO.js → PeginManager-C5HaMAcw.js} +328 -437
  12. package/dist/PeginManager-C5HaMAcw.js.map +1 -0
  13. package/dist/ProtocolParams.abi-BmvHwQJV.cjs +2 -0
  14. package/dist/ProtocolParams.abi-BmvHwQJV.cjs.map +1 -0
  15. package/dist/ProtocolParams.abi-DXu8L0Fn.js +382 -0
  16. package/dist/ProtocolParams.abi-DXu8L0Fn.js.map +1 -0
  17. package/dist/buildAndBroadcastRefund-B332dykQ.cjs +2 -0
  18. package/dist/buildAndBroadcastRefund-B332dykQ.cjs.map +1 -0
  19. package/dist/buildAndBroadcastRefund-CPjXNaMi.js +782 -0
  20. package/dist/buildAndBroadcastRefund-CPjXNaMi.js.map +1 -0
  21. package/dist/challengeAssert-BzxQmdZy.js +128 -0
  22. package/dist/challengeAssert-BzxQmdZy.js.map +1 -0
  23. package/dist/challengeAssert-Yyyj-EdR.cjs +2 -0
  24. package/dist/challengeAssert-Yyyj-EdR.cjs.map +1 -0
  25. package/dist/errors-9AkghWyk.js +22 -0
  26. package/dist/errors-9AkghWyk.js.map +1 -0
  27. package/dist/errors-BP73_stm.cjs +2 -0
  28. package/dist/errors-BP73_stm.cjs.map +1 -0
  29. package/dist/errors-Bu0H-dZD.cjs +2 -0
  30. package/dist/errors-Bu0H-dZD.cjs.map +1 -0
  31. package/dist/errors-CznAK5NB.js +96 -0
  32. package/dist/errors-CznAK5NB.js.map +1 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +159 -147
  35. package/dist/index.js.map +1 -1
  36. package/dist/mempoolApi-CAIge7Nj.js +205 -0
  37. package/dist/mempoolApi-CAIge7Nj.js.map +1 -0
  38. package/dist/mempoolApi-YNkKjQCU.cjs +2 -0
  39. package/dist/mempoolApi-YNkKjQCU.cjs.map +1 -0
  40. package/dist/noPayout-BXeUw0Qq.cjs +2 -0
  41. package/dist/noPayout-BXeUw0Qq.cjs.map +1 -0
  42. package/dist/noPayout-DBX6G96_.js +141 -0
  43. package/dist/noPayout-DBX6G96_.js.map +1 -0
  44. package/dist/payout-BNFMBXS6.js +193 -0
  45. package/dist/payout-BNFMBXS6.js.map +1 -0
  46. package/dist/payout-DQ_fmJUA.cjs +2 -0
  47. package/dist/payout-DQ_fmJUA.cjs.map +1 -0
  48. package/dist/peginInput-C2QPvuhR.js +177 -0
  49. package/dist/peginInput-C2QPvuhR.js.map +1 -0
  50. package/dist/peginInput-tbw9BpZy.cjs +2 -0
  51. package/dist/peginInput-tbw9BpZy.cjs.map +1 -0
  52. package/dist/peginState-BijNNT15.cjs +2 -0
  53. package/dist/peginState-BijNNT15.cjs.map +1 -0
  54. package/dist/peginState-CBAlxgXk.js +51 -0
  55. package/dist/peginState-CBAlxgXk.js.map +1 -0
  56. package/dist/psbtInputFields-2224j2ZY.js +128 -0
  57. package/dist/psbtInputFields-2224j2ZY.js.map +1 -0
  58. package/dist/psbtInputFields-B1lrwYzH.cjs +2 -0
  59. package/dist/psbtInputFields-B1lrwYzH.cjs.map +1 -0
  60. package/dist/reservation-CHUGW0F_.js +142 -0
  61. package/dist/reservation-CHUGW0F_.js.map +1 -0
  62. package/dist/reservation-ho7mjW3X.cjs +2 -0
  63. package/dist/reservation-ho7mjW3X.cjs.map +1 -0
  64. package/dist/signing-Bnsro0hE.cjs +2 -0
  65. package/dist/signing-Bnsro0hE.cjs.map +1 -0
  66. package/dist/signing-DaLvGwQe.js +16 -0
  67. package/dist/signing-DaLvGwQe.js.map +1 -0
  68. package/dist/tbv/core/clients/index.cjs +1 -1
  69. package/dist/tbv/core/clients/index.js +35 -32
  70. package/dist/tbv/core/clients/index.js.map +1 -1
  71. package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts +2 -0
  72. package/dist/tbv/core/clients/vault-provider/__tests__/batchAttribution.test.d.ts.map +1 -0
  73. package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts +2 -0
  74. package/dist/tbv/core/clients/vault-provider/__tests__/batchPoll.test.d.ts.map +1 -0
  75. package/dist/tbv/core/clients/vault-provider/api.d.ts +13 -4
  76. package/dist/tbv/core/clients/vault-provider/api.d.ts.map +1 -1
  77. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts +45 -0
  78. package/dist/tbv/core/clients/vault-provider/batchAttribution.d.ts.map +1 -0
  79. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts +55 -0
  80. package/dist/tbv/core/clients/vault-provider/batchPoll.d.ts.map +1 -0
  81. package/dist/tbv/core/clients/vault-provider/index.d.ts +2 -0
  82. package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
  83. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +3 -3
  84. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  85. package/dist/tbv/core/clients/vault-provider/types.d.ts +68 -24
  86. package/dist/tbv/core/clients/vault-provider/types.d.ts.map +1 -1
  87. package/dist/tbv/core/clients/vault-provider/validators.d.ts +12 -2
  88. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  89. package/dist/tbv/core/contracts/index.cjs +2 -0
  90. package/dist/tbv/core/contracts/index.cjs.map +1 -0
  91. package/dist/tbv/core/contracts/index.js +14 -0
  92. package/dist/tbv/core/contracts/index.js.map +1 -0
  93. package/dist/tbv/core/index.cjs +1 -1
  94. package/dist/tbv/core/index.js +157 -145
  95. package/dist/tbv/core/index.js.map +1 -1
  96. package/dist/tbv/core/managers/index.cjs +2 -0
  97. package/dist/tbv/core/managers/index.cjs.map +1 -0
  98. package/dist/tbv/core/managers/index.js +7 -0
  99. package/dist/tbv/core/managers/index.js.map +1 -0
  100. package/dist/tbv/core/primitives/index.cjs +1 -1
  101. package/dist/tbv/core/primitives/index.js +31 -29
  102. package/dist/tbv/core/primitives/index.js.map +1 -1
  103. package/dist/tbv/core/services/deposit/waitForPeginStatus.d.ts.map +1 -1
  104. package/dist/tbv/core/services/index.cjs +1 -1
  105. package/dist/tbv/core/services/index.js +28 -27
  106. package/dist/tbv/core/services/index.js.map +1 -1
  107. package/dist/tbv/core/services/pegout/state.d.ts +1 -1
  108. package/dist/tbv/core/utils/index.cjs +1 -1
  109. package/dist/tbv/core/utils/index.js +21 -20
  110. package/dist/tbv/core/utils/index.js.map +1 -1
  111. package/dist/tbv/index.cjs +1 -1
  112. package/dist/tbv/index.js +157 -145
  113. package/dist/tbv/index.js.map +1 -1
  114. package/dist/types-DnyyBNcC.cjs +2 -0
  115. package/dist/types-DnyyBNcC.cjs.map +1 -0
  116. package/dist/types-TiIjyo2b.js +320 -0
  117. package/dist/types-TiIjyo2b.js.map +1 -0
  118. package/dist/vault-registry-reader-BDFpXeH7.js +1152 -0
  119. package/dist/vault-registry-reader-BDFpXeH7.js.map +1 -0
  120. package/dist/vault-registry-reader-ejm2UYzk.cjs +2 -0
  121. package/dist/vault-registry-reader-ejm2UYzk.cjs.map +1 -0
  122. package/package.json +11 -1
  123. package/dist/PeginManager-C-L3huRO.js.map +0 -1
  124. package/dist/PeginManager-DmPmzPHz.cjs +0 -2
  125. package/dist/PeginManager-DmPmzPHz.cjs.map +0 -1
  126. package/dist/buildAndBroadcastRefund-Dx09Zbla.js +0 -965
  127. package/dist/buildAndBroadcastRefund-Dx09Zbla.js.map +0 -1
  128. package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs +0 -2
  129. package/dist/buildAndBroadcastRefund-PmJMNrhO.cjs.map +0 -1
  130. package/dist/challengeAssert-D3tHnLWb.js +0 -298
  131. package/dist/challengeAssert-D3tHnLWb.js.map +0 -1
  132. package/dist/challengeAssert-Dp9d1bg1.cjs +0 -2
  133. package/dist/challengeAssert-Dp9d1bg1.cjs.map +0 -1
  134. package/dist/noPayout-BnsetBKW.js +0 -327
  135. package/dist/noPayout-BnsetBKW.js.map +0 -1
  136. package/dist/noPayout-DWaCtpMU.cjs +0 -2
  137. package/dist/noPayout-DWaCtpMU.cjs.map +0 -1
  138. package/dist/psbtInputFields-6sRcZqdb.cjs +0 -2
  139. package/dist/psbtInputFields-6sRcZqdb.cjs.map +0 -1
  140. package/dist/psbtInputFields-C5QPn1YK.js +0 -264
  141. package/dist/psbtInputFields-C5QPn1YK.js.map +0 -1
  142. package/dist/signing-BZigafm0.js +0 -64
  143. package/dist/signing-BZigafm0.js.map +0 -1
  144. package/dist/signing-DHSXjhLM.cjs +0 -2
  145. package/dist/signing-DHSXjhLM.cjs.map +0 -1
  146. package/dist/types-PthVHz5q.cjs +0 -2
  147. package/dist/types-PthVHz5q.cjs.map +0 -1
  148. package/dist/types-SYvSQWnc.js +0 -732
  149. package/dist/types-SYvSQWnc.js.map +0 -1
  150. package/dist/vault-registry-reader-CKe9TbX6.cjs +0 -2
  151. package/dist/vault-registry-reader-CKe9TbX6.cjs.map +0 -1
  152. package/dist/vault-registry-reader-CWGbw_wZ.js +0 -1567
  153. package/dist/vault-registry-reader-CWGbw_wZ.js.map +0 -1
@@ -1,26 +1,27 @@
1
- var ee = Object.defineProperty;
2
- var ne = (e, t, n) => t in e ? ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var m = (e, t, n) => ne(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var Qt = Object.defineProperty;
2
+ var Jt = (e, t, n) => t in e ? Qt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var m = (e, t, n) => Jt(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { a as Rt, b as N, c as v, d as K, e as tt, s as O, f as Ct, H as te, r as V, u as ee, g as ht, h as ne } from "./sha2-6wN58S6R.js";
4
5
  import * as $t from "bitcoinjs-lib";
5
- import { Transaction as Ut, Psbt as ft } from "bitcoinjs-lib";
6
- import { Buffer as D } from "buffer";
7
- import { a as Lt, b as V, c as A, d as z, e as nt, s as O, f as Nt, H as se, r as W, u as oe, g as gt, h as re } from "./sha2-6wN58S6R.js";
8
- import { isAddressEqual as pt, encodeFunctionData as mt, zeroAddress as ie } from "viem";
9
- import { deriveVaultId as wt } from "@babylonlabs-io/babylon-tbv-rust-wasm";
10
- import { b as bt, a as ae, d as ce, e as le, f as ue } from "./challengeAssert-D3tHnLWb.js";
11
- import { s as _, u as j, h as st, e as I, p as he, g as yt, i as de } from "./bitcoin-B0S8SHCX.js";
12
- import { c as fe } from "./signing-BZigafm0.js";
13
- import { M as xt } from "./validation-CxqROCno.js";
14
- import { h as ge } from "./buildAndBroadcastRefund-Dx09Zbla.js";
15
- import { b as pe, f as Z, i as me } from "./psbtInputFields-C5QPn1YK.js";
16
- import { p as we, f as be } from "./fundPeginTransaction-oV-dNJOU.js";
17
- import { p as ye, f as xe } from "./vault-registry-reader-CWGbw_wZ.js";
18
- import { B as $ } from "./types-SYvSQWnc.js";
19
- const M = /* @__PURE__ */ BigInt(2 ** 32 - 1), Pt = /* @__PURE__ */ BigInt(32);
6
+ import { Transaction as se, Psbt as dt } from "bitcoinjs-lib";
7
+ import { Buffer as et } from "buffer";
8
+ import { isAddressEqual as ft, encodeFunctionData as gt, zeroAddress as oe } from "viem";
9
+ import { B as C } from "./BTCVaultRegistry.abi-DbJ5lsFJ.js";
10
+ import { h as B } from "./errors-CznAK5NB.js";
11
+ import { deriveVaultId as pt } from "@babylonlabs-io/babylon-tbv-rust-wasm";
12
+ import { b as mt, a as re, c as ie, e as ae, f as ce } from "./peginInput-C2QPvuhR.js";
13
+ import { s as _, u as D, h as nt, e as H, p as le, g as wt, i as ue } from "./bitcoin-B0S8SHCX.js";
14
+ import { c as he } from "./signing-DaLvGwQe.js";
15
+ import { M as bt } from "./validation-CxqROCno.js";
16
+ import { c as de } from "./PayoutManager-C9XHKZ5j.js";
17
+ import { s as fe, c as G, d as ge } from "./psbtInputFields-2224j2ZY.js";
18
+ import { p as pe, f as me } from "./fundPeginTransaction-oV-dNJOU.js";
19
+ import { p as we, f as be } from "./mempoolApi-CAIge7Nj.js";
20
+ const W = /* @__PURE__ */ BigInt(2 ** 32 - 1), Pt = /* @__PURE__ */ BigInt(32);
20
21
  function Pe(e, t = !1) {
21
- return t ? { h: Number(e & M), l: Number(e >> Pt & M) } : { h: Number(e >> Pt & M) | 0, l: Number(e & M) | 0 };
22
+ return t ? { h: Number(e & W), l: Number(e >> Pt & W) } : { h: Number(e >> Pt & W) | 0, l: Number(e & W) | 0 };
22
23
  }
23
- function Ee(e, t = !1) {
24
+ function ye(e, t = !1) {
24
25
  const n = e.length;
25
26
  let s = new Uint32Array(n), o = new Uint32Array(n);
26
27
  for (let r = 0; r < n; r++) {
@@ -29,7 +30,7 @@ function Ee(e, t = !1) {
29
30
  }
30
31
  return [s, o];
31
32
  }
32
- const Te = (e, t, n) => e << n | t >>> 32 - n, ke = (e, t, n) => t << n | e >>> 32 - n, _e = (e, t, n) => t << n - 32 | e >>> 64 - n, ve = (e, t, n) => e << n - 32 | t >>> 64 - n, Ie = 106, Be = 32, Et = 34;
33
+ const xe = (e, t, n) => e << n | t >>> 32 - n, Ee = (e, t, n) => t << n | e >>> 32 - n, ke = (e, t, n) => t << n - 32 | e >>> 64 - n, Te = (e, t, n) => e << n - 32 | t >>> 64 - n, _e = 106, Ie = 32, yt = 34;
33
34
  function He(e, t, n) {
34
35
  const s = _(e), o = $t.Transaction.fromHex(s);
35
36
  if (o.outs.length <= t)
@@ -37,9 +38,9 @@ function He(e, t, n) {
37
38
  `Pre-PegIn auth-anchor OP_RETURN missing: tx has ${o.outs.length} outputs, expected at least ${t + 1} (vault outputs + OP_RETURN)`
38
39
  );
39
40
  const r = o.outs[t], i = r.script;
40
- if (i.length !== Et || i[0] !== Ie || i[1] !== Be)
41
+ if (i.length !== yt || i[0] !== _e || i[1] !== Ie)
41
42
  throw new Error(
42
- `Pre-PegIn auth-anchor OP_RETURN at vout ${t} has unexpected script encoding (got ${i.length}-byte script with prefix 0x${i.slice(0, Math.min(2, i.length)).toString("hex")}; expected ${Et}-byte OP_RETURN + PUSH32 layout)`
43
+ `Pre-PegIn auth-anchor OP_RETURN at vout ${t} has unexpected script encoding (got ${i.length}-byte script with prefix 0x${i.slice(0, Math.min(2, i.length)).toString("hex")}; expected ${yt}-byte OP_RETURN + PUSH32 layout)`
43
44
  );
44
45
  const a = i.slice(2).toString("hex").toLowerCase();
45
46
  if (a !== n.toLowerCase())
@@ -51,7 +52,7 @@ function He(e, t, n) {
51
52
  `Pre-PegIn auth-anchor OP_RETURN at vout ${t} has non-zero value ${r.value}; OP_RETURN outputs must be 0-value`
52
53
  );
53
54
  }
54
- class Vt {
55
+ class Ut {
55
56
  constructor(t, n) {
56
57
  m(this, "oHash");
57
58
  m(this, "iHash");
@@ -59,7 +60,7 @@ class Vt {
59
60
  m(this, "outputLen");
60
61
  m(this, "finished", !1);
61
62
  m(this, "destroyed", !1);
62
- if (Lt(t), V(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
63
+ if (Rt(t), N(n, void 0, "key"), this.iHash = t.create(), typeof this.iHash.update != "function")
63
64
  throw new Error("Expected instance of class which extends utils.Hash");
64
65
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
65
66
  const s = this.blockLen, o = new Uint8Array(s);
@@ -69,13 +70,13 @@ class Vt {
69
70
  this.iHash.update(o), this.oHash = t.create();
70
71
  for (let r = 0; r < o.length; r++)
71
72
  o[r] ^= 106;
72
- this.oHash.update(o), A(o);
73
+ this.oHash.update(o), v(o);
73
74
  }
74
75
  update(t) {
75
- return z(this), this.iHash.update(t), this;
76
+ return K(this), this.iHash.update(t), this;
76
77
  }
77
78
  digestInto(t) {
78
- z(this), V(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
79
+ K(this), N(t, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
79
80
  }
80
81
  digest() {
81
82
  const t = new Uint8Array(this.oHash.outputLen);
@@ -93,148 +94,137 @@ class Vt {
93
94
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
94
95
  }
95
96
  }
96
- const Wt = (e, t, n) => new Vt(e, t).update(n).digest();
97
- Wt.create = (e, t) => new Vt(e, t);
98
- const q = /* @__PURE__ */ Uint8Array.of(0), Tt = /* @__PURE__ */ Uint8Array.of();
99
- function at(e, t, n, s = 32) {
100
- Lt(e), nt(s, "length");
97
+ const Lt = (e, t, n) => new Ut(e, t).update(n).digest();
98
+ Lt.create = (e, t) => new Ut(e, t);
99
+ const j = /* @__PURE__ */ Uint8Array.of(0), xt = /* @__PURE__ */ Uint8Array.of();
100
+ function it(e, t, n, s = 32) {
101
+ Rt(e), tt(s, "length");
101
102
  const o = e.outputLen;
102
103
  if (s > 255 * o)
103
104
  throw new Error("Length must be <= 255*HashLen");
104
105
  const r = Math.ceil(s / o);
105
- n === void 0 ? n = Tt : V(n, void 0, "info");
106
- const i = new Uint8Array(r * o), a = Wt.create(e, t), l = a._cloneInto(), u = new Uint8Array(a.outputLen);
106
+ n === void 0 ? n = xt : N(n, void 0, "info");
107
+ const i = new Uint8Array(r * o), a = Lt.create(e, t), l = a._cloneInto(), u = new Uint8Array(a.outputLen);
107
108
  for (let c = 0; c < r; c++)
108
- q[0] = c + 1, l.update(c === 0 ? Tt : u).update(n).update(q).digestInto(u), i.set(u, o * c), a._cloneInto(l);
109
- return a.destroy(), l.destroy(), A(u, q), i.slice(0, s);
109
+ j[0] = c + 1, l.update(c === 0 ? xt : u).update(n).update(j).digestInto(u), i.set(u, o * c), a._cloneInto(l);
110
+ return a.destroy(), l.destroy(), v(u, j), i.slice(0, s);
110
111
  }
111
- const Y = new TextEncoder().encode("babylonvault"), kt = 255, _t = 65535, vt = 2, Se = "hashlock", Ae = "auth-anchor", Ce = "wots-seed";
112
- function Mt(e) {
112
+ const Z = new TextEncoder().encode("babylonvault"), Et = 255, kt = 65535, Tt = 2, Se = "hashlock", Ae = "auth-anchor", Be = "wots-seed";
113
+ function Nt(e) {
113
114
  if (!Number.isInteger(e) || e < 0 || e > 4294967295)
114
115
  throw new Error(`i2osp4: value must be a u32, got ${e}`);
115
116
  const t = new Uint8Array(4);
116
117
  return t[0] = e >>> 24 & 255, t[1] = e >>> 16 & 255, t[2] = e >>> 8 & 255, t[3] = e & 255, t;
117
118
  }
118
- function ct(e, t = new Uint8Array(0)) {
119
+ function at(e, t = new Uint8Array(0)) {
119
120
  const n = new TextEncoder().encode(e);
120
- if (n.length === 0 || n.length > kt)
121
+ if (n.length === 0 || n.length > Et)
121
122
  throw new Error(
122
- `info: label length must be in [1, ${kt}], got ${n.length}`
123
+ `info: label length must be in [1, ${Et}], got ${n.length}`
123
124
  );
124
- if (t.length > _t)
125
+ if (t.length > kt)
125
126
  throw new Error(
126
- `info: ctx length must be in [0, ${_t}], got ${t.length}`
127
+ `info: ctx length must be in [0, ${kt}], got ${t.length}`
127
128
  );
128
- const s = Y.length + 1 + n.length + vt + t.length, o = new Uint8Array(s);
129
+ const s = Z.length + 1 + n.length + Tt + t.length, o = new Uint8Array(s);
129
130
  let r = 0;
130
- return o.set(Y, r), r += Y.length, o[r] = n.length, r += 1, o.set(n, r), r += n.length, o[r] = t.length >>> 8 & 255, o[r + 1] = t.length & 255, r += vt, o.set(t, r), o;
131
+ return o.set(Z, r), r += Z.length, o[r] = n.length, r += 1, o.set(n, r), r += n.length, o[r] = t.length >>> 8 & 255, o[r + 1] = t.length & 255, r += Tt, o.set(t, r), o;
131
132
  }
132
- const It = 32, Oe = 32, Re = 32, $e = 64;
133
- function lt(e) {
134
- if (e.length !== It)
133
+ const _t = 32, ve = 32, Oe = 32, Re = 64;
134
+ function ct(e) {
135
+ if (e.length !== _t)
135
136
  throw new Error(
136
- `vault-secrets: root must be exactly ${It} bytes, got ${e.length}`
137
+ `vault-secrets: root must be exactly ${_t} bytes, got ${e.length}`
137
138
  );
138
139
  }
139
- function Ue(e) {
140
- return lt(e), at(
140
+ function Ce(e) {
141
+ return ct(e), it(
141
142
  O,
142
143
  e,
143
- ct(Ae),
144
- Oe
144
+ at(Ae),
145
+ ve
145
146
  );
146
147
  }
147
- function Le(e, t) {
148
- return lt(e), at(
148
+ function $e(e, t) {
149
+ return ct(e), it(
149
150
  O,
150
151
  e,
151
- ct(Se, Mt(t)),
152
- Re
152
+ at(Se, Nt(t)),
153
+ Oe
153
154
  );
154
155
  }
155
- function Ne(e, t) {
156
- return lt(e), at(
156
+ function Ue(e, t) {
157
+ return ct(e), it(
157
158
  O,
158
159
  e,
159
- ct(Ce, Mt(t)),
160
- $e
160
+ at(Be, Nt(t)),
161
+ Re
161
162
  );
162
163
  }
163
- const N = 32, Q = 32, ot = 36, Ft = 32, G = 4, Ve = G + N + G + Ft;
164
- function rt(e, t, n) {
164
+ const L = 32, q = 32, st = 36, Vt = 32, z = 4, Le = z + L + z + Vt;
165
+ function ot(e, t, n) {
165
166
  e[t] = n >>> 24 & 255, e[t + 1] = n >>> 16 & 255, e[t + 2] = n >>> 8 & 255, e[t + 3] = n & 255;
166
167
  }
167
- function We(e) {
168
- if (e.txid.length !== Q)
168
+ function Ne(e) {
169
+ if (e.txid.length !== q)
169
170
  throw new Error(
170
- `outpoint.txid must be exactly ${Q} bytes, got ${e.txid.length}`
171
+ `outpoint.txid must be exactly ${q} bytes, got ${e.txid.length}`
171
172
  );
172
173
  if (!Number.isInteger(e.vout) || e.vout < 0 || e.vout > 4294967295)
173
174
  throw new Error(`outpoint.vout must be a u32, got ${e.vout}`);
174
- const t = new Uint8Array(ot);
175
- return t.set(e.txid, 0), rt(t, Q, e.vout), t;
175
+ const t = new Uint8Array(st);
176
+ return t.set(e.txid, 0), ot(t, q, e.vout), t;
176
177
  }
177
- function Bt(e, t) {
178
+ function It(e, t) {
178
179
  const n = Math.min(e.length, t.length);
179
180
  for (let s = 0; s < n; s++)
180
181
  if (e[s] !== t[s]) return e[s] - t[s];
181
182
  return e.length - t.length;
182
183
  }
183
- function Me(e) {
184
+ function Ve(e) {
184
185
  if (e.length === 0)
185
186
  throw new Error(
186
187
  "buildFundingOutpointsCommitment: outpoints must be non-empty"
187
188
  );
188
- const t = e.map(We);
189
- t.sort(Bt);
189
+ const t = e.map(Ne);
190
+ t.sort(It);
190
191
  for (let s = 1; s < t.length; s++)
191
- if (Bt(t[s - 1], t[s]) === 0)
192
+ if (It(t[s - 1], t[s]) === 0)
192
193
  throw new Error(
193
194
  "buildFundingOutpointsCommitment: duplicate outpoint detected"
194
195
  );
195
- const n = new Uint8Array(t.length * ot);
196
+ const n = new Uint8Array(t.length * st);
196
197
  for (let s = 0; s < t.length; s++)
197
- n.set(t[s], s * ot);
198
+ n.set(t[s], s * st);
198
199
  return O(n);
199
200
  }
200
- function Fe(e) {
201
- if (e.depositorBtcPubkey.length !== N)
201
+ function We(e) {
202
+ if (e.depositorBtcPubkey.length !== L)
202
203
  throw new Error(
203
- `vaultContext: depositorBtcPubkey must be exactly ${N} bytes, got ${e.depositorBtcPubkey.length}`
204
+ `vaultContext: depositorBtcPubkey must be exactly ${L} bytes, got ${e.depositorBtcPubkey.length}`
204
205
  );
205
- const t = Me(e.fundingOutpoints), n = new Uint8Array(Ve);
206
+ const t = Ve(e.fundingOutpoints), n = new Uint8Array(Le);
206
207
  let s = 0;
207
- return rt(n, s, N), s += G, n.set(e.depositorBtcPubkey, s), s += N, rt(n, s, Ft), s += G, n.set(t, s), n;
208
+ return ot(n, s, L), s += z, n.set(e.depositorBtcPubkey, s), s += L, ot(n, s, Vt), s += z, n.set(t, s), n;
208
209
  }
209
- const Xe = "babylon-vault", Xt = 32, Ht = Xt * 2, Ke = /^[0-9a-f]+$/;
210
- async function De(e, t) {
211
- const n = Fe(t), s = j(n), o = await e.deriveContextHash(Xe, s);
210
+ const Me = "babylon-vault", Wt = 32, Ht = Wt * 2, Fe = /^[0-9a-f]+$/;
211
+ async function Xe(e, t) {
212
+ const n = We(t), s = D(n), o = await e.deriveContextHash(Me, s);
212
213
  if (typeof o != "string")
213
214
  throw new Error(
214
215
  `deriveVaultRoot: wallet must return a string, got ${typeof o}`
215
216
  );
216
217
  if (o.length !== Ht)
217
218
  throw new Error(
218
- `deriveVaultRoot: wallet must return a ${Ht}-character hex string (${Xt} bytes), got length ${o.length}`
219
+ `deriveVaultRoot: wallet must return a ${Ht}-character hex string (${Wt} bytes), got length ${o.length}`
219
220
  );
220
- if (!Ke.test(o))
221
+ if (!Fe.test(o))
221
222
  throw new Error(
222
223
  "deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters"
223
224
  );
224
- return st(o);
225
- }
226
- function Fn(e) {
227
- if (!e)
228
- throw new Error("Pre-pegin transaction hex is empty");
229
- const t = e.startsWith("0x") ? e.slice(2) : e, n = Ut.fromHex(t);
230
- if (n.ins.length === 0)
231
- throw new Error("Pre-pegin transaction has no inputs");
232
- return n.ins.map((s) => ({
233
- txid: Uint8Array.from(D.from(s.hash).reverse()),
234
- vout: s.index
235
- }));
225
+ return nt(o);
236
226
  }
237
- const ze = /* @__PURE__ */ Uint8Array.from([
227
+ const Ke = /* @__PURE__ */ Uint8Array.from([
238
228
  7,
239
229
  4,
240
230
  13,
@@ -251,25 +241,25 @@ const ze = /* @__PURE__ */ Uint8Array.from([
251
241
  14,
252
242
  11,
253
243
  8
254
- ]), Kt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), je = Kt.map((e) => (9 * e + 5) % 16), Dt = /* @__PURE__ */ (() => {
255
- const n = [[Kt], [je]];
244
+ ]), Mt = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), De = Mt.map((e) => (9 * e + 5) % 16), Ft = /* @__PURE__ */ (() => {
245
+ const n = [[Mt], [De]];
256
246
  for (let s = 0; s < 4; s++)
257
247
  for (let o of n)
258
- o.push(o[s].map((r) => ze[r]));
248
+ o.push(o[s].map((r) => Ke[r]));
259
249
  return n;
260
- })(), zt = Dt[0], jt = Dt[1], Gt = /* @__PURE__ */ [
250
+ })(), Xt = Ft[0], Kt = Ft[1], Dt = /* @__PURE__ */ [
261
251
  [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
262
252
  [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
263
253
  [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
264
254
  [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
265
255
  [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
266
- ].map((e) => Uint8Array.from(e)), Ge = /* @__PURE__ */ zt.map((e, t) => e.map((n) => Gt[t][n])), Ze = /* @__PURE__ */ jt.map((e, t) => e.map((n) => Gt[t][n])), qe = /* @__PURE__ */ Uint32Array.from([
256
+ ].map((e) => Uint8Array.from(e)), ze = /* @__PURE__ */ Xt.map((e, t) => e.map((n) => Dt[t][n])), Ge = /* @__PURE__ */ Kt.map((e, t) => e.map((n) => Dt[t][n])), je = /* @__PURE__ */ Uint32Array.from([
267
257
  0,
268
258
  1518500249,
269
259
  1859775393,
270
260
  2400959708,
271
261
  2840853838
272
- ]), Ye = /* @__PURE__ */ Uint32Array.from([
262
+ ]), Ze = /* @__PURE__ */ Uint32Array.from([
273
263
  1352829926,
274
264
  1548603684,
275
265
  1836072691,
@@ -279,8 +269,8 @@ const ze = /* @__PURE__ */ Uint8Array.from([
279
269
  function St(e, t, n, s) {
280
270
  return e === 0 ? t ^ n ^ s : e === 1 ? t & n | ~t & s : e === 2 ? (t | ~n) ^ s : e === 3 ? t & s | n & ~s : t ^ (n | ~s);
281
271
  }
282
- const F = /* @__PURE__ */ new Uint32Array(16);
283
- class Qe extends se {
272
+ const M = /* @__PURE__ */ new Uint32Array(16);
273
+ class qe extends te {
284
274
  constructor() {
285
275
  super(64, 20, 8, !0);
286
276
  m(this, "h0", 1732584193);
@@ -298,50 +288,50 @@ class Qe extends se {
298
288
  }
299
289
  process(n, s) {
300
290
  for (let h = 0; h < 16; h++, s += 4)
301
- F[h] = n.getUint32(s, !0);
302
- let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, l = this.h2 | 0, u = l, c = this.h3 | 0, w = c, b = this.h4 | 0, y = b;
291
+ M[h] = n.getUint32(s, !0);
292
+ let o = this.h0 | 0, r = o, i = this.h1 | 0, a = i, l = this.h2 | 0, u = l, c = this.h3 | 0, w = c, b = this.h4 | 0, P = b;
303
293
  for (let h = 0; h < 5; h++) {
304
- const g = 4 - h, T = qe[h], B = Ye[h], d = zt[h], P = jt[h], f = Ge[h], E = Ze[h];
305
- for (let x = 0; x < 16; x++) {
306
- const p = W(o + St(h, i, l, c) + F[d[x]] + T, f[x]) + b | 0;
307
- o = b, b = c, c = W(l, 10) | 0, l = i, i = p;
294
+ const g = 4 - h, k = je[h], S = Ze[h], d = Xt[h], x = Kt[h], f = ze[h], E = Ge[h];
295
+ for (let y = 0; y < 16; y++) {
296
+ const p = V(o + St(h, i, l, c) + M[d[y]] + k, f[y]) + b | 0;
297
+ o = b, b = c, c = V(l, 10) | 0, l = i, i = p;
308
298
  }
309
- for (let x = 0; x < 16; x++) {
310
- const p = W(r + St(g, a, u, w) + F[P[x]] + B, E[x]) + y | 0;
311
- r = y, y = w, w = W(u, 10) | 0, u = a, a = p;
299
+ for (let y = 0; y < 16; y++) {
300
+ const p = V(r + St(g, a, u, w) + M[x[y]] + S, E[y]) + P | 0;
301
+ r = P, P = w, w = V(u, 10) | 0, u = a, a = p;
312
302
  }
313
303
  }
314
- this.set(this.h1 + l + w | 0, this.h2 + c + y | 0, this.h3 + b + r | 0, this.h4 + o + a | 0, this.h0 + i + u | 0);
304
+ this.set(this.h1 + l + w | 0, this.h2 + c + P | 0, this.h3 + b + r | 0, this.h4 + o + a | 0, this.h0 + i + u | 0);
315
305
  }
316
306
  roundClean() {
317
- A(F);
307
+ v(M);
318
308
  }
319
309
  destroy() {
320
- this.destroyed = !0, A(this.buffer), this.set(0, 0, 0, 0, 0);
310
+ this.destroyed = !0, v(this.buffer), this.set(0, 0, 0, 0, 0);
321
311
  }
322
312
  }
323
- const Je = /* @__PURE__ */ Nt(() => new Qe()), tn = BigInt(0), U = BigInt(1), en = BigInt(2), nn = BigInt(7), sn = BigInt(256), on = BigInt(113), Zt = [], qt = [], Yt = [];
324
- for (let e = 0, t = U, n = 1, s = 0; e < 24; e++) {
325
- [n, s] = [s, (2 * n + 3 * s) % 5], Zt.push(2 * (5 * s + n)), qt.push((e + 1) * (e + 2) / 2 % 64);
326
- let o = tn;
313
+ const Ye = /* @__PURE__ */ Ct(() => new qe()), Qe = BigInt(0), $ = BigInt(1), Je = BigInt(2), tn = BigInt(7), en = BigInt(256), nn = BigInt(113), zt = [], Gt = [], jt = [];
314
+ for (let e = 0, t = $, n = 1, s = 0; e < 24; e++) {
315
+ [n, s] = [s, (2 * n + 3 * s) % 5], zt.push(2 * (5 * s + n)), Gt.push((e + 1) * (e + 2) / 2 % 64);
316
+ let o = Qe;
327
317
  for (let r = 0; r < 7; r++)
328
- t = (t << U ^ (t >> nn) * on) % sn, t & en && (o ^= U << (U << BigInt(r)) - U);
329
- Yt.push(o);
318
+ t = (t << $ ^ (t >> tn) * nn) % en, t & Je && (o ^= $ << ($ << BigInt(r)) - $);
319
+ jt.push(o);
330
320
  }
331
- const Qt = Ee(Yt, !0), rn = Qt[0], an = Qt[1], At = (e, t, n) => n > 32 ? _e(e, t, n) : Te(e, t, n), Ct = (e, t, n) => n > 32 ? ve(e, t, n) : ke(e, t, n);
332
- function cn(e, t = 24) {
321
+ const Zt = ye(jt, !0), sn = Zt[0], on = Zt[1], At = (e, t, n) => n > 32 ? ke(e, t, n) : xe(e, t, n), Bt = (e, t, n) => n > 32 ? Te(e, t, n) : Ee(e, t, n);
322
+ function rn(e, t = 24) {
333
323
  const n = new Uint32Array(10);
334
324
  for (let s = 24 - t; s < 24; s++) {
335
325
  for (let i = 0; i < 10; i++)
336
326
  n[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
337
327
  for (let i = 0; i < 10; i += 2) {
338
- const a = (i + 8) % 10, l = (i + 2) % 10, u = n[l], c = n[l + 1], w = At(u, c, 1) ^ n[a], b = Ct(u, c, 1) ^ n[a + 1];
339
- for (let y = 0; y < 50; y += 10)
340
- e[i + y] ^= w, e[i + y + 1] ^= b;
328
+ const a = (i + 8) % 10, l = (i + 2) % 10, u = n[l], c = n[l + 1], w = At(u, c, 1) ^ n[a], b = Bt(u, c, 1) ^ n[a + 1];
329
+ for (let P = 0; P < 50; P += 10)
330
+ e[i + P] ^= w, e[i + P + 1] ^= b;
341
331
  }
342
332
  let o = e[2], r = e[3];
343
333
  for (let i = 0; i < 24; i++) {
344
- const a = qt[i], l = At(o, r, a), u = Ct(o, r, a), c = Zt[i];
334
+ const a = Gt[i], l = At(o, r, a), u = Bt(o, r, a), c = zt[i];
345
335
  o = e[c], r = e[c + 1], e[c] = l, e[c + 1] = u;
346
336
  }
347
337
  for (let i = 0; i < 50; i += 10) {
@@ -350,11 +340,11 @@ function cn(e, t = 24) {
350
340
  for (let a = 0; a < 10; a++)
351
341
  e[i + a] ^= ~n[(a + 2) % 10] & n[(a + 4) % 10];
352
342
  }
353
- e[0] ^= rn[s], e[1] ^= an[s];
343
+ e[0] ^= sn[s], e[1] ^= on[s];
354
344
  }
355
- A(n);
345
+ v(n);
356
346
  }
357
- class ut {
347
+ class lt {
358
348
  // NOTE: we accept arguments in bytes instead of bits here.
359
349
  constructor(t, n, s, o = !1, r = 24) {
360
350
  m(this, "state");
@@ -368,18 +358,18 @@ class ut {
368
358
  m(this, "outputLen");
369
359
  m(this, "enableXOF", !1);
370
360
  m(this, "rounds");
371
- if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = o, this.rounds = r, nt(s, "outputLen"), !(0 < t && t < 200))
361
+ if (this.blockLen = t, this.suffix = n, this.outputLen = s, this.enableXOF = o, this.rounds = r, tt(s, "outputLen"), !(0 < t && t < 200))
372
362
  throw new Error("only keccak-f1600 function is supported");
373
- this.state = new Uint8Array(200), this.state32 = oe(this.state);
363
+ this.state = new Uint8Array(200), this.state32 = ee(this.state);
374
364
  }
375
365
  clone() {
376
366
  return this._cloneInto();
377
367
  }
378
368
  keccak() {
379
- gt(this.state32), cn(this.state32, this.rounds), gt(this.state32), this.posOut = 0, this.pos = 0;
369
+ ht(this.state32), rn(this.state32, this.rounds), ht(this.state32), this.posOut = 0, this.pos = 0;
380
370
  }
381
371
  update(t) {
382
- z(this), V(t);
372
+ K(this), N(t);
383
373
  const { blockLen: n, state: s } = this, o = t.length;
384
374
  for (let r = 0; r < o; ) {
385
375
  const i = Math.min(n - this.pos, o - r);
@@ -397,7 +387,7 @@ class ut {
397
387
  t[s] ^= n, (n & 128) !== 0 && s === o - 1 && this.keccak(), t[o - 1] ^= 128, this.keccak();
398
388
  }
399
389
  writeInto(t) {
400
- z(this, !1), V(t), this.finish();
390
+ K(this, !1), N(t), this.finish();
401
391
  const n = this.state, { blockLen: s } = this;
402
392
  for (let o = 0, r = t.length; o < r; ) {
403
393
  this.posOut >= s && this.keccak();
@@ -412,10 +402,10 @@ class ut {
412
402
  return this.writeInto(t);
413
403
  }
414
404
  xof(t) {
415
- return nt(t), this.xofInto(new Uint8Array(t));
405
+ return tt(t), this.xofInto(new Uint8Array(t));
416
406
  }
417
407
  digestInto(t) {
418
- if (re(t, this), this.finished)
408
+ if (ne(t, this), this.finished)
419
409
  throw new Error("digest() was already called");
420
410
  return this.writeInto(t), this.destroy(), t;
421
411
  }
@@ -423,30 +413,30 @@ class ut {
423
413
  return this.digestInto(new Uint8Array(this.outputLen));
424
414
  }
425
415
  destroy() {
426
- this.destroyed = !0, A(this.state);
416
+ this.destroyed = !0, v(this.state);
427
417
  }
428
418
  _cloneInto(t) {
429
419
  const { blockLen: n, suffix: s, outputLen: o, rounds: r, enableXOF: i } = this;
430
- return t || (t = new ut(n, s, o, i, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = s, t.outputLen = o, t.enableXOF = i, t.destroyed = this.destroyed, t;
420
+ return t || (t = new lt(n, s, o, i, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = s, t.outputLen = o, t.enableXOF = i, t.destroyed = this.destroyed, t;
431
421
  }
432
422
  }
433
- const ln = (e, t, n, s = {}) => Nt(() => new ut(t, e, n), s), un = /* @__PURE__ */ ln(1, 136, 32), Ot = 64, v = 20, it = 4, Jt = 2, hn = 0, dn = 1, X = [64, 64], fn = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
434
- function ht(e) {
435
- return Je(O(e));
423
+ const an = (e, t, n, s = {}) => Ct(() => new lt(t, e, n), s), cn = /* @__PURE__ */ an(1, 136, 32), vt = 64, I = 20, rt = 4, qt = 2, ln = 0, un = 1, F = [64, 64], hn = (e) => Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
424
+ function ut(e) {
425
+ return Ye(O(e));
436
426
  }
437
- function te(e) {
427
+ function Yt(e) {
438
428
  return (1 << e) - 1;
439
429
  }
440
- function gn(e) {
430
+ function dn(e) {
441
431
  let t = 1;
442
432
  for (; t * t < e + 1; ) t++;
443
433
  return Math.max(t, 2);
444
434
  }
445
- function pn(e) {
446
- const t = it, n = e * te(t);
447
- return { d: t, n: e, checksum_radix: gn(n) };
435
+ function fn(e) {
436
+ const t = rt, n = e * Yt(t);
437
+ return { d: t, n: e, checksum_radix: dn(n) };
448
438
  }
449
- function J(e, t) {
439
+ function Y(e, t) {
450
440
  const n = [];
451
441
  let s = t;
452
442
  for (; s > 0; )
@@ -455,30 +445,30 @@ function J(e, t) {
455
445
  o.set(e);
456
446
  for (let r = 0; r < n.length; r++)
457
447
  o[e.length + r] = n[r];
458
- return ht(o);
448
+ return ut(o);
459
449
  }
460
- function tt(e, t) {
450
+ function Q(e, t) {
461
451
  let n = e;
462
452
  for (let s = 0; s < t; s++)
463
- n = ht(n);
453
+ n = ut(n);
464
454
  return n;
465
455
  }
466
- function mn(e, t) {
467
- const n = te(t.d), s = t.checksum_radix - 1, o = Math.floor(t.n * n / t.checksum_radix), r = [];
456
+ function gn(e, t) {
457
+ const n = Yt(t.d), s = t.checksum_radix - 1, o = Math.floor(t.n * n / t.checksum_radix), r = [];
468
458
  for (let c = 0; c < t.n; c++) {
469
- const w = J(e, c + Jt), b = tt(w, n);
459
+ const w = Y(e, c + qt), b = Q(w, n);
470
460
  r.push(Array.from(b));
471
461
  }
472
- const i = J(
462
+ const i = Y(
473
463
  e,
474
- hn
475
- ), a = tt(
464
+ ln
465
+ ), a = Q(
476
466
  i,
477
467
  s
478
- ), l = J(
468
+ ), l = Y(
479
469
  e,
480
- dn
481
- ), u = tt(
470
+ un
471
+ ), u = Q(
482
472
  l,
483
473
  o
484
474
  );
@@ -489,22 +479,22 @@ function mn(e, t) {
489
479
  checksum_minor_terminal: Array.from(a)
490
480
  };
491
481
  }
492
- async function wn(e) {
482
+ async function pn(e) {
493
483
  try {
494
- if (e.length !== Ot)
484
+ if (e.length !== vt)
495
485
  throw new Error(
496
- `WOTS seed must be exactly ${Ot} bytes, got ${e.length}`
486
+ `WOTS seed must be exactly ${vt} bytes, got ${e.length}`
497
487
  );
498
488
  const t = [];
499
- for (let n = 0; n < X.length; n++) {
500
- const s = X[n], o = pn(s), r = new Uint8Array(e.length + 1);
489
+ for (let n = 0; n < F.length; n++) {
490
+ const s = F[n], o = fn(s), r = new Uint8Array(e.length + 1);
501
491
  r.set(e), r[e.length] = n;
502
- const i = ht(r);
492
+ const i = ut(r);
503
493
  try {
504
- const a = mn(i, o);
505
- if (a.config.d !== it)
494
+ const a = gn(i, o);
495
+ if (a.config.d !== rt)
506
496
  throw new Error(
507
- `Block ${n}: expected d=${it}, got d=${a.config.d}`
497
+ `Block ${n}: expected d=${rt}, got d=${a.config.d}`
508
498
  );
509
499
  if (a.config.n !== s)
510
500
  throw new Error(
@@ -515,36 +505,36 @@ async function wn(e) {
515
505
  `Block ${n}: expected ${s} message terminals, got ${a.message_terminals.length}`
516
506
  );
517
507
  for (let l = 0; l < a.message_terminals.length; l++)
518
- if (a.message_terminals[l].length !== v)
508
+ if (a.message_terminals[l].length !== I)
519
509
  throw new Error(
520
- `Block ${n} terminal ${l}: expected ${v} bytes, got ${a.message_terminals[l].length}`
510
+ `Block ${n} terminal ${l}: expected ${I} bytes, got ${a.message_terminals[l].length}`
521
511
  );
522
- if (a.checksum_minor_terminal.length !== v)
512
+ if (a.checksum_minor_terminal.length !== I)
523
513
  throw new Error(
524
- `Block ${n} checksum_minor: expected ${v} bytes`
514
+ `Block ${n} checksum_minor: expected ${I} bytes`
525
515
  );
526
- if (a.checksum_major_terminal.length !== v)
516
+ if (a.checksum_major_terminal.length !== I)
527
517
  throw new Error(
528
- `Block ${n} checksum_major: expected ${v} bytes`
518
+ `Block ${n} checksum_major: expected ${I} bytes`
529
519
  );
530
520
  t.push(a);
531
521
  } finally {
532
522
  r.fill(0), i.fill(0);
533
523
  }
534
524
  }
535
- if (t.length !== X.length)
525
+ if (t.length !== F.length)
536
526
  throw new Error(
537
- `Expected ${X.length} blocks, got ${t.length}`
527
+ `Expected ${F.length} blocks, got ${t.length}`
538
528
  );
539
529
  return t;
540
530
  } finally {
541
531
  e.fill(0);
542
532
  }
543
533
  }
544
- function et(e, t, n) {
545
- if (e.length !== v)
534
+ function J(e, t, n) {
535
+ if (e.length !== I)
546
536
  throw new Error(
547
- `Block ${t} ${n}: expected ${v} bytes, got ${e.length}`
537
+ `Block ${t} ${n}: expected ${I} bytes, got ${e.length}`
548
538
  );
549
539
  for (let s = 0; s < e.length; s++) {
550
540
  const o = e[s];
@@ -554,47 +544,43 @@ function et(e, t, n) {
554
544
  );
555
545
  }
556
546
  }
557
- function bn(e) {
547
+ function mn(e) {
558
548
  if (e.length === 0)
559
549
  throw new Error("Public keys array must not be empty");
560
550
  for (let r = 0; r < e.length; r++) {
561
551
  const i = e[r];
562
- et(i.checksum_minor_terminal, r, "checksum_minor_terminal"), et(i.checksum_major_terminal, r, "checksum_major_terminal");
552
+ J(i.checksum_minor_terminal, r, "checksum_minor_terminal"), J(i.checksum_major_terminal, r, "checksum_major_terminal");
563
553
  for (let a = 0; a < i.message_terminals.length; a++)
564
- et(i.message_terminals[a], r, `message_terminal[${a}]`);
554
+ J(i.message_terminals[a], r, `message_terminal[${a}]`);
565
555
  }
566
556
  let t = 0;
567
557
  for (const r of e)
568
- t += Jt + r.message_terminals.length;
569
- const n = new Uint8Array(t * v);
558
+ t += qt + r.message_terminals.length;
559
+ const n = new Uint8Array(t * I);
570
560
  let s = 0;
571
561
  for (const r of e) {
572
- n.set(r.checksum_minor_terminal, s), s += v, n.set(r.checksum_major_terminal, s), s += v;
562
+ n.set(r.checksum_minor_terminal, s), s += I, n.set(r.checksum_major_terminal, s), s += I;
573
563
  for (const i of r.message_terminals)
574
- n.set(i, s), s += v;
564
+ n.set(i, s), s += I;
575
565
  }
576
- const o = un(n);
577
- return `0x${fn(o)}`;
566
+ const o = cn(n);
567
+ return `0x${hn(o)}`;
578
568
  }
579
- function Xn(e) {
580
- const t = (e instanceof Error ? e.message : typeof e == "string" ? e : "").toLowerCase();
581
- return t.includes("wots") && t.includes("hash") && t.includes("does not match");
582
- }
583
- async function yn(e, t) {
569
+ async function wn(e, t) {
584
570
  const n = [], s = [], o = [], r = [];
585
571
  try {
586
572
  for (let i = 0; i < t; i++) {
587
- const a = Ne(e, i);
573
+ const a = Ue(e, i);
588
574
  try {
589
- const u = await wn(a);
590
- n.push(u), s.push(bn(u));
575
+ const u = await pn(a);
576
+ n.push(u), s.push(mn(u));
591
577
  } finally {
592
578
  a.fill(0);
593
579
  }
594
- const l = Le(e, i);
580
+ const l = $e(e, i);
595
581
  try {
596
- const u = j(l);
597
- o.push(u), r.push(ge(I(u)).slice(2));
582
+ const u = D(l);
583
+ o.push(u), r.push(de(H(u)).slice(2));
598
584
  } finally {
599
585
  l.fill(0);
600
586
  }
@@ -604,17 +590,17 @@ async function yn(e, t) {
604
590
  }
605
591
  return { perVaultWotsKeys: n, wotsPkHashes: s, htlcSecretHexes: o, hashlocks: r };
606
592
  }
607
- const xn = /^0x[0-9a-f]+$/i, Pn = /^[0-9a-f]+$/i, En = /^[A-Za-z0-9+/]+={0,2}$/;
608
- function L(e) {
593
+ const bn = /^0x[0-9a-f]+$/i, Pn = /^[0-9a-f]+$/i, yn = /^[A-Za-z0-9+/]+={0,2}$/;
594
+ function U(e) {
609
595
  if (typeof e != "string" || e.length === 0)
610
596
  throw new Error("BTC wallet returned empty public key");
611
- return he(e).toLowerCase();
597
+ return le(e).toLowerCase();
612
598
  }
613
- function Tn(e) {
599
+ function xn(e) {
614
600
  if (typeof e != "string" || e.length === 0)
615
601
  throw new Error("BTC wallet returned empty BIP-322 signature");
616
602
  if (e.startsWith("0x") || e.startsWith("0X")) {
617
- if (!xn.test(e) || e.length < 4 || e.length % 2 !== 0)
603
+ if (!bn.test(e) || e.length < 4 || e.length % 2 !== 0)
618
604
  throw new Error("BTC wallet returned malformed hex BIP-322 signature");
619
605
  return e.toLowerCase();
620
606
  }
@@ -623,14 +609,14 @@ function Tn(e) {
623
609
  throw new Error("BTC wallet returned malformed hex BIP-322 signature");
624
610
  return `0x${e.toLowerCase()}`;
625
611
  }
626
- if (!En.test(e) || e.length % 4 !== 0)
612
+ if (!yn.test(e) || e.length % 4 !== 0)
627
613
  throw new Error("BTC wallet returned malformed base64 BIP-322 signature");
628
- const t = D.from(e, "base64");
614
+ const t = et.from(e, "base64");
629
615
  if (t.length === 0 || t.toString("base64") !== e)
630
616
  throw new Error("BTC wallet returned malformed base64 BIP-322 signature");
631
617
  return `0x${t.toString("hex")}`;
632
618
  }
633
- async function kn(e, t, n) {
619
+ async function En(e, t, n) {
634
620
  if (typeof e.signPsbts == "function") {
635
621
  const o = await e.signPsbts(t, n);
636
622
  if (o.length !== t.length)
@@ -646,106 +632,18 @@ async function kn(e, t, n) {
646
632
  }
647
633
  return s;
648
634
  }
649
- const C = {
650
- // VaultAlreadyExists()
651
- "0x04aabf33": "Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.",
652
- // ScriptPubKeyMismatch() - taproot output doesn't match expected script
653
- "0x4fec082d": "Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. This may be caused by incorrect vault participants or key configuration.",
654
- // InvalidBTCProofOfPossession()
655
- "0x6cc363a5": "Invalid BTC proof of possession: The signature could not be verified. Please ensure you're signing with the correct Bitcoin wallet.",
656
- // InvalidBTCPublicKey()
657
- "0x6c3f2bf6": "Invalid BTC public key: The Bitcoin public key format is invalid.",
658
- // InvalidAmount()
659
- "0x2c5211c6": "Invalid amount: The deposit amount is invalid or below the minimum required.",
660
- // ApplicationNotRegistered()
661
- "0x0405f772": "Application not registered: The application controller is not registered in the system.",
662
- // InvalidProviderStatus()
663
- "0x24e165cc": "Invalid provider status: The vault provider is not in a valid state to accept deposits.",
664
- // ZeroAddress()
665
- "0xd92e233d": "Zero address: One of the required addresses is the zero address.",
666
- // BtcKeyMismatch()
667
- "0x65aa7007": "BTC key mismatch: The Bitcoin public key does not match the expected key.",
668
- // Unauthorized()
669
- "0x82b42900": "Unauthorized: You must be the depositor or vault provider to submit this transaction.",
670
- // InvalidSignature() - common signature verification error
671
- "0x8baa579f": "Invalid signature: The BTC proof of possession signature could not be verified.",
672
- // InvalidBtcTransaction()
673
- "0x2f9d01e9": "Invalid BTC transaction: The Bitcoin transaction format is invalid.",
674
- // VaultProviderNotRegistered()
675
- "0x5a3c6b3e": "Vault provider not registered: The selected vault provider is not registered.",
676
- // InvalidPeginFee(uint256,uint256)
677
- "0x979f4518": "Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction.",
678
- // PrePeginOutputAlreadyUsed()
679
- "0x5fad9694": "This pre-pegin output has already been used to activate another vault.",
680
- // PeginTransactionAlreadyUsed()
681
- "0x7ed061c9": "This pegin transaction has already been used to activate another vault."
682
- };
683
- function dt(e) {
684
- if (!e || typeof e != "object") return;
685
- const t = e;
686
- if (typeof t.data == "string" && t.data.startsWith("0x"))
687
- return t.data;
688
- if (typeof t.details == "string" && t.details.startsWith("0x"))
689
- return t.details;
690
- let n = t.cause, s = 0;
691
- const o = 5;
692
- for (; n && typeof n == "object" && s < o; ) {
693
- const a = n;
694
- if (typeof a.data == "string" && a.data.startsWith("0x"))
695
- return a.data;
696
- n = a.cause, s++;
697
- }
698
- const i = (typeof t.message == "string" ? t.message : "").match(/\b(0x[a-fA-F0-9]{8})\b/);
699
- if (i)
700
- return i[1];
701
- }
702
- function Kn(e) {
703
- const t = dt(e);
704
- if (t) {
705
- const n = t.substring(0, 10);
706
- return C[t] ?? C[n];
707
- }
708
- }
709
- function Dn(e) {
710
- const t = dt(e);
711
- if (t === void 0) return !1;
712
- const n = t.substring(0, 10);
713
- return t in C || n in C;
714
- }
715
- function S(e) {
716
- console.error("[Contract Error] Raw error:", e);
717
- const t = dt(e);
718
- if (console.error("[Contract Error] Extracted error data:", t), t) {
719
- const s = t.substring(0, 10), o = C[t] ?? C[s];
720
- if (o)
721
- throw console.error("[Contract Error] Known error:", o), new Error(o);
722
- }
723
- const n = (e == null ? void 0 : e.message) || "";
724
- if (n.includes("gas limit too high") || n.includes("21000000") || n.includes("Internal JSON-RPC error")) {
725
- const s = t ? ` (error code: ${t})` : "";
726
- throw console.error(
727
- "[Contract Error] Transaction rejected. Error code:",
728
- t,
729
- "Message:",
730
- n
731
- ), new Error(
732
- `Transaction failed: The contract rejected this transaction${s}. Possible causes: (1) Vault already exists for this transaction, (2) Invalid signature, (3) Unauthorized caller. Please check your transaction parameters and try again.`
733
- );
734
- }
735
- throw e instanceof Error ? (console.error("[Contract Error] Unhandled error:", e.message), e) : new Error(`Contract call failed: ${String(e)}`);
736
- }
737
- const _n = 0, K = "00".repeat(32);
738
- function vn(e, t, n, s) {
635
+ const kn = 0, X = "00".repeat(32);
636
+ function Tn(e, t, n, s) {
739
637
  const o = n == null ? void 0 : n[`${e}:${t}`];
740
638
  return o ? Promise.resolve({
741
639
  txid: e,
742
640
  vout: t,
743
641
  value: o.value,
744
642
  scriptPubKey: o.scriptPubKey
745
- }) : xe(e, t, s);
643
+ }) : be(e, t, s);
746
644
  }
747
- const Rt = 12e4;
748
- class zn {
645
+ const Ot = 12e4;
646
+ class Mn {
749
647
  /**
750
648
  * Creates a new PeginManager instance.
751
649
  *
@@ -767,30 +665,30 @@ class zn {
767
665
  async preparePegin(t) {
768
666
  if (t.amounts.length === 0)
769
667
  throw new Error("amounts must contain at least one entry");
770
- const n = await this.config.btcWallet.getPublicKeyHex(), s = L(n), o = await this.prepareSizing(s, t), r = o.selectedUTXOs.map(
668
+ const n = await this.config.btcWallet.getPublicKeyHex(), s = U(n), o = await this.prepareSizing(s, t), r = o.selectedUTXOs.map(
771
669
  (g) => ({
772
- txid: st(g.txid),
670
+ txid: nt(g.txid),
773
671
  vout: g.vout
774
672
  })
775
- ), i = await De(this.config.btcWallet, {
776
- depositorBtcPubkey: st(s),
673
+ ), i = await Xe(this.config.btcWallet, {
674
+ depositorBtcPubkey: nt(s),
777
675
  fundingOutpoints: r
778
676
  });
779
677
  let a, l;
780
678
  try {
781
- const g = Ue(i);
679
+ const g = Ce(i);
782
680
  try {
783
- a = j(g), l = j(O(g));
681
+ a = D(g), l = D(O(g));
784
682
  } finally {
785
683
  g.fill(0);
786
684
  }
787
685
  } catch (g) {
788
686
  throw i.fill(0), g;
789
687
  }
790
- const u = await yn(i, t.amounts.length), { perVaultWotsKeys: c, wotsPkHashes: w, htlcSecretHexes: b, hashlocks: y } = u, h = await this.preparePeginCommit({
688
+ const u = await wn(i, t.amounts.length), { perVaultWotsKeys: c, wotsPkHashes: w, htlcSecretHexes: b, hashlocks: P } = u, h = await this.preparePeginCommit({
791
689
  depositorBtcPubkeyRaw: n,
792
690
  depositorBtcPubkey: s,
793
- hashlocks: y,
691
+ hashlocks: P,
794
692
  authAnchorHash: l,
795
693
  sizing: o,
796
694
  params: t
@@ -838,8 +736,8 @@ class zn {
838
736
  */
839
737
  async prepareSizing(t, n) {
840
738
  const s = n.amounts.map(
841
- () => K
842
- ), o = n.vaultKeeperBtcPubkeys.length, r = await bt({
739
+ () => X
740
+ ), o = n.vaultKeeperBtcPubkeys.length, r = await mt({
843
741
  depositorPubkey: t,
844
742
  vaultProviderPubkey: _(n.vaultProviderBtcPubkey),
845
743
  vaultKeeperPubkeys: n.vaultKeeperBtcPubkeys.map(_),
@@ -852,14 +750,14 @@ class zn {
852
750
  councilQuorum: n.councilQuorum,
853
751
  councilSize: n.councilSize,
854
752
  network: this.config.btcNetwork,
855
- authAnchorHash: K
856
- }), i = pe(
753
+ authAnchorHash: X
754
+ }), i = fe(
857
755
  [...n.availableUTXOs],
858
756
  r.totalOutputValue,
859
757
  n.mempoolFeeRate,
860
- we(
758
+ pe(
861
759
  r.htlcValues.length,
862
- K
760
+ X
863
761
  )
864
762
  );
865
763
  return {
@@ -877,7 +775,7 @@ class zn {
877
775
  authAnchorHash: r,
878
776
  sizing: i,
879
777
  params: a
880
- } = t, l = K.toLowerCase();
778
+ } = t, l = X.toLowerCase();
881
779
  for (let p = 0; p < o.length; p++)
882
780
  if (o[p].toLowerCase() === l)
883
781
  throw new Error(
@@ -887,7 +785,7 @@ class zn {
887
785
  throw new Error(
888
786
  "preparePeginCommit refusing to build with sizing-pass placeholder auth-anchor hash — internal substitution bug"
889
787
  );
890
- const u = _(a.vaultProviderBtcPubkey), c = a.vaultKeeperBtcPubkeys.map(_), w = a.universalChallengerBtcPubkeys.map(_), b = c.length, y = {
788
+ const u = _(a.vaultProviderBtcPubkey), c = a.vaultKeeperBtcPubkeys.map(_), w = a.universalChallengerBtcPubkeys.map(_), b = c.length, P = {
891
789
  depositorPubkey: s,
892
790
  vaultProviderPubkey: u,
893
791
  vaultKeeperPubkeys: c,
@@ -901,22 +799,22 @@ class zn {
901
799
  councilSize: a.councilSize,
902
800
  network: this.config.btcNetwork,
903
801
  authAnchorHash: r
904
- }, h = await bt(y), g = yt(this.config.btcNetwork), T = be({
802
+ }, h = await mt(P), g = wt(this.config.btcNetwork), k = me({
905
803
  unfundedTxHex: h.psbtHex,
906
804
  selectedUTXOs: i.selectedUTXOs,
907
805
  changeAddress: a.changeAddress,
908
806
  changeAmount: i.changeAmount,
909
807
  network: g
910
- }), B = _(Z(T)), d = [], P = [], f = [];
808
+ }), S = _(G(k)), d = [], x = [], f = [];
911
809
  for (let p = 0; p < o.length; p++) {
912
- const k = await ae({
913
- prePeginParams: y,
810
+ const T = await re({
811
+ prePeginParams: P,
914
812
  timelockPegin: a.timelockPegin,
915
- fundedPrePeginTxHex: T,
813
+ fundedPrePeginTxHex: k,
916
814
  htlcVout: p
917
- }), H = await ce({
918
- peginTxHex: k.txHex,
919
- fundedPrePeginTxHex: T,
815
+ }), A = await ie({
816
+ peginTxHex: T.txHex,
817
+ fundedPrePeginTxHex: k,
920
818
  depositorPubkey: s,
921
819
  vaultProviderPubkey: u,
922
820
  vaultKeeperPubkeys: c,
@@ -925,33 +823,33 @@ class zn {
925
823
  timelockRefund: a.timelockRefund,
926
824
  network: this.config.btcNetwork
927
825
  });
928
- d.push(k), P.push(H.psbtHex), f.push(
929
- fe(n, 1)
826
+ d.push(T), x.push(A.psbtHex), f.push(
827
+ he(n, 1)
930
828
  );
931
829
  }
932
- const E = await kn(
830
+ const E = await En(
933
831
  this.config.btcWallet,
934
- P,
832
+ x,
935
833
  f
936
- ), x = [];
834
+ ), y = [];
937
835
  for (let p = 0; p < E.length; p++) {
938
- const k = le(
836
+ const T = ae(
939
837
  E[p],
940
838
  s
941
- ), H = ue(E[p]);
942
- x.push({
839
+ ), A = ce(E[p]);
840
+ y.push({
943
841
  htlcVout: p,
944
842
  htlcValue: h.htlcValues[p],
945
- peginTxHex: H,
843
+ peginTxHex: A,
946
844
  peginTxid: d[p].txid,
947
- peginInputSignature: k,
845
+ peginInputSignature: T,
948
846
  vaultScriptPubKey: d[p].vaultScriptPubKey
949
847
  });
950
848
  }
951
849
  return {
952
- fundedPrePeginTxHex: T,
953
- prePeginTxid: B,
954
- perVault: x
850
+ fundedPrePeginTxHex: k,
851
+ prePeginTxid: S,
852
+ perVault: y
955
853
  };
956
854
  }
957
855
  /**
@@ -970,40 +868,40 @@ class zn {
970
868
  * @throws Error if signing or broadcasting fails
971
869
  */
972
870
  async signAndBroadcast(t) {
973
- const { fundedPrePeginTxHex: n, depositorBtcPubkey: s } = t, o = n.startsWith("0x") ? n.slice(2) : n, r = Ut.fromHex(o);
871
+ const { fundedPrePeginTxHex: n, depositorBtcPubkey: s } = t, o = n.startsWith("0x") ? n.slice(2) : n, r = se.fromHex(o);
974
872
  if (r.ins.length === 0)
975
873
  throw new Error("Transaction has no inputs");
976
- const i = new ft();
874
+ const i = new dt();
977
875
  i.setVersion(r.version), i.setLocktime(r.locktime);
978
- const a = D.from(
979
- L(s),
876
+ const a = et.from(
877
+ U(s),
980
878
  "hex"
981
879
  ), l = this.config.mempoolApiUrl, u = r.ins.map((d) => {
982
- const P = D.from(d.hash).reverse().toString("hex"), f = d.index;
983
- return vn(P, f, t.localPrevouts, l).then(
984
- (E) => ({ input: d, utxoData: E, txid: P, vout: f })
880
+ const x = et.from(d.hash).reverse().toString("hex"), f = d.index;
881
+ return Tn(x, f, t.localPrevouts, l).then(
882
+ (E) => ({ input: d, utxoData: E, txid: x, vout: f })
985
883
  );
986
884
  }), c = await Promise.all(u), w = c.reduce(
987
- (d, P) => d + BigInt(P.utxoData.value),
885
+ (d, x) => d + BigInt(x.utxoData.value),
988
886
  0n
989
887
  ), b = r.outs.reduce(
990
- (d, P) => d + BigInt(P.value),
888
+ (d, x) => d + BigInt(x.value),
991
889
  0n
992
890
  );
993
891
  if (w < b)
994
892
  throw new Error(
995
893
  `UTXO value mismatch: total input value (${w} sat) is less than total output value (${b} sat). This may indicate the mempool API returned manipulated UTXO data.`
996
894
  );
997
- const y = w - b;
998
- if (y > xt)
895
+ const P = w - b;
896
+ if (P > bt)
999
897
  throw new Error(
1000
- `Implied transaction fee (${y} sat) exceeds maximum reasonable fee (${xt} sat). This may indicate manipulated UTXO data.`
898
+ `Implied transaction fee (${P} sat) exceeds maximum reasonable fee (${bt} sat). This may indicate manipulated UTXO data.`
1001
899
  );
1002
- for (const { input: d, utxoData: P, txid: f, vout: E } of c) {
1003
- const x = me(
900
+ for (const { input: d, utxoData: x, txid: f, vout: E } of c) {
901
+ const y = ge(
1004
902
  {
1005
- value: P.value,
1006
- scriptPubKey: P.scriptPubKey
903
+ value: x.value,
904
+ scriptPubKey: x.scriptPubKey
1007
905
  },
1008
906
  a
1009
907
  );
@@ -1011,7 +909,7 @@ class zn {
1011
909
  hash: d.hash,
1012
910
  index: d.index,
1013
911
  sequence: d.sequence,
1014
- ...x
912
+ ...y
1015
913
  });
1016
914
  }
1017
915
  for (const d of r.outs)
@@ -1019,7 +917,7 @@ class zn {
1019
917
  script: d.script,
1020
918
  value: d.value
1021
919
  });
1022
- const h = await this.config.btcWallet.signPsbt(i.toHex()), g = ft.fromHex(h);
920
+ const h = await this.config.btcWallet.signPsbt(i.toHex()), g = dt.fromHex(h);
1023
921
  try {
1024
922
  g.finalizeAllInputs();
1025
923
  } catch (d) {
@@ -1030,8 +928,8 @@ class zn {
1030
928
  `PSBT finalization failed and wallet did not auto-finalize: ${d}`
1031
929
  );
1032
930
  }
1033
- const T = g.extractTransaction().toHex();
1034
- return await ye(T, l);
931
+ const k = g.extractTransaction().toHex();
932
+ return await we(k, l);
1035
933
  }
1036
934
  /**
1037
935
  * Registers a peg-in on Ethereum by calling the BTCVaultRegistry contract.
@@ -1071,27 +969,27 @@ class zn {
1071
969
  if (!this.config.ethWallet.account)
1072
970
  throw new Error("Ethereum wallet account not found");
1073
971
  const c = this.config.ethWallet.account.address;
1074
- if (!pt(u.depositorEthAddress, c))
972
+ if (!ft(u.depositorEthAddress, c))
1075
973
  throw new Error(
1076
974
  `Proof of possession was signed for ${u.depositorEthAddress} but the Ethereum wallet is currently connected to ${c}. Reconnect the original account or call signProofOfPossession() again.`
1077
975
  );
1078
976
  await this.assertPopMatchesBtcWallet(u);
1079
- const w = u.btcPopSignature, b = I(u.depositorBtcPubkey), y = I(n), h = I(s), g = await this.resolvePayoutScriptPubKey(
977
+ const w = u.btcPopSignature, b = H(u.depositorBtcPubkey), P = H(n), h = H(s), g = await this.resolvePayoutScriptPubKey(
1080
978
  a
1081
- ), T = Z(h), B = await wt(
1082
- _(T),
979
+ ), k = G(h), S = await pt(
980
+ _(k),
1083
981
  _(c)
1084
- ), d = I(B);
982
+ ), d = H(S);
1085
983
  if (await this.checkVaultExists(d))
1086
984
  throw new Error(
1087
- `Vault already exists (ID: ${d}, peginTxHash: ${T}). 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.`
985
+ `Vault already exists (ID: ${d}, peginTxHash: ${k}). 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.`
1088
986
  );
1089
987
  const f = this.config.publicClient;
1090
988
  let E;
1091
989
  try {
1092
990
  E = await f.readContract({
1093
991
  address: this.config.vaultContracts.btcVaultRegistry,
1094
- abi: $,
992
+ abi: C,
1095
993
  functionName: "getPegInFee",
1096
994
  args: [o]
1097
995
  });
@@ -1101,14 +999,14 @@ class zn {
1101
999
  { cause: R }
1102
1000
  );
1103
1001
  }
1104
- const x = mt({
1105
- abi: $,
1002
+ const y = gt({
1003
+ abi: C,
1106
1004
  functionName: "submitPeginRequest",
1107
1005
  args: [
1108
1006
  c,
1109
1007
  b,
1110
1008
  w,
1111
- y,
1009
+ P,
1112
1010
  h,
1113
1011
  o,
1114
1012
  r,
@@ -1121,38 +1019,38 @@ class zn {
1121
1019
  try {
1122
1020
  p = await f.estimateGas({
1123
1021
  to: this.config.vaultContracts.btcVaultRegistry,
1124
- data: x,
1022
+ data: y,
1125
1023
  value: E,
1126
1024
  account: this.config.ethWallet.account.address
1127
1025
  });
1128
1026
  } catch (R) {
1129
- S(R);
1027
+ B(R);
1130
1028
  }
1131
- let k;
1029
+ let T;
1132
1030
  try {
1133
- k = await this.config.ethWallet.sendTransaction({
1031
+ T = await this.config.ethWallet.sendTransaction({
1134
1032
  to: this.config.vaultContracts.btcVaultRegistry,
1135
- data: x,
1033
+ data: y,
1136
1034
  value: E,
1137
1035
  account: this.config.ethWallet.account,
1138
1036
  chain: this.config.ethChain,
1139
1037
  gas: p
1140
1038
  });
1141
1039
  } catch (R) {
1142
- S(R);
1040
+ B(R);
1143
1041
  }
1144
- const H = await f.waitForTransactionReceipt({
1145
- hash: k,
1146
- timeout: Rt
1042
+ const A = await f.waitForTransactionReceipt({
1043
+ hash: T,
1044
+ timeout: Ot
1147
1045
  });
1148
- return H.status === "reverted" && S(
1046
+ return A.status === "reverted" && B(
1149
1047
  new Error(
1150
- `Transaction reverted. Hash: ${k}. Check the transaction on block explorer for details.`
1048
+ `Transaction reverted. Hash: ${T}. Check the transaction on block explorer for details.`
1151
1049
  )
1152
1050
  ), {
1153
- ethTxHash: H.transactionHash,
1051
+ ethTxHash: A.transactionHash,
1154
1052
  vaultId: d,
1155
- peginTxHash: T
1053
+ peginTxHash: k
1156
1054
  };
1157
1055
  }
1158
1056
  /**
@@ -1172,7 +1070,7 @@ class zn {
1172
1070
  if (!this.config.ethWallet.account)
1173
1071
  throw new Error("Ethereum wallet account not found");
1174
1072
  const i = this.config.ethWallet.account.address;
1175
- if (!pt(r.depositorEthAddress, i))
1073
+ if (!ft(r.depositorEthAddress, i))
1176
1074
  throw new Error(
1177
1075
  `Proof of possession was signed for ${r.depositorEthAddress} but the Ethereum wallet is currently connected to ${i}. Reconnect the original account or call signProofOfPossession() again.`
1178
1076
  );
@@ -1184,24 +1082,24 @@ class zn {
1184
1082
  );
1185
1083
  const u = [];
1186
1084
  for (const f of o) {
1187
- const E = I(
1085
+ const E = H(
1188
1086
  f.depositorSignedPeginTx
1189
- ), x = Z(E), p = await wt(
1190
- _(x),
1087
+ ), y = G(E), p = await pt(
1088
+ _(y),
1191
1089
  _(i)
1192
- ), k = I(p);
1193
- if (await this.checkVaultExists(k))
1090
+ ), T = H(p);
1091
+ if (await this.checkVaultExists(T))
1194
1092
  throw new Error(
1195
- `Vault already exists (ID: ${k}, peginTxHash: ${x}). To create a new vault, use different UTXOs or a different amount.`
1093
+ `Vault already exists (ID: ${T}, peginTxHash: ${y}). To create a new vault, use different UTXOs or a different amount.`
1196
1094
  );
1197
- u.push({ vaultId: k, peginTxHash: x });
1095
+ u.push({ vaultId: T, peginTxHash: y });
1198
1096
  }
1199
1097
  const c = this.config.publicClient;
1200
1098
  let w;
1201
1099
  try {
1202
1100
  w = await c.readContract({
1203
1101
  address: this.config.vaultContracts.btcVaultRegistry,
1204
- abi: $,
1102
+ abi: C,
1205
1103
  functionName: "getPegInFee",
1206
1104
  args: [n]
1207
1105
  });
@@ -1211,59 +1109,59 @@ class zn {
1211
1109
  { cause: f }
1212
1110
  );
1213
1111
  }
1214
- const b = w * BigInt(o.length), y = I(
1112
+ const b = w * BigInt(o.length), P = H(
1215
1113
  r.depositorBtcPubkey
1216
- ), h = I(s), g = o.map((f, E) => ({
1217
- depositorBtcPubKey: y,
1114
+ ), h = H(s), g = o.map((f, E) => ({
1115
+ depositorBtcPubKey: P,
1218
1116
  btcPopSignature: a,
1219
1117
  unsignedPrePeginTx: h,
1220
- depositorSignedPeginTx: I(
1118
+ depositorSignedPeginTx: H(
1221
1119
  f.depositorSignedPeginTx
1222
1120
  ),
1223
1121
  hashlock: f.hashlock,
1224
1122
  htlcVout: f.htlcVout,
1225
- referralCode: _n,
1123
+ referralCode: kn,
1226
1124
  depositorPayoutBtcAddress: l[E],
1227
1125
  depositorWotsPkHash: f.depositorWotsPkHash
1228
- })), T = mt({
1229
- abi: $,
1126
+ })), k = gt({
1127
+ abi: C,
1230
1128
  functionName: "submitPeginRequestBatch",
1231
1129
  args: [i, n, g]
1232
1130
  });
1233
- let B;
1131
+ let S;
1234
1132
  try {
1235
- B = await c.estimateGas({
1133
+ S = await c.estimateGas({
1236
1134
  to: this.config.vaultContracts.btcVaultRegistry,
1237
- data: T,
1135
+ data: k,
1238
1136
  value: b,
1239
1137
  account: this.config.ethWallet.account.address
1240
1138
  });
1241
1139
  } catch (f) {
1242
- S(f);
1140
+ B(f);
1243
1141
  }
1244
1142
  let d;
1245
1143
  try {
1246
1144
  d = await this.config.ethWallet.sendTransaction({
1247
1145
  to: this.config.vaultContracts.btcVaultRegistry,
1248
- data: T,
1146
+ data: k,
1249
1147
  value: b,
1250
1148
  account: this.config.ethWallet.account,
1251
1149
  chain: this.config.ethChain,
1252
- gas: B
1150
+ gas: S
1253
1151
  });
1254
1152
  } catch (f) {
1255
- S(f);
1153
+ B(f);
1256
1154
  }
1257
- const P = await c.waitForTransactionReceipt({
1155
+ const x = await c.waitForTransactionReceipt({
1258
1156
  hash: d,
1259
- timeout: Rt
1157
+ timeout: Ot
1260
1158
  });
1261
- return P.status === "reverted" && S(
1159
+ return x.status === "reverted" && B(
1262
1160
  new Error(
1263
1161
  `Batch transaction reverted. Hash: ${d}. Check the transaction on block explorer for details.`
1264
1162
  )
1265
1163
  ), {
1266
- ethTxHash: P.transactionHash,
1164
+ ethTxHash: x.transactionHash,
1267
1165
  vaults: u
1268
1166
  };
1269
1167
  }
@@ -1283,10 +1181,10 @@ class zn {
1283
1181
  async checkVaultExists(t) {
1284
1182
  return (await this.config.publicClient.readContract({
1285
1183
  address: this.config.vaultContracts.btcVaultRegistry,
1286
- abi: $,
1184
+ abi: C,
1287
1185
  functionName: "getBtcVaultBasicInfo",
1288
1186
  args: [t]
1289
- })).depositor !== ie;
1187
+ })).depositor !== oe;
1290
1188
  }
1291
1189
  /**
1292
1190
  * Resolve the BTC payout address to a scriptPubKey hex for the contract.
@@ -1302,7 +1200,7 @@ class zn {
1302
1200
  else {
1303
1201
  n = await this.config.btcWallet.getAddress();
1304
1202
  const o = await this.config.btcWallet.getPublicKeyHex();
1305
- if (!de(
1203
+ if (!ue(
1306
1204
  n,
1307
1205
  o,
1308
1206
  this.config.btcNetwork
@@ -1311,7 +1209,7 @@ class zn {
1311
1209
  "The BTC address from your wallet does not match the wallet's public key. Please ensure your wallet is using a supported address type (Taproot or Native SegWit)."
1312
1210
  );
1313
1211
  }
1314
- const s = yt(this.config.btcNetwork);
1212
+ const s = wt(this.config.btcNetwork);
1315
1213
  try {
1316
1214
  return `0x${$t.address.toOutputScript(n, s).toString("hex")}`;
1317
1215
  } catch {
@@ -1329,22 +1227,22 @@ class zn {
1329
1227
  async signProofOfPossession() {
1330
1228
  if (!this.config.ethWallet.account)
1331
1229
  throw new Error("Ethereum wallet account not found");
1332
- const t = this.config.ethWallet.account.address, n = L(
1230
+ const t = this.config.ethWallet.account.address, n = U(
1333
1231
  await this.config.btcWallet.getPublicKeyHex()
1334
1232
  ), s = this.config.vaultContracts.btcVaultRegistry, o = `${t.toLowerCase()}:${this.config.ethChain.id}:pegin:${s.toLowerCase()}`, r = await this.config.btcWallet.signMessage(
1335
1233
  o,
1336
1234
  "bip322-simple"
1337
1235
  );
1338
1236
  return {
1339
- btcPopSignature: Tn(r),
1237
+ btcPopSignature: xn(r),
1340
1238
  depositorEthAddress: t,
1341
1239
  depositorBtcPubkey: n
1342
1240
  };
1343
1241
  }
1344
1242
  async assertPopMatchesBtcWallet(t) {
1345
- const n = L(
1243
+ const n = U(
1346
1244
  await this.config.btcWallet.getPublicKeyHex()
1347
- ), s = L(t.depositorBtcPubkey);
1245
+ ), s = U(t.depositorBtcPubkey);
1348
1246
  if (n !== s)
1349
1247
  throw new Error(
1350
1248
  `Proof of possession was signed with BTC pubkey ${s} but the BTC wallet is currently connected to ${n}. Reconnect the original wallet or call signProofOfPossession() again.`
@@ -1368,22 +1266,15 @@ class zn {
1368
1266
  }
1369
1267
  }
1370
1268
  export {
1371
- C,
1372
- zn as P,
1373
- Xe as V,
1374
- Xn as a,
1269
+ Mn as P,
1270
+ Me as V,
1271
+ $e as a,
1375
1272
  Ue as b,
1376
- bn as c,
1377
- wn as d,
1378
- dt as e,
1379
- Le as f,
1380
- Kn as g,
1381
- S as h,
1382
- Dn as i,
1383
- Ne as j,
1384
- Me as k,
1385
- Fe as l,
1386
- De as m,
1387
- Fn as p
1273
+ mn as c,
1274
+ pn as d,
1275
+ Ce as e,
1276
+ Ve as f,
1277
+ We as g,
1278
+ Xe as h
1388
1279
  };
1389
- //# sourceMappingURL=PeginManager-C-L3huRO.js.map
1280
+ //# sourceMappingURL=PeginManager-C5HaMAcw.js.map