@babylonlabs-io/ts-sdk 0.38.1 → 0.39.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 (28) hide show
  1. package/dist/{PeginManager-Cp2Tn5sH.js → PeginManager-DXrfY4d6.js} +388 -334
  2. package/dist/{PeginManager-Cp2Tn5sH.js.map → PeginManager-DXrfY4d6.js.map} +1 -1
  3. package/dist/PeginManager-zkTJOy_U.cjs +2 -0
  4. package/dist/{PeginManager-DaDs-bGr.cjs.map → PeginManager-zkTJOy_U.cjs.map} +1 -1
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +128 -127
  7. package/dist/tbv/core/clients/eth/types.d.ts +2 -0
  8. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  9. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +5 -0
  10. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  11. package/dist/tbv/core/clients/index.cjs +1 -1
  12. package/dist/tbv/core/clients/index.js +1 -1
  13. package/dist/tbv/core/index.cjs +1 -1
  14. package/dist/tbv/core/index.js +125 -124
  15. package/dist/tbv/core/managers/PeginManager.d.ts +25 -0
  16. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  17. package/dist/tbv/core/managers/index.cjs +1 -1
  18. package/dist/tbv/core/managers/index.d.ts +2 -2
  19. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  20. package/dist/tbv/core/managers/index.js +5 -4
  21. package/dist/tbv/index.cjs +1 -1
  22. package/dist/tbv/index.js +125 -124
  23. package/dist/{vault-registry-reader-CbJHSxVe.cjs → vault-registry-reader-BM_993Lb.cjs} +2 -2
  24. package/dist/{vault-registry-reader-CbJHSxVe.cjs.map → vault-registry-reader-BM_993Lb.cjs.map} +1 -1
  25. package/dist/{vault-registry-reader-BrARgFre.js → vault-registry-reader-DXvw-1f6.js} +28 -16
  26. package/dist/{vault-registry-reader-BrARgFre.js.map → vault-registry-reader-DXvw-1f6.js.map} +1 -1
  27. package/package.json +1 -1
  28. package/dist/PeginManager-DaDs-bGr.cjs +0 -2
package/dist/tbv/index.js CHANGED
@@ -1,84 +1,84 @@
1
1
  import { a as s, b as t, c as r } from "../challengeAssert-CBp4mEs0.js";
2
2
  import { computeMinClaimValue as i, deriveVaultId as n, expandAuthAnchor as u, expandHashlockSecret as l, expandWotsSeed as p } from "@babylonlabs-io/babylon-tbv-rust-wasm";
3
- import { P, c, f as T, d as S, a as g, b as E, g as m, e as R } from "../assertPsbtUnsignedTxMatches-mTAnLhCz.js";
3
+ import { P, c, f as T, d as S, a as g, b as m, g as E, e as R } from "../assertPsbtUnsignedTxMatches-mTAnLhCz.js";
4
4
  import { b as _, e as x, f } from "../peginInput-BPRB9tUi.js";
5
5
  import { a as v, b as I } from "../noPayout-qbaSEKGC.js";
6
- import { d as V, a as y, b as O, e as h, f as U, j as F, g as B, h as N, i as D, c as M, p as H, s as L, t as k, u as W, v as X } from "../bitcoin-B5aNKtsk.js";
6
+ import { d as V, a as h, b as y, e as O, f as U, j as F, g as B, h as N, i as D, c as M, p as H, s as L, t as k, u as W, v as X } from "../bitcoin-B5aNKtsk.js";
7
7
  import { c as K } from "../signing-DaLvGwQe.js";
