@babylonlabs-io/ts-sdk 0.67.0 → 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 (149) 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 +41 -4
  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/verifyKeyPathSchnorrSignature.d.ts +64 -0
  81. package/dist/tbv/core/primitives/psbt/verifyKeyPathSchnorrSignature.d.ts.map +1 -0
  82. package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts +40 -0
  83. package/dist/tbv/core/primitives/psbt/verifyP2wpkhEcdsaSignature.d.ts.map +1 -0
  84. package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts +2 -1
  85. package/dist/tbv/core/primitives/psbt/verifyScriptPathSchnorrSignature.d.ts.map +1 -1
  86. package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts +13 -0
  87. package/dist/tbv/core/primitives/utils/__tests__/taproot.test.d.ts.map +1 -0
  88. package/dist/tbv/core/primitives/utils/taproot.d.ts +29 -0
  89. package/dist/tbv/core/primitives/utils/taproot.d.ts.map +1 -0
  90. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +2 -2
  91. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  92. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  93. package/dist/tbv/core/services/index.cjs +1 -1
  94. package/dist/tbv/core/services/index.js +2 -2
  95. package/dist/tbv/core/utils/index.js +2 -2
  96. package/dist/tbv/core/utils/witness/witnessStack.d.ts +24 -0
  97. package/dist/tbv/core/utils/witness/witnessStack.d.ts.map +1 -0
  98. package/dist/tbv/core/vault-secrets/index.js +1 -1
  99. package/dist/tbv/index.cjs +1 -1
  100. package/dist/tbv/index.js +244 -241
  101. package/dist/testing/MockBitcoinWallet.d.ts +10 -1
  102. package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
  103. package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts +2 -0
  104. package/dist/testing/__tests__/MockBitcoinWallet.test.d.ts.map +1 -0
  105. package/dist/testing/index.cjs +1 -1
  106. package/dist/testing/index.cjs.map +1 -1
  107. package/dist/testing/index.js +134 -47
  108. package/dist/testing/index.js.map +1 -1
  109. package/dist/testing/signBip322P2wpkhWitness.d.ts +20 -0
  110. package/dist/testing/signBip322P2wpkhWitness.d.ts.map +1 -0
  111. package/dist/{toRefundInputs-BY_fcvrv.js → toRefundInputs-9hv_6k0E.js} +6 -6
  112. package/dist/{toRefundInputs-BY_fcvrv.js.map → toRefundInputs-9hv_6k0E.js.map} +1 -1
  113. package/dist/{toRefundInputs-DYL9C-aG.cjs → toRefundInputs-D8sFs44p.cjs} +2 -2
  114. package/dist/{toRefundInputs-DYL9C-aG.cjs.map → toRefundInputs-D8sFs44p.cjs.map} +1 -1
  115. package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs +2 -0
  116. package/dist/verifyKeyPathSchnorrSignature-DCOzQkDf.cjs.map +1 -0
  117. package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js +363 -0
  118. package/dist/verifyKeyPathSchnorrSignature-oGCUbjjZ.js.map +1 -0
  119. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js +931 -0
  120. package/dist/verifyScriptPathSchnorrSignature-Dy9gF5RF.js.map +1 -0
  121. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs +2 -0
  122. package/dist/verifyScriptPathSchnorrSignature-la8XOAFm.cjs.map +1 -0
  123. package/package.json +1 -1
  124. package/dist/PeginManager-BBl4xkWz.js +0 -1359
  125. package/dist/PeginManager-BBl4xkWz.js.map +0 -1
  126. package/dist/PeginManager-p-ajwSxG.cjs +0 -2
  127. package/dist/PeginManager-p-ajwSxG.cjs.map +0 -1
  128. package/dist/batchPoll-6L5oToGr.cjs +0 -2
  129. package/dist/batchPoll-6L5oToGr.cjs.map +0 -1
  130. package/dist/batchPoll-cIxrSLLJ.js.map +0 -1
  131. package/dist/buildAndBroadcastRefund-C4LiPATK.js.map +0 -1
  132. package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs +0 -2
  133. package/dist/buildAndBroadcastRefund-Daw5ZUKR.cjs.map +0 -1
  134. package/dist/challengeAssert-BFRE2DM-.cjs +0 -2
  135. package/dist/challengeAssert-BFRE2DM-.cjs.map +0 -1
  136. package/dist/challengeAssert-C7PzyJ7g.js +0 -75
  137. package/dist/challengeAssert-C7PzyJ7g.js.map +0 -1
  138. package/dist/mempoolApi-CXfr-L6x.cjs +0 -2
  139. package/dist/peginInput-Ci921gTl.cjs +0 -2
  140. package/dist/peginInput-Ci921gTl.cjs.map +0 -1
  141. package/dist/peginInput-HQPWZfly.js +0 -123
  142. package/dist/peginInput-HQPWZfly.js.map +0 -1
  143. package/dist/signPsbtsWithFallback-Bb66DfY5.js.map +0 -1
  144. package/dist/signPsbtsWithFallback-PTgWxsG3.cjs +0 -2
  145. package/dist/signPsbtsWithFallback-PTgWxsG3.cjs.map +0 -1
  146. package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs +0 -2
  147. package/dist/verifyScriptPathSchnorrSignature-DPAd_qke.cjs.map +0 -1
  148. package/dist/verifyScriptPathSchnorrSignature-i-koT139.js +0 -817
  149. package/dist/verifyScriptPathSchnorrSignature-i-koT139.js.map +0 -1
