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