@babylonlabs-io/ts-sdk 0.66.1 → 0.68.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 (157) hide show
  1. package/dist/PeginManager--2R3T2S8.js +1458 -0
  2. package/dist/PeginManager--2R3T2S8.js.map +1 -0
  3. package/dist/PeginManager-CKWq8ouZ.cjs +2 -0
  4. package/dist/PeginManager-CKWq8ouZ.cjs.map +1 -0
  5. package/dist/{batchPoll-cIxrSLLJ.js → batchPoll-Cjj1du0i.js} +372 -421
  6. package/dist/batchPoll-Cjj1du0i.js.map +1 -0
  7. package/dist/batchPoll-REVZiE-M.cjs +2 -0
  8. package/dist/batchPoll-REVZiE-M.cjs.map +1 -0
  9. package/dist/{bitcoin-d9eaaZB_.js → bitcoin-Ch_jxnDa.js} +3 -3
  10. package/dist/{bitcoin-d9eaaZB_.js.map → bitcoin-Ch_jxnDa.js.map} +1 -1
  11. package/dist/{buildAndBroadcastRefund-C4LiPATK.js → buildAndBroadcastRefund-CpMDJ8up.js} +142 -150
  12. package/dist/buildAndBroadcastRefund-CpMDJ8up.js.map +1 -0
  13. package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs +2 -0
  14. package/dist/buildAndBroadcastRefund-DrXwxrW1.cjs.map +1 -0
  15. package/dist/challengeAssert-BNQ8sToz.js +64 -0
  16. package/dist/challengeAssert-BNQ8sToz.js.map +1 -0
  17. package/dist/challengeAssert-BrpC3-cQ.cjs +2 -0
  18. package/dist/challengeAssert-BrpC3-cQ.cjs.map +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +246 -243
  21. package/dist/mempoolApi-EU1La9wk.cjs +2 -0
  22. package/dist/{mempoolApi-CXfr-L6x.cjs.map → mempoolApi-EU1La9wk.cjs.map} +1 -1
  23. package/dist/{mempoolApi-BxSINXIB.js → mempoolApi-_D-jvtj_.js} +191 -117
  24. package/dist/{mempoolApi-BxSINXIB.js.map → mempoolApi-_D-jvtj_.js.map} +1 -1
  25. package/dist/{noPayout-BaZGRLD2.js → noPayout-CXn-geIS.js} +3 -3
  26. package/dist/{noPayout-BaZGRLD2.js.map → noPayout-CXn-geIS.js.map} +1 -1
  27. package/dist/{noPayout-CnQ1WLtr.cjs → noPayout-Ox27Td9x.cjs} +2 -2
  28. package/dist/{noPayout-CnQ1WLtr.cjs.map → noPayout-Ox27Td9x.cjs.map} +1 -1
  29. package/dist/{onChainBtcPubkey-DeF4cKoO.js → onChainBtcPubkey-BAHZyKQL.js} +2 -2
  30. package/dist/{onChainBtcPubkey-DeF4cKoO.js.map → onChainBtcPubkey-BAHZyKQL.js.map} +1 -1
  31. package/dist/{parseFundingOutpoints-pBRE11Hr.js → parseFundingOutpoints-CO-f6IHK.js} +2 -2
  32. package/dist/{parseFundingOutpoints-pBRE11Hr.js.map → parseFundingOutpoints-CO-f6IHK.js.map} +1 -1
  33. package/dist/{reservation-B4i_PQhY.js → reservation-CBAvoF3U.js} +2 -2
  34. package/dist/{reservation-B4i_PQhY.js.map → reservation-CBAvoF3U.js.map} +1 -1
  35. package/dist/{signPsbtsWithFallback-Bb66DfY5.js → signPsbtsWithFallback-Bv79gLFe.js} +122 -100
  36. package/dist/signPsbtsWithFallback-Bv79gLFe.js.map +1 -0
  37. package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs +2 -0
  38. package/dist/signPsbtsWithFallback-DJ4kE9UI.cjs.map +1 -0
  39. package/dist/tbv/core/clients/index.cjs +1 -1
  40. package/dist/tbv/core/clients/index.js +3 -3
  41. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts +32 -0
  42. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322P2wpkhVectors.d.ts.map +1 -0
  43. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts +9 -6
  44. package/dist/tbv/core/clients/vault-provider/auth/__tests__/bip322Verify.test.d.ts.map +1 -1
  45. package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts +45 -20
  46. package/dist/tbv/core/clients/vault-provider/auth/bip322Verify.d.ts.map +1 -1
  47. package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts +2 -0
  48. package/dist/tbv/core/deposit-terms/__tests__/depositTerms.test.d.ts.map +1 -0
  49. package/dist/tbv/core/deposit-terms/depositTerms.d.ts +42 -5
  50. package/dist/tbv/core/deposit-terms/depositTerms.d.ts.map +1 -1
  51. package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts +10 -5
  52. package/dist/tbv/core/deposit-terms/prePeginApproval.d.ts.map +1 -1
  53. package/dist/tbv/core/index.cjs +1 -1
  54. package/dist/tbv/core/index.js +244 -241
  55. package/dist/tbv/core/managers/PayoutManager.d.ts +8 -2
  56. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  57. package/dist/tbv/core/managers/PeginManager.d.ts +7 -0
  58. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  59. package/dist/tbv/core/managers/index.cjs +1 -1
  60. package/dist/tbv/core/managers/index.js +2 -2
  61. package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts +11 -0
  62. package/dist/tbv/core/managers/pegin/__tests__/verifyPopWitness.test.d.ts.map +1 -0
  63. package/dist/tbv/core/managers/pegin/expandPerVaultSecrets.d.ts.map +1 -1
  64. package/dist/tbv/core/managers/pegin/index.d.ts +1 -0
  65. package/dist/tbv/core/managers/pegin/index.d.ts.map +1 -1
  66. package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts +21 -0
  67. package/dist/tbv/core/managers/pegin/verifyPopWitness.d.ts.map +1 -0
  68. package/dist/tbv/core/primitives/challengers.d.ts +31 -5
  69. package/dist/tbv/core/primitives/challengers.d.ts.map +1 -1
  70. package/dist/tbv/core/primitives/index.cjs +1 -1
  71. package/dist/tbv/core/primitives/index.d.ts +2 -0
  72. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  73. package/dist/tbv/core/primitives/index.js +43 -41
  74. package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +5 -0
  75. package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts.map +1 -1
  76. package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts +12 -0
  77. package/dist/tbv/core/primitives/psbt/__tests__/verifyKeyPathSchnorrSignature.test.d.ts.map +1 -0
  78. package/dist/tbv/core/primitives/psbt/payout.d.ts +19 -7
  79. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  80. package/dist/tbv/core/primitives/psbt/pegin.d.ts +2 -2
  81. package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts +64 -0
  82. package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts.map +1 -0
  83. package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts +40 -0
  84. package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts.map +1 -0
  85. package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts +2 -1
  86. package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts.map +1 -1
  87. package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts +13 -0
  88. package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts.map +1 -0
  89. package/dist/tbv/core/primitives/utils/taproot.d.ts +29 -0
  90. package/dist/tbv/core/primitives/utils/taproot.d.ts.map +1 -0
  91. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +2 -2
  92. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  93. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  94. package/dist/tbv/core/services/index.cjs +1 -1
  95. package/dist/tbv/core/services/index.js +2 -2
  96. package/dist/tbv/core/utils/index.js +2 -2
  97. package/dist/tbv/core/utils/witness/witnessStack.d.ts +24 -0
  98. package/dist/tbv/core/utils/witness/witnessStack.d.ts.map +1 -0
  99. package/dist/tbv/core/vault-secrets/index.js +1 -1
  100. package/dist/tbv/index.cjs +1 -1
  101. package/dist/tbv/index.js +244 -241
  102. package/dist/tbv/integrations/aave/clients/__tests__/query.test.d.ts +11 -0
  103. package/dist/tbv/integrations/aave/clients/__tests__/query.test.d.ts.map +1 -0
  104. package/dist/tbv/integrations/aave/clients/query.d.ts.map +1 -1
  105. package/dist/tbv/integrations/aave/index.cjs +1 -1
  106. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  107. package/dist/tbv/integrations/aave/index.js +132 -114
  108. package/dist/tbv/integrations/aave/index.js.map +1 -1
  109. package/dist/testing/MockBitcoinWallet.d.ts +10 -1
  110. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  111. package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts +2 -0
  112. package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts.map +1 -0
  113. package/dist/testing/index.cjs +1 -1
  114. package/dist/testing/index.cjs.map +1 -1
  115. package/dist/testing/index.js +134 -47
  116. package/dist/testing/index.js.map +1 -1
  117. package/dist/testing/signBip322P2wpkhWitness.d.ts +20 -0
  118. package/dist/testing/signBip322P2wpkhWitness.d.ts.map +1 -0
  119. package/dist/{toRefundInputs-BY_fcvrv.js → toRefundInputs-9hv_6k0E.js} +6 -6
  120. package/dist/{toRefundInputs-BY_fcvrv.js.map → toRefundInputs-9hv_6k0E.js.map} +1 -1
  121. package/dist/{toRefundInputs-DYL9C-aG.cjs → toRefundInputs-D8sFs44p.cjs} +2 -2
  122. package/dist/{toRefundInputs-DYL9C-aG.cjs.map → toRefundInputs-D8sFs44p.cjs.map} +1 -1
  123. package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs +2 -0
  124. package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs.map +1 -0
  125. package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js +363 -0
  126. package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js.map +1 -0
  127. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js +931 -0
  128. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +1 -0
  129. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +2 -0
  130. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +1 -0
  131. package/package.json +2 -2
  132. package/dist/PeginManager-BBl4xkWz.js +0 -1359
  133. package/dist/PeginManager-BBl4xkWz.js.map +0 -1
  134. package/dist/PeginManager-p-ajwSxG.cjs +0 -2
  135. package/dist/PeginManager-p-ajwSxG.cjs.map +0 -1
  136. package/dist/batchPoll-6L5oToGr.cjs +0 -2
  137. package/dist/batchPoll-6L5oToGr.cjs.map +0 -1
  138. package/dist/batchPoll-cIxrSLLJ.js.map +0 -1
  139. package/dist/buildAndBroadcastRefund-C4LiPATK.js.map +0 -1
  140. package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs +0 -2
  141. package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs.map +0 -1
  142. package/dist/challengeAssert-BFRE2DM-.cjs +0 -2
  143. package/dist/challengeAssert-BFRE2DM-.cjs.map +0 -1
  144. package/dist/challengeAssert-C7PzyJ7g.js +0 -75
  145. package/dist/challengeAssert-C7PzyJ7g.js.map +0 -1
  146. package/dist/mempoolApi-CXfr-L6x.cjs +0 -2
  147. package/dist/peginInput-Ci921gTl.cjs +0 -2
  148. package/dist/peginInput-Ci921gTl.cjs.map +0 -1
  149. package/dist/peginInput-HQPWZfly.js +0 -123
  150. package/dist/peginInput-HQPWZfly.js.map +0 -1
  151. package/dist/signPsbtsWithFallback-Bb66DfY5.js.map +0 -1
  152. package/dist/signPsbtsWithFallback-PTgWxsG3.cjs +0 -2
  153. package/dist/signPsbtsWithFallback-PTgWxsG3.cjs.map +0 -1
  154. package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs +0 -2
  155. package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs.map +0 -1
  156. package/dist/verifyScriptPathSchnorrSignature-i-koT139.js +0 -817
  157. package/dist/verifyScriptPathSchnorrSignature-i-koT139.js.map +0 -1
