@babylonlabs-io/ts-sdk 0.56.1 → 0.57.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 (151) hide show
  1. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-Chs4AFBj.js → BTCVaultRegistry.abi-CixOlp3B.js} +73 -14
  4. package/dist/BTCVaultRegistry.abi-CixOlp3B.js.map +1 -0
  5. package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js +111 -0
  6. package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js.map +1 -0
  7. package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs +2 -0
  8. package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs.map +1 -0
  9. package/dist/{PeginManager-Ba7Cr51Z.js → PeginManager-CnX3uFb0.js} +5 -5
  10. package/dist/{PeginManager-Ba7Cr51Z.js.map → PeginManager-CnX3uFb0.js.map} +1 -1
  11. package/dist/PeginManager-iDbqXsKD.cjs +2 -0
  12. package/dist/{PeginManager-CcjGRo4O.cjs.map → PeginManager-iDbqXsKD.cjs.map} +1 -1
  13. package/dist/ProtocolParams.abi-C8U7BHCS.cjs +2 -0
  14. package/dist/ProtocolParams.abi-C8U7BHCS.cjs.map +1 -0
  15. package/dist/{ApplicationRegistry.abi-w5prf7Ig.js → ProtocolParams.abi-CV938AYZ.js} +150 -80
  16. package/dist/ProtocolParams.abi-CV938AYZ.js.map +1 -0
  17. package/dist/{buildAndBroadcastRefund-BtXUqBkb.js → buildAndBroadcastRefund-CCb1_z24.js} +627 -452
  18. package/dist/buildAndBroadcastRefund-CCb1_z24.js.map +1 -0
  19. package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs +2 -0
  20. package/dist/buildAndBroadcastRefund-CDzzTZ2U.cjs.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +163 -153
  23. package/dist/index.js.map +1 -1
  24. package/dist/{types-CQDRQvV-.js → json-rpc-client-Ehjthcd7.js} +61 -61
  25. package/dist/json-rpc-client-Ehjthcd7.js.map +1 -0
  26. package/dist/{types-WA0LrDk1.cjs → json-rpc-client-fUoK-TzT.cjs} +2 -2
  27. package/dist/json-rpc-client-fUoK-TzT.cjs.map +1 -0
  28. package/dist/mempoolApi-C0olk43O.js +536 -0
  29. package/dist/mempoolApi-C0olk43O.js.map +1 -0
  30. package/dist/mempoolApi-Dsm2VPXp.cjs +2 -0
  31. package/dist/mempoolApi-Dsm2VPXp.cjs.map +1 -0
  32. package/dist/{noPayout-CihCk1HE.js → noPayout-CI4l1qu2.js} +2 -2
  33. package/dist/{noPayout-CihCk1HE.js.map → noPayout-CI4l1qu2.js.map} +1 -1
  34. package/dist/{noPayout-Cb8vFrkY.cjs → noPayout-Djrv31V5.cjs} +2 -2
  35. package/dist/{noPayout-Cb8vFrkY.cjs.map → noPayout-Djrv31V5.cjs.map} +1 -1
  36. package/dist/onChainBtcPubkey-Cd9kpz-S.cjs +2 -0
  37. package/dist/onChainBtcPubkey-Cd9kpz-S.cjs.map +1 -0
  38. package/dist/onChainBtcPubkey-aPY5ib3Q.js +19 -0
  39. package/dist/onChainBtcPubkey-aPY5ib3Q.js.map +1 -0
  40. package/dist/primeVpAuth-BlxUcdBf.cjs +2 -0
  41. package/dist/primeVpAuth-BlxUcdBf.cjs.map +1 -0
  42. package/dist/{primeVpAuth-Caa5J_uv.js → primeVpAuth-DkJbvywo.js} +479 -367
  43. package/dist/primeVpAuth-DkJbvywo.js.map +1 -0
  44. package/dist/signPsbtsWithFallback-C01N6Kdo.cjs +2 -0
  45. package/dist/signPsbtsWithFallback-C01N6Kdo.cjs.map +1 -0
  46. package/dist/{PayoutManager-BVgmuKuK.js → signPsbtsWithFallback-CzZFZf0I.js} +105 -101
  47. package/dist/signPsbtsWithFallback-CzZFZf0I.js.map +1 -0
  48. package/dist/tbv/core/clients/eth/index.d.ts +5 -3
  49. package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
  50. package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts +16 -0
  51. package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts.map +1 -0
  52. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +33 -0
  53. package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -0
  54. package/dist/tbv/core/clients/eth/types.d.ts +122 -3
  55. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  56. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +25 -1
  57. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  58. package/dist/tbv/core/clients/index.cjs +1 -1
  59. package/dist/tbv/core/clients/index.js +35 -32
  60. package/dist/tbv/core/clients/index.js.map +1 -1
  61. package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts +2 -0
  62. package/dist/tbv/core/contracts/__tests__/BTCVaultRegistryKeyEpochs.abi.test.d.ts.map +1 -0
  63. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +66 -0
  64. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
  65. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +50 -0
  66. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  67. package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts +111 -0
  68. package/dist/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.d.ts.map +1 -0
  69. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +36 -0
  70. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  71. package/dist/tbv/core/contracts/index.cjs +1 -1
  72. package/dist/tbv/core/contracts/index.d.ts +2 -1
  73. package/dist/tbv/core/contracts/index.d.ts.map +1 -1
  74. package/dist/tbv/core/contracts/index.js +8 -6
  75. package/dist/tbv/core/contracts/index.js.map +1 -1
  76. package/dist/tbv/core/index.cjs +1 -1
  77. package/dist/tbv/core/index.js +163 -153
  78. package/dist/tbv/core/index.js.map +1 -1
  79. package/dist/tbv/core/managers/PayoutManager.d.ts +8 -0
  80. package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -1
  81. package/dist/tbv/core/managers/index.cjs +1 -1
  82. package/dist/tbv/core/managers/index.js +2 -2
  83. package/dist/tbv/core/primitives/index.cjs +1 -1
  84. package/dist/tbv/core/primitives/index.js +2 -2
  85. package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts +2 -0
  86. package/dist/tbv/core/primitives/psbt/__tests__/standardPayoutScript.test.d.ts.map +1 -0
  87. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts +5 -5
  88. package/dist/tbv/core/primitives/psbt/assertPayoutFeeBand.d.ts.map +1 -1
  89. package/dist/tbv/core/primitives/psbt/payout.d.ts +23 -0
  90. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  91. package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts +41 -0
  92. package/dist/tbv/core/primitives/psbt/standardPayoutScript.d.ts.map +1 -0
  93. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts +2 -0
  94. package/dist/tbv/core/services/deposit/__tests__/verifyRegisteredParticipantKeys.test.d.ts.map +1 -0
  95. package/dist/tbv/core/services/deposit/index.d.ts +7 -6
  96. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  97. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts +10 -0
  98. package/dist/tbv/core/services/deposit/runDepositorPresignFlow.d.ts.map +1 -1
  99. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts +9 -0
  100. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  101. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +38 -1
  102. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
  103. package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts +42 -0
  104. package/dist/tbv/core/services/deposit/verifyRegisteredParticipantKeys.d.ts.map +1 -0
  105. package/dist/tbv/core/services/index.cjs +1 -1
  106. package/dist/tbv/core/services/index.d.ts +1 -0
  107. package/dist/tbv/core/services/index.d.ts.map +1 -1
  108. package/dist/tbv/core/services/index.js +36 -31
  109. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts +55 -0
  110. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -0
  111. package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts +2 -0
  112. package/dist/tbv/core/services/participants/__tests__/resolveParticipantKeys.test.d.ts.map +1 -0
  113. package/dist/tbv/core/services/participants/index.d.ts +8 -0
  114. package/dist/tbv/core/services/participants/index.d.ts.map +1 -0
  115. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts +26 -0
  116. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts.map +1 -0
  117. package/dist/tbv/core/services/participants/types.d.ts +62 -0
  118. package/dist/tbv/core/services/participants/types.d.ts.map +1 -0
  119. package/dist/tbv/index.cjs +1 -1
  120. package/dist/tbv/index.js +163 -153
  121. package/dist/tbv/index.js.map +1 -1
  122. package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs +2 -0
  123. package/dist/verifyScriptPathSchnorrSignature-C-84KJ6U.cjs.map +1 -0
  124. package/dist/{verifyScriptPathSchnorrSignature-CgrnAjMW.js → verifyScriptPathSchnorrSignature-Xoo9DOHW.js} +359 -301
  125. package/dist/verifyScriptPathSchnorrSignature-Xoo9DOHW.js.map +1 -0
  126. package/package.json +1 -1
  127. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs +0 -2
  128. package/dist/ApplicationRegistry.abi-CLaa6E99.cjs.map +0 -1
  129. package/dist/ApplicationRegistry.abi-w5prf7Ig.js.map +0 -1
  130. package/dist/BTCVaultRegistry.abi-Chs4AFBj.js.map +0 -1
  131. package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs +0 -2
  132. package/dist/BTCVaultRegistry.abi-JdeqLz4x.cjs.map +0 -1
  133. package/dist/PayoutManager-BVgmuKuK.js.map +0 -1
  134. package/dist/PayoutManager-Cu4_l-_Y.cjs +0 -2
  135. package/dist/PayoutManager-Cu4_l-_Y.cjs.map +0 -1
  136. package/dist/PeginManager-CcjGRo4O.cjs +0 -2
  137. package/dist/buildAndBroadcastRefund-BtXUqBkb.js.map +0 -1
  138. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs +0 -2
  139. package/dist/buildAndBroadcastRefund-Cq01wyZX.cjs.map +0 -1
  140. package/dist/mempoolApi-DkyKmmgI.cjs +0 -2
  141. package/dist/mempoolApi-DkyKmmgI.cjs.map +0 -1
  142. package/dist/mempoolApi-lpJdvPkK.js +0 -483
  143. package/dist/mempoolApi-lpJdvPkK.js.map +0 -1
  144. package/dist/primeVpAuth-Caa5J_uv.js.map +0 -1
  145. package/dist/primeVpAuth-y-4A88ah.cjs +0 -2
  146. package/dist/primeVpAuth-y-4A88ah.cjs.map +0 -1
  147. package/dist/types-CQDRQvV-.js.map +0 -1
  148. package/dist/types-WA0LrDk1.cjs.map +0 -1
  149. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs +0 -2
  150. package/dist/verifyScriptPathSchnorrSignature-BZhX-SOd.cjs.map +0 -1
  151. package/dist/verifyScriptPathSchnorrSignature-CgrnAjMW.js.map +0 -1
