@babylonlabs-io/ts-sdk 0.36.2 → 0.37.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 (118) hide show
  1. package/dist/PayoutManager-BxAY2x0g.cjs +2 -0
  2. package/dist/PayoutManager-BxAY2x0g.cjs.map +1 -0
  3. package/dist/{PayoutManager-s_uH8Uuj.js → PayoutManager-sfxuOBGq.js} +51 -43
  4. package/dist/PayoutManager-sfxuOBGq.js.map +1 -0
  5. package/dist/{PeginManager-CB-dVkT2.js → PeginManager-C7-XYrkK.js} +13 -14
  6. package/dist/{PeginManager-CB-dVkT2.js.map → PeginManager-C7-XYrkK.js.map} +1 -1
  7. package/dist/{PeginManager-BPXVXu8t.cjs → PeginManager-CRuwG4I-.cjs} +2 -2
  8. package/dist/{PeginManager-BPXVXu8t.cjs.map → PeginManager-CRuwG4I-.cjs.map} +1 -1
  9. package/dist/assertPsbtUnsignedTxMatches-BoHwgW30.cjs +2 -0
  10. package/dist/assertPsbtUnsignedTxMatches-BoHwgW30.cjs.map +1 -0
  11. package/dist/assertPsbtUnsignedTxMatches-D7RxpR4A.js +263 -0
  12. package/dist/assertPsbtUnsignedTxMatches-D7RxpR4A.js.map +1 -0
  13. package/dist/{bitcoin-B0S8SHCX.js → bitcoin-B5aNKtsk.js} +77 -60
  14. package/dist/{bitcoin-B0S8SHCX.js.map → bitcoin-B5aNKtsk.js.map} +1 -1
  15. package/dist/bitcoin-CHfKAhcI.cjs +2 -0
  16. package/dist/{bitcoin-B3aqjuMP.cjs.map → bitcoin-CHfKAhcI.cjs.map} +1 -1
  17. package/dist/{buildAndBroadcastRefund-C2VqXiOx.js → buildAndBroadcastRefund-C1eOhIdo.js} +322 -322
  18. package/dist/buildAndBroadcastRefund-C1eOhIdo.js.map +1 -0
  19. package/dist/buildAndBroadcastRefund-_CEDUU5H.cjs +2 -0
  20. package/dist/buildAndBroadcastRefund-_CEDUU5H.cjs.map +1 -0
  21. package/dist/{challengeAssert-Yyyj-EdR.cjs → challengeAssert-BKDS_ADt.cjs} +2 -2
  22. package/dist/{challengeAssert-Yyyj-EdR.cjs.map → challengeAssert-BKDS_ADt.cjs.map} +1 -1
  23. package/dist/{challengeAssert-BzxQmdZy.js → challengeAssert-BXESW00N.js} +7 -7
  24. package/dist/{challengeAssert-BzxQmdZy.js.map → challengeAssert-BXESW00N.js.map} +1 -1
  25. package/dist/fundPeginTransaction-BBE3wTjR.cjs +2 -0
  26. package/dist/{fundPeginTransaction-DaWoYCgO.cjs.map → fundPeginTransaction-BBE3wTjR.cjs.map} +1 -1
  27. package/dist/fundPeginTransaction-t-6TsHAY.js +84 -0
  28. package/dist/{fundPeginTransaction-oV-dNJOU.js.map → fundPeginTransaction-t-6TsHAY.js.map} +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +174 -166
  31. package/dist/{noPayout-BXeUw0Qq.cjs → noPayout-B6s8vrW6.cjs} +2 -2
  32. package/dist/{noPayout-BXeUw0Qq.cjs.map → noPayout-B6s8vrW6.cjs.map} +1 -1
  33. package/dist/{noPayout-DBX6G96_.js → noPayout-BhgknZBx.js} +2 -2
  34. package/dist/{noPayout-DBX6G96_.js.map → noPayout-BhgknZBx.js.map} +1 -1
  35. package/dist/{peginInput-tbw9BpZy.cjs → peginInput-57FK2O99.cjs} +2 -2
  36. package/dist/{peginInput-tbw9BpZy.cjs.map → peginInput-57FK2O99.cjs.map} +1 -1
  37. package/dist/{peginInput-C2QPvuhR.js → peginInput-CYJzbuwA.js} +3 -3
  38. package/dist/{peginInput-C2QPvuhR.js.map → peginInput-CYJzbuwA.js.map} +1 -1
  39. package/dist/{reservation-CHUGW0F_.js → reservation-CB-4FBPk.js} +37 -36
  40. package/dist/reservation-CB-4FBPk.js.map +1 -0
  41. package/dist/reservation-hjXStM03.cjs +2 -0
  42. package/dist/reservation-hjXStM03.cjs.map +1 -0
  43. package/dist/tbv/core/clients/index.cjs +1 -1
  44. package/dist/tbv/core/clients/index.js +1 -1
  45. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  46. package/dist/tbv/core/index.cjs +1 -1
  47. package/dist/tbv/core/index.js +172 -164
  48. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  49. package/dist/tbv/core/managers/PeginManager.d.ts +7 -8
  50. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  51. package/dist/tbv/core/managers/index.cjs +1 -1
  52. package/dist/tbv/core/managers/index.js +2 -2
  53. package/dist/tbv/core/primitives/index.cjs +1 -1
  54. package/dist/tbv/core/primitives/index.d.ts +3 -1
  55. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  56. package/dist/tbv/core/primitives/index.js +31 -27
  57. package/dist/tbv/core/primitives/psbt/__tests__/assertPsbtUnsignedTxMatches.test.d.ts +5 -0
  58. package/dist/tbv/core/primitives/psbt/__tests__/assertPsbtUnsignedTxMatches.test.d.ts.map +1 -0
  59. package/dist/tbv/core/primitives/psbt/assertPsbtUnsignedTxMatches.d.ts +31 -0
  60. package/dist/tbv/core/primitives/psbt/assertPsbtUnsignedTxMatches.d.ts.map +1 -0
  61. package/dist/tbv/core/primitives/psbt/index.d.ts +2 -0
  62. package/dist/tbv/core/primitives/psbt/index.d.ts.map +1 -1
  63. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +33 -3
  64. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
  65. package/dist/tbv/core/primitives/utils/index.d.ts +1 -1
  66. package/dist/tbv/core/primitives/utils/index.d.ts.map +1 -1
  67. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  68. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  69. package/dist/tbv/core/services/index.cjs +1 -1
  70. package/dist/tbv/core/services/index.js +2 -2
  71. package/dist/tbv/core/utils/fee/__tests__/peginFeeMath.test.d.ts +19 -0
  72. package/dist/tbv/core/utils/fee/__tests__/peginFeeMath.test.d.ts.map +1 -0
  73. package/dist/tbv/core/utils/fee/index.d.ts +1 -0
  74. package/dist/tbv/core/utils/fee/index.d.ts.map +1 -1
  75. package/dist/tbv/core/utils/fee/peginFeeMath.d.ts +99 -0
  76. package/dist/tbv/core/utils/fee/peginFeeMath.d.ts.map +1 -0
  77. package/dist/tbv/core/utils/index.cjs +1 -1
  78. package/dist/tbv/core/utils/index.js +44 -40
  79. package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -1
  80. package/dist/tbv/core/utils/utxo/reservation.d.ts +4 -1
  81. package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
  82. package/dist/tbv/core/utils/utxo/selectUtxos.d.ts.map +1 -1
  83. package/dist/tbv/index.cjs +1 -1
  84. package/dist/tbv/index.js +172 -164
  85. package/dist/testing/index.cjs +1 -1
  86. package/dist/testing/index.js +1 -1
  87. package/dist/vault-registry-reader-7gOYnrQD.cjs +2 -0
  88. package/dist/vault-registry-reader-7gOYnrQD.cjs.map +1 -0
  89. package/dist/{vault-registry-reader-CrLodprY.js → vault-registry-reader-Blhu9FW2.js} +130 -125
  90. package/dist/vault-registry-reader-Blhu9FW2.js.map +1 -0
  91. package/dist/waitForTransactionReceiptSmartAware-CmgFXFza.js +265 -0
  92. package/dist/waitForTransactionReceiptSmartAware-CmgFXFza.js.map +1 -0
  93. package/dist/waitForTransactionReceiptSmartAware-tv1mtSIY.cjs +2 -0
  94. package/dist/waitForTransactionReceiptSmartAware-tv1mtSIY.cjs.map +1 -0
  95. package/package.json +1 -1
  96. package/dist/PayoutManager-BhJoQZsG.cjs +0 -2
  97. package/dist/PayoutManager-BhJoQZsG.cjs.map +0 -1
  98. package/dist/PayoutManager-s_uH8Uuj.js.map +0 -1
  99. package/dist/bitcoin-B3aqjuMP.cjs +0 -2
  100. package/dist/buildAndBroadcastRefund-C2VqXiOx.js.map +0 -1
  101. package/dist/buildAndBroadcastRefund-CBIfcF47.cjs +0 -2
  102. package/dist/buildAndBroadcastRefund-CBIfcF47.cjs.map +0 -1
  103. package/dist/fundPeginTransaction-DaWoYCgO.cjs +0 -2
  104. package/dist/fundPeginTransaction-oV-dNJOU.js +0 -76
  105. package/dist/payout-BNFMBXS6.js +0 -193
  106. package/dist/payout-BNFMBXS6.js.map +0 -1
  107. package/dist/payout-DQ_fmJUA.cjs +0 -2
  108. package/dist/payout-DQ_fmJUA.cjs.map +0 -1
  109. package/dist/reservation-CHUGW0F_.js.map +0 -1
  110. package/dist/reservation-ho7mjW3X.cjs +0 -2
  111. package/dist/reservation-ho7mjW3X.cjs.map +0 -1
  112. package/dist/vault-registry-reader-CLnhAUN4.cjs +0 -2
  113. package/dist/vault-registry-reader-CLnhAUN4.cjs.map +0 -1
  114. package/dist/vault-registry-reader-CrLodprY.js.map +0 -1
  115. package/dist/waitForTransactionReceiptSmartAware-Cj_DKm0G.js +0 -217
  116. package/dist/waitForTransactionReceiptSmartAware-Cj_DKm0G.js.map +0 -1
  117. package/dist/waitForTransactionReceiptSmartAware-D9ykVriz.cjs +0 -2
  118. package/dist/waitForTransactionReceiptSmartAware-D9ykVriz.cjs.map +0 -1