8
- import { B as Y, H as Z, K as J, M as j, T as z } from "../validation-CxqROCno.js";
9
- import { P as Q, V as $, b as aa, a as ea, c as sa, e as ta, d as ra } from "../PeginManager-Cp2Tn5sH.js";
10
- import { P as ia, c as na, v as ua } from "../PayoutManager-D29D-K-V.js";
11
- import { A as pa, P as da } from "../ProtocolParams.abi-C2brDWTI.js";
12
- import { B as ca } from "../BTCVaultRegistry.abi-Cq9-JlqT.js";
13
- import { C as Sa, e as ga, g as Ea, h as ma, i as Ra } from "../errors-CznAK5NB.js";
14
- import { B as _a, a as xa, f as fa, c as ba, b as va, d as Ia, g as Ca, i as Va, h as ya, s as Oa, e as ha, w as Ua } from "../waitForTransactionReceiptSmartAware-CmgFXFza.js";
15
- import { B as Ba, D as Na, F as Da, L as Ma, M as Ha, P as La, b as ka, a as Wa, S as Xa, T as wa, W as Ka, f as Ga, c as Ya, p as Za, r as Ja } from "../fundPeginTransaction-t-6TsHAY.js";
16
- import { U as za, a as qa, c as Qa, e as $a, s as ae, v as ee } from "../reservation-CB-4FBPk.js";
17
- import { M as te, g as re, a as oe, b as ie, c as ne, d as ue, e as le, f as pe, p as de } from "../mempoolApi-CAIge7Nj.js";
18
- import { S as ce, V as Te, j as Se, k as ge, l as Ee, m as me, a as Re, d as Ae, b as _e, f as xe, p as fe, r as be, g as ve, h as Ie, v as Ce, i as Ve, c as ye, e as Oe } from "../vault-registry-reader-BrARgFre.js";
19
- import { D as Ue, b as Fe, J as Be, a as Ne, d as De, P as Me, R as He, e as Le, c as ke, V as We } from "../types-TOmEvvRy.js";
20
- import { i as we, p as Ke } from "../errors-9AkghWyk.js";
21
- import { B as Ye, C as Ze, p as Je, R as je, a as ze, n as qe, o as Qe, i as $e, m as as, l as es, j as ss, r as ts, b as rs, s as os, v as is, g as ns, h as us, d as ls, c as ps, e as ds, f as Ps, k as cs, w as Ts } from "../buildAndBroadcastRefund-B5cOyUzj.js";
22
- import { C as gs, P as Es, c as ms, g as Rs } from "../peginState-CBAlxgXk.js";
8
+ import { B as Y, H as Z, K as J, M as j, T as q } from "../validation-CxqROCno.js";
9
+ import { P as Q, V as $, b as aa, a as ea, c as sa, f as ta, d as ra, e as oa } from "../PeginManager-DXrfY4d6.js";
10
+ import { P as na, c as ua, v as la } from "../PayoutManager-D29D-K-V.js";
11
+ import { A as da, P as Pa } from "../ProtocolParams.abi-C2brDWTI.js";
12
+ import { B as Ta } from "../BTCVaultRegistry.abi-Cq9-JlqT.js";
13
+ import { C as ga, e as ma, g as Ea, h as Ra, i as Aa } from "../errors-CznAK5NB.js";
14
+ import { B as xa, a as fa, f as ba, c as va, b as Ia, d as Ca, g as Va, i as ha, h as ya, s as Oa, e as Ua, w as Fa } from "../waitForTransactionReceiptSmartAware-CmgFXFza.js";
15
+ import { B as Na, D as Da, F as Ma, L as Ha, M as La, P as ka, b as Wa, a as Xa, S as wa, T as Ka, W as Ga, f as Ya, c as Za, p as Ja, r as ja } from "../fundPeginTransaction-t-6TsHAY.js";
16
+ import { U as za, a as Qa, c as $a, e as ae, s as ee, v as se } from "../reservation-CB-4FBPk.js";
17
+ import { M as re, g as oe, a as ie, b as ne, c as ue, d as le, e as pe, f as de, p as Pe } from "../mempoolApi-CAIge7Nj.js";
18
+ import { S as Te, V as Se, j as ge, k as me, l as Ee, m as Re, a as Ae, d as _e, b as xe, f as fe, p as be, r as ve, g as Ie, h as Ce, v as Ve, i as he, c as ye, e as Oe } from "../vault-registry-reader-DXvw-1f6.js";
19
+ import { D as Fe, b as Be, J as Ne, a as De, d as Me, P as He, R as Le, e as ke, c as We, V as Xe } from "../types-TOmEvvRy.js";
20
+ import { i as Ke, p as Ge } from "../errors-9AkghWyk.js";
21
+ import { B as Ze, C as Je, p as je, R as qe, a as ze, n as Qe, o as $e, i as as, m as es, l as ss, j as ts, r as rs, b as os, s as is, v as ns, g as us, h as ls, d as ps, c as ds, e as Ps, f as cs, k as Ts, w as Ss } from "../buildAndBroadcastRefund-B5cOyUzj.js";
22
+ import { C as ms, P as Es, c as Rs, g as As } from "../peginState-CBAlxgXk.js";
23
23
  export {
24
- pa as ApplicationRegistryABI,
25
- Ye as BIP68NotMatureError,
24
+ da as ApplicationRegistryABI,
25
+ Ze as BIP68NotMatureError,
26
26
  Y as BITCOIN_ADDRESS_RE,
27
- ca as BTCVaultRegistryABI,
28
- Ba as BTC_DUST_SAT,
29
- _a as BitcoinScriptType,
30
- Sa as CONTRACT_ERRORS,
31
- Ze as ClaimerPegoutStatusValue,
32
- gs as ContractStatus,
33
- Na as DUST_THRESHOLD,
34
- Ue as DaemonStatus,
35
- Da as FEE_SAFETY_MARGIN,
27
+ Ta as BTCVaultRegistryABI,
28
+ Na as BTC_DUST_SAT,
29
+ xa as BitcoinScriptType,
30
+ ga as CONTRACT_ERRORS,
31
+ Je as ClaimerPegoutStatusValue,
32
+ ms as ContractStatus,
33
+ Da as DUST_THRESHOLD,
34
+ Fe as DaemonStatus,
35
+ Ma as FEE_SAFETY_MARGIN,
36
36
  Z as HEX_RE,
37
- Fe as JSON_RPC_ERROR_CODES,
38
- Be as JsonRpcClient,
39
- Ne as JsonRpcError,
37
+ Be as JSON_RPC_ERROR_CODES,
38
+ Ne as JsonRpcClient,
39
+ De as JsonRpcError,
40
40
  J as KNOWN_SCRIPT_PREFIXES,
41
- Ma as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
42
- Ha as MAX_NON_LEGACY_OUTPUT_SIZE,
41
+ Ha as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
42
+ La as MAX_NON_LEGACY_OUTPUT_SIZE,
43
43
  j as MAX_REASONABLE_FEE_SATS,
44
- te as MEMPOOL_API_URLS,
45
- La as P2TR_INPUT_SIZE,
46
- ka as PEGIN_AUTH_ANCHOR_OUTPUTS,
47
- Wa as PEGIN_FIXED_OUTPUTS,
48
- De as POST_WOTS_STATUSES,
49
- Me as PRE_DEPOSITOR_SIGNATURES_STATES,
50
- ia as PayoutManager,
44
+ re as MEMPOOL_API_URLS,
45
+ ka as P2TR_INPUT_SIZE,
46
+ Wa as PEGIN_AUTH_ANCHOR_OUTPUTS,
47
+ Xa as PEGIN_FIXED_OUTPUTS,
48
+ Me as POST_WOTS_STATUSES,
49
+ He as PRE_DEPOSITOR_SIGNATURES_STATES,
50
+ na as PayoutManager,
51
51
  Es as PeginAction,
52
52
  Q as PeginManager,
53
- da as ProtocolParamsABI,
53
+ Pa as ProtocolParamsABI,
54
54
  P as PsbtSubstitutionError,
55
- Je as REFUND_VSIZE,
56
- je as RegisteredVaultVersionMismatchError,
57
- He as RpcErrorCode,
58
- Xa as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
59
- ce as ServerIdentityError,
60
- z as TXID_RE,
61
- wa as TX_BUFFER_SIZE_OVERHEAD,
55
+ je as REFUND_VSIZE,
56
+ qe as RegisteredVaultVersionMismatchError,
57
+ Le as RpcErrorCode,
58
+ wa as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
59
+ Te as ServerIdentityError,
60
+ q as TXID_RE,
61
+ Ka as TX_BUFFER_SIZE_OVERHEAD,
62
62
  za as UtxoNotAvailableError,
63
63
  $ as VAULT_APP_NAME,
64
- Le as VP_BATCH_MAX_SIZE,
65
- ke as VP_TERMINAL_FAILURE_STATUSES,
66
- We as VP_TRANSIENT_STATUSES,
67
- Te as VaultProviderRpcClient,
68
- Se as ViemProtocolParamsReader,
69
- ge as ViemUniversalChallengerReader,
64
+ ke as VP_BATCH_MAX_SIZE,
65
+ We as VP_TERMINAL_FAILURE_STATUSES,
66
+ Xe as VP_TRANSIENT_STATUSES,
67
+ Se as VaultProviderRpcClient,
68
+ ge as ViemProtocolParamsReader,
69
+ me as ViemUniversalChallengerReader,
70
70
  Ee as ViemVaultKeeperReader,
71
- me as ViemVaultRegistryReader,
72
- Re as VpResponseValidationError,
73
- Ae as VpTokenRegistry,
74
- Ka as WALLET_RELAY_FEE_RATE_THRESHOLD,
71
+ Re as ViemVaultRegistryReader,
72
+ Ae as VpResponseValidationError,
73
+ _e as VpTokenRegistry,
74
+ Ga as WALLET_RELAY_FEE_RATE_THRESHOLD,
75
75
  ze as activateVault,
76
- xa as applyChangeOutputPolicy,
76
+ fa as applyChangeOutputPolicy,
77
77
  c as assertPayoutOutputMatchesRegistered,
78
78
  T as assertPsbtUnsignedTxMatches,
79
- qa as assertUtxosAvailable,
80
- _e as batchPollByProvider,
81
- qe as buildAndBroadcastRefund,
79
+ Qa as assertUtxosAvailable,
80
+ xe as batchPollByProvider,
81
+ Qe as buildAndBroadcastRefund,
82
82
  s as buildChallengeAssertPsbt,
83
83
  t as buildDepositorPayoutPsbt,
84
84
  aa as buildFundingOutpointsCommitment,
@@ -86,99 +86,100 @@ export {
86
86
  S as buildPayoutPsbt,
87
87
  _ as buildPeginInputPsbt,
88
88
  g as buildPeginTxFromFundedPrePegin,
89
- E as buildPrePeginPsbt,
89
+ m as buildPrePeginPsbt,
90
90
  I as buildRefundPsbt,
91
91
  ea as buildVaultContext,
92
- fa as calculateBtcTxHash,
93
- ms as canPerformAction,
94
- Qa as collectReservedUtxoRefs,
95
- ba as computeChangeOutputFeeSats,
96
- na as computeHashlock,
97
- va as computeMaxDeposit,
92
+ ba as calculateBtcTxHash,
93
+ Rs as canPerformAction,
94
+ $a as collectReservedUtxoRefs,
95
+ va as computeChangeOutputFeeSats,
96
+ ua as computeHashlock,
97
+ Ia as computeMaxDeposit,
98
98
  i as computeMinClaimValue,
99
99
  r as computeNumLocalChallengers,
100
- Ia as computePeginBaseFeeSats,
100
+ Ca as computePeginBaseFeeSats,
101
101
  sa as computeWotsBlockPublicKeysHash,
102
- xe as createAuthenticatedVpClient,
103
- m as createPayoutScript,
102
+ fe as createAuthenticatedVpClient,
103
+ E as createPayoutScript,
104
104
  K as createTaprootScriptPathSignOptions,
105
105
  V as deriveBip86ScriptPubKeyHex,
106
- y as deriveNativeSegwitAddress,
107
- O as deriveTaprootAddress,
106
+ h as deriveNativeSegwitAddress,
107
+ y as deriveTaprootAddress,
108
108
  n as deriveVaultId,
109
109
  ta as deriveVaultRoot,
110
110
  ra as deriveWotsBlocksFromSeed,
111
- h as ensureHexPrefix,
112
- Qe as estimateRefundFeeSats,
111
+ O as ensureHexPrefix,
112
+ $e as estimateRefundFeeSats,
113
+ oa as estimateSubmitPeginRequestBatchGas,
113
114
  u as expandAuthAnchor,
114
115
  l as expandHashlockSecret,
115
116
  p as expandWotsSeed,
116
- ga as extractErrorData,
117
- $a as extractInputsFromTransaction,
117
+ ma as extractErrorData,
118
+ ae as extractInputsFromTransaction,
118
119
  R as extractPayoutSignature,
119
120
  x as extractPeginInputSignature,
120
121
  f as finalizePeginInputPsbt,
121
122
  U as formatSatoshisToBtc,
122
- Ga as fundPeginTransaction,
123
- re as getAddressTxs,
124
- oe as getAddressUtxos,
123
+ Ya as fundPeginTransaction,
124
+ oe as getAddressTxs,
125
+ ie as getAddressUtxos,
125
126
  Ea as getContractErrorMessage,
126
- Ca as getDustThreshold,
127
- ie as getMempoolApiUrl,
127
+ Va as getDustThreshold,
128
+ ne as getMempoolApiUrl,
128
129
  F as getNetwork,
129
- ne as getNetworkFees,
130
- Rs as getPeginProtocolState,
131
- Va as getPsbtInputFields,
130
+ ue as getNetworkFees,
131
+ As as getPeginProtocolState,
132
+ ha as getPsbtInputFields,
132
133
  ya as getScriptType,
133
134
  B as getSortedXOnlyPubkeys,
134
- ue as getTxHex,
135
- le as getTxInfo,
136
- pe as getUtxoInfo,
137
- ma as handleContractError,
135
+ le as getTxHex,
136
+ pe as getTxInfo,
137
+ de as getUtxoInfo,
138
+ Ra as handleContractError,
138
139
  N as hexToUint8Array,
139
140
  D as isAddressFromPublicKey,
140
- $e as isDepositAmountValid,
141
- Ra as isKnownContractError,
142
- as as isPegoutTerminalStatus,
143
- es as isRecognizedPegoutStatus,
144
- ss as isRegisteredVaultVersionMismatchError,
141
+ as as isDepositAmountValid,
142
+ Aa as isKnownContractError,
143
+ es as isPegoutTerminalStatus,
144
+ ss as isRecognizedPegoutStatus,
145
+ ts as isRegisteredVaultVersionMismatchError,
145
146
  M as isValidHex,
146
- we as isWotsMismatchError,
147
- Ke as parseFundingOutpointsFromTx,
148
- Ya as parseUnfundedWasmTransaction,
149
- Za as peginOutputCount,
150
- fe as primeVpTokenRegistry,
147
+ Ke as isWotsMismatchError,
148
+ Ge as parseFundingOutpointsFromTx,
149
+ Za as parseUnfundedWasmTransaction,
150
+ Ja as peginOutputCount,
151
+ be as primeVpTokenRegistry,
151
152
  H as processPublicKeyToXOnly,
152
- de as pushTx,
153
- Ja as rateBasedTxBufferFee,
154
- be as resolveProtocolAddresses,
155
- ts as runDepositorPresignFlow,
156
- ae as selectUtxosForDeposit,
153
+ Pe as pushTx,
154
+ ja as rateBasedTxBufferFee,
155
+ ve as resolveProtocolAddresses,
156
+ rs as runDepositorPresignFlow,
157
+ ee as selectUtxosForDeposit,
157
158
  Oa as selectUtxosForPegin,
158
- ha as shouldAddChangeOutput,
159
- rs as signDepositorGraph,
159
+ Ua as shouldAddChangeOutput,
160
+ os as signDepositorGraph,
160
161
  L as stripHexPrefix,
161
- os as submitWotsPublicKey,
162
+ is as submitWotsPublicKey,
162
163
  k as toXOnly,
163
164
  W as uint8ArrayToHex,
164
- is as validateDepositAmount,
165
- ns as validateMultiVaultDepositInputs,
166
- ve as validateOffchainParams,
167
- us as validateOnChainParticipantKeys,
168
- Ie as validatePegInConfiguration,
169
- ls as validateProviderSelection,
170
- ps as validateRemainingCapacity,
171
- Ce as validateRequestDepositorClaimerArtifactsResponse,
172
- ua as validateSecretAgainstHashlock,
173
- Ve as validateTBVProtocolParams,
174
- ee as validateUtxosAvailable,
175
- ds as validateVaultAmounts,
176
- Ps as validateVaultProviderPubkey,
165
+ ns as validateDepositAmount,
166
+ us as validateMultiVaultDepositInputs,
167
+ Ie as validateOffchainParams,
168
+ ls as validateOnChainParticipantKeys,
169
+ Ce as validatePegInConfiguration,
170
+ ps as validateProviderSelection,
171
+ ds as validateRemainingCapacity,
172
+ Ve as validateRequestDepositorClaimerArtifactsResponse,
173
+ la as validateSecretAgainstHashlock,
174
+ he as validateTBVProtocolParams,
175
+ se as validateUtxosAvailable,
176
+ Ps as validateVaultAmounts,
177
+ cs as validateVaultProviderPubkey,
177
178
  X as validateWalletPubkey,
178
- cs as verifyRegisteredVaultVersions,
179
+ Ts as verifyRegisteredVaultVersions,
179
180
  ye as verifyServerIdentity,
180
181
  Oe as vpTokenRegistry,
181
- Ts as waitForPeginStatus,
182
- Ua as waitForTransactionReceiptSmartAware
182
+ Ss as waitForPeginStatus,
183
+ Fa as waitForTransactionReceiptSmartAware
183
184
  };
184
185
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var be=Object.defineProperty;var _e=(t,e,n)=>e in t?be(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var f=(t,e,n)=>_e(t,typeof e!="symbol"?e+"":e,n);const U=require("./types-D2jcXfm7.cjs"),m=require("./bitcoin-CHfKAhcI.cjs"),C=require("./validation-u8W7Lp2x.cjs"),Pe=require("@bitcoin-js/tiny-secp256k1-asmjs"),B=require("bitcoinjs-lib"),$=require("buffer"),Y=require("./sha2-DsrLC4NM.cjs"),v=require("./BTCVaultRegistry.abi-CHFGevwa.cjs"),g=require("./ProtocolParams.abi-DQhcqsNr.cjs");function ye(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const K=ye(Pe),W=new Set(Object.values(U.DaemonStatus)),we=200;function l(t){var e;return((e=JSON.stringify(t))==null?void 0:e.slice(0,we))??"undefined"}const ve="The vault provider returned an unexpected response. Please try again or contact support.";class o extends Error{constructor(n){super(ve);f(this,"detail");this.name="VpResponseValidationError",this.detail=n}}const T=64;function x(t){return typeof t=="string"&&t.length>0&&C.HEX_RE.test(t)}function ie(t){return typeof t=="string"&&t.length>0}function se(t,e){if(!x(t))throw new o(`VP response validation failed: "${e}" must be a non-empty hex string, got ${l(t)}`)}function _(t,e){if(!ie(t))throw new o(`VP response validation failed: "${e}" must be a non-empty string, got ${l(t)}`)}function X(t,e){if(!x(t)||t.length!==m.X_ONLY_PUBKEY_HEX_LEN&&t.length!==m.COMPRESSED_PUBKEY_HEX_LEN)throw new o(`VP response validation failed: "${e}" must be a ${m.X_ONLY_PUBKEY_HEX_LEN} or ${m.COMPRESSED_PUBKEY_HEX_LEN}-char hex string (BTC pubkey), got ${l(t)}`)}function xe(t){const e=t.presigning;if(e==null)return;if(typeof e!="object"||Array.isArray(e))throw new o('VP response validation failed: "progress.presigning" must be an object if present');const n=e;if(n.depositor_graph_created!==void 0&&typeof n.depositor_graph_created!="boolean")throw new o(`VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${l(n.depositor_graph_created)}`);if(n.vk_challenger_presigning_completed!==void 0&&typeof n.vk_challenger_presigning_completed!="number")throw new o(`VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${l(n.vk_challenger_presigning_completed)}`);if(n.vk_challenger_presigning_total!==void 0&&typeof n.vk_challenger_presigning_total!="number")throw new o(`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${l(n.vk_challenger_presigning_total)}`)}function oe(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: getPeginStatus response is not an object");const e=t;if(!x(e.pegin_txid)||e.pegin_txid.length!==T)throw new o(`VP response validation failed: "pegin_txid" must be a ${T}-char hex string (txid), got ${l(e.pegin_txid)}`);if(typeof e.status!="string")throw new o('VP response validation failed: "status" must be a string');if(!W.has(e.status))throw new o(`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...W].join(", ")}`);if(e.progress===null||typeof e.progress!="object"||Array.isArray(e.progress))throw new o('VP response validation failed: "progress" must be an object');if(xe(e.progress),typeof e.health_info!="string")throw new o('VP response validation failed: "health_info" must be a string');if(e.last_error!==void 0&&typeof e.last_error!="string")throw new o(`VP response validation failed: "last_error" must be a string if present, got ${l(e.last_error)}`)}function Ve(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: requestDepositorPresignTransactions response is not an object");const e=t;if(!Array.isArray(e.txs))throw new o('VP response validation failed: "txs" must be an array');for(let n=0;n<e.txs.length;n++)Ae(e.txs[n],`txs[${n}]`);if(e.depositor_graph===null||typeof e.depositor_graph!="object")throw new o('VP response validation failed: "depositor_graph" must be an object');Ee(e.depositor_graph)}function y(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);se(t.tx_hex,`${e}.tx_hex`)}function Ae(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);const n=t;X(n.claimer_pubkey,`${e}.claimer_pubkey`),y(n.claim_tx,`${e}.claim_tx`),y(n.assert_tx,`${e}.assert_tx`),y(n.payout_tx,`${e}.payout_tx`),_(n.payout_psbt,`${e}.payout_psbt`)}function $e(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);const n=t;_(n.wots_pks_json,`${e}.wots_pks_json`),_(n.gc_wots_keys_json,`${e}.gc_wots_keys_json`)}function Te(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);const n=t;if(X(n.challenger_pubkey,`${e}.challenger_pubkey`),y(n.challenge_assert_x_tx,`${e}.challenge_assert_x_tx`),y(n.challenge_assert_y_tx,`${e}.challenge_assert_y_tx`),y(n.nopayout_tx,`${e}.nopayout_tx`),_(n.nopayout_psbt,`${e}.nopayout_psbt`),!Array.isArray(n.challenge_assert_connectors))throw new o(`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`);for(let r=0;r<n.challenge_assert_connectors.length;r++)$e(n.challenge_assert_connectors[r],`${e}.challenge_assert_connectors[${r}]`);if(!Array.isArray(n.output_label_hashes))throw new o(`VP response validation failed: "${e}.output_label_hashes" must be an array`);for(let r=0;r<n.output_label_hashes.length;r++)se(n.output_label_hashes[r],`${e}.output_label_hashes[${r}]`)}function ae(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: requestDepositorClaimerArtifacts response is not an object");const e=t;if(!ie(e.tx_graph_json))throw new o(`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${l(e.tx_graph_json)}`);if(!x(e.verifying_key_hex))throw new o(`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${l(e.verifying_key_hex)}`);if(e.babe_sessions===null||typeof e.babe_sessions!="object"||Array.isArray(e.babe_sessions))throw new o('VP response validation failed: "babe_sessions" must be an object');const n=Object.entries(e.babe_sessions);if(n.length===0)throw new o('VP response validation failed: "babe_sessions" must contain at least one challenger entry');for(const[r,s]of n){if(X(r,`babe_sessions["${r}"]`),s===null||typeof s!="object")throw new o(`VP response validation failed: "babe_sessions.${r}" must be an object`);const i=s;if(!x(i.decryptor_artifacts_hex))throw new o(`VP response validation failed: "babe_sessions.${r}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(i.decryptor_artifacts_hex)}`)}}function Ce(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: pegout status payload is not an object");const e=t;if(!x(e.pegin_txid)||e.pegin_txid.length!==T)throw new o(`VP response validation failed: "pegin_txid" must be a ${T}-char hex string (txid), got ${l(e.pegin_txid)}`);if(typeof e.found!="boolean")throw new o(`VP response validation failed: "found" must be a boolean, got ${l(e.found)}`);if(e.claimer!==null){if(typeof e.claimer!="object")throw new o(`VP response validation failed: "claimer" must be an object or null, got ${l(e.claimer)}`);Ie(e.claimer)}if(!Array.isArray(e.challengers))throw new o(`VP response validation failed: "challengers" must be an array, got ${l(e.challengers)}`);for(let n=0;n<e.challengers.length;n++)Se(e.challengers[n],n)}function Ie(t){if(_(t.status,"claimer.status"),typeof t.failed!="boolean")throw new o(`VP response validation failed: "claimer.failed" must be a boolean, got ${l(t.failed)}`);if(_(t.claim_txid,"claimer.claim_txid"),_(t.claimer_pubkey,"claimer.claimer_pubkey"),_(t.assert_txid,"claimer.assert_txid"),typeof t.created_at!="number")throw new o(`VP response validation failed: "claimer.created_at" must be a number, got ${l(t.created_at)}`);if(typeof t.updated_at!="number")throw new o(`VP response validation failed: "claimer.updated_at" must be a number, got ${l(t.updated_at)}`)}function Se(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "challengers[${e}]" must be an object, got ${l(t)}`);const n=t;if(_(n.status,`challengers[${e}].status`),_(n.claim_txid,`challengers[${e}].claim_txid`),_(n.claimer_pubkey,`challengers[${e}].claimer_pubkey`),E(n.assert_txid,`challengers[${e}].assert_txid`),E(n.challenge_assert_x_txid,`challengers[${e}].challenge_assert_x_txid`),E(n.challenge_assert_y_txid,`challengers[${e}].challenge_assert_y_txid`),E(n.nopayout_txid,`challengers[${e}].nopayout_txid`),typeof n.created_at!="number")throw new o(`VP response validation failed: "challengers[${e}].created_at" must be a number, got ${l(n.created_at)}`);if(typeof n.updated_at!="number")throw new o(`VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${l(n.updated_at)}`)}function E(t,e){if(t!==null&&typeof t!="string")throw new o(`VP response validation failed: "${e}" must be a string or null, got ${l(t)}`)}function ke(t){ce(t,"batchGetPeginStatus",e=>{e.result!==null&&oe(e.result)})}function Be(t){ce(t,"batchGetPegoutStatus",e=>{e.result!==null&&Ce(e.result)})}function ce(t,e,n){if(t===null||typeof t!="object")throw new o(`VP response validation failed: ${e} response is not an object`);const r=t;if(!Array.isArray(r.results))throw new o(`VP response validation failed: "${e}.results" must be an array, got ${l(r.results)}`);for(let s=0;s<r.results.length;s++){const i=r.results[s];if(i===null||typeof i!="object")throw new o(`VP response validation failed: "${e}.results[${s}]" must be an object, got ${l(i)}`);const a=i;if(!x(a.pegin_txid)||a.pegin_txid.length!==T)throw new o(`VP response validation failed: "${e}.results[${s}].pegin_txid" must be a ${T}-char hex string, got ${l(a.pegin_txid)}`);if(a.error!==null&&typeof a.error!="string")throw new o(`VP response validation failed: "${e}.results[${s}].error" must be a string or null, got ${l(a.error)}`);if(a.result===null&&a.error===null)throw new o(`VP response validation failed: "${e}.results[${s}]" has neither "result" nor "error" populated`);if(a.result!==null&&a.error!==null)throw new o(`VP response validation failed: "${e}.results[${s}]" has both "result" and "error" populated`);n(a,s)}}function Ee(t){if(y(t.claim_tx,"depositor_graph.claim_tx"),y(t.assert_tx,"depositor_graph.assert_tx"),y(t.payout_tx,"depositor_graph.payout_tx"),_(t.payout_psbt,"depositor_graph.payout_psbt"),!Array.isArray(t.challenger_presign_data))throw new o('VP response validation failed: "depositor_graph.challenger_presign_data" must be an array');for(let e=0;e<t.challenger_presign_data.length;e++)Te(t.challenger_presign_data[e],`depositor_graph.challenger_presign_data[${e}]`);if(typeof t.offchain_params_version!="number")throw new o('VP response validation failed: "depositor_graph.offchain_params_version" must be a number')}const Re=6e4;class le{constructor(e,n){f(this,"client");const r={baseUrl:e,timeout:(n==null?void 0:n.timeout)??Re,retries:n==null?void 0:n.retries,retryDelay:n==null?void 0:n.retryDelay,retryableFor:n==null?void 0:n.retryableFor,headers:n==null?void 0:n.headers,tokenProvider:n==null?void 0:n.tokenProvider,maxResponseBytes:n==null?void 0:n.maxResponseBytes};this.client=new U.JsonRpcClient(r)}async requestDepositorPresignTransactions(e,n){const r=await this.client.call("vaultProvider_requestDepositorPresignTransactions",e,n);return Ve(r),r}async submitDepositorPresignatures(e,n){return this.client.call("vaultProvider_submitDepositorPresignatures",e,n)}async submitDepositorWotsKey(e,n){return this.client.call("vaultProvider_submitDepositorWotsKey",e,n)}async requestDepositorClaimerArtifacts(e,n){const r=await this.client.call("vaultProvider_requestDepositorClaimerArtifacts",e,n);return ae(r),r}async getPeginStatus(e,n){const r=await this.client.call("vaultProvider_getPeginStatus",e,n);return oe(r),r}async batchGetPeginStatus(e,n){const r=await this.client.call("vaultProvider_batchGetPeginStatus",e,n);return ke(r),r}async batchGetPegoutStatus(e,n){const r=await this.client.call("vaultProvider_batchGetPegoutStatus",e,n);return Be(r),r}}function Ne(t,e){const n=new Set;for(const u of t)n.add(u.toLowerCase());const r=new Map,s=new Set,i=[],a=[];for(const u of e){const d=u.pegin_txid.toLowerCase();if(!n.has(d)){a.push(d);continue}if(s.has(d)){i.push(d);continue}s.add(d),r.set(d,{result:u.result,error:u.error})}const c=[];for(const u of n)s.has(u)||c.push(u);return{byTxid:r,missing:c,unexpected:a,duplicate:i}}async function He(t){const{items:e,getTxid:n,batchCall:r,onItem:s,onMissing:i,onDuplicate:a,onDuplicateBatch:c,onWholeBatchError:u,onUnexpected:d,batchSize:b=U.VP_BATCH_MAX_SIZE}=t;if(!Number.isInteger(b)||b<=0)throw new Error(`batchPollByProvider: batchSize must be a positive integer, got ${b}`);for(let w=0;w<e.length;w+=b){const V=e.slice(w,w+b),S=new Map,L=[];for(const h of V){const P=n(h).toLowerCase();S.set(P,h),L.push(P)}let A;try{const h=await r(L);A=Ne(L,h.results)}catch(h){u(V,h);continue}d&&A.unexpected.length>0&&d(A.unexpected);const k=new Set(A.duplicate);for(const h of k){const P=S.get(h);P&&a(P)}c&&k.size>0&&c(k.size);for(const h of A.missing){const P=S.get(h);P&&i(P)}for(const[h,P]of A.byTxid){if(k.has(h))continue;const z=S.get(h);z&&s(z,{pegin_txid:h,result:P.result,error:P.error})}}}const Oe="BIP0322-signed-message",De="TapTweak",ue=32,je=64;function de(t,e){const n=new TextEncoder().encode(t),r=Y.sha256(n),s=new Uint8Array(r.length*2+e.length);return s.set(r,0),s.set(r,r.length),s.set(e,r.length*2),Y.sha256(s)}function Ue(t){if(t.length!==ue)return null;const e=de(De,t),n=K.xOnlyPointAddTweak(t,e);return n?n.xOnlyPubkey:null}function Ke(t,e,n){if(e.length!==ue||n.length!==je)return!1;try{const r=de(Oe,t),s=B.payments.p2tr({internalPubkey:$.Buffer.from(e)});if(!s.output)return!1;const i=s.output,a=0,c=new B.Transaction;c.version=0,c.locktime=0;const u=$.Buffer.concat([$.Buffer.from([0,32]),$.Buffer.from(r)]);c.addInput($.Buffer.alloc(32,0),4294967295,0,u),c.addOutput(i,a);const d=new B.Transaction;d.version=0,d.locktime=0;const b=c.getHash();d.addInput(b,0,0),d.addOutput($.Buffer.from([106]),a);const w=d.hashForWitnessV1(0,[i],[a],B.Transaction.SIGHASH_DEFAULT),V=Ue(e);return V?K.verifySchnorr(w,V,n):!1}catch{return!1}}function O(t,e){const n=(t&7)<<5,r=typeof e=="bigint"?e:BigInt(e);if(r<0n)throw new Error("cborHead: negative argument");if(r<24n)return new Uint8Array([n|Number(r)]);if(r<0x100n)return new Uint8Array([n|24,Number(r)]);if(r<0x10000n){const i=Number(r);return new Uint8Array([n|25,i>>>8&255,i&255])}if(r<0x100000000n){const i=Number(r);return new Uint8Array([n|26,i>>>24&255,i>>>16&255,i>>>8&255,i&255])}const s=new Uint8Array(9);s[0]=n|27;for(let i=7;i>=0;i--)s[1+i]=Number(r>>BigInt((7-i)*8))&255;return s}function he(...t){const e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Q(t){const n=[O(4,t.length)];for(const r of t)n.push(O(0,r));return he(...n)}function Le(t,e,n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${n}`);const r=O(4,3),s=Q(t),i=Q(e),a=O(0,n);return he(r,s,i,a)}const Fe=new TextEncoder().encode("btc-auth.server-identity.v1"),Me=2*3600;class p extends Error{constructor(e,n){super(e),this.reason=n,this.name="ServerIdentityError"}}function R(t){const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function pe(t){const{proof:e,pinnedServerPubkey:n,now:r}=t,s=t.maxLifetimeSecs??Me,i=m.stripHexPrefix(n).toLowerCase();if(i.length!==m.X_ONLY_PUBKEY_HEX_LEN||!C.HEX_RE.test(i))throw new p(`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,"invalid_pubkey_encoding");const a=m.stripHexPrefix(e.server_pubkey).toLowerCase();if(a.length!==m.X_ONLY_PUBKEY_HEX_LEN||!C.HEX_RE.test(a))throw new p(`server_pubkey must be 32-byte hex; got ${a.length} chars`,"invalid_pubkey_encoding");if(a!==i)throw new p(`server_pubkey does not match pinned value: expected ${i}, got ${a}`,"pinned_pubkey_mismatch");if(!Number.isSafeInteger(e.expires_at))throw new p(`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,"invalid_expires_at");if(!Number.isSafeInteger(r))throw new p(`now must be a finite integer; got ${JSON.stringify(r)}`,"invalid_expires_at");if(e.expires_at<=r)throw new p(`server identity proof expired at ${e.expires_at}, now ${r}`,"expired");if(!Number.isSafeInteger(s)||s<=0)throw new p(`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,"invalid_max_lifetime");if(e.expires_at-r>s)throw new p(`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${s}s`,"expires_too_far");const c=m.stripHexPrefix(e.ephemeral_pubkey).toLowerCase();if(c.length!==m.COMPRESSED_PUBKEY_HEX_LEN||!C.HEX_RE.test(c))throw new p(`ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,"invalid_ephemeral_pubkey");const u=c.slice(0,2);if(u!=="02"&&u!=="03")throw new p(`ephemeral_pubkey must be compressed (prefix 02/03); got ${u}`,"invalid_ephemeral_pubkey");const d=R(c);if(!K.isPoint(d))throw new p("ephemeral_pubkey is not a valid secp256k1 point","invalid_ephemeral_pubkey");const b=m.stripHexPrefix(e.signature).toLowerCase();if(b.length!==m.SCHNORR_SIG_HEX_LEN||!C.HEX_RE.test(b))throw new p(`signature must be 64-byte Schnorr hex; got ${b.length} chars`,"invalid_signature_encoding");const w=Le(Fe,R(c),e.expires_at);if(!Ke(w,R(a),R(b)))throw new p("BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey","signature_verification_failed")}const Xe=new Set(["vaultProvider_submitDepositorWotsKey","vaultProvider_submitDepositorPresignatures","vaultProvider_requestDepositorPresignTransactions","vaultProvider_requestDepositorClaimerArtifacts"]),Ge=6e4,M="auth_createDepositorToken";function ge(t,e){return new U.JsonRpcClient({baseUrl:t,timeout:Ge,headers:e,retryableFor:n=>n===M})}const J=4102444800,qe=30;class ze{constructor(e){f(this,"client");f(this,"peginTxid");f(this,"authAnchorHex");f(this,"pinnedServerPubkey");f(this,"authGatedMethods");f(this,"refreshSkewSecs");f(this,"now");f(this,"cached",null);f(this,"inFlight",null);this.client=e.client,this.peginTxid=e.peginTxid,this.authAnchorHex=e.authAnchorHex,this.pinnedServerPubkey=e.pinnedServerPubkey,this.authGatedMethods=e.authGatedMethods,this.refreshSkewSecs=e.refreshSkewSecs??qe,this.now=e.now??(()=>Math.floor(Date.now()/1e3))}async getToken(e){if(e===M||!this.authGatedMethods.has(e))return null;const n=this.cached;return n&&this.now()+this.refreshSkewSecs<n.expiresAt?n.token:(await this.acquireSingleFlight()).token}invalidate(){this.cached=null}setClient(e){this.client=e}acquireSingleFlight(){const e=this.inFlight;if(e)return e;const n=(async()=>{try{const r=await this.client.call(M,{pegin_txid:this.peginTxid,auth_anchor:this.authAnchorHex});if(pe({proof:r.server_identity,pinnedServerPubkey:this.pinnedServerPubkey,now:this.now()}),typeof r.token!="string"||r.token.length===0)throw new Error(`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`);const s=this.now();if(!Number.isSafeInteger(r.expires_at)||r.expires_at<=s||r.expires_at>J)throw new Error(`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${s}, ${J}])`);const i={token:r.token,expiresAt:r.expires_at};return this.cached=i,i}finally{this.inFlight=null}})();return this.inFlight=n,n}}class fe{constructor(){f(this,"entries",new Map)}getOrCreate(e){const n=this.entries.get(e.peginTxid);if(n){if(n.authAnchorHex!==e.authAnchorHex)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${n.authAnchorHex.slice(0,8)}…; got ${e.authAnchorHex.slice(0,8)}…`);if(n.pinnedServerPubkey!==e.pinnedServerPubkey)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${n.pinnedServerPubkey.slice(0,8)}…; got ${e.pinnedServerPubkey.slice(0,8)}…`);return n.provider.setClient(e.client),n.provider}const r=new ze({client:e.client,peginTxid:e.peginTxid,authAnchorHex:e.authAnchorHex,pinnedServerPubkey:e.pinnedServerPubkey,authGatedMethods:Xe});return this.entries.set(e.peginTxid,{provider:r,authAnchorHex:e.authAnchorHex,pinnedServerPubkey:e.pinnedServerPubkey}),r}peek(e){var n;return(n=this.entries.get(e))==null?void 0:n.provider}release(e){this.entries.delete(e)}clear(){this.entries.clear()}get size(){return this.entries.size}}const G=new fe;function Ye(t){var r;const e=ge(t.baseUrl,(r=t.options)==null?void 0:r.headers),n=G.getOrCreate({client:e,peginTxid:t.peginTxid,authAnchorHex:t.authAnchorHex,pinnedServerPubkey:t.pinnedServerPubkey});return new le(t.baseUrl,{...t.options,tokenProvider:n})}function We(t){G.getOrCreate({client:ge(t.baseUrl,t.headers),peginTxid:t.peginTxid,authAnchorHex:t.authAnchorHex,pinnedServerPubkey:t.pinnedServerPubkey})}async function Qe(t,e){const[n,r]=await t.multicall({contracts:[{address:e,abi:v.BTCVaultRegistryABI,functionName:"protocolParams"},{address:e,abi:v.BTCVaultRegistryABI,functionName:"applicationRegistry"}],allowFailure:!1});return{protocolParams:n,applicationRegistry:r}}const F=65535,Z=1e4,D=4294967295,ee=255;function H(t){if(!Number.isInteger(t)||t<0||t>D)throw new Error(`Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`)}function I(t){const e=[];if(t.timelockAssert<=0n&&e.push(`timelockAssert must be positive, got ${t.timelockAssert}`),t.timelockAssert>BigInt(F)&&e.push(`timelockAssert ${t.timelockAssert} exceeds uint16 max (${F})`),t.timelockChallengeAssert<=0n&&e.push(`timelockChallengeAssert must be positive, got ${t.timelockChallengeAssert}`),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(`councilQuorum (${t.councilQuorum}) exceeds securityCouncilKeys count (${t.securityCouncilKeys.length})`),t.feeRate<=0n&&e.push(`feeRate must be positive, got ${t.feeRate}`),t.minPeginFeeRate<=0n&&e.push(`minPeginFeeRate must be positive, got ${t.minPeginFeeRate}`),(!Number.isInteger(t.proverCircuitVersion)||t.proverCircuitVersion<0||t.proverCircuitVersion>F)&&e.push(`proverCircuitVersion must be a uint16, got ${t.proverCircuitVersion}`),(!Number.isInteger(t.minPrepeginDepth)||t.minPrepeginDepth<=0||t.minPrepeginDepth>D)&&e.push(`minPrepeginDepth must be a uint32 in [1, ${D}], got ${t.minPrepeginDepth}`),t.babeTotalInstances<=0&&e.push(`babeTotalInstances must be positive, got ${t.babeTotalInstances}`),t.babeInstancesToFinalize<=0&&e.push(`babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`),t.babeInstancesToFinalize>t.babeTotalInstances&&e.push(`babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`),(t.minVpCommissionBps<0||t.minVpCommissionBps>Z)&&e.push(`minVpCommissionBps must be in [0, ${Z}], got ${t.minVpCommissionBps}`),e.length>0)throw new Error(`Invalid offchain protocol parameters: ${e.join("; ")}`)}function q(t){const e=[];if(t.minimumPegInAmount<=0n&&e.push(`minimumPegInAmount must be positive, got ${t.minimumPegInAmount}`),t.maxPegInAmount<t.minimumPegInAmount&&e.push(`maxPegInAmount (${t.maxPegInAmount}) must be >= minimumPegInAmount (${t.minimumPegInAmount})`),t.pegInAckTimeout<=0n&&e.push(`pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`),t.pegInActivationTimeout<=0n&&e.push(`pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`),(!Number.isInteger(t.maxHtlcOutputCount)||t.maxHtlcOutputCount<=0||t.maxHtlcOutputCount>ee)&&e.push(`maxHtlcOutputCount must be an integer in [1, ${ee}], got ${t.maxHtlcOutputCount}`),(typeof t.expiredPegInGraceBlocks!="bigint"||t.expiredPegInGraceBlocks<=0n)&&e.push(`expiredPegInGraceBlocks must be a positive bigint, got ${t.expiredPegInGraceBlocks}`),e.length>0)throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`)}function me(t){if(q(t),I(t.offchainParams),!Number.isInteger(t.offchainParamsVersion)||t.offchainParamsVersion<0||t.offchainParamsVersion>D)throw new Error(`Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`)}const te=65535;function N(t){return{timelockAssert:t.timelockAssert,timelockChallengeAssert:t.timelockChallengeAssert,securityCouncilKeys:[...t.securityCouncilKeys],councilQuorum:t.councilQuorum,feeRate:t.feeRate,babeTotalInstances:t.babeTotalInstances,babeInstancesToFinalize:t.babeInstancesToFinalize,minVpCommissionBps:t.minVpCommissionBps,tRefund:t.tRefund,tStale:t.tStale,minPeginFeeRate:t.minPeginFeeRate,proverCircuitVersion:t.proverCircuitVersion,minPrepeginDepth:t.minPrepeginDepth}}function ne(t){return{minimumPegInAmount:t.minimumPegInAmount,maxPegInAmount:t.maxPegInAmount,pegInAckTimeout:t.pegInAckTimeout,pegInActivationTimeout:t.pegInActivationTimeout,maxHtlcOutputCount:t.maxHtlcOutputCount,expiredPegInGraceBlocks:t.expiredPegInGraceBlocks}}function re(t){if(t>BigInt(te))throw new Error(`timelockAssert value ${t} exceeds uint16 max (${te})`);return Number(t)}class Je{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getTBVProtocolParams(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getTBVProtocolParams"}),n=ne(e);return q(n),n}async getLatestOffchainParams(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getLatestOffchainParams"}),n=N(e);return I(n),n}async getOffchainParamsByVersion(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getOffchainParamsByVersion",args:[e]}),r=N(n);return I(r),r}async getLatestOffchainParamsVersion(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"latestOffchainParamsVersion"}),n=Number(e);return H(n),n}async getTimelockPeginByVersion(e){const n=await this.getOffchainParamsByVersion(e);return re(n.timelockAssert)}async getPegInConfiguration(){const e=await this.publicClient.multicall({contracts:[{address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getTBVProtocolParams"},{address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getLatestOffchainParams"},{address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"latestOffchainParamsVersion"}],allowFailure:!1}),n=ne(e[0]),r=N(e[1]),s=Number(e[2]),i={minimumPegInAmount:n.minimumPegInAmount,maxPegInAmount:n.maxPegInAmount,pegInAckTimeout:n.pegInAckTimeout,pegInActivationTimeout:n.pegInActivationTimeout,maxHtlcOutputCount:n.maxHtlcOutputCount,expiredPegInGraceBlocks:n.expiredPegInGraceBlocks,timelockPegin:re(r.timelockAssert),timelockRefund:r.tRefund,minVpCommissionBps:r.minVpCommissionBps,offchainParams:r,offchainParamsVersion:s};return me(i),i}async fetchAllOffchainParams(e){const n=await this.getLatestOffchainParamsVersion();if(n===0)return{byVersion:new Map,latestVersion:0};const r=Array.from({length:n},(c,u)=>u+1),s=r.map(c=>({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getOffchainParamsByVersion",args:[c]})),i=await this.publicClient.multicall({contracts:s,allowFailure:!1}),a=new Map;for(let c=0;c<r.length;c++){const u=N(i[c]);try{I(u),a.set(r[c],u)}catch(d){e==null||e(r[c],d instanceof Error?d:new Error(String(d)))}}return{byVersion:a,latestVersion:n}}}function j(t){return t.map(e=>({ethAddress:e.ethAddress,btcPubKey:e.btcPubKey}))}class Ze{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getVaultKeepersByVersion(e,n){const r=await this.publicClient.readContract({address:this.contractAddress,abi:g.ApplicationRegistryABI,functionName:"getVaultKeepersByVersion",args:[e,n]});return j(r)}async getCurrentVaultKeepers(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:g.ApplicationRegistryABI,functionName:"getCurrentVaultKeepers",args:[e]});return j(n)}async getCurrentVaultKeepersVersion(e){return await this.publicClient.readContract({address:this.contractAddress,abi:g.ApplicationRegistryABI,functionName:"getCurrentVaultKeepersVersion",args:[e]})}}class et{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getUniversalChallengersByVersion(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getUniversalChallengersByVersion",args:[e]});return j(n)}async getCurrentUniversalChallengers(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getCurrentUniversalChallengers"});return j(e)}async getLatestUniversalChallengersVersion(){return await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"latestUniversalChallengersVersion"})}}class tt{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getVaultProviderBtcPubKey(e){const r=(await this.publicClient.readContract({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getVaultProviderBTCKey",args:[e]})).toLowerCase();if(!/^0x[0-9a-f]{64}$/.test(r))throw new Error(`getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0,2)}")`);const s=r.slice(2);if(!K.isXOnlyPoint(m.hexToUint8Array(s)))throw new Error(`getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`);return s}async getVaultBasicInfo(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultBasicInfo",args:[e]});return{depositor:n.depositor,depositorBtcPubKey:n.depositorBtcPubKey,amount:n.amount,vaultProvider:n.vaultProvider,status:n.status,applicationEntryPoint:n.applicationEntryPoint,createdAt:n.createdAt}}async getVaultProtocolInfo(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultProtocolInfo",args:[e]}),r=Number(n.offchainParamsVersion);return H(r),{depositorSignedPeginTx:n.depositorSignedPeginTx,universalChallengersVersion:n.universalChallengersVersion,appVaultKeepersVersion:n.appVaultKeepersVersion,offchainParamsVersion:r,verifiedAt:n.verifiedAt,depositorWotsPkHash:n.depositorWotsPkHash,hashlock:n.hashlock,htlcVout:n.htlcVout,depositorPopSignature:n.depositorPopSignature,prePeginTxHash:n.prePeginTxHash,vaultProviderCommissionBps:n.vaultProviderCommissionBps,claimExpiredUntil:n.claimExpiredUntil,vaultCoreVersion:n.vaultCoreVersion}}async getProtocolInfoBatch(e){return e.length===0?[]:(await this.publicClient.multicall({contracts:e.map(r=>({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultProtocolInfo",args:[r]})),allowFailure:!1})).map((r,s)=>{const i=r;if(!i.depositorSignedPeginTx||i.depositorSignedPeginTx==="0x")throw new Error(`Vault ${e[s]} not found on-chain or has no pegin transaction`);const a=Number(i.offchainParamsVersion);return H(a),{depositorSignedPeginTx:i.depositorSignedPeginTx,universalChallengersVersion:i.universalChallengersVersion,appVaultKeepersVersion:i.appVaultKeepersVersion,offchainParamsVersion:a,verifiedAt:i.verifiedAt,depositorWotsPkHash:i.depositorWotsPkHash,hashlock:i.hashlock,htlcVout:i.htlcVout,depositorPopSignature:i.depositorPopSignature,prePeginTxHash:i.prePeginTxHash,vaultProviderCommissionBps:i.vaultProviderCommissionBps,claimExpiredUntil:i.claimExpiredUntil,vaultCoreVersion:i.vaultCoreVersion}})}async getVaultData(e){const[n,r]=await Promise.all([this.getVaultBasicInfo(e),this.getVaultProtocolInfo(e)]);if(!r.depositorSignedPeginTx||r.depositorSignedPeginTx==="0x")throw new Error(`Vault ${e} not found on-chain or has no pegin transaction`);return{basic:n,protocol:r}}async getOffchainParamsVersionsByVaultIds(e){return e.length===0?[]:(await this.publicClient.multicall({contracts:e.map(r=>({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultProtocolInfo",args:[r]})),allowFailure:!1})).map(r=>{const s=r;if(!s.depositorSignedPeginTx||s.depositorSignedPeginTx==="0x")throw new Error("Vault not found on-chain or has no pegin transaction while reading offchain params version");const i=Number(s.offchainParamsVersion);return H(i),i})}}exports.ServerIdentityError=p;exports.VaultProviderRpcClient=le;exports.ViemProtocolParamsReader=Je;exports.ViemUniversalChallengerReader=et;exports.ViemVaultKeeperReader=Ze;exports.ViemVaultRegistryReader=tt;exports.VpResponseValidationError=o;exports.VpTokenRegistry=fe;exports.batchPollByProvider=He;exports.createAuthenticatedVpClient=Ye;exports.primeVpTokenRegistry=We;exports.resolveProtocolAddresses=Qe;exports.validateOffchainParams=I;exports.validatePegInConfiguration=me;exports.validateRequestDepositorClaimerArtifactsResponse=ae;exports.validateTBVProtocolParams=q;exports.verifyServerIdentity=pe;exports.vpTokenRegistry=G;
2
- //# sourceMappingURL=vault-registry-reader-CbJHSxVe.cjs.map
1
+ "use strict";var be=Object.defineProperty;var _e=(t,e,n)=>e in t?be(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var f=(t,e,n)=>_e(t,typeof e!="symbol"?e+"":e,n);const U=require("./types-D2jcXfm7.cjs"),m=require("./bitcoin-CHfKAhcI.cjs"),$=require("./validation-u8W7Lp2x.cjs"),Pe=require("@bitcoin-js/tiny-secp256k1-asmjs"),B=require("bitcoinjs-lib"),C=require("buffer"),Y=require("./sha2-DsrLC4NM.cjs"),v=require("./BTCVaultRegistry.abi-CHFGevwa.cjs"),g=require("./ProtocolParams.abi-DQhcqsNr.cjs");function ye(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const K=ye(Pe),W=new Set(Object.values(U.DaemonStatus)),we=200;function l(t){var e;return((e=JSON.stringify(t))==null?void 0:e.slice(0,we))??"undefined"}const ve="The vault provider returned an unexpected response. Please try again or contact support.";class o extends Error{constructor(n){super(ve);f(this,"detail");this.name="VpResponseValidationError",this.detail=n}}const T=64;function x(t){return typeof t=="string"&&t.length>0&&$.HEX_RE.test(t)}function ie(t){return typeof t=="string"&&t.length>0}function se(t,e){if(!x(t))throw new o(`VP response validation failed: "${e}" must be a non-empty hex string, got ${l(t)}`)}function _(t,e){if(!ie(t))throw new o(`VP response validation failed: "${e}" must be a non-empty string, got ${l(t)}`)}function X(t,e){if(!x(t)||t.length!==m.X_ONLY_PUBKEY_HEX_LEN&&t.length!==m.COMPRESSED_PUBKEY_HEX_LEN)throw new o(`VP response validation failed: "${e}" must be a ${m.X_ONLY_PUBKEY_HEX_LEN} or ${m.COMPRESSED_PUBKEY_HEX_LEN}-char hex string (BTC pubkey), got ${l(t)}`)}function xe(t){const e=t.presigning;if(e==null)return;if(typeof e!="object"||Array.isArray(e))throw new o('VP response validation failed: "progress.presigning" must be an object if present');const n=e;if(n.depositor_graph_created!==void 0&&typeof n.depositor_graph_created!="boolean")throw new o(`VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${l(n.depositor_graph_created)}`);if(n.vk_challenger_presigning_completed!==void 0&&typeof n.vk_challenger_presigning_completed!="number")throw new o(`VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${l(n.vk_challenger_presigning_completed)}`);if(n.vk_challenger_presigning_total!==void 0&&typeof n.vk_challenger_presigning_total!="number")throw new o(`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${l(n.vk_challenger_presigning_total)}`)}function oe(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: getPeginStatus response is not an object");const e=t;if(!x(e.pegin_txid)||e.pegin_txid.length!==T)throw new o(`VP response validation failed: "pegin_txid" must be a ${T}-char hex string (txid), got ${l(e.pegin_txid)}`);if(typeof e.status!="string")throw new o('VP response validation failed: "status" must be a string');if(!W.has(e.status))throw new o(`VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...W].join(", ")}`);if(e.progress===null||typeof e.progress!="object"||Array.isArray(e.progress))throw new o('VP response validation failed: "progress" must be an object');if(xe(e.progress),typeof e.health_info!="string")throw new o('VP response validation failed: "health_info" must be a string');if(e.last_error!==void 0&&typeof e.last_error!="string")throw new o(`VP response validation failed: "last_error" must be a string if present, got ${l(e.last_error)}`)}function Ve(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: requestDepositorPresignTransactions response is not an object");const e=t;if(!Array.isArray(e.txs))throw new o('VP response validation failed: "txs" must be an array');for(let n=0;n<e.txs.length;n++)Ae(e.txs[n],`txs[${n}]`);if(e.depositor_graph===null||typeof e.depositor_graph!="object")throw new o('VP response validation failed: "depositor_graph" must be an object');Ee(e.depositor_graph)}function y(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);se(t.tx_hex,`${e}.tx_hex`)}function Ae(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);const n=t;X(n.claimer_pubkey,`${e}.claimer_pubkey`),y(n.claim_tx,`${e}.claim_tx`),y(n.assert_tx,`${e}.assert_tx`),y(n.payout_tx,`${e}.payout_tx`),_(n.payout_psbt,`${e}.payout_psbt`)}function Ce(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);const n=t;_(n.wots_pks_json,`${e}.wots_pks_json`),_(n.gc_wots_keys_json,`${e}.gc_wots_keys_json`)}function Te(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "${e}" must be an object`);const n=t;if(X(n.challenger_pubkey,`${e}.challenger_pubkey`),y(n.challenge_assert_x_tx,`${e}.challenge_assert_x_tx`),y(n.challenge_assert_y_tx,`${e}.challenge_assert_y_tx`),y(n.nopayout_tx,`${e}.nopayout_tx`),_(n.nopayout_psbt,`${e}.nopayout_psbt`),!Array.isArray(n.challenge_assert_connectors))throw new o(`VP response validation failed: "${e}.challenge_assert_connectors" must be an array`);for(let r=0;r<n.challenge_assert_connectors.length;r++)Ce(n.challenge_assert_connectors[r],`${e}.challenge_assert_connectors[${r}]`);if(!Array.isArray(n.output_label_hashes))throw new o(`VP response validation failed: "${e}.output_label_hashes" must be an array`);for(let r=0;r<n.output_label_hashes.length;r++)se(n.output_label_hashes[r],`${e}.output_label_hashes[${r}]`)}function ae(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: requestDepositorClaimerArtifacts response is not an object");const e=t;if(!ie(e.tx_graph_json))throw new o(`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${l(e.tx_graph_json)}`);if(!x(e.verifying_key_hex))throw new o(`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${l(e.verifying_key_hex)}`);if(e.babe_sessions===null||typeof e.babe_sessions!="object"||Array.isArray(e.babe_sessions))throw new o('VP response validation failed: "babe_sessions" must be an object');const n=Object.entries(e.babe_sessions);if(n.length===0)throw new o('VP response validation failed: "babe_sessions" must contain at least one challenger entry');for(const[r,s]of n){if(X(r,`babe_sessions["${r}"]`),s===null||typeof s!="object")throw new o(`VP response validation failed: "babe_sessions.${r}" must be an object`);const i=s;if(!x(i.decryptor_artifacts_hex))throw new o(`VP response validation failed: "babe_sessions.${r}.decryptor_artifacts_hex" must be a non-empty hex string, got ${l(i.decryptor_artifacts_hex)}`)}}function $e(t){if(t===null||typeof t!="object")throw new o("VP response validation failed: pegout status payload is not an object");const e=t;if(!x(e.pegin_txid)||e.pegin_txid.length!==T)throw new o(`VP response validation failed: "pegin_txid" must be a ${T}-char hex string (txid), got ${l(e.pegin_txid)}`);if(typeof e.found!="boolean")throw new o(`VP response validation failed: "found" must be a boolean, got ${l(e.found)}`);if(e.claimer!==null){if(typeof e.claimer!="object")throw new o(`VP response validation failed: "claimer" must be an object or null, got ${l(e.claimer)}`);Ie(e.claimer)}if(!Array.isArray(e.challengers))throw new o(`VP response validation failed: "challengers" must be an array, got ${l(e.challengers)}`);for(let n=0;n<e.challengers.length;n++)Se(e.challengers[n],n)}function Ie(t){if(_(t.status,"claimer.status"),typeof t.failed!="boolean")throw new o(`VP response validation failed: "claimer.failed" must be a boolean, got ${l(t.failed)}`);if(_(t.claim_txid,"claimer.claim_txid"),_(t.claimer_pubkey,"claimer.claimer_pubkey"),_(t.assert_txid,"claimer.assert_txid"),typeof t.created_at!="number")throw new o(`VP response validation failed: "claimer.created_at" must be a number, got ${l(t.created_at)}`);if(typeof t.updated_at!="number")throw new o(`VP response validation failed: "claimer.updated_at" must be a number, got ${l(t.updated_at)}`)}function Se(t,e){if(t===null||typeof t!="object")throw new o(`VP response validation failed: "challengers[${e}]" must be an object, got ${l(t)}`);const n=t;if(_(n.status,`challengers[${e}].status`),_(n.claim_txid,`challengers[${e}].claim_txid`),_(n.claimer_pubkey,`challengers[${e}].claimer_pubkey`),E(n.assert_txid,`challengers[${e}].assert_txid`),E(n.challenge_assert_x_txid,`challengers[${e}].challenge_assert_x_txid`),E(n.challenge_assert_y_txid,`challengers[${e}].challenge_assert_y_txid`),E(n.nopayout_txid,`challengers[${e}].nopayout_txid`),typeof n.created_at!="number")throw new o(`VP response validation failed: "challengers[${e}].created_at" must be a number, got ${l(n.created_at)}`);if(typeof n.updated_at!="number")throw new o(`VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${l(n.updated_at)}`)}function E(t,e){if(t!==null&&typeof t!="string")throw new o(`VP response validation failed: "${e}" must be a string or null, got ${l(t)}`)}function ke(t){ce(t,"batchGetPeginStatus",e=>{e.result!==null&&oe(e.result)})}function Be(t){ce(t,"batchGetPegoutStatus",e=>{e.result!==null&&$e(e.result)})}function ce(t,e,n){if(t===null||typeof t!="object")throw new o(`VP response validation failed: ${e} response is not an object`);const r=t;if(!Array.isArray(r.results))throw new o(`VP response validation failed: "${e}.results" must be an array, got ${l(r.results)}`);for(let s=0;s<r.results.length;s++){const i=r.results[s];if(i===null||typeof i!="object")throw new o(`VP response validation failed: "${e}.results[${s}]" must be an object, got ${l(i)}`);const a=i;if(!x(a.pegin_txid)||a.pegin_txid.length!==T)throw new o(`VP response validation failed: "${e}.results[${s}].pegin_txid" must be a ${T}-char hex string, got ${l(a.pegin_txid)}`);if(a.error!==null&&typeof a.error!="string")throw new o(`VP response validation failed: "${e}.results[${s}].error" must be a string or null, got ${l(a.error)}`);if(a.result===null&&a.error===null)throw new o(`VP response validation failed: "${e}.results[${s}]" has neither "result" nor "error" populated`);if(a.result!==null&&a.error!==null)throw new o(`VP response validation failed: "${e}.results[${s}]" has both "result" and "error" populated`);n(a,s)}}function Ee(t){if(y(t.claim_tx,"depositor_graph.claim_tx"),y(t.assert_tx,"depositor_graph.assert_tx"),y(t.payout_tx,"depositor_graph.payout_tx"),_(t.payout_psbt,"depositor_graph.payout_psbt"),!Array.isArray(t.challenger_presign_data))throw new o('VP response validation failed: "depositor_graph.challenger_presign_data" must be an array');for(let e=0;e<t.challenger_presign_data.length;e++)Te(t.challenger_presign_data[e],`depositor_graph.challenger_presign_data[${e}]`);if(typeof t.offchain_params_version!="number")throw new o('VP response validation failed: "depositor_graph.offchain_params_version" must be a number')}const Re=6e4;class le{constructor(e,n){f(this,"client");const r={baseUrl:e,timeout:(n==null?void 0:n.timeout)??Re,retries:n==null?void 0:n.retries,retryDelay:n==null?void 0:n.retryDelay,retryableFor:n==null?void 0:n.retryableFor,headers:n==null?void 0:n.headers,tokenProvider:n==null?void 0:n.tokenProvider,maxResponseBytes:n==null?void 0:n.maxResponseBytes};this.client=new U.JsonRpcClient(r)}async requestDepositorPresignTransactions(e,n){const r=await this.client.call("vaultProvider_requestDepositorPresignTransactions",e,n);return Ve(r),r}async submitDepositorPresignatures(e,n){return this.client.call("vaultProvider_submitDepositorPresignatures",e,n)}async submitDepositorWotsKey(e,n){return this.client.call("vaultProvider_submitDepositorWotsKey",e,n)}async requestDepositorClaimerArtifacts(e,n){const r=await this.client.call("vaultProvider_requestDepositorClaimerArtifacts",e,n);return ae(r),r}async getPeginStatus(e,n){const r=await this.client.call("vaultProvider_getPeginStatus",e,n);return oe(r),r}async batchGetPeginStatus(e,n){const r=await this.client.call("vaultProvider_batchGetPeginStatus",e,n);return ke(r),r}async batchGetPegoutStatus(e,n){const r=await this.client.call("vaultProvider_batchGetPegoutStatus",e,n);return Be(r),r}}function Ne(t,e){const n=new Set;for(const u of t)n.add(u.toLowerCase());const r=new Map,s=new Set,i=[],a=[];for(const u of e){const d=u.pegin_txid.toLowerCase();if(!n.has(d)){a.push(d);continue}if(s.has(d)){i.push(d);continue}s.add(d),r.set(d,{result:u.result,error:u.error})}const c=[];for(const u of n)s.has(u)||c.push(u);return{byTxid:r,missing:c,unexpected:a,duplicate:i}}async function He(t){const{items:e,getTxid:n,batchCall:r,onItem:s,onMissing:i,onDuplicate:a,onDuplicateBatch:c,onWholeBatchError:u,onUnexpected:d,batchSize:b=U.VP_BATCH_MAX_SIZE}=t;if(!Number.isInteger(b)||b<=0)throw new Error(`batchPollByProvider: batchSize must be a positive integer, got ${b}`);for(let w=0;w<e.length;w+=b){const V=e.slice(w,w+b),S=new Map,L=[];for(const h of V){const P=n(h).toLowerCase();S.set(P,h),L.push(P)}let A;try{const h=await r(L);A=Ne(L,h.results)}catch(h){u(V,h);continue}d&&A.unexpected.length>0&&d(A.unexpected);const k=new Set(A.duplicate);for(const h of k){const P=S.get(h);P&&a(P)}c&&k.size>0&&c(k.size);for(const h of A.missing){const P=S.get(h);P&&i(P)}for(const[h,P]of A.byTxid){if(k.has(h))continue;const z=S.get(h);z&&s(z,{pegin_txid:h,result:P.result,error:P.error})}}}const Oe="BIP0322-signed-message",De="TapTweak",ue=32,je=64;function de(t,e){const n=new TextEncoder().encode(t),r=Y.sha256(n),s=new Uint8Array(r.length*2+e.length);return s.set(r,0),s.set(r,r.length),s.set(e,r.length*2),Y.sha256(s)}function Ue(t){if(t.length!==ue)return null;const e=de(De,t),n=K.xOnlyPointAddTweak(t,e);return n?n.xOnlyPubkey:null}function Ke(t,e,n){if(e.length!==ue||n.length!==je)return!1;try{const r=de(Oe,t),s=B.payments.p2tr({internalPubkey:C.Buffer.from(e)});if(!s.output)return!1;const i=s.output,a=0,c=new B.Transaction;c.version=0,c.locktime=0;const u=C.Buffer.concat([C.Buffer.from([0,32]),C.Buffer.from(r)]);c.addInput(C.Buffer.alloc(32,0),4294967295,0,u),c.addOutput(i,a);const d=new B.Transaction;d.version=0,d.locktime=0;const b=c.getHash();d.addInput(b,0,0),d.addOutput(C.Buffer.from([106]),a);const w=d.hashForWitnessV1(0,[i],[a],B.Transaction.SIGHASH_DEFAULT),V=Ue(e);return V?K.verifySchnorr(w,V,n):!1}catch{return!1}}function O(t,e){const n=(t&7)<<5,r=typeof e=="bigint"?e:BigInt(e);if(r<0n)throw new Error("cborHead: negative argument");if(r<24n)return new Uint8Array([n|Number(r)]);if(r<0x100n)return new Uint8Array([n|24,Number(r)]);if(r<0x10000n){const i=Number(r);return new Uint8Array([n|25,i>>>8&255,i&255])}if(r<0x100000000n){const i=Number(r);return new Uint8Array([n|26,i>>>24&255,i>>>16&255,i>>>8&255,i&255])}const s=new Uint8Array(9);s[0]=n|27;for(let i=7;i>=0;i--)s[1+i]=Number(r>>BigInt((7-i)*8))&255;return s}function he(...t){const e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Q(t){const n=[O(4,t.length)];for(const r of t)n.push(O(0,r));return he(...n)}function Le(t,e,n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${n}`);const r=O(4,3),s=Q(t),i=Q(e),a=O(0,n);return he(r,s,i,a)}const Fe=new TextEncoder().encode("btc-auth.server-identity.v1"),Me=2*3600;class p extends Error{constructor(e,n){super(e),this.reason=n,this.name="ServerIdentityError"}}function R(t){const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function pe(t){const{proof:e,pinnedServerPubkey:n,now:r}=t,s=t.maxLifetimeSecs??Me,i=m.stripHexPrefix(n).toLowerCase();if(i.length!==m.X_ONLY_PUBKEY_HEX_LEN||!$.HEX_RE.test(i))throw new p(`pinnedServerPubkey must be 32-byte hex; got ${i.length} chars`,"invalid_pubkey_encoding");const a=m.stripHexPrefix(e.server_pubkey).toLowerCase();if(a.length!==m.X_ONLY_PUBKEY_HEX_LEN||!$.HEX_RE.test(a))throw new p(`server_pubkey must be 32-byte hex; got ${a.length} chars`,"invalid_pubkey_encoding");if(a!==i)throw new p(`server_pubkey does not match pinned value: expected ${i}, got ${a}`,"pinned_pubkey_mismatch");if(!Number.isSafeInteger(e.expires_at))throw new p(`expires_at must be a finite integer; got ${JSON.stringify(e.expires_at)}`,"invalid_expires_at");if(!Number.isSafeInteger(r))throw new p(`now must be a finite integer; got ${JSON.stringify(r)}`,"invalid_expires_at");if(e.expires_at<=r)throw new p(`server identity proof expired at ${e.expires_at}, now ${r}`,"expired");if(!Number.isSafeInteger(s)||s<=0)throw new p(`maxLifetimeSecs must be a positive safe integer; got ${JSON.stringify(s)}`,"invalid_max_lifetime");if(e.expires_at-r>s)throw new p(`server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${r}, max lifetime=${s}s`,"expires_too_far");const c=m.stripHexPrefix(e.ephemeral_pubkey).toLowerCase();if(c.length!==m.COMPRESSED_PUBKEY_HEX_LEN||!$.HEX_RE.test(c))throw new p(`ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,"invalid_ephemeral_pubkey");const u=c.slice(0,2);if(u!=="02"&&u!=="03")throw new p(`ephemeral_pubkey must be compressed (prefix 02/03); got ${u}`,"invalid_ephemeral_pubkey");const d=R(c);if(!K.isPoint(d))throw new p("ephemeral_pubkey is not a valid secp256k1 point","invalid_ephemeral_pubkey");const b=m.stripHexPrefix(e.signature).toLowerCase();if(b.length!==m.SCHNORR_SIG_HEX_LEN||!$.HEX_RE.test(b))throw new p(`signature must be 64-byte Schnorr hex; got ${b.length} chars`,"invalid_signature_encoding");const w=Le(Fe,R(c),e.expires_at);if(!Ke(w,R(a),R(b)))throw new p("BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey","signature_verification_failed")}const Xe=new Set(["vaultProvider_submitDepositorWotsKey","vaultProvider_submitDepositorPresignatures","vaultProvider_requestDepositorPresignTransactions","vaultProvider_requestDepositorClaimerArtifacts"]),Ge=6e4,M="auth_createDepositorToken";function ge(t,e){return new U.JsonRpcClient({baseUrl:t,timeout:Ge,headers:e,retryableFor:n=>n===M})}const J=4102444800,qe=30;class ze{constructor(e){f(this,"client");f(this,"peginTxid");f(this,"authAnchorHex");f(this,"pinnedServerPubkey");f(this,"authGatedMethods");f(this,"refreshSkewSecs");f(this,"now");f(this,"cached",null);f(this,"inFlight",null);this.client=e.client,this.peginTxid=e.peginTxid,this.authAnchorHex=e.authAnchorHex,this.pinnedServerPubkey=e.pinnedServerPubkey,this.authGatedMethods=e.authGatedMethods,this.refreshSkewSecs=e.refreshSkewSecs??qe,this.now=e.now??(()=>Math.floor(Date.now()/1e3))}async getToken(e){if(e===M||!this.authGatedMethods.has(e))return null;const n=this.cached;return n&&this.now()+this.refreshSkewSecs<n.expiresAt?n.token:(await this.acquireSingleFlight()).token}invalidate(){this.cached=null}setClient(e){this.client=e}acquireSingleFlight(){const e=this.inFlight;if(e)return e;const n=(async()=>{try{const r=await this.client.call(M,{pegin_txid:this.peginTxid,auth_anchor:this.authAnchorHex});if(pe({proof:r.server_identity,pinnedServerPubkey:this.pinnedServerPubkey,now:this.now()}),typeof r.token!="string"||r.token.length===0)throw new Error(`VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof r.token})`);const s=this.now();if(!Number.isSafeInteger(r.expires_at)||r.expires_at<=s||r.expires_at>J)throw new Error(`VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(r.expires_at)}; must be a safe integer in (${s}, ${J}])`);const i={token:r.token,expiresAt:r.expires_at};return this.cached=i,i}finally{this.inFlight=null}})();return this.inFlight=n,n}}class fe{constructor(){f(this,"entries",new Map)}getOrCreate(e){const n=this.entries.get(e.peginTxid);if(n){if(n.authAnchorHex!==e.authAnchorHex)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to authAnchorHex ${n.authAnchorHex.slice(0,8)}…; got ${e.authAnchorHex.slice(0,8)}…`);if(n.pinnedServerPubkey!==e.pinnedServerPubkey)throw new Error(`VpTokenRegistry: peginTxid ${e.peginTxid} already bound to pinnedServerPubkey ${n.pinnedServerPubkey.slice(0,8)}…; got ${e.pinnedServerPubkey.slice(0,8)}…`);return n.provider.setClient(e.client),n.provider}const r=new ze({client:e.client,peginTxid:e.peginTxid,authAnchorHex:e.authAnchorHex,pinnedServerPubkey:e.pinnedServerPubkey,authGatedMethods:Xe});return this.entries.set(e.peginTxid,{provider:r,authAnchorHex:e.authAnchorHex,pinnedServerPubkey:e.pinnedServerPubkey}),r}peek(e){var n;return(n=this.entries.get(e))==null?void 0:n.provider}release(e){this.entries.delete(e)}clear(){this.entries.clear()}get size(){return this.entries.size}}const G=new fe;function Ye(t){var r;const e=ge(t.baseUrl,(r=t.options)==null?void 0:r.headers),n=G.getOrCreate({client:e,peginTxid:t.peginTxid,authAnchorHex:t.authAnchorHex,pinnedServerPubkey:t.pinnedServerPubkey});return new le(t.baseUrl,{...t.options,tokenProvider:n})}function We(t){G.getOrCreate({client:ge(t.baseUrl,t.headers),peginTxid:t.peginTxid,authAnchorHex:t.authAnchorHex,pinnedServerPubkey:t.pinnedServerPubkey})}async function Qe(t,e){const[n,r]=await t.multicall({contracts:[{address:e,abi:v.BTCVaultRegistryABI,functionName:"protocolParams"},{address:e,abi:v.BTCVaultRegistryABI,functionName:"applicationRegistry"}],allowFailure:!1});return{protocolParams:n,applicationRegistry:r}}const F=65535,Z=1e4,D=4294967295,ee=255;function H(t){if(!Number.isInteger(t)||t<0||t>D)throw new Error(`Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`)}function I(t){const e=[];if(t.timelockAssert<=0n&&e.push(`timelockAssert must be positive, got ${t.timelockAssert}`),t.timelockAssert>BigInt(F)&&e.push(`timelockAssert ${t.timelockAssert} exceeds uint16 max (${F})`),t.timelockChallengeAssert<=0n&&e.push(`timelockChallengeAssert must be positive, got ${t.timelockChallengeAssert}`),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(`councilQuorum (${t.councilQuorum}) exceeds securityCouncilKeys count (${t.securityCouncilKeys.length})`),t.feeRate<=0n&&e.push(`feeRate must be positive, got ${t.feeRate}`),t.minPeginFeeRate<=0n&&e.push(`minPeginFeeRate must be positive, got ${t.minPeginFeeRate}`),(!Number.isInteger(t.proverCircuitVersion)||t.proverCircuitVersion<0||t.proverCircuitVersion>F)&&e.push(`proverCircuitVersion must be a uint16, got ${t.proverCircuitVersion}`),(!Number.isInteger(t.minPrepeginDepth)||t.minPrepeginDepth<=0||t.minPrepeginDepth>D)&&e.push(`minPrepeginDepth must be a uint32 in [1, ${D}], got ${t.minPrepeginDepth}`),t.babeTotalInstances<=0&&e.push(`babeTotalInstances must be positive, got ${t.babeTotalInstances}`),t.babeInstancesToFinalize<=0&&e.push(`babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`),t.babeInstancesToFinalize>t.babeTotalInstances&&e.push(`babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`),(t.minVpCommissionBps<0||t.minVpCommissionBps>Z)&&e.push(`minVpCommissionBps must be in [0, ${Z}], got ${t.minVpCommissionBps}`),e.length>0)throw new Error(`Invalid offchain protocol parameters: ${e.join("; ")}`)}function q(t){const e=[];if(t.minimumPegInAmount<=0n&&e.push(`minimumPegInAmount must be positive, got ${t.minimumPegInAmount}`),t.maxPegInAmount<t.minimumPegInAmount&&e.push(`maxPegInAmount (${t.maxPegInAmount}) must be >= minimumPegInAmount (${t.minimumPegInAmount})`),t.pegInAckTimeout<=0n&&e.push(`pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`),t.pegInActivationTimeout<=0n&&e.push(`pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`),(!Number.isInteger(t.maxHtlcOutputCount)||t.maxHtlcOutputCount<=0||t.maxHtlcOutputCount>ee)&&e.push(`maxHtlcOutputCount must be an integer in [1, ${ee}], got ${t.maxHtlcOutputCount}`),(typeof t.expiredPegInGraceBlocks!="bigint"||t.expiredPegInGraceBlocks<=0n)&&e.push(`expiredPegInGraceBlocks must be a positive bigint, got ${t.expiredPegInGraceBlocks}`),e.length>0)throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`)}function me(t){if(q(t),I(t.offchainParams),!Number.isInteger(t.offchainParamsVersion)||t.offchainParamsVersion<0||t.offchainParamsVersion>D)throw new Error(`Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`)}const te=65535;function N(t){return{timelockAssert:t.timelockAssert,timelockChallengeAssert:t.timelockChallengeAssert,securityCouncilKeys:[...t.securityCouncilKeys],councilQuorum:t.councilQuorum,feeRate:t.feeRate,babeTotalInstances:t.babeTotalInstances,babeInstancesToFinalize:t.babeInstancesToFinalize,minVpCommissionBps:t.minVpCommissionBps,tRefund:t.tRefund,tStale:t.tStale,minPeginFeeRate:t.minPeginFeeRate,proverCircuitVersion:t.proverCircuitVersion,minPrepeginDepth:t.minPrepeginDepth}}function ne(t){return{minimumPegInAmount:t.minimumPegInAmount,maxPegInAmount:t.maxPegInAmount,pegInAckTimeout:t.pegInAckTimeout,pegInActivationTimeout:t.pegInActivationTimeout,maxHtlcOutputCount:t.maxHtlcOutputCount,expiredPegInGraceBlocks:t.expiredPegInGraceBlocks}}function re(t){if(t>BigInt(te))throw new Error(`timelockAssert value ${t} exceeds uint16 max (${te})`);return Number(t)}class Je{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getTBVProtocolParams(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getTBVProtocolParams"}),n=ne(e);return q(n),n}async getLatestOffchainParams(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getLatestOffchainParams"}),n=N(e);return I(n),n}async getOffchainParamsByVersion(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getOffchainParamsByVersion",args:[e]}),r=N(n);return I(r),r}async getLatestOffchainParamsVersion(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"latestOffchainParamsVersion"}),n=Number(e);return H(n),n}async getTimelockPeginByVersion(e){const n=await this.getOffchainParamsByVersion(e);return re(n.timelockAssert)}async getPegInConfiguration(){const e=await this.publicClient.multicall({contracts:[{address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getTBVProtocolParams"},{address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getLatestOffchainParams"},{address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"latestOffchainParamsVersion"}],allowFailure:!1}),n=ne(e[0]),r=N(e[1]),s=Number(e[2]),i={minimumPegInAmount:n.minimumPegInAmount,maxPegInAmount:n.maxPegInAmount,pegInAckTimeout:n.pegInAckTimeout,pegInActivationTimeout:n.pegInActivationTimeout,maxHtlcOutputCount:n.maxHtlcOutputCount,expiredPegInGraceBlocks:n.expiredPegInGraceBlocks,timelockPegin:re(r.timelockAssert),timelockRefund:r.tRefund,minVpCommissionBps:r.minVpCommissionBps,offchainParams:r,offchainParamsVersion:s};return me(i),i}async fetchAllOffchainParams(e){const n=await this.getLatestOffchainParamsVersion();if(n===0)return{byVersion:new Map,latestVersion:0};const r=Array.from({length:n},(c,u)=>u+1),s=r.map(c=>({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getOffchainParamsByVersion",args:[c]})),i=await this.publicClient.multicall({contracts:s,allowFailure:!1}),a=new Map;for(let c=0;c<r.length;c++){const u=N(i[c]);try{I(u),a.set(r[c],u)}catch(d){e==null||e(r[c],d instanceof Error?d:new Error(String(d)))}}return{byVersion:a,latestVersion:n}}}function j(t){return t.map(e=>({ethAddress:e.ethAddress,btcPubKey:e.btcPubKey}))}class Ze{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getVaultKeepersByVersion(e,n){const r=await this.publicClient.readContract({address:this.contractAddress,abi:g.ApplicationRegistryABI,functionName:"getVaultKeepersByVersion",args:[e,n]});return j(r)}async getCurrentVaultKeepers(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:g.ApplicationRegistryABI,functionName:"getCurrentVaultKeepers",args:[e]});return j(n)}async getCurrentVaultKeepersVersion(e){return await this.publicClient.readContract({address:this.contractAddress,abi:g.ApplicationRegistryABI,functionName:"getCurrentVaultKeepersVersion",args:[e]})}}class et{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getUniversalChallengersByVersion(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getUniversalChallengersByVersion",args:[e]});return j(n)}async getCurrentUniversalChallengers(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getCurrentUniversalChallengers"});return j(e)}async getLatestUniversalChallengersVersion(){return await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"latestUniversalChallengersVersion"})}}class tt{constructor(e,n){this.publicClient=e,this.contractAddress=n}async getVaultProviderBtcPubKey(e){const r=(await this.publicClient.readContract({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getVaultProviderBTCKey",args:[e]})).toLowerCase();if(!/^0x[0-9a-f]{64}$/.test(r))throw new Error(`getVaultProviderBTCKey returned an unexpected value (vp=${e}, length ${r.length}, prefix "${r.slice(0,2)}")`);const s=r.slice(2);if(!K.isXOnlyPoint(m.hexToUint8Array(s)))throw new Error(`getVaultProviderBTCKey returned a value that is not on the secp256k1 curve (vp=${e})`);return s}async getVaultBasicInfo(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultBasicInfo",args:[e]});return{depositor:n.depositor,depositorBtcPubKey:n.depositorBtcPubKey,amount:n.amount,vaultProvider:n.vaultProvider,status:n.status,applicationEntryPoint:n.applicationEntryPoint,createdAt:n.createdAt}}async getVaultProtocolInfo(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultProtocolInfo",args:[e]}),r=Number(n.offchainParamsVersion);return H(r),{depositorSignedPeginTx:n.depositorSignedPeginTx,universalChallengersVersion:n.universalChallengersVersion,appVaultKeepersVersion:n.appVaultKeepersVersion,offchainParamsVersion:r,verifiedAt:n.verifiedAt,depositorWotsPkHash:n.depositorWotsPkHash,hashlock:n.hashlock,htlcVout:n.htlcVout,depositorPopSignature:n.depositorPopSignature,prePeginTxHash:n.prePeginTxHash,vaultProviderCommissionBps:n.vaultProviderCommissionBps,claimExpiredUntil:n.claimExpiredUntil,vaultCoreVersion:n.vaultCoreVersion}}async getProtocolInfoBatch(e){return e.length===0?[]:(await this.publicClient.multicall({contracts:e.map(r=>({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultProtocolInfo",args:[r]})),allowFailure:!1})).map((r,s)=>{const i=r;if(!i.depositorSignedPeginTx||i.depositorSignedPeginTx==="0x")throw new Error(`Vault ${e[s]} not found on-chain or has no pegin transaction`);const a=Number(i.offchainParamsVersion);return H(a),{depositorSignedPeginTx:i.depositorSignedPeginTx,universalChallengersVersion:i.universalChallengersVersion,appVaultKeepersVersion:i.appVaultKeepersVersion,offchainParamsVersion:a,verifiedAt:i.verifiedAt,depositorWotsPkHash:i.depositorWotsPkHash,hashlock:i.hashlock,htlcVout:i.htlcVout,depositorPopSignature:i.depositorPopSignature,prePeginTxHash:i.prePeginTxHash,vaultProviderCommissionBps:i.vaultProviderCommissionBps,claimExpiredUntil:i.claimExpiredUntil,vaultCoreVersion:i.vaultCoreVersion}})}async getPegInFee(e){return await this.publicClient.readContract({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getPegInFee",args:[e]})}async getVaultData(e){const[n,r]=await Promise.all([this.getVaultBasicInfo(e),this.getVaultProtocolInfo(e)]);if(!r.depositorSignedPeginTx||r.depositorSignedPeginTx==="0x")throw new Error(`Vault ${e} not found on-chain or has no pegin transaction`);return{basic:n,protocol:r}}async getOffchainParamsVersionsByVaultIds(e){return e.length===0?[]:(await this.publicClient.multicall({contracts:e.map(r=>({address:this.contractAddress,abi:v.BTCVaultRegistryABI,functionName:"getBtcVaultProtocolInfo",args:[r]})),allowFailure:!1})).map(r=>{const s=r;if(!s.depositorSignedPeginTx||s.depositorSignedPeginTx==="0x")throw new Error("Vault not found on-chain or has no pegin transaction while reading offchain params version");const i=Number(s.offchainParamsVersion);return H(i),i})}}exports.ServerIdentityError=p;exports.VaultProviderRpcClient=le;exports.ViemProtocolParamsReader=Je;exports.ViemUniversalChallengerReader=et;exports.ViemVaultKeeperReader=Ze;exports.ViemVaultRegistryReader=tt;exports.VpResponseValidationError=o;exports.VpTokenRegistry=fe;exports.batchPollByProvider=He;exports.createAuthenticatedVpClient=Ye;exports.primeVpTokenRegistry=We;exports.resolveProtocolAddresses=Qe;exports.validateOffchainParams=I;exports.validatePegInConfiguration=me;exports.validateRequestDepositorClaimerArtifactsResponse=ae;exports.validateTBVProtocolParams=q;exports.verifyServerIdentity=pe;exports.vpTokenRegistry=G;
2
+ //# sourceMappingURL=vault-registry-reader-BM_993Lb.cjs.map