package/dist/tbv/index.js CHANGED
@@ -1,203 +1,213 @@
1
1
  import { b as s, c as t } from "../challengeAssert-BVQq50su.js";
2
2
  import { a as o } from "../constants-CDQE812z.js";
3
3
  import { computeMinClaimValue as n, computeMinPeginFee as p, deriveVaultId as u, expandAuthAnchor as l, expandHashlockSecret as d, expandWotsSeed as P, peginP2aAnchorOutput as c, supportedTxGraphVersions as T, validatePeginP2aAnchor as A } from "@babylonlabs-io/babylon-tbv-rust-wasm";
4
- import { P as S, d as g, f as _, c as R, b as m, a as x, g as f, e as b } from "../verifyScriptPathSchnorrSignature-CgrnAjMW.js";
5
- import { b as O, e as v, f as I } from "../peginInput-BKD_b3gq.js";
6
- import { a as C, b as F } from "../noPayout-CihCk1HE.js";
7
- import { d as N, a as y, b as D, e as B, f as M, j as H, g as L, h as X, i as k, c as W, p as w, s as K, t as G, u as Y, v as Z } from "../bitcoin-B5aNKtsk.js";
8
- import { B as j, H as q, K as z, M as Q, T as $, c as aa } from "../validation-Dj3dqYtl.js";
4
+ import { P as S, d as g, f as R, c as _, b as m, a as f, g as x, e as b } from "../verifyScriptPathSchnorrSignature-Xoo9DOHW.js";
5
+ import { b as v, e as O, f as h } from "../peginInput-BKD_b3gq.js";
6
+ import { a as I, b as y } from "../noPayout-CI4l1qu2.js";
7
+ import { d as U, a as B, b as D, e as N, f as M, j as H, g as L, h as K, i as X, c as k, p as W, s as w, t as G, u as Y, v as Z } from "../bitcoin-B5aNKtsk.js";
8
+ import { B as J, H as q, K as z, M as Q, T as $, c as aa } from "../validation-Dj3dqYtl.js";
9
9
  import { c as sa } from "../signing-DaLvGwQe.js";
