@babylonlabs-io/ts-sdk 0.56.1 → 0.57.1

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 (157) hide show
  1. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-Chs4AFBj.js → BTCVaultRegistry.abi-CixOlp3B.js} +73 -14
  4. package/dist/BTCVaultRegistry.abi-CixOlp3B.js.map +1 -0
  5. package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js +111 -0
  6. package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js.map +1 -0
  7. package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs +2 -0
  8. package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs.map +1 -0
  9. package/dist/{PeginManager-Ba7Cr51Z.js → PeginManager-CnX3uFb0.js} +5 -5
  10. package/dist/{PeginManager-Ba7Cr51Z.js.map → PeginManager-CnX3uFb0.js.map} +1 -1
  11. package/dist/PeginManager-iDbqXsKD.cjs +2 -0
  12. package/dist/{PeginManager-CcjGRo4O.cjs.map → PeginManager-iDbqXsKD.cjs.map} +1 -1
  13. package/dist/ProtocolParams.abi-C8U7BHCS.cjs +2 -0
  14. package/dist/ProtocolParams.abi-C8U7BHCS.cjs.map +1 -0
  15. package/dist/{ApplicationRegistry.abi-w5prf7Ig.js → ProtocolParams.abi-CV938AYZ.js} +150 -80
  16. package/dist/ProtocolParams.abi-CV938AYZ.js.map +1 -0
  17. package/dist/batchPoll-BXIy3R7h.cjs +2 -0
  18. package/dist/batchPoll-BXIy3R7h.cjs.map +1 -0
  19. package/dist/{primeVpAuth-Caa5J_uv.js → batchPoll-DTYXoTEc.js} +515 -403
  20. package/dist/batchPoll-DTYXoTEc.js.map +1 -0
  21. package/dist/buildAndBroadcastRefund-4uAl7OIk.cjs +2 -0
  22. package/dist/buildAndBroadcastRefund-4uAl7OIk.cjs.map +1 -0
  23. package/dist/{buildAndBroadcastRefund-BtXUqBkb.js → buildAndBroadcastRefund-Bo3AlqCk.js} +627 -452
  24. package/dist/buildAndBroadcastRefund-Bo3AlqCk.js.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +168 -157
  27. package/dist/index.js.map +1 -1
  28. package/dist/json-rpc-client-BiAmg_ho.cjs +2 -0
  29. package/dist/json-rpc-client-BiAmg_ho.cjs.map +1 -0
  30. package/dist/json-rpc-client-DuUARJvV.js +334 -0
  31. package/dist/json-rpc-client-DuUARJvV.js.map +1 -0
  32. package/dist/mempoolApi-C0olk43O.js +536 -0
  33. package/dist/mempoolApi-C0olk43O.js.map +1 -0
  34. package/dist/mempoolApi-Dsm2VPXp.cjs +2 -0
  35. package/dist/mempoolApi-Dsm2VPXp.cjs.map +1 -0
  36. package/dist/{noPayout-CihCk1HE.js → noPayout-CI4l1qu2.js} +2 -2
  37. package/dist/{noPayout-CihCk1HE.js.map → noPayout-CI4l1qu2.js.map} +1 -1
  38. package/dist/{noPayout-Cb8vFrkY.cjs → noPayout-Djrv31V5.cjs} +2 -2
  39. package/dist/{noPayout-Cb8vFrkY.cjs.map → noPayout-Djrv31V5.cjs.map} +1 -1
  40. package/dist/onChainBtcPubkey-Cd9kpz-S.cjs +2 -0
  41. package/dist/onChainBtcPubkey-Cd9kpz-S.cjs.map +1 -0
  42. package/dist/onChainBtcPubkey-aPY5ib3Q.js +19 -0
  43. package/dist/onChainBtcPubkey-aPY5ib3Q.js.map +1 -0
  44. package/dist/signPsbtsWithFallback-C01N6Kdo.cjs +2 -0
  45. package/dist/signPsbtsWithFallback-C01N6Kdo.cjs.map +1 -0
  46. package/dist/{PayoutManager-BVgmuKuK.js → signPsbtsWithFallback-CzZFZf0I.js} +105 -101
  47. package/dist/signPsbtsWithFallback-CzZFZf0I.js.map +1 -0
  48. package/dist/tbv/core/clients/eth/index.d.ts +5 -3
  49. package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
  50. package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts +16 -0
  51. package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts.map +1 -0
  52. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +33 -0
  53. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -0
  54. package/dist/tbv/core/clients/eth/types.d.ts +122 -3
  55. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  56. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +25 -1
  57. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  58. package/dist/tbv/core/clients/index.cjs +1 -1
  59. package/dist/tbv/core/clients/index.js +36 -32
  60. package/dist/tbv/core/clients/index.js.map +1 -1
  61. package/dist/tbv/core/clients/vault-provider/index.d.ts +4 -4
  62. package/dist/tbv/core/clients/vault-provider/index.d.ts.map +1 -1
  63. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts +36 -14
  64. package/dist/tbv/core/clients/vault-provider/json-rpc-client.d.ts.map +1 -1
  65. package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts +2 -0
  66. package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts.map +1 -0
  67. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +66 -0
  68. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
  69. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +50 -0
  70. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  71. package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts +111 -0
  72. package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts.map +1 -0
  73. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +36 -0
  74. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  75. package/dist/tbv/core/contracts/index.cjs +1 -1
  76. package/dist/tbv/core/contracts/index.d.ts +2 -1
  77. package/dist/tbv/core/contracts/index.d.ts.map +1 -1
  78. package/dist/tbv/core/contracts/index.js +8 -6
  79. package/dist/tbv/core/contracts/index.js.map +1 -1
  80. package/dist/tbv/core/index.cjs +1 -1
  81. package/dist/tbv/core/index.js +167 -156
  82. package/dist/tbv/core/index.js.map +1 -1
  83. package/dist/tbv/core/managers/PayoutManager.d.ts +8 -0
  84. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  85. package/dist/tbv/core/managers/index.cjs +1 -1
  86. package/dist/tbv/core/managers/index.js +2 -2
  87. package/dist/tbv/core/primitives/index.cjs +1 -1
  88. package/dist/tbv/core/primitives/index.js +2 -2
  89. package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts +2 -0
  90. package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts.map +1 -0
  91. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts +5 -5
  92. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts.map +1 -1
  93. package/dist/tbv/core/primitives/psbt/payout.d.ts +23 -0
  94. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  95. package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts +41 -0
  96. package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts.map +1 -0
  97. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts +2 -0
  98. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts.map +1 -0
  99. package/dist/tbv/core/services/deposit/index.d.ts +7 -6
  100. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  101. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +10 -0
  102. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  103. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +9 -0
  104. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  105. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +38 -1
  106. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
  107. package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts +42 -0
  108. package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts.map +1 -0
  109. package/dist/tbv/core/services/index.cjs +1 -1
  110. package/dist/tbv/core/services/index.d.ts +1 -0
  111. package/dist/tbv/core/services/index.d.ts.map +1 -1
  112. package/dist/tbv/core/services/index.js +36 -31
  113. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts +55 -0
  114. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -0
  115. package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts +2 -0
  116. package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts.map +1 -0
  117. package/dist/tbv/core/services/participants/index.d.ts +8 -0
  118. package/dist/tbv/core/services/participants/index.d.ts.map +1 -0
  119. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts +26 -0
  120. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts.map +1 -0
  121. package/dist/tbv/core/services/participants/types.d.ts +62 -0
  122. package/dist/tbv/core/services/participants/types.d.ts.map +1 -0
  123. package/dist/tbv/index.cjs +1 -1
  124. package/dist/tbv/index.js +167 -156
  125. package/dist/tbv/index.js.map +1 -1
  126. package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs +2 -0
  127. package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs.map +1 -0
  128. package/dist/{verifyScriptPathSchnorrSignature-CgrnAjMW.js → verifyScriptPathSchnorrSignature-Xoo9DOHW.js} +359 -301
  129. package/dist/verifyScriptPathSchnorrSignature-Xoo9DOHW.js.map +1 -0
  130. package/package.json +1 -1
  131. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs +0 -2
  132. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs.map +0 -1
  133. package/dist/ApplicationRegistry.abi-w5prf7Ig.js.map +0 -1
  134. package/dist/BTCVaultRegistry.abi-Chs4AFBj.js.map +0 -1
  135. package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs +0 -2
  136. package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs.map +0 -1
  137. package/dist/PayoutManager-BVgmuKuK.js.map +0 -1
  138. package/dist/PayoutManager-Cu4_l-_Y.cjs +0 -2
  139. package/dist/PayoutManager-Cu4_l-_Y.cjs.map +0 -1
  140. package/dist/PeginManager-CcjGRo4O.cjs +0 -2
  141. package/dist/buildAndBroadcastRefund-BtXUqBkb.js.map +0 -1
  142. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs +0 -2
  143. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs.map +0 -1
  144. package/dist/mempoolApi-DkyKmmgI.cjs +0 -2
  145. package/dist/mempoolApi-DkyKmmgI.cjs.map +0 -1
  146. package/dist/mempoolApi-lpJdvPkK.js +0 -483
  147. package/dist/mempoolApi-lpJdvPkK.js.map +0 -1
  148. package/dist/primeVpAuth-Caa5J_uv.js.map +0 -1
  149. package/dist/primeVpAuth-y-4A88ah.cjs +0 -2
  150. package/dist/primeVpAuth-y-4A88ah.cjs.map +0 -1
  151. package/dist/types-CQDRQvV-.js +0 -324
  152. package/dist/types-CQDRQvV-.js.map +0 -1
  153. package/dist/types-WA0LrDk1.cjs +0 -2
  154. package/dist/types-WA0LrDk1.cjs.map +0 -1
  155. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs +0 -2
  156. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs.map +0 -1
  157. package/dist/verifyScriptPathSchnorrSignature-CgrnAjMW.js.map +0 -1