@@ -1,45 +1,117 @@
1
+ import * as p from "@bitcoin-js/tiny-secp256k1-asmjs";
2
+ import { Transaction as u, payments as b, script as D } from "bitcoinjs-lib";
3
+ import { s as T } from "./sha2-BYVxyZzX.js";
4
+ import { Buffer as c } from "buffer";
1
5
  import { B as a } from "./BTCVaultRegistry.abi-CJwWI2EO.js";
2
- import { B as d } from "./BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js";
3
- import { a as w } from "./onChainBtcPubkey-DeF4cKoO.js";
4
- import { a as x } from "./constants-GjWXdaqV.js";
5
- import { B as F, H as B, K, T as k, c as N } from "./validation-Dj3dqYtl.js";
6
- const h = 65535, b = 1e4, l = 4294967295, $ = 255;
7
- function O(t) {
8
- if (!Number.isInteger(t) || t < 0 || t > l)
6
+ import { B as y } from "./BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js";
7
+ import { a as A } from "./onChainBtcPubkey-BAHZyKQL.js";
8
+ import { a as G } from "./constants-GjWXdaqV.js";
9
+ import { B as L, H as W, K as Q, T as j, c as z } from "./validation-Dj3dqYtl.js";
10
+ const Y = "BIP0322-signed-message", Z = "TapTweak", N = 32, J = 64, q = 33, tt = 71, et = 72, g = 0, V = 0, C = 0, v = 0, ot = 32, nt = 4294967295, rt = 0, it = 0, st = 32, at = 106;
11
+ function k(t, e) {
12
+ const o = new TextEncoder().encode(t), n = T(o), i = new Uint8Array(n.length * 2 + e.length);
13
+ return i.set(n, 0), i.set(n, n.length), i.set(e, n.length * 2), T(i);
14
+ }
15
+ function ct(t) {
16
+ if (t.length !== N) return null;
17
+ const e = k(Z, t), o = p.xOnlyPointAddTweak(t, e);
18
+ return o ? o.xOnlyPubkey : null;
19
+ }
20
+ function U(t, e) {
21
+ const o = k(Y, t), n = new u();
22
+ n.version = V, n.locktime = C;
23
+ const i = c.concat([
24
+ c.from([it, st]),
25
+ c.from(o)
26
+ ]);
27
+ n.addInput(
28
+ c.alloc(ot, 0),
29
+ nt,
30
+ v,
31
+ i
32
+ ), n.addOutput(e, g);
33
+ const r = new u();
34
+ return r.version = V, r.locktime = C, r.addInput(
35
+ n.getHash(),
36
+ rt,
37
+ v
38
+ ), r.addOutput(c.from([at]), g), r;
39
+ }
40
+ function At(t, e, o, n = u.SIGHASH_DEFAULT) {
41
+ if (e.length !== N || o.length !== J || n !== u.SIGHASH_DEFAULT && n !== u.SIGHASH_ALL)
42
+ return !1;
43
+ try {
44
+ const i = b.p2tr({
45
+ internalPubkey: c.from(e)
46
+ });
47
+ if (!i.output) return !1;
48
+ const r = i.output, h = U(t, r).hashForWitnessV1(
49
+ 0,
50
+ [r],
51
+ [g],
52
+ n
53
+ ), m = ct(e);
54
+ return m ? p.verifySchnorr(h, m, o) : !1;
55
+ } catch {
56
+ return !1;
57
+ }
58
+ }
59
+ function Vt(t, e, o) {
60
+ if (e.length !== q || o.length < tt || o.length > et)
61
+ return !1;
62
+ try {
63
+ if (!p.isPointCompressed(e)) return !1;
64
+ const { signature: n, hashType: i } = D.signature.decode(
65
+ c.from(o)
66
+ );
67
+ if (i !== u.SIGHASH_ALL) return !1;
68
+ const r = b.p2wpkh({ pubkey: c.from(e) });
69
+ if (!r.output || !r.hash) return !1;
70
+ const s = U(t, r.output), h = b.p2pkh({ hash: r.hash }).output;
71
+ if (!h) return !1;
72
+ const m = s.hashForWitnessV0(0, h, g, i);
73
+ return p.verify(m, e, n, !0);
74
+ } catch {
75
+ return !1;
76
+ }
77
+ }
78
+ const P = 65535, S = 1e4, d = 4294967295, _ = 255;
79
+ function ut(t) {
80
+ if (!Number.isInteger(t) || t < 0 || t > d)
9
81
  throw new Error(
10
82
  `Invalid offchainParamsVersion from contract: must be a uint32, got ${t}`
11
83
  );
12
84
  }
13
- function S(t) {
85
+ function lt(t) {
14
86
  const e = [];
15
87
  if (t.timelockAssert <= 0n && e.push(
16
88
  `timelockAssert must be positive, got ${t.timelockAssert}`
17
- ), t.timelockAssert > BigInt(h) && e.push(
18
- `timelockAssert ${t.timelockAssert} exceeds uint16 max (${h})`
89
+ ), t.timelockAssert > BigInt(P) && e.push(
90
+ `timelockAssert ${t.timelockAssert} exceeds uint16 max (${P})`
19
91
  ), t.timelockChallengeAssert <= 0n && e.push(
20
92
  `timelockChallengeAssert must be positive, got ${t.timelockChallengeAssert}`
21
93
  ), 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(
22
94
  `councilQuorum (${t.councilQuorum}) exceeds securityCouncilKeys count (${t.securityCouncilKeys.length})`
23
95
  ), t.feeRate <= 0n && e.push(`feeRate must be positive, got ${t.feeRate}`), t.minPeginFeeRate <= 0n && e.push(
24
96
  `minPeginFeeRate must be positive, got ${t.minPeginFeeRate}`
25
- ), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion > h) && e.push(
97
+ ), (!Number.isInteger(t.proverCircuitVersion) || t.proverCircuitVersion < 0 || t.proverCircuitVersion > P) && e.push(
26
98
  `proverCircuitVersion must be a uint16, got ${t.proverCircuitVersion}`
27
- ), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > l) && e.push(
28
- `minPrepeginDepth must be a uint32 in [1, ${l}], got ${t.minPrepeginDepth}`
99
+ ), (!Number.isInteger(t.minPrepeginDepth) || t.minPrepeginDepth <= 0 || t.minPrepeginDepth > d) && e.push(
100
+ `minPrepeginDepth must be a uint32 in [1, ${d}], got ${t.minPrepeginDepth}`
29
101
  ), t.babeTotalInstances <= 0 && e.push(
30
102
  `babeTotalInstances must be positive, got ${t.babeTotalInstances}`
31
103
  ), t.babeInstancesToFinalize <= 0 && e.push(
32
104
  `babeInstancesToFinalize must be positive, got ${t.babeInstancesToFinalize}`
33
105
  ), t.babeInstancesToFinalize > t.babeTotalInstances && e.push(
34
106
  `babeInstancesToFinalize (${t.babeInstancesToFinalize}) exceeds babeTotalInstances (${t.babeTotalInstances})`
35
- ), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > b) && e.push(
36
- `minVpCommissionBps must be in [0, ${b}], got ${t.minVpCommissionBps}`
107
+ ), (t.minVpCommissionBps < 0 || t.minVpCommissionBps > S) && e.push(
108
+ `minVpCommissionBps must be in [0, ${S}], got ${t.minVpCommissionBps}`
37
109
  ), e.length > 0)