@@ -1,28 +1,26 @@
1
- var Ce = Object.defineProperty;
2
- var Te = (r, e, t) => e in r ? Ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var f = (r, e, t) => Te(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { B } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
5
- import { A as R, P as y } from "./ProtocolParams.abi-C0TSRaHV.js";
6
- import { k as $e, v as U, l as Ve, j as Ie } from "./mempoolApi-BxSINXIB.js";
7
- import { X as O, C as j, s as I, S as Re, h as Oe, p as fe } from "./bitcoin-d9eaaZB_.js";
8
- import { D as Ne, a as _e, e as Be } from "./json-rpc-client-DuUARJvV.js";
9
- import { C as ee } from "./constants-GjWXdaqV.js";
1
+ var ve = Object.defineProperty;
2
+ var Ae = (r, e, t) => e in r ? ve(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var f = (r, e, t) => Ae(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { B as N } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
5
+ import { A as I, P as m } from "./ProtocolParams.abi-C0TSRaHV.js";
6
+ import { k as Ee, v as H, n as Ce, j as ke, l as Se } from "./mempoolApi-_D-jvtj_.js";
7
+ import { X as R, C as G, s as V, S as $e, h as Te, p as de } from "./bitcoin-Ch_jxnDa.js";
8
+ import { D as Ve, a as pe, e as Ie } from "./json-rpc-client-DuUARJvV.js";
9
+ import { C as Y } from "./constants-GjWXdaqV.js";
10
10
  import { H as k } from "./validation-Dj3dqYtl.js";
11
- import * as K from "@bitcoin-js/tiny-secp256k1-asmjs";
12
- import { payments as De, Transaction as X } from "bitcoinjs-lib";
13
- import { Buffer as V } from "buffer";
14
- import { s as Y } from "./sha2-BYVxyZzX.js";
15
- async function cr(r, e) {
11
+ import * as he from "@bitcoin-js/tiny-secp256k1-asmjs";
12
+ import { s as Re } from "./sha2-BYVxyZzX.js";
13
+ async function qt(r, e) {
16
14
  const [t, n] = await r.multicall({
17
15
  contracts: [
18
16
  {
19
17
  address: e,
20
- abi: B,
18
+ abi: N,
21
19
  functionName: "protocolParams"
22
20
  },
23
21
  {
24
22
  address: e,
25
- abi: B,
23
+ abi: N,
26
24
  functionName: "applicationRegistry"
27
25
  }
28
26
  ],
@@ -33,20 +31,20 @@ async function cr(r, e) {
33
31
  applicationRegistry: n
34
32
  };
35
33
  }
36
- function te(r, e, t) {
34
+ function q(r, e, t) {
37
35
  if (r !== e)
38
36
  throw new Error(
39
37
  `${t}: multicall returned ${r} results for ${e} calls, so the results are not roster-aligned; refusing to use them`
40
38
  );
41
39
  }
42
- function Ge(r, e) {
40
+ function Oe(r, e) {
43
41
  return {
44
42
  vaultProvider: r[0],
45
43
  vaultKeepers: r.slice(1, 1 + e),
46
44
  universalChallengers: r.slice(1 + e)
47
45
  };
48
46
  }
49
- class lr {
47
+ class Qt {
50
48
  constructor(e, t) {
51
49
  this.publicClient = e, this.contracts = t;
52
50
  }
@@ -61,29 +59,29 @@ class lr {
61
59
  contracts: e,
62
60
  allowFailure: !1
63
61
  });
64
- return te(
62
+ return q(
65
63
  s.length,
66
64
  1 + t + n,
67
65
  i
68
- ), Ge(s, t);
66
+ ), Oe(s, t);
69
67
  }
70
68
  async getCurrentOperationKeys(e) {
71
69
  const t = [
72
70
  {
73
71
  address: this.contracts.btcVaultRegistry,
74
- abi: B,
72
+ abi: N,
75
73
  functionName: "getCurrentOperationBtcKey",
76
74
  args: [e.vaultProviderEthAddress]
77
75
  },
78
76
  ...e.vaultKeepers.map((n) => ({
79
77
  address: this.contracts.applicationRegistry,
80
- abi: R,
78
+ abi: I,
81
79
  functionName: "getCurrentOperationBtcKey",
82
80
  args: [e.applicationEntryPoint, n.ethAddress]
83
81
  })),
84
82
  ...e.universalChallengers.map((n) => ({
85
83
  address: this.contracts.protocolParams,
86
- abi: y,
84
+ abi: m,
87
85
  functionName: "getCurrentOperationBtcKey",
88
86
  args: [n.ethAddress]
89
87
  }))
@@ -102,7 +100,7 @@ class lr {
102
100
  // unambiguous and the contract resolves it internally.
103
101
  {
104
102
  address: this.contracts.btcVaultRegistry,
105
- abi: B,
103
+ abi: N,
106
104
  functionName: "getOperationBtcKeyAtEpoch",
107
105
  args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
108
106
  },
@@ -113,7 +111,7 @@ class lr {
113
111
  // version, would otherwise resolve against the wrong genesis.
114
112
  ...e.vaultKeepers.map((i) => ({
115
113
  address: this.contracts.applicationRegistry,
116
- abi: R,
114
+ abi: I,
117
115
  functionName: "getOperationBtcKeyAtEpochOrGenesis",
118
116
  args: [
119
117
  e.applicationEntryPoint,
@@ -124,7 +122,7 @@ class lr {
124
122
  })),
125
123
  ...e.universalChallengers.map((i) => ({
126
124
  address: this.contracts.protocolParams,
127
- abi: y,
125
+ abi: m,
128
126
  functionName: "getOperationBtcKeyAtEpochOrGenesis",
129
127
  args: [i.ethAddress, t.ucKeyEpoch, i.btcPubKey]
130
128
  }))
@@ -141,13 +139,13 @@ class lr {
141
139
  contracts: [
142
140
  {
143
141
  address: this.contracts.btcVaultRegistry,
144
- abi: B,
142
+ abi: N,
145
143
  functionName: "getPayoutScriptAtEpoch",
146
144
  args: [e.vaultProviderEthAddress, t.vpKeyEpoch]
147
145
  },
148
146
  ...e.vaultKeepers.map((i) => ({
149
147
  address: this.contracts.applicationRegistry,
150
- abi: R,
148
+ abi: I,
151
149
  functionName: "getPayoutScriptAtEpoch",
152
150
  args: [
153
151
  e.applicationEntryPoint,
@@ -158,7 +156,7 @@ class lr {
158
156
  ],
159
157
  allowFailure: !1
160
158
  });
161
- return te(
159
+ return q(
162
160
  n.length,
163
161
  1 + e.vaultKeepers.length,
164
162
  "getPayoutScriptsAtEpochs"
@@ -168,8 +166,8 @@ class lr {
168
166
  };
169
167
  }
170
168
  }
171
- const re = 65535;
172
- function D(r) {
169
+ const Q = 65535;
170
+ function B(r) {
173
171
  return {
174
172
  timelockAssert: r.timelockAssert,
175
173
  timelockChallengeAssert: r.timelockChallengeAssert,
@@ -186,7 +184,7 @@ function D(r) {
186
184
  minPrepeginDepth: r.minPrepeginDepth
187
185
  };
188
186
  }
189
- function ne(r) {
187
+ function Z(r) {
190
188
  return {
191
189
  minimumPegInAmount: r.minimumPegInAmount,
192
190
  maxPegInAmount: r.maxPegInAmount,
@@ -196,53 +194,53 @@ function ne(r) {
196
194
  expiredPegInGraceBlocks: r.expiredPegInGraceBlocks
197
195
  };
198
196
  }
199
- function se(r) {
200
- if (r > BigInt(re))
197
+ function ee(r) {
198
+ if (r > BigInt(Q))
201
199
  throw new Error(
202
- `timelockAssert value ${r} exceeds uint16 max (${re})`
200
+ `timelockAssert value ${r} exceeds uint16 max (${Q})`
203
201
  );
204
202
  return Number(r);
205
203
  }
206
- class ur {
204
+ class Zt {
207
205
  constructor(e, t) {
208
206
  this.publicClient = e, this.contractAddress = t;
209
207
  }
210
208
  async getTBVProtocolParams() {
211
209
  const e = await this.publicClient.readContract({
212
210
  address: this.contractAddress,
213
- abi: y,
211
+ abi: m,
214
212
  functionName: "getTBVProtocolParams"
215
- }), t = ne(e);
216
- return $e(t), t;
213
+ }), t = Z(e);
214
+ return Ee(t), t;
217
215
  }
218
216
  async getLatestOffchainParams() {
219
217
  const e = await this.publicClient.readContract({
220
218
  address: this.contractAddress,
221
- abi: y,
219
+ abi: m,
222
220
  functionName: "getLatestOffchainParams"
223
- }), t = D(e);
224
- return U(t), t;
221
+ }), t = B(e);
222
+ return H(t), t;
225
223
  }
226
224
  async getOffchainParamsByVersion(e) {
227
225
  const t = await this.publicClient.readContract({
228
226
  address: this.contractAddress,
229
- abi: y,
227
+ abi: m,
230
228
  functionName: "getOffchainParamsByVersion",
231
229
  args: [e]
232
- }), n = D(t);
233
- return U(n), n;
230
+ }), n = B(t);
231
+ return H(n), n;
234
232
  }
235
233
  async getLatestOffchainParamsVersion() {
236
234
  const e = await this.publicClient.readContract({
237
235
  address: this.contractAddress,
238
- abi: y,
236
+ abi: m,
239
237
  functionName: "latestOffchainParamsVersion"
240
238
  }), t = Number(e);
241
- return Ve(t), t;
239
+ return Ce(t), t;
242
240
  }
243
241
  async getTimelockPeginByVersion(e) {
244
242
  const t = await this.getOffchainParamsByVersion(e);
245
- return se(t.timelockAssert);
243
+ return ee(t.timelockAssert);
246
244
  }
247
245
  /**
248
246
  * Returned as `bigint` with no `Number` narrowing: the registry compares it
@@ -257,7 +255,7 @@ class ur {
257
255
  async getPeginActivationDelay() {
258
256
  const e = await this.publicClient.readContract({
259
257
  address: this.contractAddress,
260
- abi: y,
258
+ abi: m,
261
259
  functionName: "peginActivationDelay"
262
260
  });
263
261
  if (typeof e != "bigint")
@@ -278,41 +276,41 @@ class ur {
278
276
  contracts: [
279
277
  {
280
278
  address: this.contractAddress,
281
- abi: y,
279
+ abi: m,
282
280
  functionName: "getTBVProtocolParams"
283
281
  },
284
282
  {
285
283
  address: this.contractAddress,
286
- abi: y,
284
+ abi: m,
287
285
  functionName: "getLatestOffchainParams"
288
286
  },
289
287
  {
290
288
  address: this.contractAddress,
291
- abi: y,
289
+ abi: m,
292
290
  functionName: "latestOffchainParamsVersion"
293
291
  },
294
292
  {
295
293
  address: this.contractAddress,
296
- abi: y,
294
+ abi: m,
297
295
  functionName: "activeVaultCoreVersion"
298
296
  }
299
297
  ],
300
298
  allowFailure: !1
301
- }), t = ne(e[0]), n = D(e[1]), i = Number(e[2]), s = Number(e[3]), a = {
299
+ }), t = Z(e[0]), n = B(e[1]), i = Number(e[2]), s = Number(e[3]), a = {
302
300
  minimumPegInAmount: t.minimumPegInAmount,
303
301
  maxPegInAmount: t.maxPegInAmount,
304
302
  pegInAckTimeout: t.pegInAckTimeout,
305
303
  pegInActivationTimeout: t.pegInActivationTimeout,
306
304
  maxHtlcOutputCount: t.maxHtlcOutputCount,
307
305
  expiredPegInGraceBlocks: t.expiredPegInGraceBlocks,
308
- timelockPegin: se(n.timelockAssert),
306
+ timelockPegin: ee(n.timelockAssert),
309
307
  timelockRefund: n.tRefund,
310
308
  minVpCommissionBps: n.minVpCommissionBps,
311
309
  offchainParams: n,
312
310
  offchainParamsVersion: i,
313
311
  activeVaultCoreVersion: s
314
312
  };
315
- return Ie(a), a;
313
+ return ke(a), a;
316
314
  }
317
315
  /**
318
316
  * Fetch every historical offchain params version in a single multicall.
@@ -328,9 +326,9 @@ class ur {
328
326
  const t = await this.getLatestOffchainParamsVersion();
329
327
  if (t === 0)
330
328
  return { byVersion: /* @__PURE__ */ new Map(), latestVersion: 0 };
331
- const n = Array.from({ length: t }, (c, d) => d + 1), i = n.map((c) => ({
329
+ const n = Array.from({ length: t }, (c, u) => u + 1), i = n.map((c) => ({
332
330
  address: this.contractAddress,
333
- abi: y,
331
+ abi: m,
334
332
  functionName: "getOffchainParamsByVersion",
335
333
  args: [c]
336
334
  })), s = await this.publicClient.multicall({
@@ -338,125 +336,125 @@ class ur {
338
336
  allowFailure: !1
339
337
  }), a = /* @__PURE__ */ new Map();
340
338
  for (let c = 0; c < n.length; c++) {
341
- const d = D(s[c]);
339
+ const u = B(s[c]);
342
340
  try {
343
- U(d), a.set(n[c], d);
344
- } catch (l) {
341
+ H(u), a.set(n[c], u);
342
+ } catch (d) {
345
343
  e == null || e(
346
344
  n[c],
347
- l instanceof Error ? l : new Error(String(l))
345
+ d instanceof Error ? d : new Error(String(d))
348
346
  );
349
347
  }
350
348
  }
351
349
  return { byVersion: a, latestVersion: t };
352
350
  }
353
351
  }
354
- function H(r) {
352
+ function j(r) {
355
353
  return r.map((e) => ({
356
354
  ethAddress: e.ethAddress,
357
355
  btcPubKey: e.btcPubKey
358
356
  }));
359
357
  }
360
- class dr {
358
+ class er {
361
359
  constructor(e, t) {
362
360
  this.publicClient = e, this.contractAddress = t;
363
361
  }
364
362
  async getVaultKeepersByVersion(e, t) {
365
363
  const n = await this.publicClient.readContract({
366
364
  address: this.contractAddress,
367
- abi: R,
365
+ abi: I,
368
366
  functionName: "getVaultKeepersByVersion",
369
367
  args: [e, t]
370
368
  });
371
- return H(n);
369
+ return j(n);
372
370
  }
373
371
  async getCurrentVaultKeepers(e) {
374
372
  const t = await this.publicClient.readContract({
375
373
  address: this.contractAddress,
376
- abi: R,
374
+ abi: I,
377
375
  functionName: "getCurrentVaultKeepers",
378
376
  args: [e]
379
377
  });
380
- return H(t);
378
+ return j(t);
381
379
  }
382
380
  async getCurrentVaultKeepersVersion(e) {
383
381
  return await this.publicClient.readContract({
384
382
  address: this.contractAddress,
385
- abi: R,
383
+ abi: I,
386
384
  functionName: "getCurrentVaultKeepersVersion",
387
385
  args: [e]
388
386
  });
389
387
  }
390
388
  }
391
- class pr {
389
+ class tr {
392
390
  constructor(e, t) {
393
391
  this.publicClient = e, this.contractAddress = t;
394
392
  }
395
393
  async getUniversalChallengersByVersion(e) {
396
394
  const t = await this.publicClient.readContract({
397
395
  address: this.contractAddress,
398
- abi: y,
396
+ abi: m,
399
397
  functionName: "getUniversalChallengersByVersion",
400
398
  args: [e]
401
399
  });
402
- return H(t);
400
+ return j(t);
403
401
  }
404
402
  async getCurrentUniversalChallengers() {
405
403
  const e = await this.publicClient.readContract({
406
404
  address: this.contractAddress,
407
- abi: y,
405
+ abi: m,
408
406
  functionName: "getCurrentUniversalChallengers"
409
407
  });
410
- return H(e);
408
+ return j(e);
411
409
  }
412
410
  async getLatestUniversalChallengersVersion() {
413
411
  return await this.publicClient.readContract({
414
412
  address: this.contractAddress,
415
- abi: y,
413
+ abi: m,
416
414
  functionName: "latestUniversalChallengersVersion"
417
415
  });
418
416
  }
419
417
  }
420
- var Me = /* @__PURE__ */ ((r) => (r[r.PENDING = 0] = "PENDING", r[r.VERIFIED = 1] = "VERIFIED", r[r.ACTIVE = 2] = "ACTIVE", r[r.REDEEMED = 3] = "REDEEMED", r[r.EXPIRED = 4] = "EXPIRED", r))(Me || {});
421
- const ie = new Set(Object.values(Ne)), je = 200;
418
+ var Ne = /* @__PURE__ */ ((r) => (r[r.PENDING = 0] = "PENDING", r[r.VERIFIED = 1] = "VERIFIED", r[r.ACTIVE = 2] = "ACTIVE", r[r.REDEEMED = 3] = "REDEEMED", r[r.EXPIRED = 4] = "EXPIRED", r))(Ne || {});
419
+ const te = new Set(Object.values(Ve)), Be = 200;
422
420
  function h(r) {
423
421
  var e;
424
- return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, je)) ?? "undefined";
422
+ return ((e = JSON.stringify(r)) == null ? void 0 : e.slice(0, Be)) ?? "undefined";
425
423
  }
426
- const He = "The vault provider returned an unexpected response. Please try again or contact support.";
424
+ const De = "The vault provider returned an unexpected response. Please try again or contact support.";
427
425
  class o extends Error {
428
426
  constructor(t) {
429
- super(He);
427
+ super(De);
430
428
  f(this, "detail");
431
429
  this.name = "VpResponseValidationError", this.detail = t;
432
430
  }
433
431
  }
434
- const N = 64;
435
- function T(r) {
432
+ const O = 64;
433
+ function $(r) {
436
434
  return typeof r == "string" && r.length > 0 && k.test(r);
437
435
  }
438
- function me(r) {
436
+ function ge(r) {
439
437
  return typeof r == "string" && r.length > 0;
440
438
  }
441
- function ye(r, e) {
442
- if (!T(r))
439
+ function fe(r, e) {
440
+ if (!$(r))
443
441
  throw new o(
444
442
  `VP response validation failed: "${e}" must be a non-empty hex string, got ${h(r)}`
445
443
  );
446
444
  }
447
445
  function w(r, e) {
448
- if (!me(r))
446
+ if (!ge(r))
449
447
  throw new o(
450
448
  `VP response validation failed: "${e}" must be a non-empty string, got ${h(r)}`
451
449
  );
452
450
  }
453
- function Q(r, e) {
454
- if (!T(r) || r.length !== O && r.length !== j)
451
+ function z(r, e) {
452
+ if (!$(r) || r.length !== R && r.length !== G)
455
453
  throw new o(
456
- `VP response validation failed: "${e}" must be a ${O} or ${j}-char hex string (BTC pubkey), got ${h(r)}`
454
+ `VP response validation failed: "${e}" must be a ${R} or ${G}-char hex string (BTC pubkey), got ${h(r)}`
457
455
  );
458
456
  }
459
- function Le(r) {
457
+ function Me(r) {
460
458
  const e = r.presigning;
461
459
  if (e == null) return;
462
460
  if (typeof e != "object" || Array.isArray(e))
@@ -477,29 +475,29 @@ function Le(r) {
477
475
  `VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${h(t.vk_challenger_presigning_total)}`
478
476
  );
479
477
  }
480
- function be(r) {
478
+ function _e(r) {
481
479
  if (r === null || typeof r != "object")
482
480
  throw new o(
483
481
  "VP response validation failed: getPeginStatus response is not an object"
484
482
  );
485
483
  const e = r;
486
- if (!T(e.pegin_txid) || e.pegin_txid.length !== N)
484
+ if (!$(e.pegin_txid) || e.pegin_txid.length !== O)
487
485
  throw new o(
488
- `VP response validation failed: "pegin_txid" must be a ${N}-char hex string (txid), got ${h(e.pegin_txid)}`
486
+ `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${h(e.pegin_txid)}`
489
487
  );
490
488
  if (typeof e.status != "string")
491
489
  throw new o(
492
490
  'VP response validation failed: "status" must be a string'
493
491
  );
494
- if (!ie.has(e.status))
492
+ if (!te.has(e.status))
495
493
  throw new o(
496
- `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...ie].join(", ")}`
494
+ `VP response validation failed: unrecognized status "${e.status}". Expected one of: ${[...te].join(", ")}`
497
495
  );
498
496
  if (e.progress === null || typeof e.progress != "object" || Array.isArray(e.progress))
499
497
  throw new o(
500
498
  'VP response validation failed: "progress" must be an object'
501
499
  );
502
- if (Le(e.progress), typeof e.health_info != "string")
500
+ if (Me(e.progress), typeof e.health_info != "string")
503
501
  throw new o(
504
502
  'VP response validation failed: "health_info" must be a string'
505
503
  );
@@ -508,7 +506,7 @@ function be(r) {
508
506
  `VP response validation failed: "last_error" must be a string if present, got ${h(e.last_error)}`
509
507
  );
510
508
  }
511
- function Ke(r) {
509
+ function Ge(r) {
512
510
  if (r === null || typeof r != "object")
513
511
  throw new o(
514
512
  "VP response validation failed: requestDepositorPresignTransactions response is not an object"
@@ -519,31 +517,31 @@ function Ke(r) {
519
517
  'VP response validation failed: "txs" must be an array'
520
518
  );
521
519
  for (let t = 0; t < e.txs.length; t++)
522
- Ue(e.txs[t], `txs[${t}]`);
520
+ je(e.txs[t], `txs[${t}]`);
523
521
  if (e.depositor_graph === null || typeof e.depositor_graph != "object")
524
522
  throw new o(
525
523
  'VP response validation failed: "depositor_graph" must be an object'
526
524
  );
527
- Qe(
525
+ ze(
528
526
  e.depositor_graph
529
527
  );
530
528
  }
531
- function A(r, e) {
529
+ function v(r, e) {
532
530
  if (r === null || typeof r != "object")
533
531
  throw new o(
534
532
  `VP response validation failed: "${e}" must be an object`
535
533
  );
536
- ye(r.tx_hex, `${e}.tx_hex`);
534
+ fe(r.tx_hex, `${e}.tx_hex`);
537
535
  }
538
- function Ue(r, e) {
536
+ function je(r, e) {
539
537
  if (r === null || typeof r != "object")
540
538
  throw new o(
541
539
  `VP response validation failed: "${e}" must be an object`
542
540
  );
543
541
  const t = r;
544
- Q(t.claimer_pubkey, `${e}.claimer_pubkey`), A(t.claim_tx, `${e}.claim_tx`), A(t.assert_tx, `${e}.assert_tx`), A(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
542
+ z(t.claimer_pubkey, `${e}.claimer_pubkey`), v(t.claim_tx, `${e}.claim_tx`), v(t.assert_tx, `${e}.assert_tx`), v(t.payout_tx, `${e}.payout_tx`), w(t.payout_psbt, `${e}.payout_psbt`);
545
543
  }
546
- function Xe(r, e) {
544
+ function Le(r, e) {
547
545
  if (r === null || typeof r != "object")
548
546
  throw new o(
549
547
  `VP response validation failed: "${e}" must be an object`
@@ -551,28 +549,28 @@ function Xe(r, e) {
551
549
  const t = r;
552
550
  w(t.wots_pks_json, `${e}.wots_pks_json`), w(t.gc_wots_keys_json, `${e}.gc_wots_keys_json`);
553
551
  }
554
- function Fe(r, e) {
552
+ function He(r, e) {
555
553
  if (r === null || typeof r != "object")
556
554
  throw new o(
557
555
  `VP response validation failed: "${e}" must be an object`
558
556
  );
559
557
  const t = r;
560
- if (Q(t.challenger_pubkey, `${e}.challenger_pubkey`), A(
558
+ if (z(t.challenger_pubkey, `${e}.challenger_pubkey`), v(
561
559
  t.challenge_assert_x_tx,
562
560
  `${e}.challenge_assert_x_tx`
563
- ), A(
561
+ ), v(
564
562
  t.challenge_assert_y_tx,
565
563
  `${e}.challenge_assert_y_tx`
566
- ), A(t.nopayout_tx, `${e}.nopayout_tx`), w(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
564
+ ), v(t.nopayout_tx, `${e}.nopayout_tx`), w(t.nopayout_psbt, `${e}.nopayout_psbt`), !Array.isArray(t.challenge_assert_connectors))
567
565
  throw new o(
568
566
  `VP response validation failed: "${e}.challenge_assert_connectors" must be an array`
569
567
  );
570
- if (t.challenge_assert_connectors.length !== ee)
568
+ if (t.challenge_assert_connectors.length !== Y)
571
569
  throw new o(
572
- `VP response validation failed: "${e}.challenge_assert_connectors" must have exactly ${ee} entries, got ${t.challenge_assert_connectors.length}`
570
+ `VP response validation failed: "${e}.challenge_assert_connectors" must have exactly ${Y} entries, got ${t.challenge_assert_connectors.length}`
573
571
  );
574
572
  for (let n = 0; n < t.challenge_assert_connectors.length; n++)
575
- Xe(
573
+ Le(
576
574
  t.challenge_assert_connectors[n],
577
575
  `${e}.challenge_assert_connectors[${n}]`
578
576
  );
@@ -581,22 +579,22 @@ function Fe(r, e) {
581
579
  `VP response validation failed: "${e}.output_label_hashes" must be an array`
582
580
  );
583
581
  for (let n = 0; n < t.output_label_hashes.length; n++)
584
- ye(
582
+ fe(
585
583
  t.output_label_hashes[n],
586
584
  `${e}.output_label_hashes[${n}]`
587
585
  );
588
586
  }
589
- function Je(r) {
587
+ function Ke(r) {
590
588
  if (r === null || typeof r != "object")
591
589
  throw new o(
592
590
  "VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
593
591
  );
594
592
  const e = r;
595
- if (!me(e.tx_graph_json))
593
+ if (!ge(e.tx_graph_json))
596
594
  throw new o(
597
595
  `VP response validation failed: "tx_graph_json" must be a non-empty string, got ${h(e.tx_graph_json)}`
598
596
  );
599
- if (!T(e.verifying_key_hex))
597
+ if (!$(e.verifying_key_hex))
600
598
  throw new o(
601
599
  `VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${h(e.verifying_key_hex)}`
602
600
  );
@@ -612,26 +610,26 @@ function Je(r) {
612
610
  'VP response validation failed: "babe_sessions" must contain at least one challenger entry'
613
611
  );
614
612
  for (const [n, i] of t) {
615
- if (Q(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
613
+ if (z(n, `babe_sessions["${n}"]`), i === null || typeof i != "object")
616
614
  throw new o(
617
615
  `VP response validation failed: "babe_sessions.${n}" must be an object`
618
616
  );
619
617
  const s = i;
620
- if (!T(s.decryptor_artifacts_hex))
618
+ if (!$(s.decryptor_artifacts_hex))
621
619
  throw new o(
622
620
  `VP response validation failed: "babe_sessions.${n}.decryptor_artifacts_hex" must be a non-empty hex string, got ${h(s.decryptor_artifacts_hex)}`
623
621
  );
624
622
  }
625
623
  }
626
- function We(r) {
624
+ function Ue(r) {
627
625
  if (r === null || typeof r != "object")
628
626
  throw new o(
629
627
  "VP response validation failed: pegout status payload is not an object"
630
628
  );
631
629
  const e = r;
632
- if (!T(e.pegin_txid) || e.pegin_txid.length !== N)
630
+ if (!$(e.pegin_txid) || e.pegin_txid.length !== O)
633
631
  throw new o(
634
- `VP response validation failed: "pegin_txid" must be a ${N}-char hex string (txid), got ${h(e.pegin_txid)}`
632
+ `VP response validation failed: "pegin_txid" must be a ${O}-char hex string (txid), got ${h(e.pegin_txid)}`
635
633
  );
636
634
  if (typeof e.found != "boolean")
637
635
  throw new o(
@@ -642,16 +640,16 @@ function We(r) {
642
640
  throw new o(
643
641
  `VP response validation failed: "claimer" must be an object or null, got ${h(e.claimer)}`
644
642
  );
645
- Ye(e.claimer);
643
+ Xe(e.claimer);
646
644
  }
647
645
  if (!Array.isArray(e.challengers))
648
646
  throw new o(
649
647
  `VP response validation failed: "challengers" must be an array, got ${h(e.challengers)}`
650
648
  );
651
649
  for (let t = 0; t < e.challengers.length; t++)
652
- ze(e.challengers[t], t);
650
+ Fe(e.challengers[t], t);
653
651
  }
654
- function Ye(r) {
652
+ function Xe(r) {
655
653
  if (w(r.status, "claimer.status"), typeof r.failed != "boolean")
656
654
  throw new o(
657
655
  `VP response validation failed: "claimer.failed" must be a boolean, got ${h(r.failed)}`
@@ -665,19 +663,19 @@ function Ye(r) {
665
663
  `VP response validation failed: "claimer.updated_at" must be a number, got ${h(r.updated_at)}`
666
664
  );
667
665
  }
668
- function ze(r, e) {
666
+ function Fe(r, e) {
669
667
  if (r === null || typeof r != "object")
670
668
  throw new o(
671
669
  `VP response validation failed: "challengers[${e}]" must be an object, got ${h(r)}`
672
670
  );
673
671
  const t = r;
674
- if (w(t.status, `challengers[${e}].status`), w(t.claim_txid, `challengers[${e}].claim_txid`), w(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), G(t.assert_txid, `challengers[${e}].assert_txid`), G(
672
+ if (w(t.status, `challengers[${e}].status`), w(t.claim_txid, `challengers[${e}].claim_txid`), w(t.claimer_pubkey, `challengers[${e}].claimer_pubkey`), D(t.assert_txid, `challengers[${e}].assert_txid`), D(
675
673
  t.challenge_assert_x_txid,
676
674
  `challengers[${e}].challenge_assert_x_txid`
677
- ), G(
675
+ ), D(
678
676
  t.challenge_assert_y_txid,
679
677
  `challengers[${e}].challenge_assert_y_txid`
680
- ), G(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
678
+ ), D(t.nopayout_txid, `challengers[${e}].nopayout_txid`), typeof t.created_at != "number")
681
679
  throw new o(
682
680
  `VP response validation failed: "challengers[${e}].created_at" must be a number, got ${h(t.created_at)}`
683
681
  );
@@ -686,23 +684,23 @@ function ze(r, e) {
686
684
  `VP response validation failed: "challengers[${e}].updated_at" must be a number, got ${h(t.updated_at)}`
687
685
  );
688
686
  }
689
- function G(r, e) {
687
+ function D(r, e) {
690
688
  if (r !== null && typeof r != "string")
691
689
  throw new o(
692
690
  `VP response validation failed: "${e}" must be a string or null, got ${h(r)}`
693
691
  );
694
692
  }
695
- function qe(r) {
696
- we(r, "batchGetPeginStatus", (e) => {
697
- e.result !== null && be(e.result);
693
+ function Je(r) {
694
+ me(r, "batchGetPeginStatus", (e) => {
695
+ e.result !== null && _e(e.result);
698
696
  });
699
697
  }
700
- function Ze(r) {
701
- we(r, "batchGetPegoutStatus", (e) => {
702
- e.result !== null && We(e.result);
698
+ function We(r) {
699
+ me(r, "batchGetPegoutStatus", (e) => {
700
+ e.result !== null && Ue(e.result);
703
701
  });
704
702
  }
705
- function we(r, e, t) {
703
+ function me(r, e, t) {
706
704
  if (r === null || typeof r != "object")
707
705
  throw new o(
708
706
  `VP response validation failed: ${e} response is not an object`
@@ -719,9 +717,9 @@ function we(r, e, t) {
719
717
  `VP response validation failed: "${e}.results[${i}]" must be an object, got ${h(s)}`
720
718
  );
721
719
  const a = s;
722
- if (!T(a.pegin_txid) || a.pegin_txid.length !== N)
720
+ if (!$(a.pegin_txid) || a.pegin_txid.length !== O)
723
721
  throw new o(
724
- `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${N}-char hex string, got ${h(a.pegin_txid)}`
722
+ `VP response validation failed: "${e}.results[${i}].pegin_txid" must be a ${O}-char hex string, got ${h(a.pegin_txid)}`
725
723
  );
726
724
  if (a.error !== null && typeof a.error != "string")
727
725
  throw new o(
@@ -738,13 +736,13 @@ function we(r, e, t) {
738
736
  t(a, i);
739
737
  }
740
738
  }
741
- function Qe(r) {
742
- if (A(r.claim_tx, "depositor_graph.claim_tx"), A(r.assert_tx, "depositor_graph.assert_tx"), A(r.payout_tx, "depositor_graph.payout_tx"), w(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
739
+ function ze(r) {
740
+ if (v(r.claim_tx, "depositor_graph.claim_tx"), v(r.assert_tx, "depositor_graph.assert_tx"), v(r.payout_tx, "depositor_graph.payout_tx"), w(r.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(r.challenger_presign_data))
743
741
  throw new o(
744
742
  'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
745
743
  );
746
744
  for (let e = 0; e < r.challenger_presign_data.length; e++)
747
- Fe(
745
+ He(
748
746
  r.challenger_presign_data[e],
749
747
  `depositor_graph.challenger_presign_data[${e}]`
750
748
  );
@@ -753,13 +751,13 @@ function Qe(r) {
753
751
  'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
754
752
  );
755
753
  }
756
- const et = 6e4;
757
- class tt {
754
+ const Ye = 6e4;
755
+ class qe {
758
756
  constructor(e, t) {
759
757
  f(this, "client");
760
758
  const n = {
761
759
  baseUrl: e,
762
- timeout: (t == null ? void 0 : t.timeout) ?? et,
760
+ timeout: (t == null ? void 0 : t.timeout) ?? Ye,
763
761
  retries: t == null ? void 0 : t.retries,
764
762
  retryDelay: t == null ? void 0 : t.retryDelay,
765
763
  retryableFor: t == null ? void 0 : t.retryableFor,
@@ -767,7 +765,7 @@ class tt {
767
765
  tokenProvider: t == null ? void 0 : t.tokenProvider,
768
766
  maxResponseBytes: t == null ? void 0 : t.maxResponseBytes
769
767
  };
770
- this.client = new _e(n);
768
+ this.client = new pe(n);
771
769
  }
772
770
  /**
773
771
  * Request the payout/claim/assert transactions that the depositor
@@ -775,7 +773,7 @@ class tt {
775
773
  */
776
774
  async requestDepositorPresignTransactions(e, t) {
777
775
  const n = await this.client.call("vaultProvider_requestDepositorPresignTransactions", e, t);
778
- return Ke(n), n;
776
+ return Ge(n), n;
779
777
  }
780
778
  /**
781
779
  * Submit the depositor's pre-signatures for the payout transactions
@@ -806,7 +804,7 @@ class tt {
806
804
  */
807
805
  async requestDepositorClaimerArtifacts(e, t) {
808
806
  const n = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", e, t);
809
- return Je(n), n;
807
+ return Ke(n), n;
810
808
  }
811
809
  /** Get the current pegin status from the vault provider daemon. */
812
810
  async getPeginStatus(e, t) {
@@ -815,7 +813,7 @@ class tt {
815
813
  e,
816
814
  t
817
815
  );
818
- return be(n), n;
816
+ return _e(n), n;
819
817
  }
820
818
  /**
821
819
  * Get pegin status for many txids in one round trip. Per-result envelope
@@ -824,7 +822,7 @@ class tt {
824
822
  */
825
823
  async batchGetPeginStatus(e, t) {
826
824
  const n = await this.client.call("vaultProvider_batchGetPeginStatus", e, t);
827
- return qe(n), n;
825
+ return Je(n), n;
828
826
  }
829
827
  /**
830
828
  * Get pegout status for many txids in one round trip. Same per-result
@@ -832,54 +830,7 @@ class tt {
832
830
  */
833
831
  async batchGetPegoutStatus(e, t) {
834
832
  const n = await this.client.call("vaultProvider_batchGetPegoutStatus", e, t);
835
- return Ze(n), n;
836
- }
837
- }
838
- const rt = "BIP0322-signed-message", nt = "TapTweak", xe = 32, st = 64;
839
- function Pe(r, e) {
840
- const t = new TextEncoder().encode(r), n = Y(t), i = new Uint8Array(n.length * 2 + e.length);
841
- return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), Y(i);
842
- }
843
- function it(r) {
844
- if (r.length !== xe) return null;
845
- const e = Pe(nt, r), t = K.xOnlyPointAddTweak(r, e);
846
- return t ? t.xOnlyPubkey : null;
847
- }
848
- function at(r, e, t) {
849
- if (e.length !== xe || t.length !== st) return !1;
850
- try {
851
- const n = Pe(rt, r), i = De.p2tr({
852
- internalPubkey: V.from(e)
853
- });
854
- if (!i.output) return !1;
855
- const s = i.output, a = 0, c = new X();
856
- c.version = 0, c.locktime = 0;
857
- const d = V.concat([
858
- V.from([0, 32]),
859
- V.from(n)
860
- ]);
861
- c.addInput(
862
- V.alloc(32, 0),
863
- // prev_txid = 0x0000...0000
864
- 4294967295,
865
- // prev_vout = 0xFFFFFFFF
866
- 0,
867
- // sequence = 0
868
- d
869
- ), c.addOutput(s, a);
870
- const l = new X();
871
- l.version = 0, l.locktime = 0;
872
- const g = c.getHash();
873
- l.addInput(g, 0, 0), l.addOutput(V.from([106]), a);
874
- const m = l.hashForWitnessV1(
875
- 0,
876
- [s],
877
- [a],
878
- X.SIGHASH_DEFAULT
879
- ), x = it(e);
880
- return x ? K.verifySchnorr(m, x, t) : !1;
881
- } catch {
882
- return !1;
833
+ return We(n), n;
883
834
  }
884
835
  }
885
836
  function L(r, e) {
@@ -907,30 +858,30 @@ function L(r, e) {
907
858
  i[1 + s] = Number(n >> BigInt((7 - s) * 8)) & 255;
908
859
  return i;
909
860
  }
910
- function ve(...r) {
861
+ function ye(...r) {
911
862
  const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
912
863
  let n = 0;
913
864
  for (const i of r)
914
865
  t.set(i, n), n += i.length;
915
866
  return t;
916
867
  }
917
- function ae(r) {
868
+ function re(r) {
918
869
  const t = [L(4, r.length)];
919
870
  for (const n of r)
920
871
  t.push(L(0, n));
921
- return ve(...t);
872
+ return ye(...t);
922
873
  }
923
- function ot(r, e, t) {
874
+ function Qe(r, e, t) {
924
875
  if (!Number.isSafeInteger(t) || t < 0)
925
876
  throw new Error(
926
877
  `encodeServerIdentityPayload: expires_at must be a non-negative safe integer, got ${t}`
927
878
  );
928
- const n = L(4, 3), i = ae(r), s = ae(e), a = L(0, t);
929
- return ve(n, i, s, a);
879
+ const n = L(4, 3), i = re(r), s = re(e), a = L(0, t);
880
+ return ye(n, i, s, a);
930
881
  }
931
- const ct = new TextEncoder().encode(
882
+ const Ze = new TextEncoder().encode(
932
883
  "btc-auth.server-identity.v1"
933
- ), lt = 2 * 3600;
884
+ ), et = 2 * 3600;
934
885
  class b extends Error {
935
886
  constructor(e, t) {
936
887
  super(e), this.reason = t, this.name = "ServerIdentityError";
@@ -942,15 +893,15 @@ function M(r) {
942
893
  e[t] = parseInt(r.slice(t * 2, t * 2 + 2), 16);
943
894
  return e;
944
895
  }
945
- function ut(r) {
946
- const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? lt, s = I(t).toLowerCase();
947
- if (s.length !== O || !k.test(s))
896
+ function tt(r) {
897
+ const { proof: e, pinnedServerPubkey: t, now: n } = r, i = r.maxLifetimeSecs ?? et, s = V(t).toLowerCase();
898
+ if (s.length !== R || !k.test(s))
948
899
  throw new b(
949
900
  `pinnedServerPubkey must be 32-byte hex; got ${s.length} chars`,
950
901
  "invalid_pubkey_encoding"
951
902
  );
952
- const a = I(e.server_pubkey).toLowerCase();
953
- if (a.length !== O || !k.test(a))
903
+ const a = V(e.server_pubkey).toLowerCase();
904
+ if (a.length !== R || !k.test(a))
954
905
  throw new b(
955
906
  `server_pubkey must be 32-byte hex; got ${a.length} chars`,
956
907
  "invalid_pubkey_encoding"
@@ -985,63 +936,63 @@ function ut(r) {
985
936
  `server identity proof expires too far in the future: expires_at=${e.expires_at}, now=${n}, max lifetime=${i}s`,
986
937
  "expires_too_far"
987
938
  );
988
- const c = I(e.ephemeral_pubkey).toLowerCase();
989
- if (c.length !== j || !k.test(c))
939
+ const c = V(e.ephemeral_pubkey).toLowerCase();
940
+ if (c.length !== G || !k.test(c))
990
941
  throw new b(
991
942
  `ephemeral_pubkey must be 33-byte compressed hex; got ${c.length} chars`,
992
943
  "invalid_ephemeral_pubkey"
993
944
  );
994
- const d = c.slice(0, 2);
995
- if (d !== "02" && d !== "03")
945
+ const u = c.slice(0, 2);
946
+ if (u !== "02" && u !== "03")
996
947
  throw new b(
997
- `ephemeral_pubkey must be compressed (prefix 02/03); got ${d}`,
948
+ `ephemeral_pubkey must be compressed (prefix 02/03); got ${u}`,
998
949
  "invalid_ephemeral_pubkey"
999
950
  );
1000
- const l = M(c);
1001
- if (!K.isPoint(l))
951
+ const d = M(c);
952
+ if (!he.isPoint(d))
1002
953
  throw new b(
1003
954
  "ephemeral_pubkey is not a valid secp256k1 point",
1004
955
  "invalid_ephemeral_pubkey"
1005
956
  );
1006
- const g = I(e.signature).toLowerCase();
1007
- if (g.length !== Re || !k.test(g))
957
+ const g = V(e.signature).toLowerCase();
958
+ if (g.length !== $e || !k.test(g))
1008
959
  throw new b(
1009
960
  `signature must be 64-byte Schnorr hex; got ${g.length} chars`,
1010
961
  "invalid_signature_encoding"
1011
962
  );
1012
- const m = ot(
1013
- ct,
963
+ const y = Qe(
964
+ Ze,
1014
965
  M(c),
1015
966
  e.expires_at
1016
967
  );
1017
- if (!at(m, M(a), M(g)))
968
+ if (!Se(y, M(a), M(g)))
1018
969
  throw new b(
1019
970
  "BIP-322 signature verification failed — ephemeral key is not attested by pinned server pubkey",
1020
971
  "signature_verification_failed"
1021
972
  );
1022
973
  }
1023
- const dt = /* @__PURE__ */ new Set([
974
+ const rt = /* @__PURE__ */ new Set([
1024
975
  "vaultProvider_submitDepositorWotsKey",
1025
976
  "vaultProvider_submitDepositorPresignatures",
1026
977
  "vaultProvider_requestDepositorPresignTransactions"
1027
- ]), pt = /* @__PURE__ */ new Set([
978
+ ]), nt = /* @__PURE__ */ new Set([
1028
979
  "vaultProvider_requestDepositorClaimerArtifacts"
1029
- ]), ht = 6e4, z = "auth_createDepositorToken", q = "auth_createDepositorTokenGrpc";
1030
- function Ae(r, e) {
1031
- return new _e({
980
+ ]), st = 6e4, F = "auth_createDepositorToken", J = "auth_createDepositorTokenGrpc";
981
+ function be(r, e) {
982
+ return new pe({
1032
983
  baseUrl: r,
1033
- timeout: ht,
984
+ timeout: st,
1034
985
  headers: e,
1035
- retryableFor: (t) => t === z || t === q
986
+ retryableFor: (t) => t === F || t === J
1036
987
  });
1037
988
  }
1038
- const gt = 0, ft = 1, F = 2, _t = 3, mt = 4, yt = 5, bt = 6, wt = 7, oe = 24, xt = 28, Pt = 20, vt = 21, At = 22, ce = 256;
1039
- class v extends Error {
989
+ const it = 0, at = 1, K = 2, ot = 3, ct = 4, lt = 5, ut = 6, dt = 7, ne = 24, pt = 28, ht = 20, gt = 21, ft = 22, se = 256;
990
+ class P extends Error {
1040
991
  constructor(e) {
1041
992
  super(`CBOR decode: ${e}`), this.name = "CborDecodeError";
1042
993
  }
1043
994
  }
1044
- class Ee {
995
+ class we {
1045
996
  constructor(e) {
1046
997
  f(this, "buf");
1047
998
  /** Current read offset. Public so callers can slice encoded sub-ranges. */
@@ -1050,7 +1001,7 @@ class Ee {
1050
1001
  }
1051
1002
  nextByte() {
1052
1003
  if (this.pos >= this.buf.length)
1053
- throw new v("unexpected end of input");
1004
+ throw new P("unexpected end of input");
1054
1005
  return this.buf[this.pos++];
1055
1006
  }
1056
1007
  /**
@@ -1061,24 +1012,24 @@ class Ee {
1061
1012
  */
1062
1013
  readHead() {
1063
1014
  const e = this.nextByte(), t = e >> 5, n = e & 31;
1064
- if (n < oe)
1015
+ if (n < ne)
1065
1016
  return { major: t, arg: n };
1066
- if (n >= xt)
1067
- throw new v(
1017
+ if (n >= pt)
1018
+ throw new P(
1068
1019
  `unsupported additional info ${n} (indefinite-length or reserved)`
1069
1020
  );
1070
- const i = 1 << n - oe;
1021
+ const i = 1 << n - ne;
1071
1022
  let s = 0n;
1072
1023
  for (let a = 0; a < i; a++)
1073
1024
  s = s << 8n | BigInt(this.nextByte());
1074
1025
  if (s > BigInt(Number.MAX_SAFE_INTEGER))
1075
- throw new v(`argument ${s} exceeds safe integer range`);
1026
+ throw new P(`argument ${s} exceeds safe integer range`);
1076
1027
  return { major: t, arg: Number(s) };
1077
1028
  }
1078
1029
  /** Read `length` raw bytes as a sub-array view into the backing buffer. */
1079
1030
  readBytes(e) {
1080
1031
  if (this.pos + e > this.buf.length)
1081
- throw new v("length overruns end of input");
1032
+ throw new P("length overruns end of input");
1082
1033
  const t = this.buf.subarray(this.pos, this.pos + e);
1083
1034
  return this.pos += e, t;
1084
1035
  }
@@ -1088,9 +1039,9 @@ class Ee {
1088
1039
  */
1089
1040
  readByteString() {
1090
1041
  const e = this.readHead();
1091
- if (e.major !== F)
1092
- throw new v(
1093
- `expected byte string (major ${F}), got major ${e.major}`
1042
+ if (e.major !== K)
1043
+ throw new P(
1044
+ `expected byte string (major ${K}), got major ${e.major}`
1094
1045
  );
1095
1046
  return this.readBytes(e.arg);
1096
1047
  }
@@ -1102,29 +1053,29 @@ class Ee {
1102
1053
  * native call stack (see {@link MAX_NESTING_DEPTH}).
1103
1054
  */
1104
1055
  readValue(e = 0) {
1105
- if (e > ce)
1106
- throw new v(
1107
- `nesting exceeds maximum depth ${ce}`
1056
+ if (e > se)
1057
+ throw new P(
1058
+ `nesting exceeds maximum depth ${se}`
1108
1059
  );
1109
1060
  const t = this.readHead();
1110
1061
  switch (t.major) {
1111
- case gt:
1062
+ case it:
1112
1063
  return t.arg;
1113
- case ft:
1064
+ case at:
1114
1065
  return -1 - t.arg;
1115
- case F:
1066
+ case K:
1116
1067
  return this.readBytes(t.arg);
1117
- case _t:
1068
+ case ot:
1118
1069
  return new TextDecoder("utf-8", { fatal: !0 }).decode(
1119
1070
  this.readBytes(t.arg)
1120
1071
  );
1121
- case mt: {
1072
+ case ct: {
1122
1073
  const n = [];
1123
1074
  for (let i = 0; i < t.arg; i++)
1124
1075
  n.push(this.readValue(e + 1));
1125
1076
  return n;
1126
1077
  }
1127
- case yt: {
1078
+ case lt: {
1128
1079
  const n = /* @__PURE__ */ new Map();
1129
1080
  for (let i = 0; i < t.arg; i++) {
1130
1081
  const s = this.readValue(e + 1), a = this.readValue(e + 1);
@@ -1132,57 +1083,57 @@ class Ee {
1132
1083
  }
1133
1084
  return n;
1134
1085
  }
1135
- case bt:
1086
+ case ut:
1136
1087
  return { tag: t.arg, value: this.readValue(e + 1) };
1137
- case wt:
1138
- if (t.arg === Pt) return !1;
1139
- if (t.arg === vt) return !0;
1140
- if (t.arg === At) return null;
1141
- throw new v(
1088
+ case dt:
1089
+ if (t.arg === ht) return !1;
1090
+ if (t.arg === gt) return !0;
1091
+ if (t.arg === ft) return null;
1092
+ throw new P(
1142
1093
  `unsupported simple/float value ${t.arg}`
1143
1094
  );
1144
1095
  default:
1145
- throw new v(`unsupported major type ${t.major}`);
1096
+ throw new P(`unsupported major type ${t.major}`);
1146
1097
  }
1147
1098
  }
1148
1099
  }
1149
- function Se(r) {
1150
- const e = new Ee(r), t = e.readValue();
1100
+ function xe(r) {
1101
+ const e = new we(r), t = e.readValue();
1151
1102
  if (e.pos !== r.length)
1152
- throw new v("trailing bytes after top-level item");
1103
+ throw new P("trailing bytes after top-level item");
1153
1104
  return t;
1154
1105
  }
1155
- const Et = "vaultd-jsonrpc", St = "vaultd-grpc", le = 18, Z = 4, ue = -47, kt = 1, de = 64, Ct = 128, Tt = 96, $t = 64, Vt = 1, It = 2, Rt = 3, Ot = 4, Nt = 5, Bt = 6, Dt = 7, pe = new TextEncoder().encode("Signature1");
1106
+ const _t = "vaultd-jsonrpc", mt = "vaultd-grpc", ie = 18, W = 4, ae = -47, yt = 1, oe = 64, bt = 128, wt = 96, xt = 64, Pt = 1, vt = 2, At = 3, Et = 4, Ct = 5, kt = 6, St = 7, ce = new TextEncoder().encode("Signature1");
1156
1107
  class p extends Error {
1157
1108
  constructor(e, t) {
1158
1109
  super(e), this.reason = t, this.name = "CwtVerificationError";
1159
1110
  }
1160
1111
  }
1161
- function Gt(r) {
1162
- const e = he(
1112
+ function $t(r) {
1113
+ const e = le(
1163
1114
  r.expectedIssuerXOnlyPubkey,
1164
1115
  "expectedIssuerXOnlyPubkey"
1165
- ), t = he(
1116
+ ), t = le(
1166
1117
  r.expectedAudienceXOnlyPubkey,
1167
1118
  "expectedAudienceXOnlyPubkey"
1168
- ), n = Kt(r.ephemeralPubkeyHex), i = Xt(r.token), s = new Ee(i), a = s.readHead();
1169
- if (a.major !== 6 || a.arg !== le)
1119
+ ), n = Ot(r.ephemeralPubkeyHex), i = Bt(r.token), s = new we(i), a = s.readHead();
1120
+ if (a.major !== 6 || a.arg !== ie)
1170
1121
  throw new p(
1171
- `token is not a COSE Sign1 tagged value (tag ${le})`,
1122
+ `token is not a COSE Sign1 tagged value (tag ${ie})`,
1172
1123
  "invalid_token_structure"
1173
1124
  );
1174
1125
  const c = s.readHead();
1175
- if (c.major !== 4 || c.arg !== Z)
1126
+ if (c.major !== 4 || c.arg !== W)
1176
1127
  throw new p(
1177
- `COSE Sign1 must be a ${Z}-element array`,
1128
+ `COSE Sign1 must be a ${W}-element array`,
1178
1129
  "invalid_token_structure"
1179
1130
  );
1180
- const d = s.pos, l = s.readByteString(), g = i.subarray(d, s.pos);
1131
+ const u = s.pos, d = s.readByteString(), g = i.subarray(u, s.pos);
1181
1132
  s.readValue();
1182
- const m = s.pos, x = s.readByteString(), E = i.subarray(m, s.pos), C = s.readByteString();
1183
- if (C.length !== de)
1133
+ const y = s.pos, A = s.readByteString(), E = i.subarray(y, s.pos), S = s.readByteString();
1134
+ if (S.length !== oe)
1184
1135
  throw new p(
1185
- `COSE signature must be ${de} bytes, got ${C.length}`,
1136
+ `COSE signature must be ${oe} bytes, got ${S.length}`,
1186
1137
  "invalid_token_structure"
1187
1138
  );
1188
1139
  if (s.pos !== i.length)
@@ -1190,81 +1141,81 @@ function Gt(r) {
1190
1141
  "COSE Sign1 token has trailing bytes after the signature",
1191
1142
  "invalid_token_structure"
1192
1143
  );
1193
- const P = Mt(l);
1194
- if (P !== ue)
1144
+ const x = Tt(d);
1145
+ if (x !== ae)
1195
1146
  throw new p(
1196
- `unexpected COSE algorithm ${P} (expected ES256K ${ue})`,
1147
+ `unexpected COSE algorithm ${x} (expected ES256K ${ae})`,
1197
1148
  "unexpected_algorithm"
1198
1149
  );
1199
- const $ = jt(g, E), _ = Y($);
1200
- if (!K.verify(_, n, C, !0))
1150
+ const T = Vt(g, E), _ = Re(T);
1151
+ if (!he.verify(_, n, S, !0))
1201
1152
  throw new p(
1202
1153
  "COSE signature does not verify against the server's ephemeral key",
1203
1154
  "signature_verification_failed"
1204
1155
  );
1205
- const u = Ht(x), S = u.audience.toLowerCase();
1206
- if (S.length !== O || !k.test(S))
1156
+ const l = It(A), C = l.audience.toLowerCase();
1157
+ if (C.length !== R || !k.test(C))
1207
1158
  throw new p(
1208
1159
  "token `aud` is not a 32-byte x-only pubkey hex",
1209
1160
  "invalid_claims"
1210
1161
  );
1211
- if (u.issuedAt > u.expiresAt)
1162
+ if (l.issuedAt > l.expiresAt)
1212
1163
  throw new p(
1213
- `token iat (${u.issuedAt}) is after exp (${u.expiresAt})`,
1164
+ `token iat (${l.issuedAt}) is after exp (${l.expiresAt})`,
1214
1165
  "invalid_claims"
1215
1166
  );
1216
- if (u.issuer.toLowerCase() !== e)
1167
+ if (l.issuer.toLowerCase() !== e)
1217
1168
  throw new p(
1218
- `token issuer does not match pinned server pubkey: expected ${e}, got ${u.issuer.toLowerCase()}`,
1169
+ `token issuer does not match pinned server pubkey: expected ${e}, got ${l.issuer.toLowerCase()}`,
1219
1170
  "issuer_mismatch"
1220
1171
  );
1221
- if (u.subject !== r.expectedSubject)
1172
+ if (l.subject !== r.expectedSubject)
1222
1173
  throw new p(
1223
- `token subject mismatch: expected ${r.expectedSubject}, got ${u.subject}`,
1174
+ `token subject mismatch: expected ${r.expectedSubject}, got ${l.subject}`,
1224
1175
  "subject_mismatch"
1225
1176
  );
1226
- if (S !== t)
1177
+ if (C !== t)
1227
1178
  throw new p(
1228
- `token audience does not match depositor pubkey: expected ${t}, got ${S}`,
1179
+ `token audience does not match depositor pubkey: expected ${t}, got ${C}`,
1229
1180
  "audience_mismatch"
1230
1181
  );
1231
- if (u.expiresAt <= r.now)
1182
+ if (l.expiresAt <= r.now)
1232
1183
  throw new p(
1233
- `token expired: exp ${u.expiresAt} <= now ${r.now}`,
1184
+ `token expired: exp ${l.expiresAt} <= now ${r.now}`,
1234
1185
  "token_expired"
1235
1186
  );
1236
- if (r.responseExpiresAt !== u.expiresAt)
1187
+ if (r.responseExpiresAt !== l.expiresAt)
1237
1188
  throw new p(
1238
- `response expires_at (${r.responseExpiresAt}) does not equal token exp (${u.expiresAt})`,
1189
+ `response expires_at (${r.responseExpiresAt}) does not equal token exp (${l.expiresAt})`,
1239
1190
  "expiry_mismatch"
1240
1191
  );
1241
- if (r.serverIdentityExpiresAt < u.expiresAt)
1192
+ if (r.serverIdentityExpiresAt < l.expiresAt)
1242
1193
  throw new p(
1243
- `server identity expires (${r.serverIdentityExpiresAt}) before token exp (${u.expiresAt})`,
1194
+ `server identity expires (${r.serverIdentityExpiresAt}) before token exp (${l.expiresAt})`,
1244
1195
  "server_identity_expires_before_token"
1245
1196
  );
1246
1197
  return {
1247
- issuer: u.issuer,
1248
- subject: u.subject,
1249
- audience: S,
1250
- expiresAt: u.expiresAt,
1251
- notBefore: u.notBefore,
1252
- issuedAt: u.issuedAt
1198
+ issuer: l.issuer,
1199
+ subject: l.subject,
1200
+ audience: C,
1201
+ expiresAt: l.expiresAt,
1202
+ notBefore: l.notBefore,
1203
+ issuedAt: l.issuedAt
1253
1204
  };
1254
1205
  }
1255
- function Mt(r) {
1206
+ function Tt(r) {
1256
1207
  if (r.length === 0)
1257
1208
  throw new p(
1258
1209
  "empty COSE protected header (no algorithm)",
1259
1210
  "unexpected_algorithm"
1260
1211
  );
1261
- const e = Se(r);
1212
+ const e = xe(r);
1262
1213
  if (!(e instanceof Map))
1263
1214
  throw new p(
1264
1215
  "COSE protected header is not a map",
1265
1216
  "invalid_token_structure"
1266
1217
  );
1267
- const t = e.get(kt);
1218
+ const t = e.get(yt);
1268
1219
  if (typeof t != "number")
1269
1220
  throw new p(
1270
1221
  "COSE protected header missing integer algorithm label",
@@ -1272,35 +1223,35 @@ function Mt(r) {
1272
1223
  );
1273
1224
  return t;
1274
1225
  }
1275
- function jt(r, e) {
1276
- return Ft(
1277
- Uint8Array.of(Ct | Z),
1278
- Uint8Array.of(Tt | pe.length),
1279
- pe,
1226
+ function Vt(r, e) {
1227
+ return Dt(
1228
+ Uint8Array.of(bt | W),
1229
+ Uint8Array.of(wt | ce.length),
1230
+ ce,
1280
1231
  r,
1281
- Uint8Array.of($t),
1232
+ Uint8Array.of(xt),
1282
1233
  e
1283
1234
  );
1284
1235
  }
1285
- function Ht(r) {
1286
- const e = Se(r);
1236
+ function It(r) {
1237
+ const e = xe(r);
1287
1238
  if (!(e instanceof Map))
1288
1239
  throw new p(
1289
1240
  "CWT claims root is not a map",
1290
1241
  "invalid_claims"
1291
1242
  );
1292
- if (Lt(e, Dt, "cti").length === 0)
1243
+ if (Rt(e, St, "cti").length === 0)
1293
1244
  throw new p("token cti is empty", "invalid_claims");
1294
1245
  return {
1295
- issuer: J(e, Vt, "iss"),
1296
- subject: J(e, It, "sub"),
1297
- audience: J(e, Rt, "aud"),
1298
- expiresAt: W(e, Ot, "exp"),
1299
- notBefore: W(e, Nt, "nbf"),
1300
- issuedAt: W(e, Bt, "iat")
1246
+ issuer: U(e, Pt, "iss"),
1247
+ subject: U(e, vt, "sub"),
1248
+ audience: U(e, At, "aud"),
1249
+ expiresAt: X(e, Et, "exp"),
1250
+ notBefore: X(e, Ct, "nbf"),
1251
+ issuedAt: X(e, kt, "iat")
1301
1252
  };
1302
1253
  }
1303
- function J(r, e, t) {
1254
+ function U(r, e, t) {
1304
1255
  const n = r.get(e);
1305
1256
  if (typeof n != "string")
1306
1257
  throw new p(
@@ -1309,7 +1260,7 @@ function J(r, e, t) {
1309
1260
  );
1310
1261
  return n;
1311
1262
  }
1312
- function Lt(r, e, t) {
1263
+ function Rt(r, e, t) {
1313
1264
  const n = r.get(e);
1314
1265
  if (!(n instanceof Uint8Array))
1315
1266
  throw new p(
@@ -1318,7 +1269,7 @@ function Lt(r, e, t) {
1318
1269
  );
1319
1270
  return n;
1320
1271
  }
1321
- function W(r, e, t) {
1272
+ function X(r, e, t) {
1322
1273
  const n = r.get(e);
1323
1274
  if (typeof n != "number" || !Number.isSafeInteger(n) || n < 0)
1324
1275
  throw new p(
@@ -1327,39 +1278,39 @@ function W(r, e, t) {
1327
1278
  );
1328
1279
  return n;
1329
1280
  }
1330
- function he(r, e) {
1331
- const t = I(r).toLowerCase();
1332
- if (t.length !== O || !k.test(t))
1281
+ function le(r, e) {
1282
+ const t = V(r).toLowerCase();
1283
+ if (t.length !== R || !k.test(t))
1333
1284
  throw new p(
1334
1285
  `${e} must be 32-byte x-only hex; got ${t.length} chars`,
1335
1286
  "invalid_input"
1336
1287
  );
1337
1288
  return t;
1338
1289
  }
1339
- function Kt(r) {
1340
- const e = I(r).toLowerCase(), t = e.slice(0, 2);
1341
- if (e.length !== j || !k.test(e) || t !== "02" && t !== "03")
1290
+ function Ot(r) {
1291
+ const e = V(r).toLowerCase(), t = e.slice(0, 2);
1292
+ if (e.length !== G || !k.test(e) || t !== "02" && t !== "03")
1342
1293
  throw new p(
1343
1294
  "ephemeralPubkeyHex must be 33-byte compressed pubkey hex (prefix 02/03)",
1344
1295
  "invalid_input"
1345
1296
  );
1346
- return Oe(e);
1297
+ return Te(e);
1347
1298
  }
1348
- const Ut = (() => {
1299
+ const Nt = (() => {
1349
1300
  const r = new Int16Array(128).fill(-1), e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1350
1301
  for (let t = 0; t < e.length; t++)
1351
1302
  r[e.charCodeAt(t)] = t;
1352
1303
  return r;
1353
1304
  })();
1354
- function Xt(r) {
1305
+ function Bt(r) {
1355
1306
  const e = r.length, t = Math.floor(e / 4), n = e % 4;
1356
1307
  if (n === 1)
1357
1308
  throw new p(
1358
1309
  "invalid base64url length",
1359
1310
  "invalid_token_structure"
1360
1311
  );
1361
- const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), a = (l) => {
1362
- const g = l < 128 ? Ut[l] : -1;
1312
+ const i = t * 3 + (n === 0 ? 0 : n - 1), s = new Uint8Array(i), a = (d) => {
1313
+ const g = d < 128 ? Nt[d] : -1;
1363
1314
  if (g < 0)
1364
1315
  throw new p(
1365
1316
  "invalid base64url character",
@@ -1367,29 +1318,29 @@ function Xt(r) {
1367
1318
  );
1368
1319
  return g;
1369
1320
  };
1370
- let c = 0, d = 0;
1371
- for (let l = 0; l < t; l++) {
1372
- const g = a(r.charCodeAt(c++)), m = a(r.charCodeAt(c++)), x = a(r.charCodeAt(c++)), E = a(r.charCodeAt(c++));
1373
- s[d++] = g << 2 | m >> 4, s[d++] = (m & 15) << 4 | x >> 2, s[d++] = (x & 3) << 6 | E;
1321
+ let c = 0, u = 0;
1322
+ for (let d = 0; d < t; d++) {
1323
+ const g = a(r.charCodeAt(c++)), y = a(r.charCodeAt(c++)), A = a(r.charCodeAt(c++)), E = a(r.charCodeAt(c++));
1324
+ s[u++] = g << 2 | y >> 4, s[u++] = (y & 15) << 4 | A >> 2, s[u++] = (A & 3) << 6 | E;
1374
1325
  }
1375
1326
  if (n === 2) {
1376
- const l = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++));
1377
- s[d++] = l << 2 | g >> 4;
1327
+ const d = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++));
1328
+ s[u++] = d << 2 | g >> 4;
1378
1329
  } else if (n === 3) {
1379
- const l = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++)), m = a(r.charCodeAt(c++));
1380
- s[d++] = l << 2 | g >> 4, s[d++] = (g & 15) << 4 | m >> 2;
1330
+ const d = a(r.charCodeAt(c++)), g = a(r.charCodeAt(c++)), y = a(r.charCodeAt(c++));
1331
+ s[u++] = d << 2 | g >> 4, s[u++] = (g & 15) << 4 | y >> 2;
1381
1332
  }
1382
1333
  return s;
1383
1334
  }
1384
- function Ft(...r) {
1335
+ function Dt(...r) {
1385
1336
  const e = r.reduce((i, s) => i + s.length, 0), t = new Uint8Array(e);
1386
1337
  let n = 0;
1387
1338
  for (const i of r)
1388
1339
  t.set(i, n), n += i.length;
1389
1340
  return t;
1390
1341
  }
1391
- const ge = 4102444800, Jt = 30;
1392
- class Wt {
1342
+ const ue = 4102444800, Mt = 30;
1343
+ class Gt {
1393
1344
  constructor(e) {
1394
1345
  // `client` is the only mutable field — see `setClient`. The
1395
1346
  // identity-bearing fields (peginTxid/authAnchorHex/pinnedServerPubkey)
@@ -1410,7 +1361,7 @@ class Wt {
1410
1361
  /** Cached gRPC-subject bearer (auth_createDepositorTokenGrpc). */
1411
1362
  f(this, "cachedGrpc", null);
1412
1363
  f(this, "inFlightGrpc", null);
1413
- this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Jt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1364
+ this.client = e.client, this.peginTxid = e.peginTxid, this.authAnchorHex = e.authAnchorHex, this.pinnedServerPubkey = e.pinnedServerPubkey, this.expectedAudienceXOnlyPubkey = e.expectedAudienceXOnlyPubkey, this.authGatedMethods = e.authGatedMethods, this.grpcGatedMethods = e.grpcGatedMethods, this.refreshSkewSecs = e.refreshSkewSecs ?? Mt, this.now = e.now ?? (() => Math.floor(Date.now() / 1e3));
1414
1365
  }
1415
1366
  /**
1416
1367
  * Return a bearer token for `method`, or `null` if `method` is not
@@ -1430,7 +1381,7 @@ class Wt {
1430
1381
  * deterministically.
1431
1382
  */
1432
1383
  async getToken(e) {
1433
- return e === z || e === q ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
1384
+ return e === F || e === J ? null : this.grpcGatedMethods.has(e) ? this.getTokenForSubject("grpc") : this.authGatedMethods.has(e) ? this.getTokenForSubject("jsonrpc") : null;
1434
1385
  }
1435
1386
  /**
1436
1387
  * Drop both cached tokens. Next `getToken` call re-acquires the slot
@@ -1463,13 +1414,13 @@ class Wt {
1463
1414
  acquireSingleFlight(e) {
1464
1415
  const t = e === "grpc" ? this.inFlightGrpc : this.inFlightJsonRpc;
1465
1416
  if (t) return t;
1466
- const n = e === "grpc" ? q : z, i = (async () => {
1417
+ const n = e === "grpc" ? J : F, i = (async () => {
1467
1418
  try {
1468
1419
  const s = await this.client.call(n, {
1469
1420
  pegin_txid: this.peginTxid,
1470
1421
  auth_anchor: this.authAnchorHex
1471
1422
  });
1472
- if (ut({
1423
+ if (tt({
1473
1424
  proof: s.server_identity,
1474
1425
  pinnedServerPubkey: this.pinnedServerPubkey,
1475
1426
  now: this.now()
@@ -1478,15 +1429,15 @@ class Wt {
1478
1429
  `VpTokenProvider: invalid token in acquire response (expected non-empty string, got ${typeof s.token})`
1479
1430
  );
1480
1431
  const a = this.now();
1481
- if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at > ge)
1432
+ if (!Number.isSafeInteger(s.expires_at) || s.expires_at <= a || s.expires_at > ue)
1482
1433
  throw new Error(
1483
- `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${ge}])`
1434
+ `VpTokenProvider: invalid expires_at in acquire response (got ${JSON.stringify(s.expires_at)}; must be a safe integer in (${a}, ${ue}])`
1484
1435
  );
1485
- Gt({
1436
+ $t({
1486
1437
  token: s.token,
1487
1438
  ephemeralPubkeyHex: s.server_identity.ephemeral_pubkey,
1488
1439
  expectedIssuerXOnlyPubkey: this.pinnedServerPubkey,
1489
- expectedSubject: e === "grpc" ? St : Et,
1440
+ expectedSubject: e === "grpc" ? mt : _t,
1490
1441
  expectedAudienceXOnlyPubkey: this.expectedAudienceXOnlyPubkey,
1491
1442
  responseExpiresAt: s.expires_at,
1492
1443
  serverIdentityExpiresAt: s.server_identity.expires_at,
@@ -1504,7 +1455,7 @@ class Wt {
1504
1455
  return e === "grpc" ? this.inFlightGrpc = i : this.inFlightJsonRpc = i, i;
1505
1456
  }
1506
1457
  }
1507
- class Yt {
1458
+ class jt {
1508
1459
  constructor() {
1509
1460
  f(this, "entries", /* @__PURE__ */ new Map());
1510
1461
  }
@@ -1531,14 +1482,14 @@ class Yt {
1531
1482
  );
1532
1483
  return t.provider.setClient(e.client), t.provider;
1533
1484
  }
1534
- const n = new Wt({
1485
+ const n = new Gt({
1535
1486
  client: e.client,
1536
1487
  peginTxid: e.peginTxid,
1537
1488
  authAnchorHex: e.authAnchorHex,
1538
1489
  pinnedServerPubkey: e.pinnedServerPubkey,
1539
1490
  expectedAudienceXOnlyPubkey: e.expectedAudienceXOnlyPubkey,
1540
- authGatedMethods: dt,
1541
- grpcGatedMethods: pt
1491
+ authGatedMethods: rt,
1492
+ grpcGatedMethods: nt
1542
1493
  });
1543
1494
  return this.entries.set(e.peginTxid, {
1544
1495
  provider: n,
@@ -1573,60 +1524,60 @@ class Yt {
1573
1524
  return this.entries.size;
1574
1525
  }
1575
1526
  }
1576
- const ke = new Yt();
1577
- function hr(r) {
1527
+ const Pe = new jt();
1528
+ function rr(r) {
1578
1529
  var n;
1579
- const e = Ae(
1530
+ const e = be(
1580
1531
  r.baseUrl,
1581
1532
  (n = r.options) == null ? void 0 : n.headers
1582
- ), t = ke.getOrCreate({
1533
+ ), t = Pe.getOrCreate({
1583
1534
  client: e,
1584
1535
  peginTxid: r.peginTxid,
1585
1536
  authAnchorHex: r.authAnchorHex,
1586
1537
  pinnedServerPubkey: r.pinnedServerPubkey,
1587
- expectedAudienceXOnlyPubkey: fe(
1538
+ expectedAudienceXOnlyPubkey: de(
1588
1539
  r.depositorBtcPubkey
1589
1540
  )
1590
1541
  });
1591
- return new tt(r.baseUrl, {
1542
+ return new qe(r.baseUrl, {
1592
1543
  ...r.options,
1593
1544
  tokenProvider: t
1594
1545
  });
1595
1546
  }
1596
- function gr(r) {
1597
- ke.getOrCreate({
1598
- client: Ae(r.baseUrl, r.headers),
1547
+ function nr(r) {
1548
+ Pe.getOrCreate({
1549
+ client: be(r.baseUrl, r.headers),
1599
1550
  peginTxid: r.peginTxid,
1600
1551
  authAnchorHex: r.authAnchorHex,
1601
1552
  pinnedServerPubkey: r.pinnedServerPubkey,
1602
- expectedAudienceXOnlyPubkey: fe(
1553
+ expectedAudienceXOnlyPubkey: de(
1603
1554
  r.depositorBtcPubkey
1604
1555
  )
1605
1556
  });
1606
1557
  }
1607
- function zt(r, e) {
1558
+ function Lt(r, e) {
1608
1559
  const t = /* @__PURE__ */ new Set();
1609
- for (const d of r)
1610
- t.add(d.toLowerCase());
1560
+ for (const u of r)
1561
+ t.add(u.toLowerCase());
1611
1562
  const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [], a = [];
1612
- for (const d of e) {
1613
- const l = d.pegin_txid.toLowerCase();
1614
- if (!t.has(l)) {
1615
- a.push(l);
1563
+ for (const u of e) {
1564
+ const d = u.pegin_txid.toLowerCase();
1565
+ if (!t.has(d)) {
1566
+ a.push(d);
1616
1567
  continue;
1617
1568
  }
1618
- if (i.has(l)) {
1619
- s.push(l);
1569
+ if (i.has(d)) {
1570
+ s.push(d);
1620
1571
  continue;
1621
1572
  }
1622
- i.add(l), n.set(l, { result: d.result, error: d.error });
1573
+ i.add(d), n.set(d, { result: u.result, error: u.error });
1623
1574
  }
1624
1575
  const c = [];
1625
- for (const d of t)
1626
- i.has(d) || c.push(d);
1576
+ for (const u of t)
1577
+ i.has(u) || c.push(u);
1627
1578
  return { byTxid: n, missing: c, unexpected: a, duplicate: s };
1628
1579
  }
1629
- async function fr(r) {
1580
+ async function sr(r) {
1630
1581
  const {
1631
1582
  items: e,
1632
1583
  getTxid: t,
@@ -1635,66 +1586,66 @@ async function fr(r) {
1635
1586
  onMissing: s,
1636
1587
  onDuplicate: a,
1637
1588
  onDuplicateBatch: c,
1638
- onWholeBatchError: d,
1639
- onUnexpected: l,
1640
- batchSize: g = Be
1589
+ onWholeBatchError: u,
1590
+ onUnexpected: d,
1591
+ batchSize: g = Ie
1641
1592
  } = r;
1642
1593
  if (!Number.isInteger(g) || g <= 0)
1643
1594
  throw new Error(
1644
1595
  `batchPollByProvider: batchSize must be a positive integer, got ${g}`
1645
1596
  );
1646
- for (let m = 0; m < e.length; m += g) {
1647
- const x = e.slice(m, m + g), E = /* @__PURE__ */ new Map(), C = [];
1648
- for (const _ of x) {
1649
- const u = t(_).toLowerCase();
1650
- E.set(u, _), C.push(u);
1597
+ for (let y = 0; y < e.length; y += g) {
1598
+ const A = e.slice(y, y + g), E = /* @__PURE__ */ new Map(), S = [];
1599
+ for (const _ of A) {
1600
+ const l = t(_).toLowerCase();
1601
+ E.set(l, _), S.push(l);
1651
1602
  }
1652
- let P;
1603
+ let x;
1653
1604
  try {
1654
- const _ = await n(C);
1655
- P = zt(C, _.results);
1605
+ const _ = await n(S);
1606
+ x = Lt(S, _.results);
1656
1607
  } catch (_) {
1657
- d(x, _);
1608
+ u(A, _);
1658
1609
  continue;
1659
1610
  }
1660
- l && P.unexpected.length > 0 && l(P.unexpected);
1661
- const $ = new Set(P.duplicate);
1662
- for (const _ of $) {
1663
- const u = E.get(_);
1664
- u && a(u);
1611
+ d && x.unexpected.length > 0 && d(x.unexpected);
1612
+ const T = new Set(x.duplicate);
1613
+ for (const _ of T) {
1614
+ const l = E.get(_);
1615
+ l && a(l);
1665
1616
  }
1666
- c && $.size > 0 && c($.size);
1667
- for (const _ of P.missing) {
1668
- const u = E.get(_);
1669
- u && s(u);
1617
+ c && T.size > 0 && c(T.size);
1618
+ for (const _ of x.missing) {
1619
+ const l = E.get(_);
1620
+ l && s(l);
1670
1621
  }
1671
- for (const [_, u] of P.byTxid) {
1672
- if ($.has(_)) continue;
1673
- const S = E.get(_);
1674
- S && i(S, {
1622
+ for (const [_, l] of x.byTxid) {
1623
+ if (T.has(_)) continue;
1624
+ const C = E.get(_);
1625
+ C && i(C, {
1675
1626
  pegin_txid: _,
1676
- result: u.result,
1677
- error: u.error
1627
+ result: l.result,
1628
+ error: l.error
1678
1629
  });
1679
1630
  }
1680
1631
  }
1681
1632
  }
1682
1633
  export {
1683
- Me as O,
1634
+ Ne as O,
1684
1635
  b as S,
1685
- tt as V,
1636
+ qe as V,
1686
1637
  o as a,
1687
- fr as b,
1688
- ut as c,
1689
- Yt as d,
1690
- ke as e,
1691
- hr as f,
1692
- lr as g,
1693
- ur as h,
1694
- pr as i,
1695
- dr as j,
1696
- gr as p,
1697
- cr as r,
1698
- Je as v
1638
+ sr as b,
1639
+ tt as c,
1640
+ jt as d,
1641
+ Pe as e,
1642
+ rr as f,
1643
+ Qt as g,
1644
+ Zt as h,
1645
+ tr as i,
1646
+ er as j,
1647
+ nr as p,
1648
+ qt as r,
1649
+ Ke as v
1699
1650
  };
1700
- //# sourceMappingURL=batchPoll-cIxrSLLJ.js.map
1651
+ //# sourceMappingURL=batchPoll-Cjj1du0i.js.map