10
- import { P as ra, b as oa, c as ia, d as na, e as pa } from "../PeginManager-Ba7Cr51Z.js";
11
- import { P as la, c as da, f as Pa, s as ca, v as Ta } from "../PayoutManager-BVgmuKuK.js";
12
- import { A as Ea, P as Sa } from "../ApplicationRegistry.abi-w5prf7Ig.js";
13
- import { B as _a } from "../BTCVaultRegistry.abi-Chs4AFBj.js";
14
- import { C as ma, e as xa, g as fa, h as ba, i as Va } from "../errors-Blc-JWnI.js";
15
- import { V as va, b as Ia, a as ha, d as Ca } from "../deriveVaultRoot-B_gEOTD6.js";
16
- import { p as Ua } from "../parseFundingOutpoints-GSM-IaaK.js";
17
- import { B as ya, a as Da, f as Ba, c as Ma, b as Ha, d as La, g as Xa, i as ka, h as Wa, s as wa, e as Ka, w as Ga } from "../waitForTransactionReceiptSmartAware-lobLm0q0.js";
18
- import { B as Za, D as Ja, L as ja, M as qa, c as za, P as Qa, b as $a, a as ae, S as ee, T as se, W as te, f as re, d as oe, p as ie, r as ne } from "../fundPeginTransaction-B2wyjqp0.js";
19
- import { U as ue, a as le, e as de, f as Pe, v as ce } from "../reservation-cHDRn4DA.js";
20
- import { M as Ae, V as Ee, g as Se, a as ge, b as _e, c as Re, d as me, e as xe, f as fe, h as be, i as Ve, p as Oe, v as ve, j as Ie, k as he } from "../mempoolApi-lpJdvPkK.js";
21
- import { O as Fe, S as Ue, V as Ne, g as ye, h as De, i as Be, a as Me, d as He, b as Le, f as Xe, p as ke, r as We, v as we, c as Ke, e as Ge } from "../primeVpAuth-Caa5J_uv.js";
22
- import { A as Ze, D as Je, b as je, J as qe, a as ze, d as Qe, P as $e, R as as, e as es, c as ss, V as ts } from "../types-CQDRQvV-.js";
23
- import { i as os } from "../errors-B-H0seUG.js";
24
- import { B as ns, C as ps, p as us, q as ls, t as ds, u as Ps, R as cs, a as Ts, n as As, o as Es, i as Ss, m as gs, l as _s, j as Rs, r as ms, b as xs, s as fs, v as bs, g as Vs, h as Os, d as vs, c as Is, e as hs, f as Cs, k as Fs, w as Us } from "../buildAndBroadcastRefund-BtXUqBkb.js";
25
- import { C as ys, P as Ds, c as Bs, g as Ms, i as Hs } from "../peginState-BB81JI6I.js";
10
+ import { P as ra, b as oa, c as ia, d as na, e as pa } from "../PeginManager-CnX3uFb0.js";
11
+ import { P as la, c as da, f as Pa, s as ca, v as Ta } from "../signPsbtsWithFallback-CzZFZf0I.js";
12
+ import { A as Ea, P as Sa } from "../ProtocolParams.abi-CV938AYZ.js";
13
+ import { B as Ra } from "../BTCVaultRegistry.abi-CixOlp3B.js";
14
+ import { B as ma } from "../BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js";
15
+ import { C as xa, e as ba, g as Va, h as va, i as Oa } from "../errors-Blc-JWnI.js";
16
+ import { V as Ca, b as Ia, a as ya, d as Fa } from "../deriveVaultRoot-B_gEOTD6.js";
17
+ import { p as Ba } from "../parseFundingOutpoints-GSM-IaaK.js";
18
+ import { B as Na, a as Ma, f as Ha, c as La, b as Ka, d as Xa, g as ka, i as Wa, h as wa, s as Ga, e as Ya, w as Za } from "../waitForTransactionReceiptSmartAware-lobLm0q0.js";
19
+ import { B as Ja, D as qa, L as za, M as Qa, c as $a, P as ae, b as ee, a as se, S as te, T as re, W as oe, f as ie, d as ne, p as pe, r as ue } from "../fundPeginTransaction-B2wyjqp0.js";
20
+ import { U as de, a as Pe, e as ce, f as Te, v as Ae } from "../reservation-cHDRn4DA.js";
21
+ import { M as Se, V as ge, g as Re, a as _e, b as me, c as fe, d as xe, e as be, f as Ve, h as ve, i as Oe, p as he, v as Ce, j as Ie, k as ye } from "../mempoolApi-C0olk43O.js";
22
+ import { O as Ue, S as Be, V as De, g as Ne, h as Me, i as He, j as Le, a as Ke, d as Xe, b as ke, f as We, p as we, r as Ge, v as Ye, c as Ze, e as je } from "../primeVpAuth-DkJbvywo.js";
23
+ import { A as qe, D as ze, b as Qe, J as $e, a as as, d as es, P as ss, R as ts, e as rs, c as os, V as is } from "../json-rpc-client-Ehjthcd7.js";
24
+ import { a as ps } from "../onChainBtcPubkey-aPY5ib3Q.js";
25
+ import { i as ls } from "../errors-B-H0seUG.js";
26
+ import { B as Ps, C as cs, P as Ts, x as As, y as Es, z as Ss, A as gs, R as Rs, a as _s, t as ms, u as fs, i as xs, j as bs, q as Vs, p as vs, l as Os, n as hs, o as Cs, r as Is, s as ys, b as Fs, c as Us, d as Bs, v as Ds, e as Ns, f as Ms, g as Hs, h as Ls, k as Ks, m as Xs, w as ks } from "../buildAndBroadcastRefund-CCb1_z24.js";
27
+ import { C as ws, P as Gs, c as Ys, g as Zs, i as js } from "../peginState-BB81JI6I.js";
26
28
  export {
27
- Ze as AUTH_EXPIRED_DATA_KIND,
29
+ qe as AUTH_EXPIRED_DATA_KIND,
28
30
  Ea as ApplicationRegistryABI,
29
- ns as BIP68NotMatureError,
30
- j as BITCOIN_ADDRESS_RE,
31
- _a as BTCVaultRegistryABI,
32
- Za as BTC_DUST_SAT,
33
- ya as BitcoinScriptType,
34
- ma as CONTRACT_ERRORS,
35
- ps as ClaimerPegoutStatusValue,
36
- ys as ContractStatus,
37
- Ja as DUST_THRESHOLD,
38
- Je as DaemonStatus,
31
+ Ps as BIP68NotMatureError,
32
+ J as BITCOIN_ADDRESS_RE,
33
+ Ra as BTCVaultRegistryABI,
34
+ ma as BTCVaultRegistryKeyEpochsABI,
35
+ Ja as BTC_DUST_SAT,
36
+ Na as BitcoinScriptType,
37
+ xa as CONTRACT_ERRORS,
38
+ cs as ClaimerPegoutStatusValue,
39
+ ws as ContractStatus,
40
+ qa as DUST_THRESHOLD,
41
+ ze as DaemonStatus,
39
42
  q as HEX_RE,
40
- je as JSON_RPC_ERROR_CODES,
41
- qe as JsonRpcClient,
42
- ze as JsonRpcError,
43
+ Qe as JSON_RPC_ERROR_CODES,
44
+ $e as JsonRpcClient,
45
+ as as JsonRpcError,
43
46
  z as KNOWN_SCRIPT_PREFIXES,
44
- ja as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
45
- qa as MAX_NON_LEGACY_OUTPUT_SIZE,
47
+ za as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
48
+ Qa as MAX_NON_LEGACY_OUTPUT_SIZE,
46
49
  Q as MAX_REASONABLE_FEE_SATS,
47
- za as MAX_REASONABLE_PEGIN_VBYTES,
48
- Ae as MEMPOOL_API_URLS,
49
- Fe as OnChainBtcVaultStatus,
50
- Qa as P2TR_INPUT_SIZE,
51
- $a as PEGIN_AUTH_ANCHOR_OUTPUTS,
52
- ae as PEGIN_FIXED_OUTPUTS,
53
- Qe as POST_WOTS_STATUSES,
54
- $e as PRE_DEPOSITOR_SIGNATURES_STATES,
50
+ $a as MAX_REASONABLE_PEGIN_VBYTES,
51
+ Se as MEMPOOL_API_URLS,
52
+ Ue as OnChainBtcVaultStatus,
53
+ ae as P2TR_INPUT_SIZE,
54
+ ee as PEGIN_AUTH_ANCHOR_OUTPUTS,
55
+ se as PEGIN_FIXED_OUTPUTS,
56
+ es as POST_WOTS_STATUSES,
57
+ ss as PRE_DEPOSITOR_SIGNATURES_STATES,
58
+ Ts as ParticipantKeyDriftError,
55
59
  la as PayoutManager,
56
- Ds as PeginAction,
60
+ Gs as PeginAction,
57
61
  ra as PeginManager,
58
62
  Sa as ProtocolParamsABI,
59
63
  S as PsbtSubstitutionError,
60
- us as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
61
- ls as REFUND_MAX_FEE_FRACTION_NUMERATOR,
62
- ds as REFUND_MAX_FEE_RATE_SATS_VB,
63
- Ps as REFUND_VSIZE,
64
- cs as RegisteredVaultVersionMismatchError,
65
- as as RpcErrorCode,
66
- ee as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
67
- Ue as ServerIdentityError,
64
+ As as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
65
+ Es as REFUND_MAX_FEE_FRACTION_NUMERATOR,
66
+ Ss as REFUND_MAX_FEE_RATE_SATS_VB,
67
+ gs as REFUND_VSIZE,
68
+ Rs as RegisteredVaultVersionMismatchError,
69
+ ts as RpcErrorCode,
70
+ te as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
71
+ Be as ServerIdentityError,
68
72
  $ as TXID_RE,
69
- se as TX_BUFFER_SIZE_OVERHEAD,
70
- ue as UtxoNotAvailableError,
71
- va as VAULT_APP_NAME,
72
- es as VP_BATCH_MAX_SIZE,
73
- ss as VP_TERMINAL_FAILURE_STATUSES,
74
- ts as VP_TRANSIENT_STATUSES,
75
- Ne as VaultProviderRpcClient,
76
- ye as ViemProtocolParamsReader,
77
- De as ViemUniversalChallengerReader,
78
- Be as ViemVaultKeeperReader,
79
- Ee as ViemVaultRegistryReader,
80
- Me as VpResponseValidationError,
81
- He as VpTokenRegistry,
82
- te as WALLET_RELAY_FEE_RATE_THRESHOLD,
83
- Ts as activateVault,
84
- Da as applyChangeOutputPolicy,
73
+ re as TX_BUFFER_SIZE_OVERHEAD,
74
+ de as UtxoNotAvailableError,
75
+ Ca as VAULT_APP_NAME,
76
+ rs as VP_BATCH_MAX_SIZE,
77
+ os as VP_TERMINAL_FAILURE_STATUSES,
78
+ is as VP_TRANSIENT_STATUSES,
79
+ De as VaultProviderRpcClient,
80
+ Ne as ViemOperationKeyReader,
81
+ Me as ViemProtocolParamsReader,
82
+ He as ViemUniversalChallengerReader,
83
+ Le as ViemVaultKeeperReader,
84
+ ge as ViemVaultRegistryReader,
85
+ Ke as VpResponseValidationError,
86
+ Xe as VpTokenRegistry,
87
+ oe as WALLET_RELAY_FEE_RATE_THRESHOLD,
88
+ _s as activateVault,
89
+ Ma as applyChangeOutputPolicy,
90
+ ps as assertOnChainBtcPubkey,
85
91
  g as assertPsbtUnsignedTxMatches,
86
- _ as assertScriptPathSchnorrSignature,
87
- le as assertUtxosAvailable,
92
+ R as assertScriptPathSchnorrSignature,
93
+ Pe as assertUtxosAvailable,
88
94
  o as assertValidVaultCoreVersion,
89
- Le as batchPollByProvider,
90
- As as buildAndBroadcastRefund,
95
+ ke as batchPollByProvider,
96
+ ms as buildAndBroadcastRefund,
91
97
  s as buildChallengeAssertPsbt,
92
98
  oa as buildDepositTerms,
93
99
  Ia as buildFundingOutpointsCommitment,
94
- C as buildNoPayoutPsbt,
95
- R as buildPayoutPsbt,
96
- O as buildPeginInputPsbt,
100
+ I as buildNoPayoutPsbt,
101
+ _ as buildPayoutPsbt,
102
+ v as buildPeginInputPsbt,
97
103
  m as buildPeginTxFromFundedPrePegin,
98
- x as buildPrePeginPsbt,
99
- F as buildRefundPsbt,
100
- ha as buildVaultContext,
101
- Ba as calculateBtcTxHash,
102
- Bs as canPerformAction,
104
+ f as buildPrePeginPsbt,
105
+ y as buildRefundPsbt,
106
+ ya as buildVaultContext,
107
+ Ha as calculateBtcTxHash,
108
+ Ys as canPerformAction,
103
109
  aa as combineAbortSignals,
104
- Ma as computeChangeOutputFeeSats,
110
+ La as computeChangeOutputFeeSats,
105
111
  da as computeHashlock,
106
- Ha as computeMaxDeposit,
112
+ Ka as computeMaxDeposit,
107
113
  n as computeMinClaimValue,
108
114
  p as computeMinPeginFee,
109
115
  t as computeNumLocalChallengers,
110
- La as computePeginBaseFeeSats,
116
+ Xa as computePeginBaseFeeSats,
111
117
  ia as computeWotsBlockPublicKeysHash,
112
- Xe as createAuthenticatedVpClient,
113
- f as createPayoutScript,
118
+ We as createAuthenticatedVpClient,
119
+ x as createPayoutScript,
114
120
  sa as createTaprootScriptPathSignOptions,
115
- N as deriveBip86ScriptPubKeyHex,
116
- y as deriveNativeSegwitAddress,
121
+ U as deriveBip86ScriptPubKeyHex,
122
+ B as deriveNativeSegwitAddress,
117
123
  D as deriveTaprootAddress,
118
124
  u as deriveVaultId,
119
- Ca as deriveVaultRoot,
125
+ Fa as deriveVaultRoot,
120
126
  na as deriveWotsBlocksFromSeed,
121
- B as ensureHexPrefix,
122
- Es as estimateRefundFeeSats,
127
+ N as ensureHexPrefix,
128
+ fs as estimateRefundFeeSats,
123
129
  pa as estimateSubmitPeginRequestBatchGas,
124
130
  l as expandAuthAnchor,
125
131
  d as expandHashlockSecret,
126
132
  P as expandWotsSeed,
127
- xa as extractErrorData,
128
- de as extractInputsFromTransaction,
133
+ ba as extractErrorData,
134
+ ce as extractInputsFromTransaction,
129
135
  b as extractPayoutSignature,
130
- v as extractPeginInputSignature,
131
- I as finalizePeginInputPsbt,
132
- Pe as findOverlappingPendingVaults,
136
+ O as extractPeginInputSignature,
137
+ h as finalizePeginInputPsbt,
138
+ Te as findOverlappingPendingVaults,
133
139
  M as formatSatoshisToBtc,
134
140
  Pa as forwardDepositApproval,
135
- re as fundPeginTransaction,
136
- Se as getAddressTxs,
137
- ge as getAddressUtxos,
138
- fa as getContractErrorMessage,
139
- Xa as getDustThreshold,
140
- _e as getMempoolApiUrl,
141
+ ie as fundPeginTransaction,
142
+ Re as getAddressTxs,
143
+ _e as getAddressUtxos,
144
+ Va as getContractErrorMessage,
145
+ ka as getDustThreshold,
146
+ me as getMempoolApiUrl,
141
147
  H as getNetwork,
142
- Re as getNetworkFees,
143
- me as getOutspend,
144
- Ms as getPeginProtocolState,
145
- ka as getPsbtInputFields,
146
- Wa as getScriptType,
148
+ fe as getNetworkFees,
149
+ xe as getOutspend,
150
+ Zs as getPeginProtocolState,
151
+ Wa as getPsbtInputFields,
152
+ wa as getScriptType,
147
153
  L as getSortedXOnlyPubkeys,
148
- xe as getTipHeight,
149
- fe as getTxHex,
150
- be as getTxInfo,
151
- Ve as getUtxoInfo,
152
- ba as handleContractError,
153
- X as hexToUint8Array,
154
- Hs as isActivationDeadlinePassedOnChain,
155
- k as isAddressFromPublicKey,
156
- Ss as isDepositAmountValid,
157
- Va as isKnownContractError,
158
- gs as isPegoutTerminalStatus,
159
- _s as isRecognizedPegoutStatus,
160
- Rs as isRegisteredVaultVersionMismatchError,
161
- W as isValidHex,
162
- os as isWotsMismatchError,
163
- Ua as parseFundingOutpointsFromTx,
164
- oe as parseUnfundedWasmTransaction,
165
- ie as peginOutputCount,
154
+ be as getTipHeight,
155
+ Ve as getTxHex,
156
+ ve as getTxInfo,
157
+ Oe as getUtxoInfo,
158
+ va as handleContractError,
159
+ K as hexToUint8Array,
160
+ js as isActivationDeadlinePassedOnChain,
161
+ X as isAddressFromPublicKey,
162
+ xs as isDepositAmountValid,
163
+ Oa as isKnownContractError,
164
+ bs as isParticipantKeyDriftError,
165
+ Vs as isPegoutTerminalStatus,
166
+ vs as isRecognizedPegoutStatus,
167
+ Os as isRegisteredVaultVersionMismatchError,
168
+ k as isValidHex,
169
+ ls as isWotsMismatchError,
170
+ Ba as parseFundingOutpointsFromTx,
171
+ ne as parseUnfundedWasmTransaction,
172
+ pe as peginOutputCount,
166
173
  c as peginP2aAnchorOutput,
167
- ke as primeVpTokenRegistry,
168
- w as processPublicKeyToXOnly,
169
- Oe as pushTx,
170
- ne as rateBasedTxBufferFee,
171
- We as resolveProtocolAddresses,
172
- ms as runDepositorPresignFlow,
173
- wa as selectUtxosForPegin,
174
- Ka as shouldAddChangeOutput,
175
- xs as signDepositorGraph,
176
- K as stripHexPrefix,
177
- fs as submitWotsPublicKey,
174
+ we as primeVpTokenRegistry,
175
+ W as processPublicKeyToXOnly,
176
+ he as pushTx,
177
+ ue as rateBasedTxBufferFee,
178
+ hs as resolveCurrentParticipantKeys,
179
+ Cs as resolveParticipantKeysAtEpochs,
180
+ Ge as resolveProtocolAddresses,
181
+ Is as runDepositorPresignFlow,
182
+ Ga as selectUtxosForPegin,
183
+ Ya as shouldAddChangeOutput,
184
+ ys as signDepositorGraph,
185
+ w as stripHexPrefix,
186
+ Fs as submitWotsPublicKey,
178
187
  T as supportedTxGraphVersions,
179
188
  ca as supportsDepositApproval,
180
189
  G as toXOnly,
181
190
  Y as uint8ArrayToHex,
182
- bs as validateDepositAmount,
183
- Vs as validateMultiVaultDepositInputs,
184
- ve as validateOffchainParams,
185
- Os as validateOnChainParticipantKeys,
191
+ Us as validateDepositAmount,
192
+ Bs as validateMultiVaultDepositInputs,
193
+ Ce as validateOffchainParams,
194
+ Ds as validateOnChainParticipantKeys,
186
195
  Ie as validatePegInConfiguration,
187
196
  A as validatePeginP2aAnchor,
188
- vs as validateProviderSelection,
189
- Is as validateRemainingCapacity,
190
- we as validateRequestDepositorClaimerArtifactsResponse,
197
+ Ns as validateProviderSelection,
198
+ Ms as validateRemainingCapacity,
199
+ Ye as validateRequestDepositorClaimerArtifactsResponse,
191
200
  Ta as validateSecretAgainstHashlock,
192
- he as validateTBVProtocolParams,
193
- ce as validateUtxosAvailable,
194
- hs as validateVaultAmounts,
195
- Cs as validateVaultProviderPubkey,
201
+ ye as validateTBVProtocolParams,
202
+ Ae as validateUtxosAvailable,
203
+ Hs as validateVaultAmounts,
204
+ Ls as validateVaultProviderPubkey,
196
205
  Z as validateWalletPubkey,
197
- Fs as verifyRegisteredVaultVersions,
198
- Ke as verifyServerIdentity,
199
- Ge as vpTokenRegistry,
200
- Us as waitForPeginStatus,
201
- Ga as waitForTransactionReceiptSmartAware
206
+ Ks as verifyRegisteredParticipantKeys,
207
+ Xs as verifyRegisteredVaultVersions,
208
+ Ze as verifyServerIdentity,
209
+ je as vpTokenRegistry,
210
+ ks as waitForPeginStatus,
211
+ Za as waitForTransactionReceiptSmartAware
202
212
  };