package/dist/tbv/index.js CHANGED
@@ -1,176 +1,184 @@
1
- import { a as s, b as t, c as r } from "../challengeAssert-BzxQmdZy.js";
2
- import { computeMinClaimValue as i, deriveVaultId as n, expandAuthAnchor as l, expandHashlockSecret as u, expandWotsSeed as d } from "@babylonlabs-io/babylon-tbv-rust-wasm";
3
- import { c as P, a as c, b as T, e as S, f as E } from "../peginInput-C2QPvuhR.js";
4
- import { a as g, b as A } from "../noPayout-DBX6G96_.js";
5
- import { a as _, b as x, c as f, e as b } from "../payout-BNFMBXS6.js";
6
- import { d as I, a as V, e as C, f as O, g as U, h, i as y, b as F, p as N, s as B, t as D, u as M, v as H } from "../bitcoin-B0S8SHCX.js";
7
- import { c as k } from "../signing-DaLvGwQe.js";
8
- import { B as X, H as w, K, M as G, T as Y } from "../validation-CxqROCno.js";
9
- import { P as J, V as j, b as z, a as q, c as Q, e as $, d as aa } from "../PeginManager-CB-dVkT2.js";
10
- import { P as sa, c as ta, v as ra } from "../PayoutManager-s_uH8Uuj.js";
11
- import { A as ia, P as na } from "../ProtocolParams.abi-DXu8L0Fn.js";
12
- import { B as ua } from "../BTCVaultRegistry.abi-DbJ5lsFJ.js";
13
- import { C as pa, e as Pa, g as ca, h as Ta, i as Sa } from "../errors-CznAK5NB.js";
14
- import { B as Ra, D as ga, F as Aa, L as ma, M as _a, P as xa, b as fa, a as ba, S as va, T as Ia, W as Va, f as Ca, c as Oa, p as Ua, r as ha } from "../fundPeginTransaction-oV-dNJOU.js";
15
- import { U as Fa, a as Na, c as Ba, e as Da, s as Ma, v as Ha } from "../reservation-CHUGW0F_.js";
16
- import { B as ka, c as Wa, g as Xa, d as wa, b as Ka, s as Ga, a as Ya, w as Za } from "../waitForTransactionReceiptSmartAware-Cj_DKm0G.js";
17
- import { M as ja, g as za, a as qa, b as Qa, c as $a, d as ae, e as ee, f as se, p as te } from "../mempoolApi-CAIge7Nj.js";
18
- import { S as oe, V as ie, j as ne, k as le, l as ue, m as de, a as pe, d as Pe, b as ce, f as Te, p as Se, r as Ee, g as Re, h as ge, v as Ae, i as me, c as _e, e as xe } from "../vault-registry-reader-CrLodprY.js";
19
- import { D as be, b as ve, J as Ie, a as Ve, d as Ce, P as Oe, R as Ue, e as he, c as ye, V as Fe } from "../types-TiIjyo2b.js";
20
- import { i as Be, p as De } from "../errors-9AkghWyk.js";
21
- import { B as He, C as Le, p as ke, R as We, a as Xe, n as we, o as Ke, i as Ge, m as Ye, l as Ze, j as Je, r as je, b as ze, s as qe, v as Qe, g as $e, h as as, d as es, c as ss, e as ts, f as rs, k as os, w as is } from "../buildAndBroadcastRefund-C2VqXiOx.js";
22
- import { C as ls, P as us, c as ds, g as ps } from "../peginState-CBAlxgXk.js";
1
+ import { a as s, b as t, c as r } from "../challengeAssert-BXESW00N.js";
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 { c as P, a as c, b as T, e as S, f as g } from "../peginInput-CYJzbuwA.js";
4
+ import { a as m, b as R } from "../noPayout-BhgknZBx.js";
5
+ import { P as _, a as x, c as f, b, d as v, e as I } from "../assertPsbtUnsignedTxMatches-D7RxpR4A.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";
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-C7-XYrkK.js";
10
+ import { P as ia, c as na, v as ua } from "../PayoutManager-sfxuOBGq.js";
11
+ import { A as pa, P as da } from "../ProtocolParams.abi-DXu8L0Fn.js";
12
+ import { B as ca } from "../BTCVaultRegistry.abi-DbJ5lsFJ.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-Blhu9FW2.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-TiIjyo2b.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-C1eOhIdo.js";
22
+ import { C as gs, P as Es, c as ms, g as Rs } from "../peginState-CBAlxgXk.js";
23
23
  export {
24
- ia as ApplicationRegistryABI,
25
- He as BIP68NotMatureError,
26
- X as BITCOIN_ADDRESS_RE,
27
- ua as BTCVaultRegistryABI,
28
- Ra as BTC_DUST_SAT,
29
- ka as BitcoinScriptType,
30
- pa as CONTRACT_ERRORS,
31
- Le as ClaimerPegoutStatusValue,
32
- ls as ContractStatus,
33
- ga as DUST_THRESHOLD,
34
- be as DaemonStatus,
35
- Aa as FEE_SAFETY_MARGIN,
36
- w as HEX_RE,
37
- ve as JSON_RPC_ERROR_CODES,
38
- Ie as JsonRpcClient,
39
- Ve as JsonRpcError,
40
- K as KNOWN_SCRIPT_PREFIXES,
41
- ma as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
42
- _a as MAX_NON_LEGACY_OUTPUT_SIZE,
43
- G as MAX_REASONABLE_FEE_SATS,
44
- ja as MEMPOOL_API_URLS,
45
- xa as P2TR_INPUT_SIZE,
46
- fa as PEGIN_AUTH_ANCHOR_OUTPUTS,
47
- ba as PEGIN_FIXED_OUTPUTS,
48
- Ce as POST_WOTS_STATUSES,
49
- Oe as PRE_DEPOSITOR_SIGNATURES_STATES,
50
- sa as PayoutManager,
51
- us as PeginAction,
52
- J as PeginManager,
53
- na as ProtocolParamsABI,
54
- ke as REFUND_VSIZE,
55
- We as RegisteredVaultVersionMismatchError,
56
- Ue as RpcErrorCode,
57
- va as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
58
- oe as ServerIdentityError,
59
- Y as TXID_RE,
60
- Ia as TX_BUFFER_SIZE_OVERHEAD,
61
- Fa as UtxoNotAvailableError,
62
- j as VAULT_APP_NAME,
63
- he as VP_BATCH_MAX_SIZE,
64
- ye as VP_TERMINAL_STATUSES,
65
- Fe as VP_TRANSIENT_STATUSES,
66
- ie as VaultProviderRpcClient,
67
- ne as ViemProtocolParamsReader,
68
- le as ViemUniversalChallengerReader,
69
- ue as ViemVaultKeeperReader,
70
- de as ViemVaultRegistryReader,
71
- pe as VpResponseValidationError,
72
- Pe as VpTokenRegistry,
73
- Va as WALLET_RELAY_FEE_RATE_THRESHOLD,
74
- Xe as activateVault,
75
- _ as assertPayoutOutputMatchesRegistered,
76
- Na as assertUtxosAvailable,
77
- ce as batchPollByProvider,
78
- we as buildAndBroadcastRefund,
24
+ pa as ApplicationRegistryABI,
25
+ Ye as BIP68NotMatureError,
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,
36
+ Z as HEX_RE,
37
+ Fe as JSON_RPC_ERROR_CODES,
38
+ Be as JsonRpcClient,
39
+ Ne as JsonRpcError,
40
+ J as KNOWN_SCRIPT_PREFIXES,
41
+ Ma as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
42
+ Ha as MAX_NON_LEGACY_OUTPUT_SIZE,
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,
51
+ Es as PeginAction,
52
+ Q as PeginManager,
53
+ da as ProtocolParamsABI,
54
+ _ 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,
62
+ za as UtxoNotAvailableError,
63
+ $ as VAULT_APP_NAME,
64
+ Le as VP_BATCH_MAX_SIZE,
65
+ ke as VP_TERMINAL_STATUSES,
66
+ We as VP_TRANSIENT_STATUSES,
67
+ Te as VaultProviderRpcClient,
68
+ Se as ViemProtocolParamsReader,
69
+ ge as ViemUniversalChallengerReader,
70
+ Ee as ViemVaultKeeperReader,
71
+ me as ViemVaultRegistryReader,
72
+ Re as VpResponseValidationError,
73
+ Ae as VpTokenRegistry,
74
+ Ka as WALLET_RELAY_FEE_RATE_THRESHOLD,
75
+ ze as activateVault,
76
+ xa as applyChangeOutputPolicy,
77
+ x as assertPayoutOutputMatchesRegistered,
78
+ f as assertPsbtUnsignedTxMatches,
79
+ qa as assertUtxosAvailable,
80
+ _e as batchPollByProvider,
81
+ qe as buildAndBroadcastRefund,
79
82
  s as buildChallengeAssertPsbt,
80
83
  t as buildDepositorPayoutPsbt,
81
- z as buildFundingOutpointsCommitment,
82
- g as buildNoPayoutPsbt,
83
- x as buildPayoutPsbt,
84
+ aa as buildFundingOutpointsCommitment,
85
+ m as buildNoPayoutPsbt,
86
+ b as buildPayoutPsbt,
84
87
  P as buildPeginInputPsbt,
85
88
  c as buildPeginTxFromFundedPrePegin,
86
89
  T as buildPrePeginPsbt,
87
- A as buildRefundPsbt,
88
- q as buildVaultContext,
89
- Wa as calculateBtcTxHash,
90
- ds as canPerformAction,
91
- Ba as collectReservedUtxoRefs,
92
- ta as computeHashlock,
90
+ R as buildRefundPsbt,
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,
93
98
  i as computeMinClaimValue,
94
99
  r as computeNumLocalChallengers,
95
- Q as computeWotsBlockPublicKeysHash,
96
- Te as createAuthenticatedVpClient,
97
- f as createPayoutScript,
98
- k as createTaprootScriptPathSignOptions,
99
- I as deriveNativeSegwitAddress,
100
- V as deriveTaprootAddress,
100
+ Ia as computePeginBaseFeeSats,
101
+ sa as computeWotsBlockPublicKeysHash,
102
+ xe as createAuthenticatedVpClient,
103
+ v as createPayoutScript,
104
+ K as createTaprootScriptPathSignOptions,
105
+ V as deriveBip86ScriptPubKeyHex,
106
+ y as deriveNativeSegwitAddress,
107
+ O as deriveTaprootAddress,
101
108
  n as deriveVaultId,
102
- $ as deriveVaultRoot,
103
- aa as deriveWotsBlocksFromSeed,
104
- C as ensureHexPrefix,
105
- Ke as estimateRefundFeeSats,
106
- l as expandAuthAnchor,
107
- u as expandHashlockSecret,
108
- d as expandWotsSeed,
109
- Pa as extractErrorData,
110
- Da as extractInputsFromTransaction,
111
- b as extractPayoutSignature,
109
+ ta as deriveVaultRoot,
110
+ ra as deriveWotsBlocksFromSeed,
111
+ h as ensureHexPrefix,
112
+ Qe as estimateRefundFeeSats,
113
+ u as expandAuthAnchor,
114
+ l as expandHashlockSecret,
115
+ p as expandWotsSeed,
116
+ ga as extractErrorData,
117
+ $a as extractInputsFromTransaction,
118
+ I as extractPayoutSignature,
112
119
  S as extractPeginInputSignature,
113
- E as finalizePeginInputPsbt,
114
- O as formatSatoshisToBtc,
115
- Ca as fundPeginTransaction,
116
- za as getAddressTxs,
117
- qa as getAddressUtxos,
118
- ca as getContractErrorMessage,
119
- Xa as getDustThreshold,
120
- Qa as getMempoolApiUrl,
121
- U as getNetwork,
122
- $a as getNetworkFees,
123
- ps as getPeginProtocolState,
124
- wa as getPsbtInputFields,
125
- Ka as getScriptType,
126
- ae as getTxHex,
127
- ee as getTxInfo,
128
- se as getUtxoInfo,
129
- Ta as handleContractError,
130
- h as hexToUint8Array,
131
- y as isAddressFromPublicKey,
132
- Ge as isDepositAmountValid,
133
- Sa as isKnownContractError,
134
- Ye as isPegoutTerminalStatus,
135
- Ze as isRecognizedPegoutStatus,
136
- Je as isRegisteredVaultVersionMismatchError,
137
- F as isValidHex,
138
- Be as isWotsMismatchError,
139
- De as parseFundingOutpointsFromTx,
140
- Oa as parseUnfundedWasmTransaction,
141
- Ua as peginOutputCount,
142
- Se as primeVpTokenRegistry,
143
- N as processPublicKeyToXOnly,
144
- te as pushTx,
145
- ha as rateBasedTxBufferFee,
146
- Ee as resolveProtocolAddresses,
147
- je as runDepositorPresignFlow,
148
- Ma as selectUtxosForDeposit,
149
- Ga as selectUtxosForPegin,
150
- Ya as shouldAddChangeOutput,
151
- ze as signDepositorGraph,
152
- B as stripHexPrefix,
153
- qe as submitWotsPublicKey,
154
- D as toXOnly,
155
- M as uint8ArrayToHex,
156
- Qe as validateDepositAmount,
157
- $e as validateMultiVaultDepositInputs,
158
- Re as validateOffchainParams,
159
- as as validateOnChainParticipantKeys,
160
- ge as validatePegInConfiguration,
161
- es as validateProviderSelection,
162
- ss as validateRemainingCapacity,
163
- Ae as validateRequestDepositorClaimerArtifactsResponse,
164
- ra as validateSecretAgainstHashlock,
165
- me as validateTBVProtocolParams,
166
- Ha as validateUtxosAvailable,
167
- ts as validateVaultAmounts,
168
- rs as validateVaultProviderPubkey,
169
- H as validateWalletPubkey,
170
- os as verifyRegisteredVaultVersions,
171
- _e as verifyServerIdentity,
172
- xe as vpTokenRegistry,
173
- is as waitForPeginStatus,
174
- Za as waitForTransactionReceiptSmartAware
120
+ g as finalizePeginInputPsbt,
121
+ U as formatSatoshisToBtc,
122
+ Ga as fundPeginTransaction,
123
+ re as getAddressTxs,
124
+ oe as getAddressUtxos,
125
+ Ea as getContractErrorMessage,
126
+ Ca as getDustThreshold,
127
+ ie as getMempoolApiUrl,
128
+ F as getNetwork,
129
+ ne as getNetworkFees,
130
+ Rs as getPeginProtocolState,
131
+ Va as getPsbtInputFields,
132
+ ya as getScriptType,
133
+ B as getSortedXOnlyPubkeys,
134
+ ue as getTxHex,
135
+ le as getTxInfo,
136
+ pe as getUtxoInfo,
137
+ ma as handleContractError,
138
+ N as hexToUint8Array,
139
+ D as isAddressFromPublicKey,
140
+ $e as isDepositAmountValid,
141
+ Ra as isKnownContractError,
142
+ as as isPegoutTerminalStatus,
143
+ es as isRecognizedPegoutStatus,
144
+ ss as isRegisteredVaultVersionMismatchError,
145
+ M as isValidHex,
146
+ we as isWotsMismatchError,
147
+ Ke as parseFundingOutpointsFromTx,
148
+ Ya as parseUnfundedWasmTransaction,
149
+ Za as peginOutputCount,
150
+ fe as primeVpTokenRegistry,
151
+ H as processPublicKeyToXOnly,
152
+ de as pushTx,
153
+ Ja as rateBasedTxBufferFee,
154
+ be as resolveProtocolAddresses,
155
+ ts as runDepositorPresignFlow,
156
+ ae as selectUtxosForDeposit,
157
+ Oa as selectUtxosForPegin,
158
+ ha as shouldAddChangeOutput,
159
+ rs as signDepositorGraph,
160
+ L as stripHexPrefix,
161
+ os as submitWotsPublicKey,
162
+ k as toXOnly,
163
+ 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,
177
+ X as validateWalletPubkey,
178
+ cs as verifyRegisteredVaultVersions,
179
+ ye as verifyServerIdentity,
180
+ Oe as vpTokenRegistry,
181
+ Ts as waitForPeginStatus,
182
+ Ua as waitForTransactionReceiptSmartAware
175
183
  };