38
110
  throw new Error(
39
111
  `Invalid offchain protocol parameters: ${e.join("; ")}`
40
112
  );
41
113
  }
42
- function R(t) {
114
+ function ft(t) {
43
115
  const e = [];
44
116
  if (t.minimumPegInAmount <= 0n && e.push(
45
117
  `minimumPegInAmount must be positive, got ${t.minimumPegInAmount}`
@@ -49,25 +121,25 @@ function R(t) {
49
121
  `pegInAckTimeout must be positive, got ${t.pegInAckTimeout}`
50
122
  ), t.pegInActivationTimeout <= 0n && e.push(
51
123
  `pegInActivationTimeout must be positive, got ${t.pegInActivationTimeout}`
52
- ), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > $) && e.push(
53
- `maxHtlcOutputCount must be an integer in [1, ${$}], got ${t.maxHtlcOutputCount}`
124
+ ), (!Number.isInteger(t.maxHtlcOutputCount) || t.maxHtlcOutputCount <= 0 || t.maxHtlcOutputCount > _) && e.push(
125
+ `maxHtlcOutputCount must be an integer in [1, ${_}], got ${t.maxHtlcOutputCount}`
54
126
  ), (typeof t.expiredPegInGraceBlocks != "bigint" || t.expiredPegInGraceBlocks <= 0n) && e.push(
55
127
  `expiredPegInGraceBlocks must be a positive bigint, got ${t.expiredPegInGraceBlocks}`
56
128
  ), e.length > 0)
57
129
  throw new Error(`Invalid TBV protocol parameters: ${e.join("; ")}`);
58
130
  }
59
- function L(t) {
60
- if (R(t), S(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > l)
131
+ function Ct(t) {
132
+ if (ft(t), lt(t.offchainParams), !Number.isInteger(t.offchainParamsVersion) || t.offchainParamsVersion < 0 || t.offchainParamsVersion > d)
61
133
  throw new Error(
62
134
  `Invalid peg-in configuration: offchainParamsVersion must be a uint32, got ${t.offchainParamsVersion}`
63
135
  );
64
- x(
136
+ G(
65
137
  t.activeVaultCoreVersion,
66
138
  "ProtocolParams.activeVaultCoreVersion()"
67
139
  );
68
140
  }
69
- const I = 9999;
70
- function P(t) {
141
+ const B = 9999;
142
+ function F(t) {
71
143
  return {
72
144
  depositor: t.depositor,
73
145
  depositorBtcPubKey: t.depositorBtcPubKey,
@@ -78,9 +150,9 @@ function P(t) {
78
150
  createdAt: t.createdAt
79
151
  };
80
152
  }
81
- function m(t) {
153
+ function I(t) {
82
154
  const e = Number(t.offchainParamsVersion);
83
- return O(e), {
155
+ return ut(e), {
84
156
  depositorSignedPeginTx: t.depositorSignedPeginTx,
85
157
  universalChallengersVersion: t.universalChallengersVersion,
86
158
  appVaultKeepersVersion: t.appVaultKeepersVersion,
@@ -96,26 +168,26 @@ function m(t) {
96
168
  vaultCoreVersion: t.vaultCoreVersion
97
169
  };
98
170
  }
99
- const _ = 1n << 64n, y = 0n;
100
- function p(t, e, o) {
101
- if (t < 0n || t >= _)
171
+ const ht = 1n << 64n, x = 0n;
172
+ function E(t, e, o) {
173
+ if (t < 0n || t >= ht)
102
174
  throw new Error(
103
175
  `getBtcVaultProtocolInfo returned ${e}=${t} for vault ${o}, outside the uint64 range — the registry may predate RFC-006`
104
176
  );
105
177
  return t;
106
178
  }
107
- function E(t, e) {
179
+ function O(t, e) {
108
180
  return {
109
- vpKeyEpoch: p(t.vpKeyEpoch, "vpKeyEpoch", e),
110
- appKeeperKeyEpoch: p(
181
+ vpKeyEpoch: E(t.vpKeyEpoch, "vpKeyEpoch", e),
182
+ appKeeperKeyEpoch: E(
111
183
  t.appKeeperKeyEpoch,
112
184
  "appKeeperKeyEpoch",
113
185
  e
114
186
  ),
115
- ucKeyEpoch: p(t.ucKeyEpoch, "ucKeyEpoch", e)
187
+ ucKeyEpoch: E(t.ucKeyEpoch, "ucKeyEpoch", e)
116
188
  };
117
189
  }
118
- class W {
190
+ class vt {
119
191
  constructor(e, o) {
120
192
  this.publicClient = e, this.contractAddress = o;
121
193
  }
@@ -147,11 +219,11 @@ class W {
147
219
  address: this.contractAddress,
148
220
  abi: a,
149
221
  functionName: "getOperationBtcKeyAtEpoch",
150
- args: [e, y]
222
+ args: [e, x]
151
223
  });
152
- return w(
224
+ return A(
153
225
  o,
154
- `getOperationBtcKeyAtEpoch (vp=${e}, epoch=${y})`
226
+ `getOperationBtcKeyAtEpoch (vp=${e}, epoch=${x})`
155
227
  );
156
228
  }
157
229
  /**
@@ -172,7 +244,7 @@ class W {
172
244
  functionName: "getCurrentOperationBtcKey",
173
245
  args: [e]
174
246
  });
175
- return w(
247
+ return A(
176
248
  o,
177
249
  `getCurrentOperationBtcKey (vp=${e})`
178
250
  );
@@ -196,23 +268,23 @@ class W {
196
268
  async getVaultKeyEpochs(e) {
197
269
  const o = await this.publicClient.readContract({
198
270
  address: this.contractAddress,
199
- abi: d,
271
+ abi: y,
200
272
  functionName: "getBtcVaultProtocolInfo",
201
273
  args: [e]
202
274
  });
203
- return E(o, e);
275
+ return O(o, e);
204
276
  }
205
277
  async getVaultKeyEpochsBatch(e) {
206
278
  return e.length === 0 ? [] : (await this.publicClient.multicall({
207
279
  contracts: e.map((n) => ({
208
280
  address: this.contractAddress,
209
- abi: d,
281
+ abi: y,
210
282
  functionName: "getBtcVaultProtocolInfo",
211
283
  args: [n]
212
284
  })),
213
285
  allowFailure: !1
214
286
  })).map(
215
- (n, i) => E(n, e[i])
287
+ (n, i) => O(n, e[i])
216
288
  );
217
289
  }
218
290
  async getVaultBasicInfo(e) {
@@ -222,7 +294,7 @@ class W {
222
294
  functionName: "getBtcVaultBasicInfo",
223
295
  args: [e]
224
296
  });
225
- return P(o);
297
+ return F(o);
226
298
  }
227
299
  async getVaultProtocolInfo(e) {
228
300
  const o = await this.publicClient.readContract({
@@ -231,7 +303,7 @@ class W {
231
303
  functionName: "getBtcVaultProtocolInfo",
232
304
  args: [e]
233
305
  });
234
- return m(o);
306
+ return I(o);
235
307
  }
236
308
  async getProtocolInfoBatch(e) {
237
309
  return e.length === 0 ? [] : (await this.publicClient.multicall({
@@ -248,7 +320,7 @@ class W {
248
320
  throw new Error(
249
321
  `Vault ${e[i]} not found on-chain or has no pegin transaction`
250
322
  );
251
- return m(r);
323
+ return I(r);
252
324
  });
253
325
  }
254
326
  /**
@@ -277,9 +349,9 @@ class W {
277
349
  functionName: "getVaultProviderCommission",
278
350
  args: [e]
279
351
  });
280
- if (!Number.isInteger(o) || o < 0 || o > I)
352
+ if (!Number.isInteger(o) || o < 0 || o > B)
281
353
  throw new Error(
282
- `getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${I}]`
354
+ `getVaultProviderCommission returned ${o} bps for ${e}, outside the protocol range [0, ${B}]`
283
355
  );
284
356
  return o;
285
357
  }
@@ -300,7 +372,7 @@ class W {
300
372
  }
301
373
  ],
302
374
  allowFailure: !1
303
- }), i = P(o), r = m(n);
375
+ }), i = F(o), r = I(n);
304
376
  if (!r.depositorSignedPeginTx || r.depositorSignedPeginTx === "0x")
305
377
  throw new Error(
306
378
  `Vault ${e} not found on-chain or has no pegin transaction`
@@ -308,14 +380,14 @@ class W {
308
380
  return { basic: i, protocol: r };
309
381
  }
310
382
  }
311
- const U = 21e6 * 1e8, V = 3e4;
312
- async function f(t, e) {
383
+ const mt = 21e6 * 1e8, K = 3e4;
384
+ async function w(t, e) {
313
385
  const o = new AbortController(), n = setTimeout(
314
386
  () => o.abort(),
315
- V
387
+ K
316
388
  ), i = [o.signal, e == null ? void 0 : e.signal].filter(
317
389
  Boolean
318
- ), r = N(i);
390
+ ), r = z(i);
319
391
  try {
320
392
  return await fetch(t, {
321
393
  ...e,
@@ -323,48 +395,48 @@ async function f(t, e) {
323
395
  });
324
396
  } catch (s) {
325
397
  throw clearTimeout(n), r.cleanup(), s != null && typeof s == "object" && "name" in s && s.name === "AbortError" ? new Error(
326
- `Mempool API request timed out after ${V}ms: ${t}`
398
+ `Mempool API request timed out after ${K}ms: ${t}`
327
399
  ) : s;
328
400
  }
329
401
  }
330
- const A = 1e4;
331
- function T(t) {
332
- return Number.isInteger(t) && t > 0 && t <= U;
402
+ const R = 1e4;
403
+ function H(t) {
404
+ return Number.isInteger(t) && t > 0 && t <= mt;
333
405
  }
334
- function M(t) {
335
- return Number.isInteger(t) && t > 0 && t <= A;
406
+ function pt(t) {
407
+ return Number.isInteger(t) && t > 0 && t <= R;
336
408
  }
337
- function g(t, e) {
409
+ function $(t, e) {
338
410
  return !Number.isInteger(t) || t < 0 ? !1 : e === void 0 || t < e;
339
411
  }
340
- function u(t) {
341
- if (!k.test(t))
412
+ function f(t) {
413
+ if (!j.test(t))
342
414
  throw new Error(`Invalid transaction ID format: ${t}`);
343
415
  }
344
- function C(t) {
345
- if (!F.test(t))
416
+ function M(t) {
417
+ if (!L.test(t))
346
418
  throw new Error(`Invalid Bitcoin address format: ${t}`);
347
419
  }
348
- function v(t, e) {
349
- if (!B.test(t))
420
+ function X(t, e) {
421
+ if (!W.test(t))
350
422
  throw new Error(
351
423
  `Invalid scriptPubKey: not valid hex for ${e}`
352
424
  );
353
- if (!K.some(
425
+ if (!Q.some(
354
426
  (n) => t.toLowerCase().startsWith(n)
355
427
  ))
356
428
  throw new Error(
357
429
  `Unrecognized scriptPubKey type for ${e}: prefix ${t.slice(0, 6)} does not match any known Bitcoin script type`
358
430
  );
359
431
  }
360
- const H = {
432
+ const gt = {
361
433
  mainnet: "https://mempool.space/api",
362
434
  testnet: "https://mempool.space/testnet/api",
363
435
  signet: "https://mempool.space/signet/api"
364
436
  };
365
- async function c(t, e) {
437
+ async function l(t, e) {
366
438
  try {
367
- const o = await f(t, e);
439
+ const o = await w(t, e);
368
440
  if (!o.ok) {
369
441
  const i = await o.text();
370
442
  throw new Error(
@@ -377,9 +449,9 @@ async function c(t, e) {
377
449
  throw o instanceof Error ? new Error(`Failed to fetch from mempool API: ${o.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
378
450
  }
379
451
  }
380
- async function J(t, e) {
452
+ async function St(t, e) {
381
453
  try {
382
- const o = await f(`${e}/tx`, {
454
+ const o = await w(`${e}/tx`, {
383
455
  method: "POST",
384
456
  body: t,
385
457
  headers: {
@@ -404,26 +476,26 @@ async function J(t, e) {
404
476
  throw o instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${o.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
405
477
  }
406
478
  }
407
- async function X(t, e) {
408
- return u(t), c(`${e}/tx/${t}`);
479
+ async function dt(t, e) {
480
+ return f(t), l(`${e}/tx/${t}`);
409
481
  }
410
- async function q(t) {
411
- const e = await c(`${t}/blocks/tip/height`), o = e.trim();
482
+ async function _t(t) {
483
+ const e = await l(`${t}/blocks/tip/height`), o = e.trim();
412
484
  if (!/^\d+$/.test(o))
413
485
  throw new Error(
414
486
  `Mempool API returned an invalid block tip height: "${e}"`
415
487
  );
416
488
  return Number.parseInt(o, 10);
417
489
  }
418
- async function Y(t, e, o) {
419
- if (u(t), !g(e))
490
+ async function Bt(t, e, o) {
491
+ if (f(t), !$(e))
420
492
  throw new Error(`Invalid vout ${e} for transaction ${t}`);
421
- return c(`${o}/tx/${t}/outspend/${e}`);
493
+ return l(`${o}/tx/${t}/outspend/${e}`);
422
494
  }
423
- async function Z(t, e) {
424
- u(t);
495
+ async function Ft(t, e) {
496
+ f(t);
425
497
  try {
426
- const o = await f(`${e}/tx/${t}/hex`);
498
+ const o = await w(`${e}/tx/${t}/hex`);
427
499
  if (!o.ok) {
428
500
  const n = await o.text();
429
501
  throw new Error(
@@ -435,36 +507,36 @@ async function Z(t, e) {
435
507
  throw o instanceof Error ? new Error(`Failed to get transaction hex for ${t}: ${o.message}`) : new Error(`Failed to get transaction hex for ${t}: Unknown error`);
436
508
  }
437
509
  }
438
- async function tt(t, e, o) {
439
- u(t);
440
- const n = await X(t, o);
441
- if (!g(e, n.vout.length))
510
+ async function xt(t, e, o) {
511
+ f(t);
512
+ const n = await dt(t, o);
513
+ if (!$(e, n.vout.length))
442
514
  throw new Error(
443
515
  `Invalid vout ${e} for transaction ${t} (has ${n.vout.length} outputs)`
444
516
  );
445
517
  const i = n.vout[e];
446
- if (!T(i.value))
518
+ if (!H(i.value))
447
519
  throw new Error(`Invalid UTXO value ${i.value} for ${t}:${e}`);
448
- return v(i.scriptpubkey, `${t}:${e}`), {
520
+ return X(i.scriptpubkey, `${t}:${e}`), {
449
521
  txid: t,
450
522
  vout: e,
451
523
  value: i.value,
452
524
  scriptPubKey: i.scriptpubkey
453
525
  };
454
526
  }
455
- async function et(t, e) {
456
- C(t);
527
+ async function Ot(t, e) {
528
+ M(t);
457
529
  try {
458
- const o = await c(`${e}/address/${t}/utxo`), n = await c(`${e}/v1/validate-address/${t}`);
530
+ const o = await l(`${e}/address/${t}/utxo`), n = await l(`${e}/v1/validate-address/${t}`);
459
531
  if (!n.isvalid)
460
532
  throw new Error(
461
533
  `Invalid Bitcoin address: ${t}. Mempool API validation failed.`
462
534
  );
463
- v(n.scriptPubKey, t);
535
+ X(n.scriptPubKey, t);
464
536
  for (const r of o) {
465
- if (u(r.txid), !g(r.vout))
537
+ if (f(r.txid), !$(r.vout))
466
538
  throw new Error(`Invalid vout ${r.vout} for ${r.txid}`);
467
- if (!T(r.value))
539
+ if (!H(r.value))
468
540
  throw new Error(
469
541
  `Invalid UTXO value ${r.value} for ${r.txid}:${r.vout}`
470
542
  );
@@ -484,14 +556,14 @@ async function et(t, e) {
484
556
  );
485
557
  }
486
558
  }
487
- function ot(t) {
488
- return H[t];
559
+ function Kt(t) {
560
+ return gt[t];
489
561
  }
490
- async function nt(t, e) {
491
- return C(t), c(`${e}/address/${t}/txs`);
562
+ async function Nt(t, e) {
563
+ return M(t), l(`${e}/address/${t}/txs`);
492
564
  }
493
- async function rt(t) {
494
- const e = await f(`${t}/v1/fees/recommended`);
565
+ async function kt(t) {
566
+ const e = await w(`${t}/v1/fees/recommended`);
495
567
  if (!e.ok)
496
568
  throw new Error(
497
569
  `Failed to fetch network fees: ${e.status} ${e.statusText}`
@@ -504,9 +576,9 @@ async function rt(t) {
504
576
  "minimumFee"
505
577
  ];
506
578
  for (const i of n)
507
- if (!M(o[i]))
579
+ if (!pt(o[i]))
508
580
  throw new Error(
509
- `Invalid fee rate ${i}=${o[i]} from mempool API: expected a positive number ≤ ${A}`
581
+ `Invalid fee rate ${i}=${o[i]} from mempool API: expected a positive number ≤ ${R}`
510
582
  );
511
583
  if (o.minimumFee > o.economyFee || o.economyFee > o.hourFee || o.hourFee > o.halfHourFee || o.halfHourFee > o.fastestFee)
512
584
  throw new Error(
@@ -515,21 +587,23 @@ async function rt(t) {
515
587
  return o;
516
588
  }
517
589
  export {
518
- H as M,
519
- W as V,
520
- et as a,
521
- ot as b,
522
- rt as c,
523
- Y as d,
524
- q as e,
525
- Z as f,
526
- nt as g,
527
- X as h,
528
- tt as i,
529
- L as j,
530
- R as k,
531
- O as l,
532
- J as p,
533
- S as v
590
+ gt as M,
591
+ vt as V,
592
+ Ot as a,
593
+ Kt as b,
594
+ kt as c,
595
+ Bt as d,
596
+ _t as e,
597
+ Ft as f,
598
+ Nt as g,
599
+ dt as h,
600
+ xt as i,
601
+ Ct as j,
602
+ ft as k,
603
+ At as l,
604
+ Vt as m,
605
+ ut as n,
606
+ St as p,
607
+ lt as v
534
608
  };
535
- //# sourceMappingURL=mempoolApi-BxSINXIB.js.map
609
+ //# sourceMappingURL=mempoolApi-_D-jvtj_.js.map