203
213
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const w=require("@babylonlabs-io/babylon-tbv-rust-wasm"),p=require("buffer"),x=require("bitcoinjs-lib"),C=require("./fundPeginTransaction-BLD8FRL9.cjs"),c=require("./bitcoin-CHfKAhcI.cjs"),v=require("./constants-BqU1Uz15.cjs"),X=require("@bitcoin-js/tiny-secp256k1-asmjs");function z(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Y=z(X);async function D(e,t){const n=t.pegInAmounts.length;if(e.htlcValues.length!==n)throw new Error(`WASM Pre-PegIn returned ${e.htlcValues.length} HTLC value(s), expected ${n} (one per requested deposit).`);if(e.peginAmounts.length!==n||e.htlcScriptPubKeys.length!==n||e.htlcAddresses.length!==n)throw new Error(`WASM Pre-PegIn returned mismatched array lengths (htlcValues=${e.htlcValues.length}, peginAmounts=${e.peginAmounts.length}, htlcScriptPubKeys=${e.htlcScriptPubKeys.length}, htlcAddresses=${e.htlcAddresses.length}); expected ${n} each.`);if(e.depositorClaimValue<=0n)throw new Error(`WASM Pre-PegIn returned non-positive depositorClaimValue ${e.depositorClaimValue}; expected > 0.`);const r=await w.computeMinClaimValue(t.vaultCoreVersion,t.numLocalChallengers,t.universalChallengerPubkeys.length,t.councilQuorum,t.councilSize,t.feeRate);if(e.depositorClaimValue!==r)throw new Error(`WASM Pre-PegIn depositorClaimValue ${e.depositorClaimValue} does not match the independently computed minimum claim value ${r} (vaultCoreVersion=${t.vaultCoreVersion}, numLocalChallengers=${t.numLocalChallengers}, numUniversalChallengers=${t.universalChallengerPubkeys.length}, councilQuorum=${t.councilQuorum}, councilSize=${t.councilSize}, feeRate=${t.feeRate}).`);const o=await w.peginP2aAnchorOutput(t.vaultCoreVersion),i=(o==null?void 0:o.value)??0n,s=await w.computeMinPeginFee(t.vaultCoreVersion,t.vaultKeeperPubkeys.length,t.universalChallengerPubkeys.length,t.minPeginFeeRate),u=s+i,P=t.minPeginFeeRate*C.MAX_REASONABLE_PEGIN_VBYTES;for(let a=0;a<n;a++){const h=t.pegInAmounts[a],l=e.peginAmounts[a],g=e.htlcValues[a];if(l!==h)throw new Error(`WASM Pre-PegIn peginAmount[${a}] ${l} does not match the requested amount ${h}; refusing to build a tx whose recorded amount differs from the depositor's request.`);if(l<=0n)throw new Error(`WASM Pre-PegIn peginAmount[${a}] is non-positive (${l}); expected > 0.`);if(g<=0n)throw new Error(`WASM Pre-PegIn htlcValue[${a}] is non-positive (${g}); expected > 0.`);const d=g-l-e.depositorClaimValue;if(d<=0n)throw new Error(`WASM Pre-PegIn htlcValue[${a}] ${g} does not strictly cover peginAmount ${l} + depositorClaimValue ${e.depositorClaimValue} + a PegIn reserve (implied reserve ${d}).`);if(d>P)throw new Error(`WASM Pre-PegIn implied reserve for HTLC[${a}] (${d} sat) exceeds the plausibility cap ${P} sat (minPeginFeeRate=${t.minPeginFeeRate} × ${C.MAX_REASONABLE_PEGIN_VBYTES} vbytes); htlcValue ${g} appears grossly inflated.`);if(d!==u)throw new Error(`WASM Pre-PegIn htlcValue[${a}] ${g} implies a PegIn fee+anchor reserve of ${d} sat, expected exactly ${u} sat (minPeginFee ${s} + p2aAnchor ${i} for vaultCoreVersion ${t.vaultCoreVersion}, vaultKeepers=${t.vaultKeeperPubkeys.length}, universalChallengers=${t.universalChallengerPubkeys.length}, minPeginFeeRate=${t.minPeginFeeRate}).`)}return s}function G(e,t,n){if(e.length<t.length)throw new Error(`Encoded Pre-PegIn tx has ${e.length} output(s), fewer than the ${t.length} HTLC output(s) the cross-check validated.`);for(let r=0;r<t.length;r++){const o=BigInt(e[r].value);if(o!==t[r])throw new Error(`Encoded Pre-PegIn HTLC output[${r}] value ${o} does not match the cross-checked htlcValue ${t[r]}; the funded/signed tx would not pay the validated amount.`);const i=e[r].script.toString("hex").toLowerCase(),s=n[r].toLowerCase();if(i!==s)throw new Error(`Encoded Pre-PegIn HTLC output[${r}] scriptPubKey ${i} does not match the cross-checked htlcScriptPubKey ${s}.`)}}const H=64,Q=/^[0-9a-fA-F]+$/;async function Z(e){const t=T(e.authAnchorHash),n=await w.createPrePeginTransaction({txGraphVersion:e.vaultCoreVersion,depositorPubkey:e.depositorPubkey,vaultProviderPubkey:e.vaultProviderPubkey,vaultKeeperPubkeys:e.vaultKeeperPubkeys,universalChallengerPubkeys:e.universalChallengerPubkeys,hashlocks:[...e.hashlocks],timelockRefund:e.timelockRefund,pegInAmounts:[...e.pegInAmounts],feeRate:e.feeRate,minPeginFeeRate:e.minPeginFeeRate,numLocalChallengers:e.numLocalChallengers,councilQuorum:e.councilQuorum,councilSize:e.councilSize,network:e.network,authAnchorHash:t}),r=await D(n,e),o=C.parseUnfundedWasmTransaction(n.txHex);G(o.outputs,n.htlcValues,n.htlcScriptPubKeys);const i=o.outputs.reduce((u,P)=>u+BigInt(P.value),0n),s=t!==void 0?n.htlcValues.length:null;return{psbtHex:n.txHex,totalOutputValue:i,htlcValues:n.htlcValues,htlcScriptPubKeys:n.htlcScriptPubKeys,htlcAddresses:n.htlcAddresses,peginAmounts:n.peginAmounts,depositorClaimValue:n.depositorClaimValue,authAnchorVout:s,minPeginFee:r}}function T(e){if(e===void 0)return;const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e;if(t.length!==H||!Q.test(t))throw new Error(`authAnchorHash must be 32-byte hex (${H} chars, no 0x prefix); got length ${t.length}`);return t.toLowerCase()}async function j(e){const t=await w.buildPeginTxFromPrePegin({txGraphVersion:e.prePeginParams.vaultCoreVersion,depositorPubkey:e.prePeginParams.depositorPubkey,vaultProviderPubkey:e.prePeginParams.vaultProviderPubkey,vaultKeeperPubkeys:e.prePeginParams.vaultKeeperPubkeys,universalChallengerPubkeys:e.prePeginParams.universalChallengerPubkeys,hashlocks:[...e.prePeginParams.hashlocks],timelockRefund:e.prePeginParams.timelockRefund,pegInAmounts:[...e.prePeginParams.pegInAmounts],feeRate:e.prePeginParams.feeRate,minPeginFeeRate:e.prePeginParams.minPeginFeeRate,numLocalChallengers:e.prePeginParams.numLocalChallengers,councilQuorum:e.prePeginParams.councilQuorum,councilSize:e.prePeginParams.councilSize,network:e.prePeginParams.network,authAnchorHash:T(e.prePeginParams.authAnchorHash)},e.timelockPegin,e.fundedPrePeginTxHex,e.htlcVout);return await te(t,e),{txHex:t.txHex,txid:t.txid,vaultScriptPubKey:t.vaultScriptPubKey,vaultValue:t.vaultValue}}const J=2,ee=1;async function te(e,t){const n=t.prePeginParams.vaultCoreVersion;await w.validatePeginP2aAnchor(n,e.txHex);const r=await w.peginP2aAnchorOutput(n),o=J+(r?1:0),i=x.Transaction.fromHex(c.stripHexPrefix(e.txHex));if(i.ins.length!==1)throw new Error(`PegIn tx has ${i.ins.length} input(s), expected exactly 1 (the Pre-PegIn HTLC outpoint).`);const s=x.Transaction.fromHex(c.stripHexPrefix(t.fundedPrePeginTxHex)).getId(),u=c.uint8ArrayToHex(new Uint8Array(i.ins[0].hash).slice().reverse());if(u!==s)throw new Error(`PegIn input spends txid ${u}, expected the funded Pre-PegIn ${s}.`);if(i.ins[0].index!==t.htlcVout)throw new Error(`PegIn input spends Pre-PegIn output ${i.ins[0].index}, expected the requested HTLC vout ${t.htlcVout}.`);if(i.outs.length!==o)throw new Error(`PegIn tx has ${i.outs.length} output(s), expected exactly ${o} for vaultCoreVersion ${n} (vault + depositor claim${r?" + P2A anchor":""}).`);const P=t.prePeginParams.pegInAmounts[t.htlcVout];if(e.vaultValue!==P)throw new Error(`PegIn vault output value ${e.vaultValue} does not match the requested peg-in amount ${P} for HTLC ${t.htlcVout}; refusing to sign a vault that locks a different amount than requested.`);const a=i.outs[0];if(BigInt(a.value)!==e.vaultValue)throw new Error(`Encoded PegIn vault output value ${a.value} does not match the WASM-reported vaultValue ${e.vaultValue}.`);const h=a.script.toString("hex"),l=c.stripHexPrefix(e.vaultScriptPubKey).toLowerCase();if(h.toLowerCase()!==l)throw new Error(`Encoded PegIn vault output scriptPubKey ${h} does not match the WASM-reported vaultScriptPubKey ${e.vaultScriptPubKey}.`);const g=i.getId();if(g!==c.stripHexPrefix(e.txid).toLowerCase())throw new Error(`Encoded PegIn txid ${g} does not match the WASM-reported txid ${e.txid}.`);const d=await w.computeMinClaimValue(n,t.prePeginParams.numLocalChallengers,t.prePeginParams.universalChallengerPubkeys.length,t.prePeginParams.councilQuorum,t.prePeginParams.councilSize,t.prePeginParams.feeRate),E=i.outs[ee];if(BigInt(E.value)!==d)throw new Error(`Encoded PegIn depositor-claim output value ${E.value} does not match the independently computed claim value ${d} for vaultCoreVersion ${n}.`);const $=ne(t.prePeginParams.depositorPubkey);if(!E.script.equals($))throw new Error(`Encoded PegIn depositor-claim output scriptPubKey ${E.script.toString("hex")} does not pay to the depositor's claim script (expected ${$.toString("hex")}).`)}function ne(e){const t=x.script.compile([p.Buffer.from(c.hexToUint8Array(e)),x.opcodes.OP_CHECKSIG]),{output:n}=x.payments.p2tr({internalPubkey:p.Buffer.from(w.tapInternalPubkey),scriptTree:{output:t}});if(!n)throw new Error("Failed to derive the depositor-claim P2TR scriptPubKey for PegIn output validation");return n}async function q(e){const t=await w.createPayoutConnector({txGraphVersion:e.vaultCoreVersion,depositor:e.depositor,vaultProvider:e.vaultProvider,vaultKeepers:e.vaultKeepers,universalChallengers:e.universalChallengers,timelockPegin:e.timelockPegin},e.network);return{payoutScript:t.payoutScript,taprootScriptHash:t.taprootScriptHash,scriptPubKey:t.scriptPubKey,address:t.address,payoutControlBlock:t.payoutControlBlock}}const re=500,oe=55,V=0xffffffffn,k=32,ie=34;function se(e){if(typeof e.protocolFeeRate!="bigint"||e.protocolFeeRate<=0n||e.protocolFeeRate>V)throw new Error(`protocolFeeRate must be in [1, ${V}] sat/vB, got ${e.protocolFeeRate}`);for(const[t,n]of[["keepers",e.numVaultKeepers],["challengers",e.numUniversalChallengers]])if(!Number.isInteger(n)||n<1||n>k)throw new Error(`Participant count for ${t} (${n}) is outside the device range [1, ${k}].`);if(!Number.isInteger(e.councilSize)||e.councilSize<1)throw new Error(`councilSize must be an integer >= 1, got ${e.councilSize}`)}async function ue(e,t){const{implicitFeeSats:n,out0Len:r,out1Len:o}=t,i=e.numVaultKeepers+e.numUniversalChallengers,s=BigInt(n),u=Math.max(0,r-ie),P=re+oe*i+u,a=e.protocolFeeRate*BigInt(P);if(s>a)throw new Error(`Payout implicit fee ${n} sats exceeds the safety cap of ${a} sats (${e.protocolFeeRate} sat/vB x ${P} vB for ${i} participants); refusing to sign payout.`);const h=await w.computePayoutFeeFloor(e.vaultCoreVersion,e.numVaultKeepers,e.numUniversalChallengers,e.numVaultKeepers,e.councilSize,r,o,e.protocolFeeRate);if(s<h)throw new Error(`Payout implicit fee ${n} sats is below the floor of ${h} sats (the smallest fee any known vault-provider build produces for this shape); refusing to sign payout.`)}const ce=22,ae=34,le=34,he=25,Pe=23;function de(e){return e.length===ce*2&&e.startsWith("0014")}function pe(e){return e.length===ae*2&&e.startsWith("0020")}function fe(e){return e.length===le*2&&e.startsWith("5120")}function ge(e){return e.length===he*2&&e.startsWith("76a914")&&e.endsWith("88ac")}function xe(e){return e.length===Pe*2&&e.startsWith("a914")&&e.endsWith("87")}function O(e,t){const n=c.stripHexPrefix(e).toLowerCase();if(n.length===0)throw new Error(`${t} is empty`);if(!/^[0-9a-f]+$/.test(n)||n.length%2!==0)throw new Error(`${t} is not valid hex`);if(n.startsWith("6a"))throw new Error(`${t} is an OP_RETURN output, which is provably unspendable`);if(!fe(n)&&!de(n)&&!pe(n)&&!ge(n)&&!xe(n))throw new Error(`${t} is not a standard scriptPubKey (expected P2TR, P2WPKH, P2WSH, P2PKH, or P2SH; got ${n.length/2} bytes: ${n})`)}const R=3;async function ve(e){const t={vaultCoreVersion:e.vaultCoreVersion,numVaultKeepers:e.vaultKeeperBtcPubkeys.length,numUniversalChallengers:e.universalChallengerBtcPubkeys.length,councilSize:e.councilSize,protocolFeeRate:e.protocolFeeRate};se(t);const n=x.Transaction.fromHex(c.stripHexPrefix(e.payoutTxHex)),r=x.Transaction.fromHex(c.stripHexPrefix(e.peginTxHex)),o=x.Transaction.fromHex(c.stripHexPrefix(e.assertTxHex));if(n.ins.length!==v.DEPOSITOR_PAYOUT_INPUT_COUNT)throw new Error(`Payout transaction must have exactly ${v.DEPOSITOR_PAYOUT_INPUT_COUNT} inputs, got ${n.ins.length}`);const i=U(n.ins[0],0,r,"PegIn",v.PEGIN_VAULT_OUTPUT_INDEX),s=U(n.ins[1],1,o,"Assert",v.ASSERT_PAYOUT_OUTPUT_INDEX),{out0Len:u,out1Len:P}=$e(n,i.value,e),a=i.value+s.value;let h=0;for(const d of n.outs)h+=d.value;if(h>a)throw new Error(`Payout outputs (${h} sats) exceed inputs (${a} sats); invalid transaction.`);const l=a-h;await ue(t,{implicitFeeSats:l,out0Len:u,out1Len:P});const g=await q({vaultCoreVersion:e.vaultCoreVersion,depositor:e.depositorBtcPubkey,vaultProvider:e.vaultProviderBtcPubkey,vaultKeepers:e.vaultKeeperBtcPubkeys,universalChallengers:e.universalChallengerBtcPubkeys,timelockPegin:e.timelockPegin,network:e.network});return{psbtHex:we(n,i,s,g)}}function U(e,t,n,r,o){const i=c.uint8ArrayToHex(new Uint8Array(e.hash).slice().reverse()),s=n.getId();if(i!==s||e.index!==o)throw new Error(`Input ${t} must spend ${r}:${o}. Expected ${s}:${o}, got ${i}:${e.index}`);const u=n.outs[e.index];if(!u)throw new Error(`Previous output not found for input ${t} (txid: ${i}, index: ${e.index})`);return u}function we(e,t,n,r){const o=new x.Psbt;o.setVersion(e.version),o.setLocktime(e.locktime);const[i,s]=e.ins;o.addInput({hash:i.hash,index:i.index,sequence:i.sequence,witnessUtxo:{script:t.script,value:t.value},tapLeafScript:[{leafVersion:c.TAPSCRIPT_LEAF_VERSION,script:p.Buffer.from(c.hexToUint8Array(r.payoutScript)),controlBlock:p.Buffer.from(c.hexToUint8Array(r.payoutControlBlock))}],tapInternalKey:p.Buffer.from(w.tapInternalPubkey)}),o.addInput({hash:s.hash,index:s.index,sequence:s.sequence,witnessUtxo:{script:n.script,value:n.value}});for(const u of e.outs)o.addOutput({script:u.script,value:u.value});return o.toHex()}function L(e,t){const n=c.stripHexPrefix(e).toLowerCase(),r=c.stripHexPrefix(c.deriveBip86ScriptPubKeyHex(t)).toLowerCase();return n===r?[n]:[n,r]}function B(e,t){return t.some(n=>e.equals(p.Buffer.from(n,"hex")))}function $e(e,t,n){const{claimerBtcPubkey:r,vaultProviderBtcPubkey:o,depositorBtcPubkey:i,vaultKeeperBtcPubkeys:s,registeredPayoutScriptPubKey:u,commissionBps:P,vkClaimerPayoutScriptPubKeys:a,vpCommissionScriptPubKey:h}=n;if(!c.isValidHex(u))throw new Error("Invalid registeredPayoutScriptPubKey: not valid hex");const l=c.stripHexPrefix(r).toLowerCase(),g=c.stripHexPrefix(o).toLowerCase(),d=c.stripHexPrefix(i).toLowerCase(),E=s.map(m=>c.stripHexPrefix(m).toLowerCase());let $,f,y;if(l===g)$="vp-claimer",f=v.VP_CLAIMER_PAYOUT_OUTPUT_COUNT,y=[c.stripHexPrefix(u)];else if(l===d)$="depositor-as-claimer",f=v.NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT,y=[c.stripHexPrefix(u)];else if(E.includes(l)){$="vk-claimer",f=v.NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT;const m=a[l];if(m===void 0)throw new Error(`No registered payout script resolved for vault keeper claimer ${l}`);O(m,`Vault keeper payout script for claimer ${l}`),y=L(m,l)}else throw new Error(`Unknown claimer pubkey ${l}: not VP, depositor, or a registered vault keeper`);if(e.outs.length!==f)throw new Error(`Payout transaction has ${e.outs.length} output(s), expected exactly ${f} for role ${$}.`);if(!B(e.outs[0].script,y))throw new Error(`Payout transaction output 0 does not pay the expected scriptPubKey for role ${$}. Accepted: ${y.join(" or ")}; got ${e.outs[0].script.toString("hex")}`);const A=f-1;if(e.outs[A].value!==v.PAYOUT_ANCHOR_DUST_SATS)throw new Error(`Payout CPFP anchor (out ${A}) value ${e.outs[A].value} sats must equal ${v.PAYOUT_ANCHOR_DUST_SATS} sats`);if($==="vp-claimer"){O(h,"Vault provider commission payout script");const m=L(h,g);if(!B(e.outs[1].script,m))throw new Error(`Payout transaction output 1 does not pay the vault provider's commission scriptPubKey. Accepted: ${m.join(" or ")}; got ${e.outs[1].script.toString("hex")}`);if(!Number.isInteger(P)||P<0||P>=v.MAX_VP_COMMISSION_BPS_EXCLUSIVE)throw new Error(`commissionBps must be an integer in [0, ${v.MAX_VP_COMMISSION_BPS_EXCLUSIVE}), got ${P}`);const I=Math.floor(t*P/v.BPS_DENOMINATOR);if(e.outs[1].value>I)throw new Error(`Payout VP commission (out 1) value ${e.outs[1].value} sats exceeds cap ${I} sats (${P} bps of peginValue=${t})`)}const b=e.outs[0].script.length;if(b===0||b>v.MAX_PAYOUT_SCRIPT_LEN)throw new Error(`Payout receiver scriptPubKey length ${b} is outside the contract's registration cap [1, ${v.MAX_PAYOUT_SCRIPT_LEN}]; refusing to sign payout.`);const W=$==="vp-claimer"?e.outs[1].script.length:void 0;return{out0Len:b,out1Len:W}}function Se(e,t,n=0){const r=x.Psbt.fromHex(e);if(n>=r.data.inputs.length)throw new Error(`Input index ${n} out of range (${r.data.inputs.length} inputs)`);const o=r.data.inputs[n];if(o.tapScriptSig&&o.tapScriptSig.length>0){const i=c.hexToUint8Array(t);for(const s of o.tapScriptSig)if(s.pubkey.equals(p.Buffer.from(i)))return N(s.signature,n);throw new Error(`No signature found for depositor pubkey: ${t} at input ${n}`)}if(o.finalScriptWitness&&o.finalScriptWitness.length>0){const i=ye(o.finalScriptWitness);if(i.length!==R)throw new Error(`Unexpected finalized witness stack size at input ${n}: expected ${R} items (signature, script, controlBlock), got ${i.length}`);return N(i[0],n)}throw new Error(`No tapScriptSig or finalScriptWitness found in signed PSBT at input ${n}`)}function N(e,t){if(e.length===64)return c.uint8ArrayToHex(new Uint8Array(e));throw e.length===65?new Error(`Unexpected sighash byte 0x${e[64].toString(16).padStart(2,"0")} at input ${t}. Expected implicit SIGHASH_DEFAULT as a 64-byte signature.`):new Error(`Unexpected signature length at input ${t}: ${e.length}`)}function ye(e){const t=[];let n=0;const r=s=>{if(n+s>e.length)throw new Error(`Malformed witness data: need ${s} byte(s) at offset ${n}, only ${e.length-n} remaining`)},o=()=>{r(1);const s=e[n++];if(s<253)return s;if(s===253){r(2);const u=(e[n]|e[n+1]<<8)>>>0;return n+=2,u}if(s===254){r(4);const u=(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0;return n+=4,u}throw new Error(`Malformed witness data: 8-byte varint (0xff) not supported at offset ${n-1}`)},i=o();for(let s=0;s<i;s++){const u=o();r(u),t.push(p.Buffer.from(e.subarray(n,n+u))),n+=u}if(n!==e.length)throw new Error(`Malformed witness data: ${e.length-n} trailing byte(s) after parsing ${i} item(s)`);return t}class S extends Error{constructor(t){super(`Wallet returned a PSBT for a different transaction: ${t}`),this.name="PsbtSubstitutionError"}}function K(e,t){try{return x.Psbt.fromHex(t)}catch(n){const r=n instanceof Error?n.message:String(n);throw new Error(`Failed to parse ${e} PSBT: ${r}`)}}const Ee=8;function _(e){return`${e.toString("hex").slice(0,Ee)}…`}function F(e){const t=p.Buffer.from(e).reverse();return _(t)}function me(e){const t=K("requested",e.requestedPsbtHex),n=K("returned",e.returnedPsbtHex);if(t.version!==n.version)throw new S(`tx version differs (requested=${t.version}, returned=${n.version})`);if(t.locktime!==n.locktime)throw new S(`tx locktime differs (requested=${t.locktime}, returned=${n.locktime})`);if(t.txInputs.length!==n.txInputs.length)throw new S(`input count differs (requested=${t.txInputs.length}, returned=${n.txInputs.length})`);if(t.txOutputs.length!==n.txOutputs.length)throw new S(`output count differs (requested=${t.txOutputs.length}, returned=${n.txOutputs.length})`);for(let r=0;r<t.txInputs.length;r++){const o=t.txInputs[r],i=n.txInputs[r];if(!o.hash.equals(i.hash))throw new S(`input ${r} prevout txid differs (requested=${F(o.hash)}, returned=${F(i.hash)})`);if(o.index!==i.index)throw new S(`input ${r} prevout vout differs (requested=${o.index}, returned=${i.index})`);if(o.sequence!==i.sequence)throw new S(`input ${r} sequence differs (requested=${o.sequence}, returned=${i.sequence})`)}for(let r=0;r<t.txOutputs.length;r++){const o=t.txOutputs[r],i=n.txOutputs[r];if(!o.script.equals(i.script))throw new S(`output ${r} scriptPubKey differs (requested=${_(o.script)}, returned=${_(i.script)})`);if(o.value!==i.value)throw new S(`output ${r} value differs (requested=${o.value}, returned=${i.value})`)}}const M=253,be=254,Ae=65535,Ce=4294967295;function _e(e){if(e<M)return p.Buffer.from([e]);if(e<=Ae){const t=p.Buffer.alloc(2);return t.writeUInt16LE(e),p.Buffer.concat([p.Buffer.from([M]),t])}if(e<=Ce){const t=p.Buffer.alloc(4);return t.writeUInt32LE(e),p.Buffer.concat([p.Buffer.from([be]),t])}throw new Error(`Script too large to encode as CompactSize: ${e} bytes`)}const Te="TapLeaf";function Ie(e,t){const n=p.Buffer.concat([p.Buffer.from([e]),_e(t.length),p.Buffer.from(t)]);return x.crypto.taggedHash(Te,n)}function He(e){const{requestedPsbtHex:t,signatureHex:n,signerXOnlyPubkeyHex:r,inputIndex:o}=e,i=c.stripHexPrefix(n);if(i.length!==c.SCHNORR_SIG_HEX_LEN)throw new Error(`Schnorr signature for input ${o} must be ${c.SCHNORR_SIG_HEX_LEN} hex chars (64 bytes), got ${i.length}.`);const s=c.stripHexPrefix(r);if(s.length!==c.X_ONLY_PUBKEY_HEX_LEN)throw new Error(`Signer x-only pubkey for input ${o} must be ${c.X_ONLY_PUBKEY_HEX_LEN} hex chars (32 bytes), got ${s.length}.`);const u=x.Psbt.fromHex(t);if(o<0||o>=u.data.inputs.length)throw new Error(`Input index ${o} out of range (${u.data.inputs.length} inputs).`);const P=[],a=[];for(let f=0;f<u.data.inputs.length;f++){const y=u.data.inputs[f].witnessUtxo;if(!y)throw new Error(`Cannot verify signature: input ${f} of the requested PSBT has no witnessUtxo (required to recompute the Taproot sighash).`);P.push(y.script),a.push(y.value)}const h=u.data.inputs[o].tapLeafScript;if(!h||h.length!==1)throw new Error(`Cannot verify signature: input ${o} of the requested PSBT must have exactly one tapLeafScript, got ${(h==null?void 0:h.length)??0}.`);const l=h[0];if(l.leafVersion!==c.TAPSCRIPT_LEAF_VERSION)throw new Error(`Cannot verify signature: input ${o} tapLeafScript has leaf version 0x${l.leafVersion.toString(16)}, expected 0x${c.TAPSCRIPT_LEAF_VERSION.toString(16)}.`);const g=Ie(l.leafVersion,l.script),d=new x.Transaction;d.version=u.version,d.locktime=u.locktime;for(const f of u.txInputs)d.addInput(f.hash,f.index,f.sequence);for(const f of u.txOutputs)d.addOutput(f.script,f.value);const E=d.hashForWitnessV1(o,P,a,x.Transaction.SIGHASH_DEFAULT,g);if(!Y.verifySchnorr(E,c.hexToUint8Array(s),c.hexToUint8Array(i)))throw new Error(`Schnorr signature for input ${o} (signer ${s}) does not verify against the expected Taproot script-path sighash. The wallet may have signed with the tweaked key, signed a different transaction, or returned an invalid signature.`)}exports.PsbtSubstitutionError=S;exports.assertPsbtUnsignedTxMatches=me;exports.assertScriptPathSchnorrSignature=He;exports.buildPayoutPsbt=ve;exports.buildPeginTxFromFundedPrePegin=j;exports.buildPrePeginPsbt=Z;exports.createPayoutScript=q;exports.extractPayoutSignature=Se;exports.normalizeAuthAnchorHash=T;
2
+ //# sourceMappingURL=verifyScriptPathSchnorrSignature-C-84KJ6U.cjs.map