176
184
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.defineProperty;var l=(i,t,e)=>t in i?d(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var r=(i,t,e)=>l(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../sha2-DsrLC4NM.cjs"),o=require("buffer"),g=require("../bitcoin-B3aqjuMP.cjs"),q=require("../shared/index.cjs"),f=async(i,t)=>{const e=new TextEncoder,n=e.encode(i),s=e.encode(t),a=new Uint8Array(4+n.length+4+s.length),c=new DataView(a.buffer);return c.setUint32(0,n.length),a.set(n,4),c.setUint32(4+n.length,s.length),a.set(s,4+n.length+4),g.uint8ArrayToHex(u.sha256(a))},h={publicKeyHex:"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",address:"tb1pqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx6jks",network:q.BitcoinNetworks.SIGNET,shouldFailSigning:!1,deriveContextHash:f};class b{constructor(t={}){r(this,"config");this.config={...h,...t.publicKeyHex?{publicKeyHex:t.publicKeyHex}:{},...t.address?{address:t.address}:{},...t.network!==void 0?{network:t.network}:{},...t.shouldFailSigning!==void 0?{shouldFailSigning:t.shouldFailSigning}:{},...t.deriveContextHash?{deriveContextHash:t.deriveContextHash}:{}}}async getPublicKeyHex(){return this.config.publicKeyHex}async getAddress(){return this.config.address}async signPsbt(t){if(this.config.shouldFailSigning)throw new Error("Mock signing failed");if(!t||t.length===0)throw new Error("Invalid PSBT: empty hex string");return t+"deadbeef"}async signPsbts(t,e){const n=[];for(const s of t){const a=await this.signPsbt(s);n.push(a)}return n}async signMessage(t,e){if(this.config.shouldFailSigning)throw new Error("Mock signing failed");if(!t||t.length===0)throw new Error("Invalid message: empty string");return o.Buffer.from(`mock-signature-${e}-${t}-${this.config.publicKeyHex}`).toString("base64")}async getNetwork(){return this.config.network}async deriveContextHash(t,e){return this.config.deriveContextHash(t,e)}updateConfig(t){this.config={...this.config,...t}}reset(){this.config={...h}}}class y{constructor(t={}){r(this,"account");r(this,"chain");r(this,"shouldFailOperations");r(this,"transactionDelay");r(this,"nonce",0);this.account={address:t.address||"0x742d35cc6634c0532925a3b844bc9e7595f0beb0"},this.chain={id:t.chainId??11155111},this.shouldFailOperations=t.shouldFailOperations??!1,this.transactionDelay=t.transactionDelay??0,this.signMessage=this.signMessage.bind(this),this.sendTransaction=this.sendTransaction.bind(this)}async signMessage(t){const e=t.message,n=t.account||this.account.address;if(this.shouldFailOperations)throw new Error("Mock signing failed");if(!e||e.length===0)throw new Error("Invalid message: empty string");const s=`personal_sign:${e}-${n}-${this.chain.id}`;return`0x${o.Buffer.from(s).toString("hex").slice(0,130).padEnd(130,"0")}`}async sendTransaction(t){var s;if(this.shouldFailOperations)throw new Error("Mock transaction failed");if(!t.to)throw new Error("Invalid transaction: missing 'to' address");this.transactionDelay>0&&await new Promise(a=>setTimeout(a,this.transactionDelay)),this.nonce++;const e=JSON.stringify({from:this.account.address,to:t.to,value:((s=t.value)==null?void 0:s.toString())||"0",nonce:this.nonce,chainId:this.chain.id});return`0x${o.Buffer.from(e).toString("hex").slice(0,64).padEnd(64,"0")}`}updateConfig(t){t.address!==void 0&&(this.account.address=t.address),t.chainId!==void 0&&(this.chain.id=t.chainId),t.shouldFailOperations!==void 0&&(this.shouldFailOperations=t.shouldFailOperations),t.transactionDelay!==void 0&&(this.transactionDelay=t.transactionDelay)}reset(){this.account.address="0x742d35cc6634c0532925a3b844bc9e7595f0beb0",this.chain.id=11155111,this.shouldFailOperations=!1,this.transactionDelay=0,this.nonce=0}getCurrentNonce(){return this.nonce}}exports.MockBitcoinWallet=b;exports.MockEthereumWallet=y;
1
+ "use strict";var d=Object.defineProperty;var l=(i,t,e)=>t in i?d(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var r=(i,t,e)=>l(i,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../sha2-DsrLC4NM.cjs"),o=require("buffer"),g=require("../bitcoin-CHfKAhcI.cjs"),q=require("../shared/index.cjs"),f=async(i,t)=>{const e=new TextEncoder,n=e.encode(i),s=e.encode(t),a=new Uint8Array(4+n.length+4+s.length),c=new DataView(a.buffer);return c.setUint32(0,n.length),a.set(n,4),c.setUint32(4+n.length,s.length),a.set(s,4+n.length+4),g.uint8ArrayToHex(u.sha256(a))},h={publicKeyHex:"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",address:"tb1pqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkx6jks",network:q.BitcoinNetworks.SIGNET,shouldFailSigning:!1,deriveContextHash:f};class b{constructor(t={}){r(this,"config");this.config={...h,...t.publicKeyHex?{publicKeyHex:t.publicKeyHex}:{},...t.address?{address:t.address}:{},...t.network!==void 0?{network:t.network}:{},...t.shouldFailSigning!==void 0?{shouldFailSigning:t.shouldFailSigning}:{},...t.deriveContextHash?{deriveContextHash:t.deriveContextHash}:{}}}async getPublicKeyHex(){return this.config.publicKeyHex}async getAddress(){return this.config.address}async signPsbt(t){if(this.config.shouldFailSigning)throw new Error("Mock signing failed");if(!t||t.length===0)throw new Error("Invalid PSBT: empty hex string");return t+"deadbeef"}async signPsbts(t,e){const n=[];for(const s of t){const a=await this.signPsbt(s);n.push(a)}return n}async signMessage(t,e){if(this.config.shouldFailSigning)throw new Error("Mock signing failed");if(!t||t.length===0)throw new Error("Invalid message: empty string");return o.Buffer.from(`mock-signature-${e}-${t}-${this.config.publicKeyHex}`).toString("base64")}async getNetwork(){return this.config.network}async deriveContextHash(t,e){return this.config.deriveContextHash(t,e)}updateConfig(t){this.config={...this.config,...t}}reset(){this.config={...h}}}class y{constructor(t={}){r(this,"account");r(this,"chain");r(this,"shouldFailOperations");r(this,"transactionDelay");r(this,"nonce",0);this.account={address:t.address||"0x742d35cc6634c0532925a3b844bc9e7595f0beb0"},this.chain={id:t.chainId??11155111},this.shouldFailOperations=t.shouldFailOperations??!1,this.transactionDelay=t.transactionDelay??0,this.signMessage=this.signMessage.bind(this),this.sendTransaction=this.sendTransaction.bind(this)}async signMessage(t){const e=t.message,n=t.account||this.account.address;if(this.shouldFailOperations)throw new Error("Mock signing failed");if(!e||e.length===0)throw new Error("Invalid message: empty string");const s=`personal_sign:${e}-${n}-${this.chain.id}`;return`0x${o.Buffer.from(s).toString("hex").slice(0,130).padEnd(130,"0")}`}async sendTransaction(t){var s;if(this.shouldFailOperations)throw new Error("Mock transaction failed");if(!t.to)throw new Error("Invalid transaction: missing 'to' address");this.transactionDelay>0&&await new Promise(a=>setTimeout(a,this.transactionDelay)),this.nonce++;const e=JSON.stringify({from:this.account.address,to:t.to,value:((s=t.value)==null?void 0:s.toString())||"0",nonce:this.nonce,chainId:this.chain.id});return`0x${o.Buffer.from(e).toString("hex").slice(0,64).padEnd(64,"0")}`}updateConfig(t){t.address!==void 0&&(this.account.address=t.address),t.chainId!==void 0&&(this.chain.id=t.chainId),t.shouldFailOperations!==void 0&&(this.shouldFailOperations=t.shouldFailOperations),t.transactionDelay!==void 0&&(this.transactionDelay=t.transactionDelay)}reset(){this.account.address="0x742d35cc6634c0532925a3b844bc9e7595f0beb0",this.chain.id=11155111,this.shouldFailOperations=!1,this.transactionDelay=0,this.nonce=0}getCurrentNonce(){return this.nonce}}exports.MockBitcoinWallet=b;exports.MockEthereumWallet=y;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -3,7 +3,7 @@ var l = (e, t, s) => t in e ? d(e, t, { enumerable: !0, configurable: !0, writab
3
3
  var o = (e, t, s) => l(e, typeof t != "symbol" ? t + "" : t, s);
4
4
  import { s as g } from "../sha2-BYVxyZzX.js";
5
5
  import { Buffer as r } from "buffer";
6
- import { u } from "../bitcoin-B0S8SHCX.js";
6
+ import { u } from "../bitcoin-B5aNKtsk.js";
7
7
  import { BitcoinNetworks as q } from "../shared/index.js";
8
8
  const f = async (e, t) => {
9
9
  const s = new TextEncoder(), n = s.encode(e), i = s.encode(t), a = new Uint8Array(4 + n.length + 4 + i.length), c = new DataView(a.buffer);
@@ -0,0 +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 j=require("./types-DnyyBNcC.cjs"),m=require("./bitcoin-CHfKAhcI.cjs"),C=require("./validation-u8W7Lp2x.cjs"),Pe=require("@bitcoin-js/tiny-secp256k1-asmjs"),E=require("bitcoinjs-lib"),$=require("buffer"),Y=require("./sha2-DsrLC4NM.cjs"),v=require("./BTCVaultRegistry.abi-ZdPpION2.cjs"),g=require("./ProtocolParams.abi-BmvHwQJV.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(j.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');Be(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)}`);Se(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++)ke(e.challengers[n],n)}function Se(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"),t.challenger_pubkey!==null&&typeof t.challenger_pubkey!="string")throw new o(`VP response validation failed: "claimer.challenger_pubkey" must be a string or null, got ${l(t.challenger_pubkey)}`);if(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 ke(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`),B(n.assert_txid,`challengers[${e}].assert_txid`),B(n.challenge_assert_x_txid,`challengers[${e}].challenge_assert_x_txid`),B(n.challenge_assert_y_txid,`challengers[${e}].challenge_assert_y_txid`),B(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 B(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 Ie(t){ce(t,"batchGetPeginStatus",e=>{e.result!==null&&oe(e.result)})}function Ee(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 Be(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 j.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 Ie(r),r}async batchGetPegoutStatus(e,n){const r=await this.client.call("vaultProvider_batchGetPegoutStatus",e,n);return Ee(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=j.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),k=new Map,U=[];for(const h of V){const P=n(h).toLowerCase();k.set(P,h),U.push(P)}let A;try{const h=await r(U);A=Ne(U,h.results)}catch(h){u(V,h);continue}d&&A.unexpected.length>0&&d(A.unexpected);const I=new Set(A.duplicate);for(const h of I){const P=k.get(h);P&&a(P)}c&&I.size>0&&c(I.size);for(const h of A.missing){const P=k.get(h);P&&i(P)}for(const[h,P]of A.byTxid){if(I.has(h))continue;const z=k.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 Ke(t){if(t.length!==ue)return null;const e=de(De,t),n=K.xOnlyPointAddTweak(t,e);return n?n.xOnlyPubkey:null}function Ue(t,e,n){if(e.length!==ue||n.length!==je)return!1;try{const r=de(Oe,t),s=E.payments.p2tr({internalPubkey:$.Buffer.from(e)});if(!s.output)return!1;const i=s.output,a=0,c=new E.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 E.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],E.Transaction.SIGHASH_DEFAULT),V=Ke(e);return V?K.verifySchnorr(w,V,n):!1}catch{return!1}}function H(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=[H(4,t.length)];for(const r of t)n.push(H(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=H(4,3),s=Q(t),i=Q(e),a=H(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(!Ue(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"]),qe=6e4,F="auth_createDepositorToken";function ge(t,e){return new j.JsonRpcClient({baseUrl:t,timeout:qe,headers:e,retryableFor:n=>n===F})}const J=4102444800,Ge=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??Ge,this.now=e.now??(()=>Math.floor(Date.now()/1e3))}async getToken(e){if(e===F||!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(F,{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 q=new fe;function Ye(t){var r;const e=ge(t.baseUrl,(r=t.options)==null?void 0:r.headers),n=q.getOrCreate({client:e,peginTxid:t.peginTxid,authAnchorHex:t.authAnchorHex,pinnedServerPubkey:t.pinnedServerPubkey});return new le(t.baseUrl,{...t.options,tokenProvider:n})}function We(t){q.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 L=65535,Z=1e4,O=4294967295,ee=255;function M(t){if(!Number.isInteger(t)||t<0||t>O)throw new Error(`Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`)}function S(t){const e=[];if(t.timelockAssert<=0n&&e.push(`timelockAssert must be positive, got ${t.timelockAssert}`),t.timelockAssert>BigInt(L)&&e.push(`timelockAssert ${t.timelockAssert} exceeds uint16 max (${L})`),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.proverProgramVersion)||t.proverProgramVersion<0||t.proverProgramVersion>L)&&e.push(`proverProgramVersion must be a uint16, got ${t.proverProgramVersion}`),(!Number.isInteger(t.minPrepeginDepth)||t.minPrepeginDepth<=0||t.minPrepeginDepth>O)&&e.push(`minPrepeginDepth must be a uint32 in [1, ${O}], 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 G(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}`),e.length>0)throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`)}function me(t){if(G(t),S(t.offchainParams),!Number.isInteger(t.offchainParamsVersion)||t.offchainParamsVersion<0||t.offchainParamsVersion>O)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,proverProgramVersion:t.proverProgramVersion,minPrepeginDepth:t.minPrepeginDepth}}function ne(t){return{minimumPegInAmount:t.minimumPegInAmount,maxPegInAmount:t.maxPegInAmount,pegInAckTimeout:t.pegInAckTimeout,pegInActivationTimeout:t.pegInActivationTimeout,maxHtlcOutputCount:t.maxHtlcOutputCount}}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 G(n),n}async getLatestOffchainParams(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getLatestOffchainParams"}),n=N(e);return S(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 S(r),r}async getLatestOffchainParamsVersion(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"latestOffchainParamsVersion"}),n=Number(e);return M(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,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{S(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 D(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 D(r)}async getCurrentVaultKeepers(e){const n=await this.publicClient.readContract({address:this.contractAddress,abi:g.ApplicationRegistryABI,functionName:"getCurrentVaultKeepers",args:[e]});return D(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 D(n)}async getCurrentUniversalChallengers(){const e=await this.publicClient.readContract({address:this.contractAddress,abi:g.ProtocolParamsABI,functionName:"getCurrentUniversalChallengers"});return D(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 M(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}}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`);return{depositorSignedPeginTx:i.depositorSignedPeginTx,universalChallengersVersion:i.universalChallengersVersion,appVaultKeepersVersion:i.appVaultKeepersVersion,offchainParamsVersion:i.offchainParamsVersion,verifiedAt:i.verifiedAt,depositorWotsPkHash:i.depositorWotsPkHash,hashlock:i.hashlock,htlcVout:i.htlcVout,depositorPopSignature:i.depositorPopSignature,prePeginTxHash:i.prePeginTxHash,vaultProviderCommissionBps:i.vaultProviderCommissionBps}})}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 M(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=S;exports.validatePegInConfiguration=me;exports.validateRequestDepositorClaimerArtifactsResponse=ae;exports.validateTBVProtocolParams=G;exports.verifyServerIdentity=pe;exports.vpTokenRegistry=q;
2
+ //# sourceMappingURL=vault-registry-reader-7gOYnrQD.cjs.map