@@ -1,28 +1,28 @@
1
- var Se = Object.defineProperty;
2
- var Ce = (r, e, t) => e in r ? Se(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
1
+ var ke = Object.defineProperty;
2
+ var Ce = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var f = (r, e, t) => Ce(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { B as Q } from "./BTCVaultRegistry.abi-Chs4AFBj.js";
5
- import { P as b, A as L } from "./ApplicationRegistry.abi-w5prf7Ig.js";
6
- import { k as Te, v as U, l as $e, j as Ve } from "./mempoolApi-lpJdvPkK.js";
7
- import { D as Ie, J as ge, e as Re } from "./types-CQDRQvV-.js";
8
- import { X as R, C as G, s as I, S as Oe, h as Ne, p as fe } from "./bitcoin-B5aNKtsk.js";
4
+ import { B } from "./BTCVaultRegistry.abi-CixOlp3B.js";
5
+ import { A as R, P as y } from "./ProtocolParams.abi-CV938AYZ.js";
6
+ import { k as Te, v as K, l as $e, j as Ve } from "./mempoolApi-C0olk43O.js";
7
+ import { X as O, C as j, s as I, S as Ie, h as Re, p as ge } from "./bitcoin-B5aNKtsk.js";
8
+ import { D as Oe, a as fe, e as Ne } from "./json-rpc-client-DuUARJvV.js";
9
9
  import { C as ee } from "./constants-CDQE812z.js";
10
- import { H as S } from "./validation-Dj3dqYtl.js";
11
- import * as H from "@bitcoin-js/tiny-secp256k1-asmjs";
10
+ import { H as k } from "./validation-Dj3dqYtl.js";
11
+ import * as U from "@bitcoin-js/tiny-secp256k1-asmjs";
12
12
  import { payments as Be, Transaction as X } from "bitcoinjs-lib";
13
13
  import { Buffer as V } from "buffer";
14
- import { s as q } from "./sha2-BYVxyZzX.js";
14
+ import { s as Y } from "./sha2-BYVxyZzX.js";
15
15
  async function or(r, e) {
16
16
  const [t, n] = await r.multicall({
17
17
  contracts: [
18
18
  {
19
19
  address: e,
20
- abi: Q,
20
+ abi: B,
21
21
  functionName: "protocolParams"
22
22
  },
23
23
  {
24
24
  address: e,
25
- abi: Q,
25
+ abi: B,
26
26
  functionName: "applicationRegistry"
27
27
  }
28
28
  ],
@@ -33,8 +33,119 @@ async function or(r, e) {
33
33
  applicationRegistry: n
34
34
  };
35
35
  }
36
+ function Ge(r, e) {
37
+ return {
38
+ vaultProvider: r[0],
39
+ vaultKeepers: r.slice(1, 1 + e),
40
+ universalChallengers: r.slice(1 + e)
41
+ };
42
+ }
43
+ class cr {
44
+ constructor(e, t) {
45
+ this.publicClient = e, this.contracts = t;
46
+ }
47
+ /**
48
+ * One multicall, `allowFailure: false`, so every key in the set is read at
49
+ * the same block. A rotation landing between two separate `eth_call`s would
50
+ * otherwise produce a mixed-epoch key set and a lock no counterparty agrees
51
+ * with.
52
+ */
53
+ async readAll(e, t) {
54
+ const n = await this.publicClient.multicall({
55
+ contracts: e,
56
+ allowFailure: !1
57
+ });
58
+ return Ge(n, t);
59
+ }
60
+ async getCurrentOperationKeys(e) {
61
+ const t = [
62
+ {
63
+ address: this.contracts.btcVaultRegistry,
64
+ abi: B,
65
+ functionName: "getCurrentOperationBtcKey",
66
+ args: [e.vaultProviderEthAddress]
67
+ },
68
+ ...e.vaultKeepers.map((n) => ({
69
+ address: this.contracts.applicationRegistry,
70
+ abi: R,
71
+ functionName: "getCurrentOperationBtcKey",
72
+ args: [e.applicationEntryPoint, n.ethAddress]
73
+ })),
74
+ ...e.universalChallengers.map((n) => ({
75
+ address: this.contracts.protocolParams,
76
+ abi: y,
77
+ functionName: "getCurrentOperationBtcKey",
78
+ args: [n.ethAddress]
79
+ }))
80
+ ];
81
+ return this.readAll(t, e.vaultKeepers.length);
82
+ }
83
+ async getOperationKeysAtEpochs(e, t) {
84
+ const n = [
85
+ // The VP takes the plain `AtEpoch` variant: it has no membership
86
+ // version, so its genesis (the registration key at version 0) is
87
+ // unambiguous and the contract resolves it internally.
88
+ {
89
+ address: this.contracts.btcVaultRegistry,
90
+ abi: B,
91
+ functionName: "getOperationBtcKeyAtEpoch",
92
+ args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
93
+ },
94
+ // Keepers and challengers take `...OrGenesis` with their roster key
95
+ // passed explicitly, because the correct genesis for them is their key
96
+ // in *this vault's frozen membership version*. An operator dropped from
97
+ // the current roster, or listed under a different key in an older
98
+ // version, would otherwise resolve against the wrong genesis.
99
+ ...e.vaultKeepers.map((i) => ({
100
+ address: this.contracts.applicationRegistry,
101
+ abi: R,
102
+ functionName: "getOperationBtcKeyAtEpochOrGenesis",
103
+ args: [
104
+ e.applicationEntryPoint,
105
+ i.ethAddress,
106
+ t.appKeeperKeyEpoch,
107
+ i.btcPubKey
108
+ ]
109
+ })),
110
+ ...e.universalChallengers.map((i) => ({
111
+ address: this.contracts.protocolParams,
112
+ abi: y,
113
+ functionName: "getOperationBtcKeyAtEpochOrGenesis",
114
+ args: [i.ethAddress, t.ucKeyEpoch, i.btcPubKey]
115
+ }))
116
+ ];
117
+ return this.readAll(n, e.vaultKeepers.length);
118
+ }
119
+ async getPayoutScriptsAtEpochs(e, t) {
120
+ const n = await this.publicClient.multicall({
121
+ contracts: [
122
+ {
123
+ address: this.contracts.btcVaultRegistry,
124
+ abi: B,
125
+ functionName: "getPayoutScriptAtEpoch",
126
+ args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
127
+ },
128
+ ...e.vaultKeepers.map((i) => ({
129
+ address: this.contracts.applicationRegistry,
130
+ abi: R,
131
+ functionName: "getPayoutScriptAtEpoch",
132
+ args: [
133
+ e.applicationEntryPoint,
134
+ i.ethAddress,
135
+ t.appKeeperKeyEpoch
136
+ ]
137
+ }))
138
+ ],
139
+ allowFailure: !1
140
+ });
141
+ return {
142
+ vaultProvider: n[0],
143
+ vaultKeepers: [...n.slice(1)]
144
+ };
145
+ }
146
+ }
36
147
  const te = 65535;
37
- function N(r) {
148
+ function G(r) {
38
149
  return {
39
150
  timelockAssert: r.timelockAssert,
40
151
  timelockChallengeAssert: r.timelockChallengeAssert,
@@ -68,14 +179,14 @@ function ne(r) {
68
179
  );
69
180
  return Number(r);
70
181
  }
71
- class ar {
182
+ class lr {
72
183
  constructor(e, t) {
73
184
  this.publicClient = e, this.contractAddress = t;
74
185
  }
75
186
  async getTBVProtocolParams() {
76
187
  const e = await this.publicClient.readContract({
77
188
  address: this.contractAddress,
78
- abi: b,
189
+ abi: y,
79
190
  functionName: "getTBVProtocolParams"
80
191
  }), t = re(e);
81
192
  return Te(t), t;
@@ -83,24 +194,24 @@ class ar {
83
194
  async getLatestOffchainParams() {
84
195
  const e = await this.publicClient.readContract({
85
196
  address: this.contractAddress,
86
- abi: b,
197
+ abi: y,
87
198
  functionName: "getLatestOffchainParams"
88
- }), t = N(e);
89
- return U(t), t;
199
+ }), t = G(e);
200
+ return K(t), t;
90
201
  }
91
202
  async getOffchainParamsByVersion(e) {
92
203
  const t = await this.publicClient.readContract({
93
204
  address: this.contractAddress,
94
- abi: b,
205
+ abi: y,
95
206
  functionName: "getOffchainParamsByVersion",
96
207
  args: [e]
97
- }), n = N(t);
98
- return U(n), n;
208
+ }), n = G(t);
209
+ return K(n), n;
99
210
  }
100
211
  async getLatestOffchainParamsVersion() {
101
212
  const e = await this.publicClient.readContract({
102
213
  address: this.contractAddress,
103
- abi: b,
214
+ abi: y,
104
215
  functionName: "latestOffchainParamsVersion"
105
216
  }), t = Number(e);
106
217
  return $e(t), t;
@@ -121,27 +232,27 @@ class ar {
121
232
  contracts: [
122
233
  {
123
234
  address: this.contractAddress,
124
- abi: b,
235
+ abi: y,
125
236
  functionName: "getTBVProtocolParams"
126
237
  },
127
238
  {
128
239
  address: this.contractAddress,
129
- abi: b,
240
+ abi: y,
130
241
  functionName: "getLatestOffchainParams"
131
242
  },
132
243
  {
133
244
  address: this.contractAddress,
134
- abi: b,
245
+ abi: y,
135
246
  functionName: "latestOffchainParamsVersion"
136
247
  },
137
248
  {
138
249
  address: this.contractAddress,
139
- abi: b,
250
+ abi: y,
140
251
  functionName: "activeVaultCoreVersion"
141
252
  }
142
253
  ],
143
254
  allowFailure: !1
144
- }), t = re(e[0]), n = N(e[1]), i = Number(e[2]), s = Number(e[3]), o = {
255
+ }), t = re(e[0]), n = G(e[1]), i = Number(e[2]), s = Number(e[3]), a = {
145
256
  minimumPegInAmount: t.minimumPegInAmount,
146
257
  maxPegInAmount: t.maxPegInAmount,
147
258
  pegInAckTimeout: t.pegInAckTimeout,
@@ -155,7 +266,7 @@ class ar {
155
266
  offchainParamsVersion: i,
156
267
  activeVaultCoreVersion: s
157
268
  };
158
- return Ve(o), o;
269
+ return Ve(a), a;
159
270
  }
160
271
  /**
161
272
  * Fetch every historical offchain params version in a single multicall.
@@ -173,17 +284,17 @@ class ar {
173
284
  return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
174
285
  const n = Array.from({ length: t }, (c, d) => d + 1), i = n.map((c) => ({
175
286
  address: this.contractAddress,
176
- abi: b,
287
+ abi: y,
177
288
  functionName: "getOffchainParamsByVersion",
178
289
  args: [c]
179
290
  })), s = await this.publicClient.multicall({
180
291
  contracts: i,
181
292
  allowFailure: !1
182
- }), o = /* @__PURE__ */ new Map();
293
+ }), a = /* @__PURE__ */ new Map();
183
294
  for (let c = 0; c < n.length; c++) {
184
- const d = N(s[c]);
295
+ const d = G(s[c]);
185
296
  try {
186
- U(d), o.set(n[c], d);
297
+ K(d), a.set(n[c], d);
187
298
  } catch (l) {
188
299
  e == null || e(
189
300
  n[c],
@@ -191,204 +302,204 @@ class ar {
191
302
  );
192
303
  }
193
304
  }
194
- return { byVersion: o, latestVersion: t };
305
+ return { byVersion: a, latestVersion: t };
195
306
  }
196
307
  }
197
- function M(r) {
308
+ function H(r) {
198
309
  return r.map((e) => ({
199
310
  ethAddress: e.ethAddress,
200
311
  btcPubKey: e.btcPubKey
201
312
  }));
202
313
  }
203
- class cr {
314
+ class ur {
204
315
  constructor(e, t) {
205
316
  this.publicClient = e, this.contractAddress = t;
206
317
  }
207
318
  async getVaultKeepersByVersion(e, t) {
208
319
  const n = await this.publicClient.readContract({
209
320
  address: this.contractAddress,
210
- abi: L,
321
+ abi: R,
211
322
  functionName: "getVaultKeepersByVersion",
212
323
  args: [e, t]
213
324
  });
214
- return M(n);
325
+ return H(n);
215
326
  }
216
327
  async getCurrentVaultKeepers(e) {
217
328
  const t = await this.publicClient.readContract({
218
329
  address: this.contractAddress,
219
- abi: L,
330
+ abi: R,
220
331
  functionName: "getCurrentVaultKeepers",
221
332
  args: [e]
222
333
  });
223
- return M(t);
334
+ return H(t);
224
335
  }
225
336
  async getCurrentVaultKeepersVersion(e) {
226
337
  return await this.publicClient.readContract({
227
338
  address: this.contractAddress,
228
- abi: L,
339
+ abi: R,
229
340
  functionName: "getCurrentVaultKeepersVersion",
230
341
  args: [e]
231
342
  });
232
343
  }
233
344
  }
234
- class lr {
345
+ class dr {
235
346
  constructor(e, t) {
236
347
  this.publicClient = e, this.contractAddress = t;
237
348
  }
238
349
  async getUniversalChallengersByVersion(e) {
239
350
  const t = await this.publicClient.readContract({
240
351
  address: this.contractAddress,
241
- abi: b,
352
+ abi: y,
242
353
  functionName: "getUniversalChallengersByVersion",
243
354
  args: [e]
244
355
  });
245
- return M(t);
356
+ return H(t);
246
357
  }
247
358
  async getCurrentUniversalChallengers() {
248
359
  const e = await this.publicClient.readContract({
249
360
  address: this.contractAddress,
250
- abi: b,
361
+ abi: y,
251
362
  functionName: "getCurrentUniversalChallengers"
252
363
  });
253
- return M(e);
364
+ return H(e);
254
365
  }
255
366
  async getLatestUniversalChallengersVersion() {
256
367
  return await this.publicClient.readContract({
257
368
  address: this.contractAddress,
258
- abi: b,
369
+ abi: y,
259
370
  functionName: "latestUniversalChallengersVersion"
260
371
  });
261
372
  }
262
373
  }
263
374
  var De = /* @__PURE__ */ ((r) => (r[r.PENDING = 0] = "PENDING", r[r.VERIFIED = 1] = "VERIFIED", r[r.ACTIVE = 2] = "ACTIVE", r[r.REDEEMED = 3] = "REDEEMED", r[r.EXPIRED = 4] = "EXPIRED", r))(De || {});
264
- const se = new Set(Object.values(Ie)), Ge = 200;
265
- function p(r) {
375
+ const se = new Set(Object.values(Oe)), Me = 200;
376
+ function h(r) {
266
377
  var e;
267
- return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Ge)) ?? "undefined";
378
+ return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Me)) ?? "undefined";
268
379
  }
269
- const Me = "The vault provider returned an unexpected response. Please try again or contact support.";
270
- class a extends Error {
380
+ const je = "The vault provider returned an unexpected response. Please try again or contact support.";
381
+ class o extends Error {
271
382
  constructor(t) {
272
- super(Me);
383
+ super(je);
273
384
  f(this, "detail");
274
385
  this.name = "VpResponseValidationError", this.detail = t;
275
386
  }
276
387
  }
277
- const O = 64;
388
+ const N = 64;
278
389
  function T(r) {
279
- return typeof r == "string" && r.length > 0 && S.test(r);
390
+ return typeof r == "string" && r.length > 0 && k.test(r);
280
391
  }
281
392
  function _e(r) {
282
393
  return typeof r == "string" && r.length > 0;
283
394
  }
284
395
  function me(r, e) {
285
396
  if (!T(r))
286
- throw new a(
287
- `VP response validation failed: "${e}" must be a non-empty hex string, got ${p(r)}`
397
+ throw new o(
398
+ `VP response validation failed: "${e}" must be a non-empty hex string, got ${h(r)}`
288
399
  );
289
400
  }
290
401
  function w(r, e) {
291
402
  if (!_e(r))
292
- throw new a(
293
- `VP response validation failed: "${e}" must be a non-empty string, got ${p(r)}`
403
+ throw new o(
404
+ `VP response validation failed: "${e}" must be a non-empty string, got ${h(r)}`
294
405
  );
295
406
  }
296
- function Z(r, e) {
297
- if (!T(r) || r.length !== R && r.length !== G)
298
- throw new a(
299
- `VP response validation failed: "${e}" must be a ${R} or ${G}-char hex string (BTC pubkey), got ${p(r)}`
407
+ function Q(r, e) {
408
+ if (!T(r) || r.length !== O && r.length !== j)
409
+ throw new o(
410
+ `VP response validation failed: "${e}" must be a ${O} or ${j}-char hex string (BTC pubkey), got ${h(r)}`
300
411
  );
301
412
  }
302
- function je(r) {
413
+ function He(r) {
303
414
  const e = r.presigning;
304
415
  if (e == null) return;
305
416
  if (typeof e != "object" || Array.isArray(e))
306
- throw new a(
417
+ throw new o(
307
418
  'VP response validation failed: "progress.presigning" must be an object if present'
308
419
  );
309
420
  const t = e;
310
421
  if (t.depositor_graph_created !== void 0 && typeof t.depositor_graph_created != "boolean")
311
- throw new a(
312
- `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${p(t.depositor_graph_created)}`
422
+ throw new o(
423
+ `VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${h(t.depositor_graph_created)}`
313
424
  );
314
425
  if (t.vk_challenger_presigning_completed !== void 0 && typeof t.vk_challenger_presigning_completed != "number")
315
- throw new a(
316
- `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${p(t.vk_challenger_presigning_completed)}`
426
+ throw new o(
427
+ `VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${h(t.vk_challenger_presigning_completed)}`
317
428
  );
318
429
  if (t.vk_challenger_presigning_total !== void 0 && typeof t.vk_challenger_presigning_total != "number")
319
- throw new a(
320
- `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${p(t.vk_challenger_presigning_total)}`
430
+ throw new o(
431
+ `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${h(t.vk_challenger_presigning_total)}`
321
432
  );
322
433
  }
323
434
  function ye(r) {
324
435
  if (r === null || typeof r != "object")
325
- throw new a(
436
+ throw new o(
326
437
  "VP response validation failed: getPeginStatus response is not an object"
327
438
  );
328
439
  const e = r;
329
- if (!T(e.pegin_txid) || e.pegin_txid.length !== O)
330
- throw new a(
331
- `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${p(e.pegin_txid)}`
440
+ if (!T(e.pegin_txid) || e.pegin_txid.length !== N)
441
+ throw new o(
442
+ `VP response validation failed: "pegin_txid" must be a ${N}-char hex string (txid), got ${h(e.pegin_txid)}`
332
443
  );
333
444
  if (typeof e.status != "string")
334
- throw new a(
445
+ throw new o(
335
446
  'VP response validation failed: "status" must be a string'
336
447
  );
337
448
  if (!se.has(e.status))
338
- throw new a(
449
+ throw new o(
339
450
  `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...se].join(", ")}`
340
451
  );
341
452
  if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
342
- throw new a(
453
+ throw new o(
343
454
  'VP response validation failed: "progress" must be an object'
344
455
  );
345
- if (je(e.progress), typeof e.health_info != "string")
346
- throw new a(
456
+ if (He(e.progress), typeof e.health_info != "string")
457
+ throw new o(
347
458
  'VP response validation failed: "health_info" must be a string'
348
459
  );
349
460
  if (e.last_error !== void 0 && typeof e.last_error != "string")
350
- throw new a(
351
- `VP response validation failed: "last_error" must be a string if present, got ${p(e.last_error)}`
461
+ throw new o(
462
+ `VP response validation failed: "last_error" must be a string if present, got ${h(e.last_error)}`
352
463
  );
353
464
  }
354
- function He(r) {
465
+ function Le(r) {
355
466
  if (r === null || typeof r != "object")
356
- throw new a(
467
+ throw new o(
357
468
  "VP response validation failed: requestDepositorPresignTransactions response is not an object"
358
469
  );
359
470
  const e = r;
360
471
  if (!Array.isArray(e.txs))
361
- throw new a(
472
+ throw new o(
362
473
  'VP response validation failed: "txs" must be an array'
363
474
  );
364
475
  for (let t = 0; t < e.txs.length; t++)
365
- Le(e.txs[t], `txs[${t}]`);
476
+ Ue(e.txs[t], `txs[${t}]`);
366
477
  if (e.depositor_graph === null || typeof e.depositor_graph != "object")
367
- throw new a(
478
+ throw new o(
368
479
  'VP response validation failed: "depositor_graph" must be an object'
369
480
  );
370
- ze(
481
+ Ze(
371
482
  e.depositor_graph
372
483
  );
373
484
  }
374
485
  function A(r, e) {
375
486
  if (r === null || typeof r != "object")
376
- throw new a(
487
+ throw new o(
377
488
  `VP response validation failed: "${e}" must be an object`
378
489
  );
379
490
  me(r.tx_hex, `${e}.tx_hex`);
380
491
  }
381
- function Le(r, e) {
492
+ function Ue(r, e) {
382
493
  if (r === null || typeof r != "object")
383
- throw new a(
494
+ throw new o(
384
495
  `VP response validation failed: "${e}" must be an object`
385
496
  );
386
497
  const t = r;
387
- Z(t.claimer_pubkey, `${e}.claimer_pubkey`), A(t.claim_tx, `${e}.claim_tx`), A(t.assert_tx, `${e}.assert_tx`), A(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
498
+ Q(t.claimer_pubkey, `${e}.claimer_pubkey`), A(t.claim_tx, `${e}.claim_tx`), A(t.assert_tx, `${e}.assert_tx`), A(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
388
499
  }
389
- function Ue(r, e) {
500
+ function Ke(r, e) {
390
501
  if (r === null || typeof r != "object")
391
- throw new a(
502
+ throw new o(
392
503
  `VP response validation failed: "${e}" must be an object`
393
504
  );
394
505
  const t = r;
@@ -396,31 +507,31 @@ function Ue(r, e) {
396
507
  }
397
508
  function Xe(r, e) {
398
509
  if (r === null || typeof r != "object")
399
- throw new a(
510
+ throw new o(
400
511
  `VP response validation failed: "${e}" must be an object`
401
512
  );
402
513
  const t = r;
403
- if (Z(t.challenger_pubkey, `${e}.challenger_pubkey`), A(
514
+ if (Q(t.challenger_pubkey, `${e}.challenger_pubkey`), A(
404
515
  t.challenge_assert_x_tx,
405
516
  `${e}.challenge_assert_x_tx`
406
517
  ), A(
407
518
  t.challenge_assert_y_tx,
408
519
  `${e}.challenge_assert_y_tx`
409
520
  ), A(t.nopayout_tx, `${e}.nopayout_tx`), w(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
410
- throw new a(
521
+ throw new o(
411
522
  `VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
412
523
  );
413
524
  if (t.challenge_assert_connectors.length !== ee)
414
- throw new a(
525
+ throw new o(
415
526
  `VP response validation failed: "${e}.challenge_assert_connectors" must have exactly ${ee} entries, got ${t.challenge_assert_connectors.length}`
416
527
  );
417
528
  for (let n = 0; n < t.challenge_assert_connectors.length; n++)
418
- Ue(
529
+ Ke(
419
530
  t.challenge_assert_connectors[n],
420
531
  `${e}.challenge_assert_connectors[${n}]`
421
532
  );
422
533
  if (!Array.isArray(t.output_label_hashes))
423
- throw new a(
534
+ throw new o(
424
535
  `VP response validation failed: "${e}.output_label_hashes" must be an array`
425
536
  );
426
537
  for (let n = 0; n < t.output_label_hashes.length; n++)
@@ -431,159 +542,159 @@ function Xe(r, e) {
431
542
  }
432
543
  function Fe(r) {
433
544
  if (r === null || typeof r != "object")
434
- throw new a(
545
+ throw new o(
435
546
  "VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
436
547
  );
437
548
  const e = r;
438
549
  if (!_e(e.tx_graph_json))
439
- throw new a(
440
- `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${p(e.tx_graph_json)}`
550
+ throw new o(
551
+ `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${h(e.tx_graph_json)}`
441
552
  );
442
553
  if (!T(e.verifying_key_hex))
443
- throw new a(
444
- `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${p(e.verifying_key_hex)}`
554
+ throw new o(
555
+ `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${h(e.verifying_key_hex)}`
445
556
  );
446
557
  if (e.babe_sessions === null || typeof e.babe_sessions != "object" || Array.isArray(e.babe_sessions))
447
- throw new a(
558
+ throw new o(
448
559
  'VP response validation failed: "babe_sessions" must be an object'
449
560
  );
450
561
  const t = Object.entries(
451
562
  e.babe_sessions
452
563
  );
453
564
  if (t.length === 0)
454
- throw new a(
565
+ throw new o(
455
566
  'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
456
567
  );
457
568
  for (const [n, i] of t) {
458
- if (Z(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
459
- throw new a(
569
+ if (Q(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
570
+ throw new o(
460
571
  `VP response validation failed: "babe_sessions.${n}" must be an object`
461
572
  );
462
573
  const s = i;
463
574
  if (!T(s.decryptor_artifacts_hex))
464
- throw new a(
465
- `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${p(s.decryptor_artifacts_hex)}`
575
+ throw new o(
576
+ `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${h(s.decryptor_artifacts_hex)}`
466
577
  );
467
578
  }
468
579
  }
469
- function Ke(r) {
580
+ function Je(r) {
470
581
  if (r === null || typeof r != "object")
471
- throw new a(
582
+ throw new o(
472
583
  "VP response validation failed: pegout status payload is not an object"
473
584
  );
474
585
  const e = r;
475
- if (!T(e.pegin_txid) || e.pegin_txid.length !== O)
476
- throw new a(
477
- `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${p(e.pegin_txid)}`
586
+ if (!T(e.pegin_txid) || e.pegin_txid.length !== N)
587
+ throw new o(
588
+ `VP response validation failed: "pegin_txid" must be a ${N}-char hex string (txid), got ${h(e.pegin_txid)}`
478
589
  );
479
590
  if (typeof e.found != "boolean")
480
- throw new a(
481
- `VP response validation failed: "found" must be a boolean, got ${p(e.found)}`
591
+ throw new o(
592
+ `VP response validation failed: "found" must be a boolean, got ${h(e.found)}`
482
593
  );
483
594
  if (e.claimer !== null) {
484
595
  if (typeof e.claimer != "object")
485
- throw new a(
486
- `VP response validation failed: "claimer" must be an object or null, got ${p(e.claimer)}`
596
+ throw new o(
597
+ `VP response validation failed: "claimer" must be an object or null, got ${h(e.claimer)}`
487
598
  );
488
- Je(e.claimer);
599
+ We(e.claimer);
489
600
  }
490
601
  if (!Array.isArray(e.challengers))
491
- throw new a(
492
- `VP response validation failed: "challengers" must be an array, got ${p(e.challengers)}`
602
+ throw new o(
603
+ `VP response validation failed: "challengers" must be an array, got ${h(e.challengers)}`
493
604
  );
494
605
  for (let t = 0; t < e.challengers.length; t++)
495
- qe(e.challengers[t], t);
606
+ Ye(e.challengers[t], t);
496
607
  }
497
- function Je(r) {
608
+ function We(r) {
498
609
  if (w(r.status, "claimer.status"), typeof r.failed != "boolean")
499
- throw new a(
500
- `VP response validation failed: "claimer.failed" must be a boolean, got ${p(r.failed)}`
610
+ throw new o(
611
+ `VP response validation failed: "claimer.failed" must be a boolean, got ${h(r.failed)}`
501
612
  );
502
613
  if (w(r.claim_txid, "claimer.claim_txid"), w(r.claimer_pubkey, "claimer.claimer_pubkey"), w(r.assert_txid, "claimer.assert_txid"), typeof r.created_at != "number")
503
- throw new a(
504
- `VP response validation failed: "claimer.created_at" must be a number, got ${p(r.created_at)}`
614
+ throw new o(
615
+ `VP response validation failed: "claimer.created_at" must be a number, got ${h(r.created_at)}`
505
616
  );
506
617
  if (typeof r.updated_at != "number")
507
- throw new a(
508
- `VP response validation failed: "claimer.updated_at" must be a number, got ${p(r.updated_at)}`
618
+ throw new o(
619
+ `VP response validation failed: "claimer.updated_at" must be a number, got ${h(r.updated_at)}`
509
620
  );
510
621
  }
511
- function qe(r, e) {
622
+ function Ye(r, e) {
512
623
  if (r === null || typeof r != "object")
513
- throw new a(
514
- `VP response validation failed: "challengers[${e}]" must be an object, got ${p(r)}`
624
+ throw new o(
625
+ `VP response validation failed: "challengers[${e}]" must be an object, got ${h(r)}`
515
626
  );
516
627
  const t = r;
517
- if (w(t.status, `challengers[${e}].status`), w(t.claim_txid, `challengers[${e}].claim_txid`), w(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), B(t.assert_txid, `challengers[${e}].assert_txid`), B(
628
+ if (w(t.status, `challengers[${e}].status`), w(t.claim_txid, `challengers[${e}].claim_txid`), w(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), D(t.assert_txid, `challengers[${e}].assert_txid`), D(
518
629
  t.challenge_assert_x_txid,
519
630
  `challengers[${e}].challenge_assert_x_txid`
520
- ), B(
631
+ ), D(
521
632
  t.challenge_assert_y_txid,
522
633
  `challengers[${e}].challenge_assert_y_txid`
523
- ), B(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
524
- throw new a(
525
- `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${p(t.created_at)}`
634
+ ), D(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
635
+ throw new o(
636
+ `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${h(t.created_at)}`
526
637
  );
527
638
  if (typeof t.updated_at != "number")
528
- throw new a(
529
- `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${p(t.updated_at)}`
639
+ throw new o(
640
+ `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${h(t.updated_at)}`
530
641
  );
531
642
  }
532
- function B(r, e) {
643
+ function D(r, e) {
533
644
  if (r !== null && typeof r != "string")
534
- throw new a(
535
- `VP response validation failed: "${e}" must be a string or null, got ${p(r)}`
645
+ throw new o(
646
+ `VP response validation failed: "${e}" must be a string or null, got ${h(r)}`
536
647
  );
537
648
  }
538
- function We(r) {
649
+ function ze(r) {
539
650
  be(r, "batchGetPeginStatus", (e) => {
540
651
  e.result !== null && ye(e.result);
541
652
  });
542
653
  }
543
- function Ye(r) {
654
+ function qe(r) {
544
655
  be(r, "batchGetPegoutStatus", (e) => {
545
- e.result !== null && Ke(e.result);
656
+ e.result !== null && Je(e.result);
546
657
  });
547
658
  }
548
659
  function be(r, e, t) {
549
660
  if (r === null || typeof r != "object")
550
- throw new a(
661
+ throw new o(
551
662
  `VP response validation failed: ${e} response is not an object`
552
663
  );
553
664
  const n = r;
554
665
  if (!Array.isArray(n.results))
555
- throw new a(
556
- `VP response validation failed: "${e}.results" must be an array, got ${p(n.results)}`
666
+ throw new o(
667
+ `VP response validation failed: "${e}.results" must be an array, got ${h(n.results)}`
557
668
  );
558
669
  for (let i = 0; i < n.results.length; i++) {
559
670
  const s = n.results[i];
560
671
  if (s === null || typeof s != "object")
561
- throw new a(
562
- `VP response validation failed: "${e}.results[${i}]" must be an object, got ${p(s)}`
672
+ throw new o(
673
+ `VP response validation failed: "${e}.results[${i}]" must be an object, got ${h(s)}`
563
674
  );
564
- const o = s;
565
- if (!T(o.pegin_txid) || o.pegin_txid.length !== O)
566
- throw new a(
567
- `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${O}-char hex string, got ${p(o.pegin_txid)}`
675
+ const a = s;
676
+ if (!T(a.pegin_txid) || a.pegin_txid.length !== N)
677
+ throw new o(
678
+ `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${N}-char hex string, got ${h(a.pegin_txid)}`
568
679
  );
569
- if (o.error !== null && typeof o.error != "string")
570
- throw new a(
571
- `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${p(o.error)}`
680
+ if (a.error !== null && typeof a.error != "string")
681
+ throw new o(
682
+ `VP response validation failed: "${e}.results[${i}].error" must be a string or null, got ${h(a.error)}`
572
683
  );
573
- if (o.result === null && o.error === null)
574
- throw new a(
684
+ if (a.result === null && a.error === null)
685
+ throw new o(
575
686
  `VP response validation failed: "${e}.results[${i}]" has neither "result" nor "error" populated`
576
687
  );
577
- if (o.result !== null && o.error !== null)
578
- throw new a(
688
+ if (a.result !== null && a.error !== null)
689
+ throw new o(
579
690
  `VP response validation failed: "${e}.results[${i}]" has both "result" and "error" populated`
580
691
  );
581
- t(o, i);
692
+ t(a, i);
582
693
  }
583
694
  }
584
- function ze(r) {
695
+ function Ze(r) {
585
696
  if (A(r.claim_tx, "depositor_graph.claim_tx"), A(r.assert_tx, "depositor_graph.assert_tx"), A(r.payout_tx, "depositor_graph.payout_tx"), w(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
586
- throw new a(
697
+ throw new o(
587
698
  'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
588
699
  );
589
700
  for (let e = 0; e < r.challenger_presign_data.length; e++)
@@ -592,17 +703,17 @@ function ze(r) {
592
703
  `depositor_graph.challenger_presign_data[${e}]`
593
704
  );
594
705
  if (typeof r.offchain_params_version != "number")
595
- throw new a(
706
+ throw new o(
596
707
  'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
597
708
  );
598
709
  }
599
- const Ze = 6e4;
600
- class Qe {
710
+ const Qe = 6e4;
711
+ class et {
601
712
  constructor(e, t) {
602
713
  f(this, "client");
603
714
  const n = {
604
715
  baseUrl: e,
605
- timeout: (t == null ? void 0 : t.timeout) ?? Ze,
716
+ timeout: (t == null ? void 0 : t.timeout) ?? Qe,
606
717
  retries: t == null ? void 0 : t.retries,
607
718
  retryDelay: t == null ? void 0 : t.retryDelay,
608
719
  retryableFor: t == null ? void 0 : t.retryableFor,
@@ -610,7 +721,7 @@ class Qe {
610
721
  tokenProvider: t == null ? void 0 : t.tokenProvider,
611
722
  maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
612
723
  };
613
- this.client = new ge(n);
724
+ this.client = new fe(n);
614
725
  }
615
726
  /**
616
727
  * Request the payout/claim/assert transactions that the depositor
@@ -618,7 +729,7 @@ class Qe {
618
729
  */
619
730
  async requestDepositorPresignTransactions(e, t) {
620
731
  const n = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
621
- return He(n), n;
732
+ return Le(n), n;
622
733
  }
623
734
  /**
624
735
  * Submit the depositor's pre-signatures for the payout transactions
@@ -667,7 +778,7 @@ class Qe {
667
778
  */
668
779
  async batchGetPeginStatus(e, t) {
669
780
  const n = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
670
- return We(n), n;
781
+ return ze(n), n;
671
782
  }
672
783
  /**
673
784
  * Get pegout status for many txids in one round trip. Same per-result
@@ -675,92 +786,17 @@ class Qe {
675
786
  */
676
787
  async batchGetPegoutStatus(e, t) {
677
788
  const n = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
678
- return Ye(n), n;
679
- }
680
- }
681
- function et(r, e) {
682
- const t = /* @__PURE__ */ new Set();
683
- for (const d of r)
684
- t.add(d.toLowerCase());
685
- const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], o = [];
686
- for (const d of e) {
687
- const l = d.pegin_txid.toLowerCase();
688
- if (!t.has(l)) {
689
- o.push(l);
690
- continue;
691
- }
692
- if (i.has(l)) {
693
- s.push(l);
694
- continue;
695
- }
696
- i.add(l), n.set(l, { result: d.result, error: d.error });
697
- }
698
- const c = [];
699
- for (const d of t)
700
- i.has(d) || c.push(d);
701
- return { byTxid: n, missing: c, unexpected: o, duplicate: s };
702
- }
703
- async function ur(r) {
704
- const {
705
- items: e,
706
- getTxid: t,
707
- batchCall: n,
708
- onItem: i,
709
- onMissing: s,
710
- onDuplicate: o,
711
- onDuplicateBatch: c,
712
- onWholeBatchError: d,
713
- onUnexpected: l,
714
- batchSize: g = Re
715
- } = r;
716
- if (!Number.isInteger(g) || g <= 0)
717
- throw new Error(
718
- `batchPollByProvider: batchSize must be a positive integer, got ${g}`
719
- );
720
- for (let m = 0; m < e.length; m += g) {
721
- const x = e.slice(m, m + g), k = /* @__PURE__ */ new Map(), C = [];
722
- for (const _ of x) {
723
- const u = t(_).toLowerCase();
724
- k.set(u, _), C.push(u);
725
- }
726
- let P;
727
- try {
728
- const _ = await n(C);
729
- P = et(C, _.results);
730
- } catch (_) {
731
- d(x, _);
732
- continue;
733
- }
734
- l && P.unexpected.length > 0 && l(P.unexpected);
735
- const $ = new Set(P.duplicate);
736
- for (const _ of $) {
737
- const u = k.get(_);
738
- u && o(u);
739
- }
740
- c && $.size > 0 && c($.size);
741
- for (const _ of P.missing) {
742
- const u = k.get(_);
743
- u && s(u);
744
- }
745
- for (const [_, u] of P.byTxid) {
746
- if ($.has(_)) continue;
747
- const E = k.get(_);
748
- E && i(E, {
749
- pegin_txid: _,
750
- result: u.result,
751
- error: u.error
752
- });
753
- }
789
+ return qe(n), n;
754
790
  }
755
791
  }
756
792
  const tt = "BIP0322-signed-message", rt = "TapTweak", we = 32, nt = 64;
757
793
  function xe(r, e) {
758
- const t = new TextEncoder().encode(r), n = q(t), i = new Uint8Array(n.length * 2 + e.length);
759
- return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), q(i);
794
+ const t = new TextEncoder().encode(r), n = Y(t), i = new Uint8Array(n.length * 2 + e.length);
795
+ return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), Y(i);
760
796
  }
761
797
  function st(r) {
762
798
  if (r.length !== we) return null;
763
- const e = xe(rt, r), t = H.xOnlyPointAddTweak(r, e);
799
+ const e = xe(rt, r), t = U.xOnlyPointAddTweak(r, e);
764
800
  return t ? t.xOnlyPubkey : null;
765
801
  }
766
802
  function it(r, e, t) {
@@ -770,7 +806,7 @@ function it(r, e, t) {
770
806
  internalPubkey: V.from(e)
771
807
  });
772
808
  if (!i.output) return !1;
773
- const s = i.output, o = 0, c = new X();
809
+ const s = i.output, a = 0, c = new X();
774
810
  c.version = 0, c.locktime = 0;
775
811
  const d = V.concat([
776
812
  V.from([0, 32]),
@@ -784,23 +820,23 @@ function it(r, e, t) {
784
820
  0,
785
821
  // sequence = 0
786
822
  d
787
- ), c.addOutput(s, o);
823
+ ), c.addOutput(s, a);
788
824
  const l = new X();
789
825
  l.version = 0, l.locktime = 0;
790
826
  const g = c.getHash();
791
- l.addInput(g, 0, 0), l.addOutput(V.from([106]), o);
827
+ l.addInput(g, 0, 0), l.addOutput(V.from([106]), a);
792
828
  const m = l.hashForWitnessV1(
793
829
  0,
794
830
  [s],
795
- [o],
831
+ [a],
796
832
  X.SIGHASH_DEFAULT
797
833
  ), x = st(e);
798
- return x ? H.verifySchnorr(m, x, t) : !1;
834
+ return x ? U.verifySchnorr(m, x, t) : !1;
799
835
  } catch {
800
836
  return !1;
801
837
  }
802
838
  }
803
- function j(r, e) {
839
+ function L(r, e) {
804
840
  const t = (r & 7) << 5, n = typeof e == "bigint" ? e : BigInt(e);
805
841
  if (n < 0n) throw new Error("cborHead: negative argument");
806
842
  if (n < 24n) return new Uint8Array([t | Number(n)]);
@@ -833,28 +869,28 @@ function Pe(...r) {
833
869
  return t;
834
870
  }
835
871
  function ie(r) {
836
- const t = [j(4, r.length)];
872
+ const t = [L(4, r.length)];
837
873
  for (const n of r)
838
- t.push(j(0, n));
874
+ t.push(L(0, n));
839
875
  return Pe(...t);
840
876
  }
841
- function ot(r, e, t) {
877
+ function at(r, e, t) {
842
878
  if (!Number.isSafeInteger(t) || t < 0)
843
879
  throw new Error(
844
880
  `encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
845
881
  );
846
- const n = j(4, 3), i = ie(r), s = ie(e), o = j(0, t);
847
- return Pe(n, i, s, o);
882
+ const n = L(4, 3), i = ie(r), s = ie(e), a = L(0, t);
883
+ return Pe(n, i, s, a);
848
884
  }
849
- const at = new TextEncoder().encode(
885
+ const ot = new TextEncoder().encode(
850
886
  "btc-auth.server-identity.v1"
851
887
  ), ct = 2 * 3600;
852
- class y extends Error {
888
+ class b extends Error {
853
889
  constructor(e, t) {
854
890
  super(e), this.reason = t, this.name = "ServerIdentityError";
855
891
  }
856
892
  }
857
- function D(r) {
893
+ function M(r) {
858
894
  const e = new Uint8Array(r.length / 2);
859
895
  for (let t = 0; t < e.length; t++)
860
896
  e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
@@ -862,78 +898,78 @@ function D(r) {
862
898
  }
863
899
  function lt(r) {
864
900
  const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? ct, s = I(t).toLowerCase();
865
- if (s.length !== R || !S.test(s))
866
- throw new y(
901
+ if (s.length !== O || !k.test(s))
902
+ throw new b(
867
903
  `pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
868
904
  "invalid_pubkey_encoding"
869
905
  );
870
- const o = I(e.server_pubkey).toLowerCase();
871
- if (o.length !== R || !S.test(o))
872
- throw new y(
873
- `server_pubkey must be 32-byte hex; got ${o.length} chars`,
906
+ const a = I(e.server_pubkey).toLowerCase();
907
+ if (a.length !== O || !k.test(a))
908
+ throw new b(
909
+ `server_pubkey must be 32-byte hex; got ${a.length} chars`,
874
910
  "invalid_pubkey_encoding"
875
911
  );
876
- if (o !== s)
877
- throw new y(
878
- `server_pubkey does not match pinned value: expected ${s}, got ${o}`,
912
+ if (a !== s)
913
+ throw new b(
914
+ `server_pubkey does not match pinned value: expected ${s}, got ${a}`,
879
915
  "pinned_pubkey_mismatch"
880
916
  );
881
917
  if (!Number.isSafeInteger(e.expires_at))
882
- throw new y(
918
+ throw new b(
883
919
  `expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,
884
920
  "invalid_expires_at"
885
921
  );
886
922
  if (!Number.isSafeInteger(n))
887
- throw new y(
923
+ throw new b(
888
924
  `now must be a finite integer; got ${JSON.stringify(n)}`,
889
925
  "invalid_expires_at"
890
926
  );
891
927
  if (e.expires_at <= n)
892
- throw new y(
928
+ throw new b(
893
929
  `server identity proof expired at ${e.expires_at}, now ${n}`,
894
930
  "expired"
895
931
  );
896
932
  if (!Number.isSafeInteger(i) || i <= 0)
897
- throw new y(
933
+ throw new b(
898
934
  `maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(i)}`,
899
935
  "invalid_max_lifetime"
900
936
  );
901
937
  if (e.expires_at - n > i)
902
- throw new y(
938
+ throw new b(
903
939
  `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${i}s`,
904
940
  "expires_too_far"
905
941
  );
906
942
  const c = I(e.ephemeral_pubkey).toLowerCase();
907
- if (c.length !== G || !S.test(c))
908
- throw new y(
943
+ if (c.length !== j || !k.test(c))
944
+ throw new b(
909
945
  `ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
910
946
  "invalid_ephemeral_pubkey"
911
947
  );
912
948
  const d = c.slice(0, 2);
913
949
  if (d !== "02" && d !== "03")
914
- throw new y(
950
+ throw new b(
915
951
  `ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
916
952
  "invalid_ephemeral_pubkey"
917
953
  );
918
- const l = D(c);
919
- if (!H.isPoint(l))
920
- throw new y(
954
+ const l = M(c);
955
+ if (!U.isPoint(l))
956
+ throw new b(
921
957
  "ephemeral_pubkey is not a valid secp256k1 point",
922
958
  "invalid_ephemeral_pubkey"
923
959
  );
924
960
  const g = I(e.signature).toLowerCase();
925
- if (g.length !== Oe || !S.test(g))
926
- throw new y(
961
+ if (g.length !== Ie || !k.test(g))
962
+ throw new b(
927
963
  `signature must be 64-byte Schnorr hex; got ${g.length} chars`,
928
964
  "invalid_signature_encoding"
929
965
  );
930
- const m = ot(
931
- at,
932
- D(c),
966
+ const m = at(
967
+ ot,
968
+ M(c),
933
969
  e.expires_at
934
970
  );
935
- if (!it(m, D(o), D(g)))
936
- throw new y(
971
+ if (!it(m, M(a), M(g)))
972
+ throw new b(
937
973
  "BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
938
974
  "signature_verification_failed"
939
975
  );
@@ -944,16 +980,16 @@ const ut = /* @__PURE__ */ new Set([
944
980
  "vaultProvider_requestDepositorPresignTransactions"
945
981
  ]), dt = /* @__PURE__ */ new Set([
946
982
  "vaultProvider_requestDepositorClaimerArtifacts"
947
- ]), ht = 6e4, W = "auth_createDepositorToken", Y = "auth_createDepositorTokenGrpc";
983
+ ]), pt = 6e4, z = "auth_createDepositorToken", q = "auth_createDepositorTokenGrpc";
948
984
  function ve(r, e) {
949
- return new ge({
985
+ return new fe({
950
986
  baseUrl: r,
951
- timeout: ht,
987
+ timeout: pt,
952
988
  headers: e,
953
- retryableFor: (t) => t === W || t === Y
989
+ retryableFor: (t) => t === z || t === q
954
990
  });
955
991
  }
956
- const pt = 0, gt = 1, F = 2, ft = 3, _t = 4, mt = 5, yt = 6, bt = 7, oe = 24, wt = 28, xt = 20, Pt = 21, vt = 22, ae = 256;
992
+ const ht = 0, gt = 1, F = 2, ft = 3, _t = 4, mt = 5, yt = 6, bt = 7, ae = 24, wt = 28, xt = 20, Pt = 21, vt = 22, oe = 256;
957
993
  class v extends Error {
958
994
  constructor(e) {
959
995
  super(`CBOR decode: ${e}`), this.name = "CborDecodeError";
@@ -979,15 +1015,15 @@ class Ae {
979
1015
  */
980
1016
  readHead() {
981
1017
  const e = this.nextByte(), t = e >> 5, n = e & 31;
982
- if (n < oe)
1018
+ if (n < ae)
983
1019
  return { major: t, arg: n };
984
1020
  if (n >= wt)
985
1021
  throw new v(
986
1022
  `unsupported additional info ${n} (indefinite-length or reserved)`
987
1023
  );
988
- const i = 1 << n - oe;
1024
+ const i = 1 << n - ae;
989
1025
  let s = 0n;
990
- for (let o = 0; o < i; o++)
1026
+ for (let a = 0; a < i; a++)
991
1027
  s = s << 8n | BigInt(this.nextByte());
992
1028
  if (s > BigInt(Number.MAX_SAFE_INTEGER))
993
1029
  throw new v(`argument ${s} exceeds safe integer range`);
@@ -1020,13 +1056,13 @@ class Ae {
1020
1056
  * native call stack (see {@link MAX_NESTING_DEPTH}).
1021
1057
  */
1022
1058
  readValue(e = 0) {
1023
- if (e > ae)
1059
+ if (e > oe)
1024
1060
  throw new v(
1025
- `nesting exceeds maximum depth ${ae}`
1061
+ `nesting exceeds maximum depth ${oe}`
1026
1062
  );
1027
1063
  const t = this.readHead();
1028
1064
  switch (t.major) {
1029
- case pt:
1065
+ case ht:
1030
1066
  return t.arg;
1031
1067
  case gt:
1032
1068
  return -1 - t.arg;
@@ -1045,8 +1081,8 @@ class Ae {
1045
1081
  case mt: {
1046
1082
  const n = /* @__PURE__ */ new Map();
1047
1083
  for (let i = 0; i < t.arg; i++) {
1048
- const s = this.readValue(e + 1), o = this.readValue(e + 1);
1049
- n.set(s, o);
1084
+ const s = this.readValue(e + 1), a = this.readValue(e + 1);
1085
+ n.set(s, a);
1050
1086
  }
1051
1087
  return n;
1052
1088
  }
@@ -1064,135 +1100,135 @@ class Ae {
1064
1100
  }
1065
1101
  }
1066
1102
  }
1067
- function ke(r) {
1103
+ function Ee(r) {
1068
1104
  const e = new Ae(r), t = e.readValue();
1069
1105
  if (e.pos !== r.length)
1070
1106
  throw new v("trailing bytes after top-level item");
1071
1107
  return t;
1072
1108
  }
1073
- const At = "vaultd-jsonrpc", kt = "vaultd-grpc", ce = 18, z = 4, le = -47, Et = 1, ue = 64, St = 128, Ct = 96, Tt = 64, $t = 1, Vt = 2, It = 3, Rt = 4, Ot = 5, Nt = 6, Bt = 7, de = new TextEncoder().encode("Signature1");
1074
- class h extends Error {
1109
+ const At = "vaultd-jsonrpc", Et = "vaultd-grpc", ce = 18, Z = 4, le = -47, St = 1, ue = 64, kt = 128, Ct = 96, Tt = 64, $t = 1, Vt = 2, It = 3, Rt = 4, Ot = 5, Nt = 6, Bt = 7, de = new TextEncoder().encode("Signature1");
1110
+ class p extends Error {
1075
1111
  constructor(e, t) {
1076
1112
  super(e), this.reason = t, this.name = "CwtVerificationError";
1077
1113
  }
1078
1114
  }
1079
- function Dt(r) {
1080
- const e = he(
1115
+ function Gt(r) {
1116
+ const e = pe(
1081
1117
  r.expectedIssuerXOnlyPubkey,
1082
1118
  "expectedIssuerXOnlyPubkey"
1083
- ), t = he(
1119
+ ), t = pe(
1084
1120
  r.expectedAudienceXOnlyPubkey,
1085
1121
  "expectedAudienceXOnlyPubkey"
1086
- ), n = Lt(r.ephemeralPubkeyHex), i = Xt(r.token), s = new Ae(i), o = s.readHead();
1087
- if (o.major !== 6 || o.arg !== ce)
1088
- throw new h(
1122
+ ), n = Lt(r.ephemeralPubkeyHex), i = Kt(r.token), s = new Ae(i), a = s.readHead();
1123
+ if (a.major !== 6 || a.arg !== ce)
1124
+ throw new p(
1089
1125
  `token is not a COSE Sign1 tagged value (tag ${ce})`,
1090
1126
  "invalid_token_structure"
1091
1127
  );
1092
1128
  const c = s.readHead();
1093
- if (c.major !== 4 || c.arg !== z)
1094
- throw new h(
1095
- `COSE Sign1 must be a ${z}-element array`,
1129
+ if (c.major !== 4 || c.arg !== Z)
1130
+ throw new p(
1131
+ `COSE Sign1 must be a ${Z}-element array`,
1096
1132
  "invalid_token_structure"
1097
1133
  );
1098
1134
  const d = s.pos, l = s.readByteString(), g = i.subarray(d, s.pos);
1099
1135
  s.readValue();
1100
- const m = s.pos, x = s.readByteString(), k = i.subarray(m, s.pos), C = s.readByteString();
1136
+ const m = s.pos, x = s.readByteString(), E = i.subarray(m, s.pos), C = s.readByteString();
1101
1137
  if (C.length !== ue)
1102
- throw new h(
1138
+ throw new p(
1103
1139
  `COSE signature must be ${ue} bytes, got ${C.length}`,
1104
1140
  "invalid_token_structure"
1105
1141
  );
1106
1142
  if (s.pos !== i.length)
1107
- throw new h(
1143
+ throw new p(
1108
1144
  "COSE Sign1 token has trailing bytes after the signature",
1109
1145
  "invalid_token_structure"
1110
1146
  );
1111
- const P = Gt(l);
1147
+ const P = Dt(l);
1112
1148
  if (P !== le)
1113
- throw new h(
1149
+ throw new p(
1114
1150
  `unexpected COSE algorithm ${P} (expected ES256K ${le})`,
1115
1151
  "unexpected_algorithm"
1116
1152
  );
1117
- const $ = Mt(g, k), _ = q($);
1118
- if (!H.verify(_, n, C, !0))
1119
- throw new h(
1153
+ const $ = Mt(g, E), _ = Y($);
1154
+ if (!U.verify(_, n, C, !0))
1155
+ throw new p(
1120
1156
  "COSE signature does not verify against the server's ephemeral key",
1121
1157
  "signature_verification_failed"
1122
1158
  );
1123
- const u = jt(x), E = u.audience.toLowerCase();
1124
- if (E.length !== R || !S.test(E))
1125
- throw new h(
1159
+ const u = jt(x), S = u.audience.toLowerCase();
1160
+ if (S.length !== O || !k.test(S))
1161
+ throw new p(
1126
1162
  "token `aud` is not a 32-byte x-only pubkey hex",
1127
1163
  "invalid_claims"
1128
1164
  );
1129
1165
  if (u.issuedAt > u.expiresAt)
1130
- throw new h(
1166
+ throw new p(
1131
1167
  `token iat (${u.issuedAt}) is after exp (${u.expiresAt})`,
1132
1168
  "invalid_claims"
1133
1169
  );
1134
1170
  if (u.issuer.toLowerCase() !== e)
1135
- throw new h(
1171
+ throw new p(
1136
1172
  `token issuer does not match pinned server pubkey: expected ${e}, got ${u.issuer.toLowerCase()}`,
1137
1173
  "issuer_mismatch"
1138
1174
  );
1139
1175
  if (u.subject !== r.expectedSubject)
1140
- throw new h(
1176
+ throw new p(
1141
1177
  `token subject mismatch: expected ${r.expectedSubject}, got ${u.subject}`,
1142
1178
  "subject_mismatch"
1143
1179
  );
1144
- if (E !== t)
1145
- throw new h(
1146
- `token audience does not match depositor pubkey: expected ${t}, got ${E}`,
1180
+ if (S !== t)
1181
+ throw new p(
1182
+ `token audience does not match depositor pubkey: expected ${t}, got ${S}`,
1147
1183
  "audience_mismatch"
1148
1184
  );
1149
1185
  if (u.expiresAt <= r.now)
1150
- throw new h(
1186
+ throw new p(
1151
1187
  `token expired: exp ${u.expiresAt} <= now ${r.now}`,
1152
1188
  "token_expired"
1153
1189
  );
1154
1190
  if (r.responseExpiresAt !== u.expiresAt)
1155
- throw new h(
1191
+ throw new p(
1156
1192
  `response expires_at (${r.responseExpiresAt}) does not equal token exp (${u.expiresAt})`,
1157
1193
  "expiry_mismatch"
1158
1194
  );
1159
1195
  if (r.serverIdentityExpiresAt < u.expiresAt)
1160
- throw new h(
1196
+ throw new p(
1161
1197
  `server identity expires (${r.serverIdentityExpiresAt}) before token exp (${u.expiresAt})`,
1162
1198
  "server_identity_expires_before_token"
1163
1199
  );
1164
1200
  return {
1165
1201
  issuer: u.issuer,
1166
1202
  subject: u.subject,
1167
- audience: E,
1203
+ audience: S,
1168
1204
  expiresAt: u.expiresAt,
1169
1205
  notBefore: u.notBefore,
1170
1206
  issuedAt: u.issuedAt
1171
1207
  };
1172
1208
  }
1173
- function Gt(r) {
1209
+ function Dt(r) {
1174
1210
  if (r.length === 0)
1175
- throw new h(
1211
+ throw new p(
1176
1212
  "empty COSE protected header (no algorithm)",
1177
1213
  "unexpected_algorithm"
1178
1214
  );
1179
- const e = ke(r);
1215
+ const e = Ee(r);
1180
1216
  if (!(e instanceof Map))
1181
- throw new h(
1217
+ throw new p(
1182
1218
  "COSE protected header is not a map",
1183
1219
  "invalid_token_structure"
1184
1220
  );
1185
- const t = e.get(Et);
1221
+ const t = e.get(St);
1186
1222
  if (typeof t != "number")
1187
- throw new h(
1223
+ throw new p(
1188
1224
  "COSE protected header missing integer algorithm label",
1189
1225
  "unexpected_algorithm"
1190
1226
  );
1191
1227
  return t;
1192
1228
  }
1193
1229
  function Mt(r, e) {
1194
- return Ft(
1195
- Uint8Array.of(St | z),
1230
+ return Xt(
1231
+ Uint8Array.of(kt | Z),
1196
1232
  Uint8Array.of(Ct | de.length),
1197
1233
  de,
1198
1234
  r,
@@ -1201,27 +1237,27 @@ function Mt(r, e) {
1201
1237
  );
1202
1238
  }
1203
1239
  function jt(r) {
1204
- const e = ke(r);
1240
+ const e = Ee(r);
1205
1241
  if (!(e instanceof Map))
1206
- throw new h(
1242
+ throw new p(
1207
1243
  "CWT claims root is not a map",
1208
1244
  "invalid_claims"
1209
1245
  );
1210
1246
  if (Ht(e, Bt, "cti").length === 0)
1211
- throw new h("token cti is empty", "invalid_claims");
1247
+ throw new p("token cti is empty", "invalid_claims");
1212
1248
  return {
1213
- issuer: K(e, $t, "iss"),
1214
- subject: K(e, Vt, "sub"),
1215
- audience: K(e, It, "aud"),
1216
- expiresAt: J(e, Rt, "exp"),
1217
- notBefore: J(e, Ot, "nbf"),
1218
- issuedAt: J(e, Nt, "iat")
1249
+ issuer: J(e, $t, "iss"),
1250
+ subject: J(e, Vt, "sub"),
1251
+ audience: J(e, It, "aud"),
1252
+ expiresAt: W(e, Rt, "exp"),
1253
+ notBefore: W(e, Ot, "nbf"),
1254
+ issuedAt: W(e, Nt, "iat")
1219
1255
  };
1220
1256
  }
1221
- function K(r, e, t) {
1257
+ function J(r, e, t) {
1222
1258
  const n = r.get(e);
1223
1259
  if (typeof n != "string")
1224
- throw new h(
1260
+ throw new p(
1225
1261
  `token claim ${t} is missing or not a text string`,
1226
1262
  "invalid_claims"
1227
1263
  );
@@ -1230,25 +1266,25 @@ function K(r, e, t) {
1230
1266
  function Ht(r, e, t) {
1231
1267
  const n = r.get(e);
1232
1268
  if (!(n instanceof Uint8Array))
1233
- throw new h(
1269
+ throw new p(
1234
1270
  `token claim ${t} is missing or not a byte string`,
1235
1271
  "invalid_claims"
1236
1272
  );
1237
1273
  return n;
1238
1274
  }
1239
- function J(r, e, t) {
1275
+ function W(r, e, t) {
1240
1276
  const n = r.get(e);
1241
1277
  if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0)
1242
- throw new h(
1278
+ throw new p(
1243
1279
  `token claim ${t} is missing or not a non-negative integer timestamp`,
1244
1280
  "invalid_claims"
1245
1281
  );
1246
1282
  return n;
1247
1283
  }
1248
- function he(r, e) {
1284
+ function pe(r, e) {
1249
1285
  const t = I(r).toLowerCase();
1250
- if (t.length !== R || !S.test(t))
1251
- throw new h(
1286
+ if (t.length !== O || !k.test(t))
1287
+ throw new p(
1252
1288
  `${e} must be 32-byte x-only hex; got ${t.length} chars`,
1253
1289
  "invalid_input"
1254
1290
  );
@@ -1256,12 +1292,12 @@ function he(r, e) {
1256
1292
  }
1257
1293
  function Lt(r) {
1258
1294
  const e = I(r).toLowerCase(), t = e.slice(0, 2);
1259
- if (e.length !== G || !S.test(e) || t !== "02" && t !== "03")
1260
- throw new h(
1295
+ if (e.length !== j || !k.test(e) || t !== "02" && t !== "03")
1296
+ throw new p(
1261
1297
  "ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)",
1262
1298
  "invalid_input"
1263
1299
  );
1264
- return Ne(e);
1300
+ return Re(e);
1265
1301
  }
1266
1302
  const Ut = (() => {
1267
1303
  const r = new Int16Array(128).fill(-1), e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
@@ -1269,17 +1305,17 @@ const Ut = (() => {
1269
1305
  r[e.charCodeAt(t)] = t;
1270
1306
  return r;
1271
1307
  })();
1272
- function Xt(r) {
1308
+ function Kt(r) {
1273
1309
  const e = r.length, t = Math.floor(e / 4), n = e % 4;
1274
1310
  if (n === 1)
1275
- throw new h(
1311
+ throw new p(
1276
1312
  "invalid base64url length",
1277
1313
  "invalid_token_structure"
1278
1314
  );
1279
- const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), o = (l) => {
1315
+ const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), a = (l) => {
1280
1316
  const g = l < 128 ? Ut[l] : -1;
1281
1317
  if (g < 0)
1282
- throw new h(
1318
+ throw new p(
1283
1319
  "invalid base64url character",
1284
1320
  "invalid_token_structure"
1285
1321
  );
@@ -1287,26 +1323,26 @@ function Xt(r) {
1287
1323
  };
1288
1324
  let c = 0, d = 0;
1289
1325
  for (let l = 0; l < t; l++) {
1290
- const g = o(r.charCodeAt(c++)), m = o(r.charCodeAt(c++)), x = o(r.charCodeAt(c++)), k = o(r.charCodeAt(c++));
1291
- s[d++] = g << 2 | m >> 4, s[d++] = (m & 15) << 4 | x >> 2, s[d++] = (x & 3) << 6 | k;
1326
+ const g = a(r.charCodeAt(c++)), m = a(r.charCodeAt(c++)), x = a(r.charCodeAt(c++)), E = a(r.charCodeAt(c++));
1327
+ s[d++] = g << 2 | m >> 4, s[d++] = (m & 15) << 4 | x >> 2, s[d++] = (x & 3) << 6 | E;
1292
1328
  }
1293
1329
  if (n === 2) {
1294
- const l = o(r.charCodeAt(c++)), g = o(r.charCodeAt(c++));
1330
+ const l = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++));
1295
1331
  s[d++] = l << 2 | g >> 4;
1296
1332
  } else if (n === 3) {
1297
- const l = o(r.charCodeAt(c++)), g = o(r.charCodeAt(c++)), m = o(r.charCodeAt(c++));
1333
+ const l = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++)), m = a(r.charCodeAt(c++));
1298
1334
  s[d++] = l << 2 | g >> 4, s[d++] = (g & 15) << 4 | m >> 2;
1299
1335
  }
1300
1336
  return s;
1301
1337
  }
1302
- function Ft(...r) {
1338
+ function Xt(...r) {
1303
1339
  const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
1304
1340
  let n = 0;
1305
1341
  for (const i of r)
1306
1342
  t.set(i, n), n += i.length;
1307
1343
  return t;
1308
1344
  }
1309
- const pe = 4102444800, Kt = 30;
1345
+ const he = 4102444800, Ft = 30;
1310
1346
  class Jt {
1311
1347
  constructor(e) {
1312
1348
  // `client` is the only mutable field — see `setClient`. The
@@ -1328,7 +1364,7 @@ class Jt {
1328
1364
  /** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
1329
1365
  f(this, "cachedGrpc", null);
1330
1366
  f(this, "inFlightGrpc", null);
1331
- this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Kt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1367
+ this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Ft, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1332
1368
  }
1333
1369
  /**
1334
1370
  * Return a bearer token for `method`, or `null` if `method` is not
@@ -1348,7 +1384,7 @@ class Jt {
1348
1384
  * deterministically.
1349
1385
  */
1350
1386
  async getToken(e) {
1351
- return e === W || e === Y ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
1387
+ return e === z || e === q ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
1352
1388
  }
1353
1389
  /**
1354
1390
  * Drop both cached tokens. Next `getToken` call re-acquires the slot
@@ -1381,7 +1417,7 @@ class Jt {
1381
1417
  acquireSingleFlight(e) {
1382
1418
  const t = e === "grpc" ? this.inFlightGrpc : this.inFlightJsonRpc;
1383
1419
  if (t) return t;
1384
- const n = e === "grpc" ? Y : W, i = (async () => {
1420
+ const n = e === "grpc" ? q : z, i = (async () => {
1385
1421
  try {
1386
1422
  const s = await this.client.call(n, {
1387
1423
  pegin_txid: this.peginTxid,
@@ -1395,20 +1431,20 @@ class Jt {
1395
1431
  throw new Error(
1396
1432
  `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`
1397
1433
  );
1398
- const o = this.now();
1399
- if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= o || s.expires_at > pe)
1434
+ const a = this.now();
1435
+ if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at > he)
1400
1436
  throw new Error(
1401
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${o}, ${pe}])`
1437
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${he}])`
1402
1438
  );
1403
- Dt({
1439
+ Gt({
1404
1440
  token: s.token,
1405
1441
  ephemeralPubkeyHex: s.server_identity.ephemeral_pubkey,
1406
1442
  expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
1407
- expectedSubject: e === "grpc" ? kt : At,
1443
+ expectedSubject: e === "grpc" ? Et : At,
1408
1444
  expectedAudienceXOnlyPubkey: this.expectedAudienceXOnlyPubkey,
1409
1445
  responseExpiresAt: s.expires_at,
1410
1446
  serverIdentityExpiresAt: s.server_identity.expires_at,
1411
- now: o
1447
+ now: a
1412
1448
  });
1413
1449
  const c = {
1414
1450
  token: s.token,
@@ -1422,7 +1458,7 @@ class Jt {
1422
1458
  return e === "grpc" ? this.inFlightGrpc = i : this.inFlightJsonRpc = i, i;
1423
1459
  }
1424
1460
  }
1425
- class qt {
1461
+ class Wt {
1426
1462
  constructor() {
1427
1463
  f(this, "entries", /* @__PURE__ */ new Map());
1428
1464
  }
@@ -1491,52 +1527,128 @@ class qt {
1491
1527
  return this.entries.size;
1492
1528
  }
1493
1529
  }
1494
- const Ee = new qt();
1495
- function dr(r) {
1530
+ const Se = new Wt();
1531
+ function pr(r) {
1496
1532
  var n;
1497
1533
  const e = ve(
1498
1534
  r.baseUrl,
1499
1535
  (n = r.options) == null ? void 0 : n.headers
1500
- ), t = Ee.getOrCreate({
1536
+ ), t = Se.getOrCreate({
1501
1537
  client: e,
1502
1538
  peginTxid: r.peginTxid,
1503
1539
  authAnchorHex: r.authAnchorHex,
1504
1540
  pinnedServerPubkey: r.pinnedServerPubkey,
1505
- expectedAudienceXOnlyPubkey: fe(
1541
+ expectedAudienceXOnlyPubkey: ge(
1506
1542
  r.depositorBtcPubkey
1507
1543
  )
1508
1544
  });
1509
- return new Qe(r.baseUrl, {
1545
+ return new et(r.baseUrl, {
1510
1546
  ...r.options,
1511
1547
  tokenProvider: t
1512
1548
  });
1513
1549
  }
1514
1550
  function hr(r) {
1515
- Ee.getOrCreate({
1551
+ Se.getOrCreate({
1516
1552
  client: ve(r.baseUrl, r.headers),
1517
1553
  peginTxid: r.peginTxid,
1518
1554
  authAnchorHex: r.authAnchorHex,
1519
1555
  pinnedServerPubkey: r.pinnedServerPubkey,
1520
- expectedAudienceXOnlyPubkey: fe(
1556
+ expectedAudienceXOnlyPubkey: ge(
1521
1557
  r.depositorBtcPubkey
1522
1558
  )
1523
1559
  });
1524
1560
  }
1561
+ function Yt(r, e) {
1562
+ const t = /* @__PURE__ */ new Set();
1563
+ for (const d of r)
1564
+ t.add(d.toLowerCase());
1565
+ const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
1566
+ for (const d of e) {
1567
+ const l = d.pegin_txid.toLowerCase();
1568
+ if (!t.has(l)) {
1569
+ a.push(l);
1570
+ continue;
1571
+ }
1572
+ if (i.has(l)) {
1573
+ s.push(l);
1574
+ continue;
1575
+ }
1576
+ i.add(l), n.set(l, { result: d.result, error: d.error });
1577
+ }
1578
+ const c = [];
1579
+ for (const d of t)
1580
+ i.has(d) || c.push(d);
1581
+ return { byTxid: n, missing: c, unexpected: a, duplicate: s };
1582
+ }
1583
+ async function gr(r) {
1584
+ const {
1585
+ items: e,
1586
+ getTxid: t,
1587
+ batchCall: n,
1588
+ onItem: i,
1589
+ onMissing: s,
1590
+ onDuplicate: a,
1591
+ onDuplicateBatch: c,
1592
+ onWholeBatchError: d,
1593
+ onUnexpected: l,
1594
+ batchSize: g = Ne
1595
+ } = r;
1596
+ if (!Number.isInteger(g) || g <= 0)
1597
+ throw new Error(
1598
+ `batchPollByProvider: batchSize must be a positive integer, got ${g}`
1599
+ );
1600
+ for (let m = 0; m < e.length; m += g) {
1601
+ const x = e.slice(m, m + g), E = /* @__PURE__ */ new Map(), C = [];
1602
+ for (const _ of x) {
1603
+ const u = t(_).toLowerCase();
1604
+ E.set(u, _), C.push(u);
1605
+ }
1606
+ let P;
1607
+ try {
1608
+ const _ = await n(C);
1609
+ P = Yt(C, _.results);
1610
+ } catch (_) {
1611
+ d(x, _);
1612
+ continue;
1613
+ }
1614
+ l && P.unexpected.length > 0 && l(P.unexpected);
1615
+ const $ = new Set(P.duplicate);
1616
+ for (const _ of $) {
1617
+ const u = E.get(_);
1618
+ u && a(u);
1619
+ }
1620
+ c && $.size > 0 && c($.size);
1621
+ for (const _ of P.missing) {
1622
+ const u = E.get(_);
1623
+ u && s(u);
1624
+ }
1625
+ for (const [_, u] of P.byTxid) {
1626
+ if ($.has(_)) continue;
1627
+ const S = E.get(_);
1628
+ S && i(S, {
1629
+ pegin_txid: _,
1630
+ result: u.result,
1631
+ error: u.error
1632
+ });
1633
+ }
1634
+ }
1635
+ }
1525
1636
  export {
1526
1637
  De as O,
1527
- y as S,
1528
- Qe as V,
1529
- a,
1530
- ur as b,
1638
+ b as S,
1639
+ et as V,
1640
+ o as a,
1641
+ gr as b,
1531
1642
  lt as c,
1532
- qt as d,
1533
- Ee as e,
1534
- dr as f,
1535
- ar as g,
1643
+ Wt as d,
1644
+ Se as e,
1645
+ pr as f,
1646
+ cr as g,
1536
1647
  lr as h,
1537
- cr as i,
1648
+ dr as i,
1649
+ ur as j,
1538
1650
  hr as p,
1539
1651
  or as r,
1540
1652
  Fe as v
1541
1653
  };
1542
- //# sourceMappingURL=primeVpAuth-Caa5J_uv.js.map
1654
+ //# sourceMappingURL=batchPoll-DTYXoTEc.js.map