@babylonlabs-io/ts-sdk 0.70.1 → 0.71.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/PeginManager-Bn8FxM35.cjs +2 -0
  2. package/dist/PeginManager-Bn8FxM35.cjs.map +1 -0
  3. package/dist/{PeginManager-BNtg6jgY.js → PeginManager-C3ojNTlv.js} +12 -12
  4. package/dist/PeginManager-C3ojNTlv.js.map +1 -0
  5. package/dist/abortSignals-BPpAUL1Z.js +18 -0
  6. package/dist/abortSignals-BPpAUL1Z.js.map +1 -0
  7. package/dist/abortSignals-msbmbqFe.cjs +2 -0
  8. package/dist/abortSignals-msbmbqFe.cjs.map +1 -0
  9. package/dist/{bitcoin-Ch_jxnDa.js → bitcoin-C-TuHb-v.js} +21 -22
  10. package/dist/bitcoin-C-TuHb-v.js.map +1 -0
  11. package/dist/bitcoin-D-O2GjbC.cjs +2 -0
  12. package/dist/bitcoin-D-O2GjbC.cjs.map +1 -0
  13. package/dist/{buildAndBroadcastReclaim-kBHwOL02.js → buildAndBroadcastReclaim-YvWDRAN8.js} +493 -489
  14. package/dist/{buildAndBroadcastReclaim-kBHwOL02.js.map → buildAndBroadcastReclaim-YvWDRAN8.js.map} +1 -1
  15. package/dist/buildAndBroadcastReclaim-zfjDI5__.cjs +2 -0
  16. package/dist/{buildAndBroadcastReclaim-iNJfx0ZG.cjs.map → buildAndBroadcastReclaim-zfjDI5__.cjs.map} +1 -1
  17. package/dist/{challengeAssert-BNQ8sToz.js → challengeAssert-Cp_GeRg8.js} +3 -3
  18. package/dist/challengeAssert-Cp_GeRg8.js.map +1 -0
  19. package/dist/challengeAssert-Z7_YULBb.cjs +2 -0
  20. package/dist/challengeAssert-Z7_YULBb.cjs.map +1 -0
  21. package/dist/constants-Bh38W9mq.cjs +2 -0
  22. package/dist/constants-Bh38W9mq.cjs.map +1 -0
  23. package/dist/constants-CPzppOdq.js +17 -0
  24. package/dist/constants-CPzppOdq.js.map +1 -0
  25. package/dist/index-Cs7_Evtk.cjs +2 -0
  26. package/dist/index-Cs7_Evtk.cjs.map +1 -0
  27. package/dist/index-LgmJhdEN.js +505 -0
  28. package/dist/index-LgmJhdEN.js.map +1 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +244 -239
  31. package/dist/index.js.map +1 -1
  32. package/dist/{mempoolApi-CfOFmov6.js → mempoolApi-CKD_IbrM.js} +59 -59
  33. package/dist/mempoolApi-CKD_IbrM.js.map +1 -0
  34. package/dist/mempoolApi-DronQ5xn.cjs +2 -0
  35. package/dist/mempoolApi-DronQ5xn.cjs.map +1 -0
  36. package/dist/noPayout-DpGRzidi.js +353 -0
  37. package/dist/noPayout-DpGRzidi.js.map +1 -0
  38. package/dist/noPayout-zEifyecV.cjs +2 -0
  39. package/dist/noPayout-zEifyecV.cjs.map +1 -0
  40. package/dist/{onChainBtcPubkey-C_a2L3kL.cjs → onChainBtcPubkey-B5ZvWCCF.cjs} +2 -2
  41. package/dist/{onChainBtcPubkey-C_a2L3kL.cjs.map → onChainBtcPubkey-B5ZvWCCF.cjs.map} +1 -1
  42. package/dist/{onChainBtcPubkey-BAHZyKQL.js → onChainBtcPubkey-DATNfAAl.js} +2 -2
  43. package/dist/{onChainBtcPubkey-BAHZyKQL.js.map → onChainBtcPubkey-DATNfAAl.js.map} +1 -1
  44. package/dist/parseFundingOutpoints-BkgGihaY.cjs +2 -0
  45. package/dist/parseFundingOutpoints-BkgGihaY.cjs.map +1 -0
  46. package/dist/{parseFundingOutpoints-CO-f6IHK.js → parseFundingOutpoints-DlINgQ3X.js} +30 -29
  47. package/dist/parseFundingOutpoints-DlINgQ3X.js.map +1 -0
  48. package/dist/primeVpAuth-Cjq6qFHq.cjs +2 -0
  49. package/dist/primeVpAuth-Cjq6qFHq.cjs.map +1 -0
  50. package/dist/{batchPoll-BM4iQ9jT.js → primeVpAuth-tLRjdHwZ.js} +311 -803
  51. package/dist/primeVpAuth-tLRjdHwZ.js.map +1 -0
  52. package/dist/{reservation-CBAvoF3U.js → reservation-Cj9F0rP9.js} +2 -2
  53. package/dist/{reservation-CBAvoF3U.js.map → reservation-Cj9F0rP9.js.map} +1 -1
  54. package/dist/{reservation-CDbInVw0.cjs → reservation-Dr2HLCxx.cjs} +2 -2
  55. package/dist/{reservation-CDbInVw0.cjs.map → reservation-Dr2HLCxx.cjs.map} +1 -1
  56. package/dist/{signPsbtsWithFallback-X6ivsbh7.js → signPsbtsWithFallback-CCFTzE0o.js} +19 -20
  57. package/dist/{signPsbtsWithFallback-X6ivsbh7.js.map → signPsbtsWithFallback-CCFTzE0o.js.map} +1 -1
  58. package/dist/signPsbtsWithFallback-CrkvpSJz.cjs +2 -0
  59. package/dist/{signPsbtsWithFallback-Bo1PJX90.cjs.map → signPsbtsWithFallback-CrkvpSJz.cjs.map} +1 -1
  60. package/dist/signing-BJ3X66b-.cjs +2 -0
  61. package/dist/signing-BJ3X66b-.cjs.map +1 -0
  62. package/dist/signing-Cm-McVR2.js +22 -0
  63. package/dist/signing-Cm-McVR2.js.map +1 -0
  64. package/dist/tbv/core/clients/eth/types.d.ts +0 -2
  65. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  66. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  67. package/dist/tbv/core/clients/index.cjs +1 -1
  68. package/dist/tbv/core/clients/index.js +36 -35
  69. package/dist/tbv/core/clients/index.js.map +1 -1
  70. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts +9 -1
  71. package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -1
  72. package/dist/tbv/core/clients/vault-provider/auth/serverIdentity.d.ts.map +1 -1
  73. package/dist/tbv/core/clients/vault-provider/auth/verifyDepositorCwt.d.ts.map +1 -1
  74. package/dist/tbv/core/clients/vault-provider/status/index.cjs +2 -0
  75. package/dist/tbv/core/clients/vault-provider/status/index.cjs.map +1 -0
  76. package/dist/tbv/core/clients/vault-provider/status/index.d.ts +18 -0
  77. package/dist/tbv/core/clients/vault-provider/status/index.d.ts.map +1 -0
  78. package/dist/tbv/core/clients/vault-provider/status/index.js +17 -0
  79. package/dist/tbv/core/clients/vault-provider/status/index.js.map +1 -0
  80. package/dist/tbv/core/clients/vault-provider/validators.d.ts.map +1 -1
  81. package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts +1 -1
  82. package/dist/tbv/core/deposit-terms/rebuildDepositTermsCore.d.ts.map +1 -1
  83. package/dist/tbv/core/index.cjs +1 -1
  84. package/dist/tbv/core/index.js +237 -232
  85. package/dist/tbv/core/index.js.map +1 -1
  86. package/dist/tbv/core/managers/index.cjs +1 -1
  87. package/dist/tbv/core/managers/index.js +2 -2
  88. package/dist/tbv/core/primitives/index.cjs +1 -1
  89. package/dist/tbv/core/primitives/index.d.ts +4 -2
  90. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  91. package/dist/tbv/core/primitives/index.js +26 -25
  92. package/dist/tbv/core/primitives/psbt/__tests__/finalizeScriptPathWithSignatures.test.d.ts +11 -0
  93. package/dist/tbv/core/primitives/psbt/__tests__/finalizeScriptPathWithSignatures.test.d.ts.map +1 -0
  94. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +1 -1
  95. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  96. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +1 -1
  97. package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -1
  98. package/dist/tbv/core/primitives/psbt/finalizeScriptPathWithSignatures.d.ts +52 -0
  99. package/dist/tbv/core/primitives/psbt/finalizeScriptPathWithSignatures.d.ts.map +1 -0
  100. package/dist/tbv/core/primitives/psbt/noPayout.d.ts +1 -1
  101. package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -1
  102. package/dist/tbv/core/primitives/psbt/payout.d.ts +1 -1
  103. package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
  104. package/dist/tbv/core/primitives/psbt/pegin.d.ts +1 -1
  105. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  106. package/dist/tbv/core/primitives/psbt/peginInput.d.ts +1 -1
  107. package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
  108. package/dist/tbv/core/primitives/psbt/reclaim.d.ts +23 -1
  109. package/dist/tbv/core/primitives/psbt/reclaim.d.ts.map +1 -1
  110. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  111. package/dist/tbv/core/primitives/scripts/payout.d.ts +1 -1
  112. package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -1
  113. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +0 -10
  114. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
  115. package/dist/tbv/core/recovery/reconstructPeginParams.d.ts.map +1 -1
  116. package/dist/tbv/core/services/deposit/signDepositorGraph.d.ts.map +1 -1
  117. package/dist/tbv/core/services/index.cjs +1 -1
  118. package/dist/tbv/core/services/index.js +2 -2
  119. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.walletPsbt.test.d.ts +14 -0
  120. package/dist/tbv/core/services/reclaim/__tests__/buildAndBroadcastReclaim.walletPsbt.test.d.ts.map +1 -0
  121. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts +14 -2
  122. package/dist/tbv/core/services/reclaim/buildAndBroadcastReclaim.d.ts.map +1 -1
  123. package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -1
  124. package/dist/tbv/core/utils/index.cjs +1 -1
  125. package/dist/tbv/core/utils/index.js +47 -44
  126. package/dist/tbv/core/utils/index.js.map +1 -1
  127. package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
  128. package/dist/tbv/core/utils/validation.d.ts +4 -0
  129. package/dist/tbv/core/utils/validation.d.ts.map +1 -1
  130. package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -1
  131. package/dist/tbv/core/vault-secrets/index.cjs +1 -1
  132. package/dist/tbv/core/vault-secrets/index.d.ts +1 -1
  133. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  134. package/dist/tbv/core/vault-secrets/index.js +2 -2
  135. package/dist/tbv/core/wasm/__tests__/constants.test.d.ts +2 -0
  136. package/dist/tbv/core/wasm/__tests__/constants.test.d.ts.map +1 -0
  137. package/dist/tbv/core/wasm/__tests__/loader.test.d.ts +2 -0
  138. package/dist/tbv/core/wasm/__tests__/loader.test.d.ts.map +1 -0
  139. package/dist/tbv/core/wasm/__tests__/value-guards.test.d.ts +2 -0
  140. package/dist/tbv/core/wasm/__tests__/value-guards.test.d.ts.map +1 -0
  141. package/dist/tbv/core/wasm/constants.d.ts +11 -0
  142. package/dist/tbv/core/wasm/constants.d.ts.map +1 -0
  143. package/dist/tbv/core/wasm/index.cjs +2 -0
  144. package/dist/tbv/core/wasm/index.cjs.map +1 -0
  145. package/dist/tbv/core/wasm/index.d.ts +191 -0
  146. package/dist/tbv/core/wasm/index.d.ts.map +1 -0
  147. package/dist/tbv/core/wasm/index.js +144 -0
  148. package/dist/tbv/core/wasm/index.js.map +1 -0
  149. package/dist/tbv/core/wasm/value-guards.d.ts +30 -0
  150. package/dist/tbv/core/wasm/value-guards.d.ts.map +1 -0
  151. package/dist/tbv/index.cjs +1 -1
  152. package/dist/tbv/index.js +237 -232
  153. package/dist/tbv/index.js.map +1 -1
  154. package/dist/testing/index.cjs +1 -1
  155. package/dist/testing/index.js +1 -1
  156. package/dist/toRefundInputs-CY9u84U9.cjs +2 -0
  157. package/dist/toRefundInputs-CY9u84U9.cjs.map +1 -0
  158. package/dist/{toRefundInputs-DPNYBFkP.js → toRefundInputs-Df1vi23S.js} +8 -8
  159. package/dist/toRefundInputs-Df1vi23S.js.map +1 -0
  160. package/dist/validation-C6XTfZak.cjs +2 -0
  161. package/dist/validation-C6XTfZak.cjs.map +1 -0
  162. package/dist/validation-OSC0xTHB.js +17 -0
  163. package/dist/validation-OSC0xTHB.js.map +1 -0
  164. package/dist/vaultCoreVersion-DYfw3qed.cjs +2 -0
  165. package/dist/vaultCoreVersion-DYfw3qed.cjs.map +1 -0
  166. package/dist/vaultCoreVersion-D_fP9P3C.js +10 -0
  167. package/dist/vaultCoreVersion-D_fP9P3C.js.map +1 -0
  168. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs +2 -0
  169. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs.map +1 -0
  170. package/dist/{verifyKeyPathSchnorrSignature-C6Cmk0R1.js → verifyKeyPathSchnorrSignature-BrgUJmV0.js} +3 -3
  171. package/dist/verifyKeyPathSchnorrSignature-BrgUJmV0.js.map +1 -0
  172. package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs +2 -0
  173. package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs.map +1 -0
  174. package/dist/{verifyScriptPathSchnorrSignature-CQYucnJA.js → verifyScriptPathSchnorrSignature-Ciq_xZhw.js} +39 -37
  175. package/dist/verifyScriptPathSchnorrSignature-Ciq_xZhw.js.map +1 -0
  176. package/dist/waitForTransactionReceiptSmartAware-DpQ69ySe.cjs +2 -0
  177. package/dist/waitForTransactionReceiptSmartAware-DpQ69ySe.cjs.map +1 -0
  178. package/dist/{waitForTransactionReceiptSmartAware-B6oYRdFO.js → waitForTransactionReceiptSmartAware-z3Xfmo44.js} +42 -47
  179. package/dist/waitForTransactionReceiptSmartAware-z3Xfmo44.js.map +1 -0
  180. package/package.json +12 -2
  181. package/dist/PeginManager-BNtg6jgY.js.map +0 -1
  182. package/dist/PeginManager-CvI99Uhd.cjs +0 -2
  183. package/dist/PeginManager-CvI99Uhd.cjs.map +0 -1
  184. package/dist/batchPoll-BM4iQ9jT.js.map +0 -1
  185. package/dist/batchPoll-cqpEfBjr.cjs +0 -2
  186. package/dist/batchPoll-cqpEfBjr.cjs.map +0 -1
  187. package/dist/bitcoin-Ch_jxnDa.js.map +0 -1
  188. package/dist/bitcoin-m84N5a8o.cjs +0 -2
  189. package/dist/bitcoin-m84N5a8o.cjs.map +0 -1
  190. package/dist/buildAndBroadcastReclaim-iNJfx0ZG.cjs +0 -2
  191. package/dist/challengeAssert-BNQ8sToz.js.map +0 -1
  192. package/dist/challengeAssert-BrpC3-cQ.cjs +0 -2
  193. package/dist/challengeAssert-BrpC3-cQ.cjs.map +0 -1
  194. package/dist/constants-BCdDRd_Y.cjs +0 -2
  195. package/dist/constants-BCdDRd_Y.cjs.map +0 -1
  196. package/dist/constants-DRiWbItj.js +0 -24
  197. package/dist/constants-DRiWbItj.js.map +0 -1
  198. package/dist/mempoolApi-CfOFmov6.js.map +0 -1
  199. package/dist/mempoolApi-Q90mz17e.cjs +0 -2
  200. package/dist/mempoolApi-Q90mz17e.cjs.map +0 -1
  201. package/dist/noPayout-BKP3mRu3.cjs +0 -2
  202. package/dist/noPayout-BKP3mRu3.cjs.map +0 -1
  203. package/dist/noPayout-BdATUPjF.js +0 -280
  204. package/dist/noPayout-BdATUPjF.js.map +0 -1
  205. package/dist/parseFundingOutpoints-CIO9Ok1L.cjs +0 -2
  206. package/dist/parseFundingOutpoints-CIO9Ok1L.cjs.map +0 -1
  207. package/dist/parseFundingOutpoints-CO-f6IHK.js.map +0 -1
  208. package/dist/signPsbtsWithFallback-Bo1PJX90.cjs +0 -2
  209. package/dist/signing-Bnsro0hE.cjs +0 -2
  210. package/dist/signing-Bnsro0hE.cjs.map +0 -1
  211. package/dist/signing-DaLvGwQe.js +0 -16
  212. package/dist/signing-DaLvGwQe.js.map +0 -1
  213. package/dist/toRefundInputs-BJojfg3k.cjs +0 -2
  214. package/dist/toRefundInputs-BJojfg3k.cjs.map +0 -1
  215. package/dist/toRefundInputs-DPNYBFkP.js.map +0 -1
  216. package/dist/validation-CDbOaDj7.cjs +0 -2
  217. package/dist/validation-CDbOaDj7.cjs.map +0 -1
  218. package/dist/validation-Dj3dqYtl.js +0 -30
  219. package/dist/validation-Dj3dqYtl.js.map +0 -1
  220. package/dist/verifyKeyPathSchnorrSignature-C6Cmk0R1.js.map +0 -1
  221. package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs +0 -2
  222. package/dist/verifyKeyPathSchnorrSignature-Cr5T4Aym.cjs.map +0 -1
  223. package/dist/verifyScriptPathSchnorrSignature-CQYucnJA.js.map +0 -1
  224. package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs +0 -2
  225. package/dist/verifyScriptPathSchnorrSignature-D-ppKNjT.cjs.map +0 -1
  226. package/dist/waitForTransactionReceiptSmartAware-B6oYRdFO.js.map +0 -1
  227. package/dist/waitForTransactionReceiptSmartAware-Ct7LPwPI.cjs +0 -2
  228. package/dist/waitForTransactionReceiptSmartAware-Ct7LPwPI.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"reservation.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/utxo/reservation.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,iEAAiE;AACjE,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,kCAAkC;IACjD,iBAAiB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACjD;AAkBD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,kCAAkC,GACzC,MAAM,EAAE,CAkCV"}
1
+ {"version":3,"file":"reservation.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/utxo/reservation.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,iEAAiE;AACjE,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,kCAAkC;IACjD,iBAAiB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACjD;AAkBD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,kCAAkC,GACzC,MAAM,EAAE,CAkCV"}
@@ -8,6 +8,10 @@
8
8
  export declare const HEX_RE: RegExp;
9
9
  /** Bitcoin txid: exactly 64 hex characters (32 bytes). */
10
10
  export declare const TXID_RE: RegExp;
11
+ /** Hex-string length of a 32-byte BIP-340 x-only public key. */
12
+ export declare const X_ONLY_PUBKEY_HEX_LEN = 64;
13
+ /** Hex-string length of a 33-byte SEC1-compressed secp256k1 public key. */
14
+ export declare const COMPRESSED_PUBKEY_HEX_LEN = 66;
11
15
  /**
12
16
  * Bitcoin address format gate: 25–90 alphanumeric characters.
13
17
  * Covers legacy (P2PKH/P2SH), bech32 (P2WPKH/P2WSH), bech32m (P2TR),
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qEAAqE;AACrE,eAAO,MAAM,MAAM,QAAmB,CAAC;AAEvC,0DAA0D;AAC1D,eAAO,MAAM,OAAO,QAAsB,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAyB,CAAC;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,qDAMxB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,WAAa,CAAC"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qEAAqE;AACrE,eAAO,MAAM,MAAM,QAAmB,CAAC;AAEvC,0DAA0D;AAC1D,eAAO,MAAM,OAAO,QAAsB,CAAC;AAE3C,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAyB,CAAC;AAEzD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,qDAMxB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,WAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deriveVaultRoot.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEtE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAUlD;;;;;;GAMG;AACH,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtE;AAED;;kCAEkC;AAClC,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,OAAO,CAAC,8BAA8B,CAAC,GAC9C,OAAO,CAAC,8BAA8B,CAAC,CAOzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,8BAA8B,EACtC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,UAAU,CAAC,CAuBrB"}
1
+ {"version":3,"file":"deriveVaultRoot.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEtE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAUlD;;;;;;GAMG;AACH,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtE;AAED;;kCAEkC;AAClC,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,OAAO,CAAC,8BAA8B,CAAC,GAC9C,OAAO,CAAC,8BAA8B,CAAC,CAWzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,8BAA8B,EACtC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,UAAU,CAAC,CAuBrB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@babylonlabs-io/babylon-tbv-rust-wasm"),e=require("../../../parseFundingOutpoints-CIO9Ok1L.cjs");Object.defineProperty(exports,"expandAuthAnchor",{enumerable:!0,get:()=>t.expandAuthAnchor});Object.defineProperty(exports,"expandHashlockSecret",{enumerable:!0,get:()=>t.expandHashlockSecret});Object.defineProperty(exports,"expandWotsSeed",{enumerable:!0,get:()=>t.expandWotsSeed});exports.VAULT_APP_NAME=e.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=e.buildFundingOutpointsCommitment;exports.buildVaultContext=e.buildVaultContext;exports.deriveVaultRoot=e.deriveVaultRoot;exports.forwardDeriveContextHash=e.forwardDeriveContextHash;exports.parseFundingOutpointsFromTx=e.parseFundingOutpointsFromTx;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../wasm/index.cjs"),e=require("../../../parseFundingOutpoints-BkgGihaY.cjs");exports.expandAuthAnchor=t.expandAuthAnchor;exports.expandHashlockSecret=t.expandHashlockSecret;exports.expandWotsSeed=t.expandWotsSeed;exports.VAULT_APP_NAME=e.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=e.buildFundingOutpointsCommitment;exports.buildVaultContext=e.buildVaultContext;exports.deriveVaultRoot=e.deriveVaultRoot;exports.forwardDeriveContextHash=e.forwardDeriveContextHash;exports.parseFundingOutpointsFromTx=e.parseFundingOutpointsFromTx;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -12,7 +12,7 @@
12
12
  * @module tbv/core/vault-secrets
13
13
  */
14
14
  /** @stability frozen — owned by btc-vault Rust via babylon-tbv-rust-wasm; see CLAUDE.md §4 + wrapper JSDoc for failure modes. */
15
- export { expandAuthAnchor, expandHashlockSecret, expandWotsSeed, } from '@babylonlabs-io/babylon-tbv-rust-wasm';
15
+ export { expandAuthAnchor, expandHashlockSecret, expandWotsSeed, } from '../wasm';
16
16
  export { buildFundingOutpointsCommitment, buildVaultContext } from './context';
17
17
  export type { FundingOutpoint, VaultContextInput } from './context';
18
18
  export { VAULT_APP_NAME, deriveVaultRoot, forwardDeriveContextHash, } from './deriveVaultRoot';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,iIAAiI;AACjI,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE/E,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEpE,OAAO,EACL,cAAc,EACd,eAAe,EACf,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,iIAAiI;AACjI,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE/E,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEpE,OAAO,EACL,cAAc,EACd,eAAe,EACf,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,5 +1,5 @@
1
- import { expandAuthAnchor as a, expandHashlockSecret as o, expandWotsSeed as n } from "@babylonlabs-io/babylon-tbv-rust-wasm";
2
- import { V as s, b as d, a as i, d as p, f as u, p as x } from "../../../parseFundingOutpoints-CO-f6IHK.js";
1
+ import { expandAuthAnchor as a, expandHashlockSecret as o, expandWotsSeed as n } from "../wasm/index.js";
2
+ import { V as s, b as d, a as i, d as p, f as u, p as x } from "../../../parseFundingOutpoints-DlINgQ3X.js";
3
3
  export {
4
4
  s as VAULT_APP_NAME,
5
5
  d as buildFundingOutpointsCommitment,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=constants.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/wasm/__tests__/constants.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=loader.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/wasm/__tests__/loader.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=value-guards.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-guards.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/wasm/__tests__/value-guards.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Protocol constants that do not require loading the vault WASM module.
3
+ *
4
+ * Keeping these values local lets Bitcoin builders construct PSBT metadata
5
+ * without resolving or evaluating the WASM engine at module-import
6
+ * time. The hex value is the BIP-341 nothing-up-my-sleeve internal key and is
7
+ * pinned by the vault protocol.
8
+ */
9
+ export declare const TAP_INTERNAL_KEY = "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0";
10
+ export declare const tapInternalPubkey: Uint8Array<ArrayBuffer>;
11
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wasm/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,qEACuC,CAAC;AAIrE,eAAO,MAAM,iBAAiB,yBAU7B,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";var y=Object.create;var d=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var w=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!m.call(e,o)&&o!==a&&d(e,o,{get:()=>t[o],enumerable:!(r=h(t,o))||r.enumerable});return e};var P=(e,t,a)=>(a=e!=null?y(b(e)):{},w(t||!e||!e.__esModule?d(a,"default",{value:e,enumerable:!0}):a,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l="50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0",i=2,A=Uint8Array.from({length:l.length/i},(e,t)=>Number.parseInt(l.slice(t*i,t*i+i),16));let s,c;function n(){return s??(s=import("@babylonlabs-io/babylon-tbv-rust-wasm").catch(e=>{throw s=void 0,new Error("The vault-WASM engine @babylonlabs-io/babylon-tbv-rust-wasm failed to load. The module could not be resolved, or it threw while evaluating, commonly a missing or stale generated WASM build. See the cause for the underlying error.",{cause:e})})),s}function v(){return c??(c=import("@babylonlabs-io/babylon-tbv-rust-wasm/raw").catch(e=>{throw c=void 0,new Error("The raw vault-WASM entry @babylonlabs-io/babylon-tbv-rust-wasm/raw failed to load. The module could not be resolved, or it threw while evaluating. See the cause for the underlying error.",{cause:e})}).then(async e=>{try{await e.initWasm()}catch(t){throw c=void 0,new Error("The raw vault-WASM entry resolved but its WebAssembly binary failed to initialize.",{cause:t})}return e})),c}async function S(e){return(await n()).createPrePeginTransaction(e)}async function T(e,t,a,r){return(await n()).buildPeginTxFromPrePegin(e,t,a,r)}async function I(e){return(await n()).getPrePeginHtlcConnectorInfo(e)}async function x(e,t,a,r,o,u){return(await n()).computeMinClaimValue(e,t,a,r,o,u)}async function W(e,t,a,r){return(await n()).computeMinPeginFee(e,t,a,r)}async function C(e,t,a,r,o,u,p,g){return(await n()).computePayoutFeeFloor(e,t,a,r,o,u,p,g)}async function M(){return(await n()).supportedTxGraphVersions()}async function F(e){return(await n()).peginP2aAnchorOutput(e)}async function E(e,t){return(await n()).validatePeginP2aAnchor(e,t)}async function V(e,t){return(await n()).createPayoutConnector(e,t)}async function H(e){return(await n()).getAssertPayoutScriptInfo(e)}async function N(e,t){return(await n()).getAssertNoPayoutScriptInfo(e,t)}async function _(e){return(await n()).getChallengeAssertScriptInfo(e)}async function R(e){return(await n()).expandAuthAnchor(e)}async function k(e,t){return(await n()).expandHashlockSecret(e,t)}async function O(e,t){return(await n()).expandWotsSeed(e,t)}async function G(e,t){return(await n()).deriveVaultId(e,t)}exports.TAP_INTERNAL_KEY=l;exports.buildPeginTxFromPrePegin=T;exports.computeMinClaimValue=x;exports.computeMinPeginFee=W;exports.computePayoutFeeFloor=C;exports.createPayoutConnector=V;exports.createPrePeginTransaction=S;exports.deriveVaultId=G;exports.expandAuthAnchor=R;exports.expandHashlockSecret=k;exports.expandWotsSeed=O;exports.getAssertNoPayoutScriptInfo=N;exports.getAssertPayoutScriptInfo=H;exports.getChallengeAssertScriptInfo=_;exports.getPrePeginHtlcConnectorInfo=I;exports.loadRawTbvWasm=v;exports.loadTbvWasm=n;exports.peginP2aAnchorOutput=F;exports.supportedTxGraphVersions=M;exports.tapInternalPubkey=A;exports.validatePeginP2aAnchor=E;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/tbv/core/wasm/constants.ts","../../../../src/tbv/core/wasm/index.ts"],"sourcesContent":["/**\n * Protocol constants that do not require loading the vault WASM module.\n *\n * Keeping these values local lets Bitcoin builders construct PSBT metadata\n * without resolving or evaluating the WASM engine at module-import\n * time. The hex value is the BIP-341 nothing-up-my-sleeve internal key and is\n * pinned by the vault protocol.\n */\nexport const TAP_INTERNAL_KEY =\n \"50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0\";\n\nconst HEX_CHARS_PER_BYTE = 2;\n\nexport const tapInternalPubkey = Uint8Array.from(\n { length: TAP_INTERNAL_KEY.length / HEX_CHARS_PER_BYTE },\n (_, index) =>\n Number.parseInt(\n TAP_INTERNAL_KEY.slice(\n index * HEX_CHARS_PER_BYTE,\n index * HEX_CHARS_PER_BYTE + HEX_CHARS_PER_BYTE,\n ),\n 16,\n ),\n);\n","/**\n * Explicit lazy boundary around the vault-WASM engine package.\n *\n * Importing the SDK (including its legacy root barrels) does not resolve the\n * WASM package or generated binary. The engine is loaded only when a caller\n * invokes an operation that actually needs the Bitcoin transaction graph.\n * ETH-only entry points never import this module.\n *\n * @module tbv/core/wasm\n */\n\nimport type {\n AssertNoPayoutScriptInfo,\n AssertPayoutNoPayoutConnectorParams,\n AssertPayoutScriptInfo,\n ChallengeAssertConnectorParams,\n ChallengeAssertScriptInfo,\n HtlcConnectorInfo,\n HtlcConnectorParams,\n Network,\n PayoutConnectorInfo,\n PayoutConnectorParams,\n PeginP2aAnchorInfo,\n PeginTxResult,\n PrePeginParams,\n PrePeginResult,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\n\nexport { TAP_INTERNAL_KEY, tapInternalPubkey } from \"./constants\";\n\ntype TbvWasmModule = typeof import(\"@babylonlabs-io/babylon-tbv-rust-wasm\");\n\nlet wasmModulePromise: Promise<TbvWasmModule> | undefined;\ntype RawTbvWasmModule =\n typeof import(\"@babylonlabs-io/babylon-tbv-rust-wasm/raw\");\nlet rawWasmModulePromise: Promise<RawTbvWasmModule> | undefined;\n\n/** Load the WASM engine on first use and share the in-flight import. */\nexport function loadTbvWasm(): Promise<TbvWasmModule> {\n wasmModulePromise ??= import(\"@babylonlabs-io/babylon-tbv-rust-wasm\").catch(\n (error: unknown) => {\n wasmModulePromise = undefined;\n throw new Error(\n \"The vault-WASM engine @babylonlabs-io/babylon-tbv-rust-wasm failed \" +\n \"to load. The module could not be resolved, or it threw while \" +\n \"evaluating, commonly a missing or stale generated WASM build. \" +\n \"See the cause for the underlying error.\",\n { cause: error },\n );\n },\n );\n return wasmModulePromise;\n}\n\n/**\n * Load the explicit raw-class entry for the one SDK primitive that must\n * reconstruct a stateful WASM transaction object (refund construction).\n */\nexport function loadRawTbvWasm(): Promise<RawTbvWasmModule> {\n rawWasmModulePromise ??= import(\"@babylonlabs-io/babylon-tbv-rust-wasm/raw\")\n .catch((error: unknown) => {\n rawWasmModulePromise = undefined;\n throw new Error(\n \"The raw vault-WASM entry @babylonlabs-io/babylon-tbv-rust-wasm/raw \" +\n \"failed to load. The module could not be resolved, or it threw \" +\n \"while evaluating. See the cause for the underlying error.\",\n { cause: error },\n );\n })\n .then(async (wasm) => {\n try {\n await wasm.initWasm();\n } catch (error: unknown) {\n rawWasmModulePromise = undefined;\n throw new Error(\n \"The raw vault-WASM entry resolved but its WebAssembly \" +\n \"binary failed to initialize.\",\n { cause: error },\n );\n }\n return wasm;\n });\n return rawWasmModulePromise;\n}\n\n/**\n * Creates an unfunded Pre-PegIn transaction with no inputs and HTLC output(s).\n *\n * The HTLC output value (htlcValue) covers the peg-in amount, depositor claim value,\n * and minimum pegin fee — all computed internally from the provided contract parameters.\n *\n * After building the Pre-PegIn transaction, the caller must:\n * 1. Select UTXOs covering htlcValue + network fees\n * 2. Fund the transaction (add inputs and change output)\n * 3. Call reconstructFromFundedTx() with the funded tx hex\n * 4. Call buildPeginTx() to derive the PegIn transaction\n * 5. Sign the PegIn input using the HTLC hashlock leaf (leaf 0)\n *\n * @param params - Pre-PegIn parameters from contract and depositor wallet\n * @returns Unfunded transaction details with HTLC output information\n */\nexport async function createPrePeginTransaction(\n params: PrePeginParams,\n): Promise<PrePeginResult> {\n return (await loadTbvWasm()).createPrePeginTransaction(params);\n}\n\n/**\n * Derives the PegIn transaction from a funded Pre-PegIn transaction.\n *\n * The PegIn transaction has a single input spending the Pre-PegIn HTLC output\n * at `htlcVout` via the hashlock + all-party script (leaf 0).\n *\n * @param params - Same PrePeginParams used to create the Pre-PegIn transaction\n * @param timelockPegin - CSV timelock in blocks for the PegIn vault output\n * @param fundedPrePeginTxHex - Hex-encoded funded Pre-PegIn transaction\n * @param htlcVout - Index of the HTLC output to spend\n * @returns PegIn transaction details including vault output information\n */\nexport async function buildPeginTxFromPrePegin(\n params: PrePeginParams,\n timelockPegin: number,\n fundedPrePeginTxHex: string,\n htlcVout: number,\n): Promise<PeginTxResult> {\n return (await loadTbvWasm()).buildPeginTxFromPrePegin(\n params,\n timelockPegin,\n fundedPrePeginTxHex,\n htlcVout,\n );\n}\n\n/**\n * Returns HTLC connector script info for signing the PegIn transaction input.\n *\n * The depositor signs PegIn input 0 using the hashlock leaf (leaf 0) of the\n * Pre-PegIn HTLC output. Use getHashlockScript() and getHashlockControlBlock()\n * to construct the tapLeafScript entry in the PSBT.\n *\n * @param params - HTLC connector parameters (subset of PrePeginParams)\n * @returns Hashlock and refund script info for PSBT construction\n */\nexport async function getPrePeginHtlcConnectorInfo(\n params: HtlcConnectorParams,\n): Promise<HtlcConnectorInfo> {\n return (await loadTbvWasm()).getPrePeginHtlcConnectorInfo(params);\n}\n\n/**\n * Compute the minimum depositor claim value (PegIn output 1) in satoshis.\n *\n * This covers the full downstream tx graph cost (Claim → Assert → Payout)\n * based on the protocol parameters.\n */\nexport async function computeMinClaimValue(\n txGraphVersion: number,\n numLocalChallengers: number,\n numUniversalChallengers: number,\n councilQuorum: number,\n councilSize: number,\n feeRate: bigint,\n): Promise<bigint> {\n return (await loadTbvWasm()).computeMinClaimValue(\n txGraphVersion,\n numLocalChallengers,\n numUniversalChallengers,\n councilQuorum,\n councilSize,\n feeRate,\n );\n}\n\n/**\n * Compute the minimum PegIn (activation) transaction fee in satoshis.\n *\n * `minPeginFee = peginTxVsize(numVks, numUcs) × minPeginFeeRate`. Each HTLC\n * the depositor funds in the Pre-PegIn tx must reserve at least this fee\n * inside its value (`htlcValue = peginAmount + depositorClaimValue +\n * minPeginFee`), otherwise the VP cannot afford to broadcast the PegIn at\n * activation. The vsize comes from a Taproot script-path-spend weight\n * prediction whose witness shape depends on the VK + UC signer count.\n */\nexport async function computeMinPeginFee(\n txGraphVersion: number,\n numVks: number,\n numUcs: number,\n minPeginFeeRate: bigint,\n): Promise<bigint> {\n return (await loadTbvWasm()).computeMinPeginFee(\n txGraphVersion,\n numVks,\n numUcs,\n minPeginFeeRate,\n );\n}\n\n/**\n * Floor of the Payout transaction fee under `txGraphVersion`: the minimum of\n * `estimatedVsize * feeRate` across every output-sizing model a deployed\n * vault provider is known to have used (fixed-34, intermediate,\n * script-aware). A VP-built payout paying less than this is provably not\n * produced by any known VP build. `out0Len` must be the TRUSTED length of the\n * pinned outs[0] script (1..=128); `out1Len` is the measured, UNTRUSTED\n * commission-script length — safe here because padding cannot raise the floor\n * (the fixed-34 model saturates the minimum) and shortening only lowers it.\n * Pass `undefined` for `out1Len` on 2-output (non-VP-claimer) payouts.\n * `feeRate` is the vault's version-locked `offchainParams.feeRate`.\n */\nexport async function computePayoutFeeFloor(\n txGraphVersion: number,\n numVaultKeepers: number,\n numUniversalChallengers: number,\n numLocalChallengers: number,\n councilSize: number,\n out0Len: number,\n out1Len: number | null | undefined,\n feeRate: bigint,\n): Promise<bigint> {\n return (await loadTbvWasm()).computePayoutFeeFloor(\n txGraphVersion,\n numVaultKeepers,\n numUniversalChallengers,\n numLocalChallengers,\n councilSize,\n out0Len,\n out1Len,\n feeRate,\n );\n}\n\n/**\n * Tx graph versions the shipped vault-wasm binary can build. Callers must\n * preflight the required version (fresh: active; resume: stamped) against\n * this list and fail closed instead of hitting per-call errors mid-flow.\n *\n * Note: the facade constructors themselves fail closed on unsupported\n * versions, and derived objects carry the version they were built with —\n * value-level cross-checks live in `assertWasmPeginSizing` and the golden\n * byte-parity tests, not in a per-call version echo.\n */\nexport async function supportedTxGraphVersions(): Promise<number[]> {\n return (await loadTbvWasm()).supportedTxGraphVersions();\n}\n\n/**\n * The PegIn transaction's P2A (pay-to-anchor) output for a graph version, or\n * `null` when that version's PegIn carries no anchor (v1). The facade returns\n * one record per version — never a zero-valued placeholder — so an absent\n * anchor can't be mistaken for a real output. For v2/v3: 240 sats at vout 2,\n * script `51024e73`.\n */\nexport async function peginP2aAnchorOutput(\n txGraphVersion: number,\n): Promise<PeginP2aAnchorInfo | null> {\n return (await loadTbvWasm()).peginP2aAnchorOutput(txGraphVersion);\n}\n\n/**\n * Validate a PegIn transaction's P2A anchor against a graph version's rules:\n * v2 and v3 require the exact anchor (240 sats, vout 2, P2A script) and v1\n * requires that NO output carries the P2A script. Throws on any mismatch — a\n * v2 PegIn checked as v1 fails closed, and vice versa.\n */\nexport async function validatePeginP2aAnchor(\n txGraphVersion: number,\n txHex: string,\n): Promise<void> {\n return (await loadTbvWasm()).validatePeginP2aAnchor(txGraphVersion, txHex);\n}\n\n/**\n * Creates a payout connector for vault transactions.\n *\n * The payout connector generates the necessary taproot scripts and information\n * required for signing payout transactions (both optimistic and regular payout paths).\n *\n * @param params - Parameters for creating the payout connector\n * @param network - Bitcoin network\n * @returns Payout connector information including scripts, hashes, and address\n */\nexport async function createPayoutConnector(\n params: PayoutConnectorParams,\n network: Network,\n): Promise<PayoutConnectorInfo> {\n return (await loadTbvWasm()).createPayoutConnector(params, network);\n}\n\n/**\n * Get the Payout script and control block for the depositor's Assert output.\n *\n * Used to build the depositor's Payout PSBT (depositor-as-claimer path).\n *\n * @param params - Assert Payout/NoPayout connector parameters\n * @returns Payout script and control block (hex encoded)\n */\nexport async function getAssertPayoutScriptInfo(\n params: AssertPayoutNoPayoutConnectorParams,\n): Promise<AssertPayoutScriptInfo> {\n return (await loadTbvWasm()).getAssertPayoutScriptInfo(params);\n}\n\n/**\n * Get the NoPayout script and control block for a specific challenger.\n *\n * Used to build the depositor's NoPayout PSBT (depositor-as-claimer path).\n * Each challenger has a distinct NoPayout script.\n *\n * @param params - Assert Payout/NoPayout connector parameters\n * @param challengerPubkey - The challenger's x-only public key (hex encoded)\n * @returns NoPayout script and control block (hex encoded)\n */\nexport async function getAssertNoPayoutScriptInfo(\n params: AssertPayoutNoPayoutConnectorParams,\n challengerPubkey: string,\n): Promise<AssertNoPayoutScriptInfo> {\n return (await loadTbvWasm()).getAssertNoPayoutScriptInfo(\n params,\n challengerPubkey,\n );\n}\n\n/**\n * Get the ChallengeAssert script and control block.\n *\n * Used to build ChallengeAssert PSBTs for the depositor-as-claimer path.\n * Each challenger has 3 ChallengeAssert transactions, and this connector\n * generates the spending scripts using WOTS public keys from the VP.\n *\n * @param params - ChallengeAssert connector parameters\n * @returns Script and control block (hex encoded)\n */\nexport async function getChallengeAssertScriptInfo(\n params: ChallengeAssertConnectorParams,\n): Promise<ChallengeAssertScriptInfo> {\n return (await loadTbvWasm()).getChallengeAssertScriptInfo(params);\n}\n\n/**\n * Derive 32-byte `authAnchor` (OP_RETURN preimage → VP bearer token).\n * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.\n */\n/**\n * Derive 32-byte `authAnchor` (OP_RETURN preimage → VP bearer token).\n * @stability frozen — owned by btc-vault Rust via the vault-wasm pin (`VAULT_WASM_COMMIT`); rotation breaks VP auth for existing deposits.\n */\nexport async function expandAuthAnchor(root: Uint8Array): Promise<Uint8Array> {\n return (await loadTbvWasm()).expandAuthAnchor(root);\n}\n\n/**\n * Derive 32-byte `hashlockSecret` for HTLC `htlcVout` (preimage → `activateVaultWithSecret`).\n * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.\n */\n/**\n * Derive 32-byte `hashlockSecret` for HTLC `htlcVout` (preimage → `activateVaultWithSecret`).\n * @stability frozen — owned by btc-vault Rust; rotation means affected vaults can never activate.\n */\nexport async function expandHashlockSecret(\n root: Uint8Array,\n htlcVout: number,\n): Promise<Uint8Array> {\n return (await loadTbvWasm()).expandHashlockSecret(root, htlcVout);\n}\n\n/**\n * Derive 64-byte `wotsSeed` for HTLC `htlcVout` (→ WOTS keys, hashed as `depositorWotsPkHash`).\n * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.\n */\n/**\n * Derive 64-byte `wotsSeed` for HTLC `htlcVout` (→ WOTS keys, hashed as `depositorWotsPkHash`).\n * @stability frozen — owned by btc-vault Rust; rotation breaks existing `depositorWotsPkHash` → no claim path.\n */\nexport async function expandWotsSeed(\n root: Uint8Array,\n htlcVout: number,\n): Promise<Uint8Array> {\n return (await loadTbvWasm()).expandWotsSeed(root, htlcVout);\n}\n\n/**\n * Derives the vault ID from a PegIn transaction hash and depositor ETH address.\n *\n * Vault ID = keccak256(abi.encode(peginTxHash, depositor))\n * This matches the Solidity-side derivation in BTCVaultRegistry.\n *\n * @param peginTxHash - 32-byte PegIn tx hash in display order (big-endian), hex encoded\n * @param depositor - 20-byte Ethereum address of the depositor, hex encoded\n * @returns Hex-encoded vault ID (32 bytes)\n */\nexport async function deriveVaultId(\n peginTxHash: string,\n depositor: string,\n): Promise<string> {\n return (await loadTbvWasm()).deriveVaultId(peginTxHash, depositor);\n}\n\nexport type {\n AssertNoPayoutScriptInfo,\n AssertPayoutNoPayoutConnectorParams,\n AssertPayoutScriptInfo,\n ChallengeAssertConnectorParams,\n ChallengeAssertScriptInfo,\n HtlcConnectorInfo,\n HtlcConnectorParams,\n Network,\n PayoutConnectorInfo,\n PayoutConnectorParams,\n PeginP2aAnchorInfo,\n PeginTxResult,\n PrePeginParams,\n PrePeginResult,\n};\n"],"names":["TAP_INTERNAL_KEY","HEX_CHARS_PER_BYTE","tapInternalPubkey","_","index","wasmModulePromise","rawWasmModulePromise","loadTbvWasm","error","loadRawTbvWasm","wasm","createPrePeginTransaction","params","buildPeginTxFromPrePegin","timelockPegin","fundedPrePeginTxHex","htlcVout","getPrePeginHtlcConnectorInfo","computeMinClaimValue","txGraphVersion","numLocalChallengers","numUniversalChallengers","councilQuorum","councilSize","feeRate","computeMinPeginFee","numVks","numUcs","minPeginFeeRate","computePayoutFeeFloor","numVaultKeepers","out0Len","out1Len","supportedTxGraphVersions","peginP2aAnchorOutput","validatePeginP2aAnchor","txHex","createPayoutConnector","network","getAssertPayoutScriptInfo","getAssertNoPayoutScriptInfo","challengerPubkey","getChallengeAssertScriptInfo","expandAuthAnchor","root","expandHashlockSecret","expandWotsSeed","deriveVaultId","peginTxHash","depositor"],"mappings":"2hBAQO,MAAMA,EACX,mEAEIC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allengeAssertConnectorParams, ChallengeAssertScriptInfo, HtlcConnectorInfo, HtlcConnectorParams, Network, PayoutConnectorInfo, PayoutConnectorParams, PeginP2aAnchorInfo, PeginTxResult, PrePeginParams, PrePeginResult } from '@babylonlabs-io/babylon-tbv-rust-wasm';
2
+ export { TAP_INTERNAL_KEY, tapInternalPubkey } from './constants';
3
+ type TbvWasmModule = typeof import("@babylonlabs-io/babylon-tbv-rust-wasm");
4
+ type RawTbvWasmModule = typeof import("@babylonlabs-io/babylon-tbv-rust-wasm/raw");
5
+ /** Load the WASM engine on first use and share the in-flight import. */
6
+ export declare function loadTbvWasm(): Promise<TbvWasmModule>;
7
+ /**
8
+ * Load the explicit raw-class entry for the one SDK primitive that must
9
+ * reconstruct a stateful WASM transaction object (refund construction).
10
+ */
11
+ export declare function loadRawTbvWasm(): Promise<RawTbvWasmModule>;
12
+ /**
13
+ * Creates an unfunded Pre-PegIn transaction with no inputs and HTLC output(s).
14
+ *
15
+ * The HTLC output value (htlcValue) covers the peg-in amount, depositor claim value,
16
+ * and minimum pegin fee — all computed internally from the provided contract parameters.
17
+ *
18
+ * After building the Pre-PegIn transaction, the caller must:
19
+ * 1. Select UTXOs covering htlcValue + network fees
20
+ * 2. Fund the transaction (add inputs and change output)
21
+ * 3. Call reconstructFromFundedTx() with the funded tx hex
22
+ * 4. Call buildPeginTx() to derive the PegIn transaction
23
+ * 5. Sign the PegIn input using the HTLC hashlock leaf (leaf 0)
24
+ *
25
+ * @param params - Pre-PegIn parameters from contract and depositor wallet
26
+ * @returns Unfunded transaction details with HTLC output information
27
+ */
28
+ export declare function createPrePeginTransaction(params: PrePeginParams): Promise<PrePeginResult>;
29
+ /**
30
+ * Derives the PegIn transaction from a funded Pre-PegIn transaction.
31
+ *
32
+ * The PegIn transaction has a single input spending the Pre-PegIn HTLC output
33
+ * at `htlcVout` via the hashlock + all-party script (leaf 0).
34
+ *
35
+ * @param params - Same PrePeginParams used to create the Pre-PegIn transaction
36
+ * @param timelockPegin - CSV timelock in blocks for the PegIn vault output
37
+ * @param fundedPrePeginTxHex - Hex-encoded funded Pre-PegIn transaction
38
+ * @param htlcVout - Index of the HTLC output to spend
39
+ * @returns PegIn transaction details including vault output information
40
+ */
41
+ export declare function buildPeginTxFromPrePegin(params: PrePeginParams, timelockPegin: number, fundedPrePeginTxHex: string, htlcVout: number): Promise<PeginTxResult>;
42
+ /**
43
+ * Returns HTLC connector script info for signing the PegIn transaction input.
44
+ *
45
+ * The depositor signs PegIn input 0 using the hashlock leaf (leaf 0) of the
46
+ * Pre-PegIn HTLC output. Use getHashlockScript() and getHashlockControlBlock()
47
+ * to construct the tapLeafScript entry in the PSBT.
48
+ *
49
+ * @param params - HTLC connector parameters (subset of PrePeginParams)
50
+ * @returns Hashlock and refund script info for PSBT construction
51
+ */
52
+ export declare function getPrePeginHtlcConnectorInfo(params: HtlcConnectorParams): Promise<HtlcConnectorInfo>;
53
+ /**
54
+ * Compute the minimum depositor claim value (PegIn output 1) in satoshis.
55
+ *
56
+ * This covers the full downstream tx graph cost (Claim → Assert → Payout)
57
+ * based on the protocol parameters.
58
+ */
59
+ export declare function computeMinClaimValue(txGraphVersion: number, numLocalChallengers: number, numUniversalChallengers: number, councilQuorum: number, councilSize: number, feeRate: bigint): Promise<bigint>;
60
+ /**
61
+ * Compute the minimum PegIn (activation) transaction fee in satoshis.
62
+ *
63
+ * `minPeginFee = peginTxVsize(numVks, numUcs) × minPeginFeeRate`. Each HTLC
64
+ * the depositor funds in the Pre-PegIn tx must reserve at least this fee
65
+ * inside its value (`htlcValue = peginAmount + depositorClaimValue +
66
+ * minPeginFee`), otherwise the VP cannot afford to broadcast the PegIn at
67
+ * activation. The vsize comes from a Taproot script-path-spend weight
68
+ * prediction whose witness shape depends on the VK + UC signer count.
69
+ */
70
+ export declare function computeMinPeginFee(txGraphVersion: number, numVks: number, numUcs: number, minPeginFeeRate: bigint): Promise<bigint>;
71
+ /**
72
+ * Floor of the Payout transaction fee under `txGraphVersion`: the minimum of
73
+ * `estimatedVsize * feeRate` across every output-sizing model a deployed
74
+ * vault provider is known to have used (fixed-34, intermediate,
75
+ * script-aware). A VP-built payout paying less than this is provably not
76
+ * produced by any known VP build. `out0Len` must be the TRUSTED length of the
77
+ * pinned outs[0] script (1..=128); `out1Len` is the measured, UNTRUSTED
78
+ * commission-script length — safe here because padding cannot raise the floor
79
+ * (the fixed-34 model saturates the minimum) and shortening only lowers it.
80
+ * Pass `undefined` for `out1Len` on 2-output (non-VP-claimer) payouts.
81
+ * `feeRate` is the vault's version-locked `offchainParams.feeRate`.
82
+ */
83
+ export declare function computePayoutFeeFloor(txGraphVersion: number, numVaultKeepers: number, numUniversalChallengers: number, numLocalChallengers: number, councilSize: number, out0Len: number, out1Len: number | null | undefined, feeRate: bigint): Promise<bigint>;
84
+ /**
85
+ * Tx graph versions the shipped vault-wasm binary can build. Callers must
86
+ * preflight the required version (fresh: active; resume: stamped) against
87
+ * this list and fail closed instead of hitting per-call errors mid-flow.
88
+ *
89
+ * Note: the facade constructors themselves fail closed on unsupported
90
+ * versions, and derived objects carry the version they were built with —
91
+ * value-level cross-checks live in `assertWasmPeginSizing` and the golden
92
+ * byte-parity tests, not in a per-call version echo.
93
+ */
94
+ export declare function supportedTxGraphVersions(): Promise<number[]>;
95
+ /**
96
+ * The PegIn transaction's P2A (pay-to-anchor) output for a graph version, or
97
+ * `null` when that version's PegIn carries no anchor (v1). The facade returns
98
+ * one record per version — never a zero-valued placeholder — so an absent
99
+ * anchor can't be mistaken for a real output. For v2/v3: 240 sats at vout 2,
100
+ * script `51024e73`.
101
+ */
102
+ export declare function peginP2aAnchorOutput(txGraphVersion: number): Promise<PeginP2aAnchorInfo | null>;
103
+ /**
104
+ * Validate a PegIn transaction's P2A anchor against a graph version's rules:
105
+ * v2 and v3 require the exact anchor (240 sats, vout 2, P2A script) and v1
106
+ * requires that NO output carries the P2A script. Throws on any mismatch — a
107
+ * v2 PegIn checked as v1 fails closed, and vice versa.
108
+ */
109
+ export declare function validatePeginP2aAnchor(txGraphVersion: number, txHex: string): Promise<void>;
110
+ /**
111
+ * Creates a payout connector for vault transactions.
112
+ *
113
+ * The payout connector generates the necessary taproot scripts and information
114
+ * required for signing payout transactions (both optimistic and regular payout paths).
115
+ *
116
+ * @param params - Parameters for creating the payout connector
117
+ * @param network - Bitcoin network
118
+ * @returns Payout connector information including scripts, hashes, and address
119
+ */
120
+ export declare function createPayoutConnector(params: PayoutConnectorParams, network: Network): Promise<PayoutConnectorInfo>;
121
+ /**
122
+ * Get the Payout script and control block for the depositor's Assert output.
123
+ *
124
+ * Used to build the depositor's Payout PSBT (depositor-as-claimer path).
125
+ *
126
+ * @param params - Assert Payout/NoPayout connector parameters
127
+ * @returns Payout script and control block (hex encoded)
128
+ */
129
+ export declare function getAssertPayoutScriptInfo(params: AssertPayoutNoPayoutConnectorParams): Promise<AssertPayoutScriptInfo>;
130
+ /**
131
+ * Get the NoPayout script and control block for a specific challenger.
132
+ *
133
+ * Used to build the depositor's NoPayout PSBT (depositor-as-claimer path).
134
+ * Each challenger has a distinct NoPayout script.
135
+ *
136
+ * @param params - Assert Payout/NoPayout connector parameters
137
+ * @param challengerPubkey - The challenger's x-only public key (hex encoded)
138
+ * @returns NoPayout script and control block (hex encoded)
139
+ */
140
+ export declare function getAssertNoPayoutScriptInfo(params: AssertPayoutNoPayoutConnectorParams, challengerPubkey: string): Promise<AssertNoPayoutScriptInfo>;
141
+ /**
142
+ * Get the ChallengeAssert script and control block.
143
+ *
144
+ * Used to build ChallengeAssert PSBTs for the depositor-as-claimer path.
145
+ * Each challenger has 3 ChallengeAssert transactions, and this connector
146
+ * generates the spending scripts using WOTS public keys from the VP.
147
+ *
148
+ * @param params - ChallengeAssert connector parameters
149
+ * @returns Script and control block (hex encoded)
150
+ */
151
+ export declare function getChallengeAssertScriptInfo(params: ChallengeAssertConnectorParams): Promise<ChallengeAssertScriptInfo>;
152
+ /**
153
+ * Derive 32-byte `authAnchor` (OP_RETURN preimage → VP bearer token).
154
+ * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.
155
+ */
156
+ /**
157
+ * Derive 32-byte `authAnchor` (OP_RETURN preimage → VP bearer token).
158
+ * @stability frozen — owned by btc-vault Rust via the vault-wasm pin (`VAULT_WASM_COMMIT`); rotation breaks VP auth for existing deposits.
159
+ */
160
+ export declare function expandAuthAnchor(root: Uint8Array): Promise<Uint8Array>;
161
+ /**
162
+ * Derive 32-byte `hashlockSecret` for HTLC `htlcVout` (preimage → `activateVaultWithSecret`).
163
+ * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.
164
+ */
165
+ /**
166
+ * Derive 32-byte `hashlockSecret` for HTLC `htlcVout` (preimage → `activateVaultWithSecret`).
167
+ * @stability frozen — owned by btc-vault Rust; rotation means affected vaults can never activate.
168
+ */
169
+ export declare function expandHashlockSecret(root: Uint8Array, htlcVout: number): Promise<Uint8Array>;
170
+ /**
171
+ * Derive 64-byte `wotsSeed` for HTLC `htlcVout` (→ WOTS keys, hashed as `depositorWotsPkHash`).
172
+ * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.
173
+ */
174
+ /**
175
+ * Derive 64-byte `wotsSeed` for HTLC `htlcVout` (→ WOTS keys, hashed as `depositorWotsPkHash`).
176
+ * @stability frozen — owned by btc-vault Rust; rotation breaks existing `depositorWotsPkHash` → no claim path.
177
+ */
178
+ export declare function expandWotsSeed(root: Uint8Array, htlcVout: number): Promise<Uint8Array>;
179
+ /**
180
+ * Derives the vault ID from a PegIn transaction hash and depositor ETH address.
181
+ *
182
+ * Vault ID = keccak256(abi.encode(peginTxHash, depositor))
183
+ * This matches the Solidity-side derivation in BTCVaultRegistry.
184
+ *
185
+ * @param peginTxHash - 32-byte PegIn tx hash in display order (big-endian), hex encoded
186
+ * @param depositor - 20-byte Ethereum address of the depositor, hex encoded
187
+ * @returns Hex-encoded vault ID (32 bytes)
188
+ */
189
+ export declare function deriveVaultId(peginTxHash: string, depositor: string): Promise<string>;
190
+ export type { AssertNoPayoutScriptInfo, AssertPayoutNoPayoutConnectorParams, AssertPayoutScriptInfo, ChallengeAssertConnectorParams, ChallengeAssertScriptInfo, HtlcConnectorInfo, HtlcConnectorParams, Network, PayoutConnectorInfo, PayoutConnectorParams, PeginP2aAnchorInfo, PeginTxResult, PrePeginParams, PrePeginResult, };
191
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wasm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,mCAAmC,EACnC,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,OAAO,EACP,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,cAAc,EACf,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElE,KAAK,aAAa,GAAG,cAAc,uCAAuC,CAAC,CAAC;AAG5E,KAAK,gBAAgB,GACnB,cAAc,2CAA2C,CAAC,CAAC;AAG7D,wEAAwE;AACxE,wBAAgB,WAAW,IAAI,OAAO,CAAC,aAAa,CAAC,CAcpD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAyB1D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,cAAc,EACtB,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,MAAM,EAC3B,QAAQ,EAAE,MA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+ { length: s.length / 2 },
4
+ (e, t) => Number.parseInt(
5
+ s.slice(
6
+ t * 2,
7
+ t * 2 + 2
8
+ ),
9
+ 16
10
+ )
11
+ );
12
+ let u, o;
13
+ function n() {
14
+ return u ?? (u = import("@babylonlabs-io/babylon-tbv-rust-wasm").catch(
15
+ (e) => {
16
+ throw u = void 0, new Error(
17
+ "The vault-WASM engine @babylonlabs-io/babylon-tbv-rust-wasm failed to load. The module could not be resolved, or it threw while evaluating, commonly a missing or stale generated WASM build. See the cause for the underlying error.",
18
+ { cause: e }
19
+ );
20
+ }
21
+ )), u;
22
+ }
23
+ function P() {
24
+ return o ?? (o = import("@babylonlabs-io/babylon-tbv-rust-wasm/raw").catch((e) => {
25
+ throw o = void 0, new Error(
26
+ "The raw vault-WASM entry @babylonlabs-io/babylon-tbv-rust-wasm/raw failed to load. The module could not be resolved, or it threw while evaluating. See the cause for the underlying error.",
27
+ { cause: e }
28
+ );
29
+ }).then(async (e) => {
30
+ try {
31
+ await e.initWasm();
32
+ } catch (t) {
33
+ throw o = void 0, new Error(
34
+ "The raw vault-WASM entry resolved but its WebAssembly binary failed to initialize.",
35
+ { cause: t }
36
+ );
37
+ }
38
+ return e;
39
+ })), o;
40
+ }
41
+ async function h(e) {
42
+ return (await n()).createPrePeginTransaction(e);
43
+ }
44
+ async function f(e, t, a, r) {
45
+ return (await n()).buildPeginTxFromPrePegin(
46
+ e,
47
+ t,
48
+ a,
49
+ r
50
+ );
51
+ }
52
+ async function w(e) {
53
+ return (await n()).getPrePeginHtlcConnectorInfo(e);
54
+ }
55
+ async function g(e, t, a, r, i, c) {
56
+ return (await n()).computeMinClaimValue(
57
+ e,
58
+ t,
59
+ a,
60
+ r,
61
+ i,
62
+ c
63
+ );
64
+ }
65
+ async function p(e, t, a, r) {
66
+ return (await n()).computeMinPeginFee(
67
+ e,
68
+ t,
69
+ a,
70
+ r
71
+ );
72
+ }
73
+ async function b(e, t, a, r, i, c, l, d) {
74
+ return (await n()).computePayoutFeeFloor(
75
+ e,
76
+ t,
77
+ a,
78
+ r,
79
+ i,
80
+ c,
81
+ l,
82
+ d
83
+ );
84
+ }
85
+ async function m() {
86
+ return (await n()).supportedTxGraphVersions();
87
+ }
88
+ async function A(e) {
89
+ return (await n()).peginP2aAnchorOutput(e);
90
+ }
91
+ async function S(e, t) {
92
+ return (await n()).validatePeginP2aAnchor(e, t);
93
+ }
94
+ async function E(e, t) {
95
+ return (await n()).createPayoutConnector(e, t);
96
+ }
97
+ async function T(e) {
98
+ return (await n()).getAssertPayoutScriptInfo(e);
99
+ }
100
+ async function v(e, t) {
101
+ return (await n()).getAssertNoPayoutScriptInfo(
102
+ e,
103
+ t
104
+ );
105
+ }
106
+ async function _(e) {
107
+ return (await n()).getChallengeAssertScriptInfo(e);
108
+ }
109
+ async function H(e) {
110
+ return (await n()).expandAuthAnchor(e);
111
+ }
112
+ async function C(e, t) {
113
+ return (await n()).expandHashlockSecret(e, t);
114
+ }
115
+ async function I(e, t) {
116
+ return (await n()).expandWotsSeed(e, t);
117
+ }
118
+ async function R(e, t) {
119
+ return (await n()).deriveVaultId(e, t);
120
+ }
121
+ export {
122
+ s as TAP_INTERNAL_KEY,
123
+ f as buildPeginTxFromPrePegin,
124
+ g as computeMinClaimValue,
125
+ p as computeMinPeginFee,
126
+ b as computePayoutFeeFloor,
127
+ E as createPayoutConnector,
128
+ h as createPrePeginTransaction,
129
+ R as deriveVaultId,
130
+ H as expandAuthAnchor,
131
+ C as expandHashlockSecret,
132
+ I as expandWotsSeed,
133
+ v as getAssertNoPayoutScriptInfo,
134
+ T as getAssertPayoutScriptInfo,
135
+ _ as getChallengeAssertScriptInfo,
136
+ w as getPrePeginHtlcConnectorInfo,
137
+ P as loadRawTbvWasm,
138
+ n as loadTbvWasm,
139
+ A as peginP2aAnchorOutput,
140
+ m as supportedTxGraphVersions,
141
+ y as tapInternalPubkey,
142
+ S as validatePeginP2aAnchor
143
+ };
144
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/tbv/core/wasm/constants.ts","../../../../src/tbv/core/wasm/index.ts"],"sourcesContent":["/**\n * Protocol constants that do not require loading the vault WASM module.\n *\n * Keeping these values local lets Bitcoin builders construct PSBT metadata\n * without resolving or evaluating the WASM engine at module-import\n * time. The hex value is the BIP-341 nothing-up-my-sleeve internal key and is\n * pinned by the vault protocol.\n */\nexport const TAP_INTERNAL_KEY =\n \"50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0\";\n\nconst HEX_CHARS_PER_BYTE = 2;\n\nexport const tapInternalPubkey = Uint8Array.from(\n { length: TAP_INTERNAL_KEY.length / HEX_CHARS_PER_BYTE },\n (_, index) =>\n Number.parseInt(\n TAP_INTERNAL_KEY.slice(\n index * HEX_CHARS_PER_BYTE,\n index * HEX_CHARS_PER_BYTE + HEX_CHARS_PER_BYTE,\n ),\n 16,\n ),\n);\n","/**\n * Explicit lazy boundary around the vault-WASM engine package.\n *\n * Importing the SDK (including its legacy root barrels) does not resolve the\n * WASM package or generated binary. The engine is loaded only when a caller\n * invokes an operation that actually needs the Bitcoin transaction graph.\n * ETH-only entry points never import this module.\n *\n * @module tbv/core/wasm\n */\n\nimport type {\n AssertNoPayoutScriptInfo,\n AssertPayoutNoPayoutConnectorParams,\n AssertPayoutScriptInfo,\n ChallengeAssertConnectorParams,\n ChallengeAssertScriptInfo,\n HtlcConnectorInfo,\n HtlcConnectorParams,\n Network,\n PayoutConnectorInfo,\n PayoutConnectorParams,\n PeginP2aAnchorInfo,\n PeginTxResult,\n PrePeginParams,\n PrePeginResult,\n} from \"@babylonlabs-io/babylon-tbv-rust-wasm\";\n\nexport { TAP_INTERNAL_KEY, tapInternalPubkey } from \"./constants\";\n\ntype TbvWasmModule = typeof import(\"@babylonlabs-io/babylon-tbv-rust-wasm\");\n\nlet wasmModulePromise: Promise<TbvWasmModule> | undefined;\ntype RawTbvWasmModule =\n typeof import(\"@babylonlabs-io/babylon-tbv-rust-wasm/raw\");\nlet rawWasmModulePromise: Promise<RawTbvWasmModule> | undefined;\n\n/** Load the WASM engine on first use and share the in-flight import. */\nexport function loadTbvWasm(): Promise<TbvWasmModule> {\n wasmModulePromise ??= import(\"@babylonlabs-io/babylon-tbv-rust-wasm\").catch(\n (error: unknown) => {\n wasmModulePromise = undefined;\n throw new Error(\n \"The vault-WASM engine @babylonlabs-io/babylon-tbv-rust-wasm failed \" +\n \"to load. The module could not be resolved, or it threw while \" +\n \"evaluating, commonly a missing or stale generated WASM build. \" +\n \"See the cause for the underlying error.\",\n { cause: error },\n );\n },\n );\n return wasmModulePromise;\n}\n\n/**\n * Load the explicit raw-class entry for the one SDK primitive that must\n * reconstruct a stateful WASM transaction object (refund construction).\n */\nexport function loadRawTbvWasm(): Promise<RawTbvWasmModule> {\n rawWasmModulePromise ??= import(\"@babylonlabs-io/babylon-tbv-rust-wasm/raw\")\n .catch((error: unknown) => {\n rawWasmModulePromise = undefined;\n throw new Error(\n \"The raw vault-WASM entry @babylonlabs-io/babylon-tbv-rust-wasm/raw \" +\n \"failed to load. The module could not be resolved, or it threw \" +\n \"while evaluating. See the cause for the underlying error.\",\n { cause: error },\n );\n })\n .then(async (wasm) => {\n try {\n await wasm.initWasm();\n } catch (error: unknown) {\n rawWasmModulePromise = undefined;\n throw new Error(\n \"The raw vault-WASM entry resolved but its WebAssembly \" +\n \"binary failed to initialize.\",\n { cause: error },\n );\n }\n return wasm;\n });\n return rawWasmModulePromise;\n}\n\n/**\n * Creates an unfunded Pre-PegIn transaction with no inputs and HTLC output(s).\n *\n * The HTLC output value (htlcValue) covers the peg-in amount, depositor claim value,\n * and minimum pegin fee — all computed internally from the provided contract parameters.\n *\n * After building the Pre-PegIn transaction, the caller must:\n * 1. Select UTXOs covering htlcValue + network fees\n * 2. Fund the transaction (add inputs and change output)\n * 3. Call reconstructFromFundedTx() with the funded tx hex\n * 4. Call buildPeginTx() to derive the PegIn transaction\n * 5. Sign the PegIn input using the HTLC hashlock leaf (leaf 0)\n *\n * @param params - Pre-PegIn parameters from contract and depositor wallet\n * @returns Unfunded transaction details with HTLC output information\n */\nexport async function createPrePeginTransaction(\n params: PrePeginParams,\n): Promise<PrePeginResult> {\n return (await loadTbvWasm()).createPrePeginTransaction(params);\n}\n\n/**\n * Derives the PegIn transaction from a funded Pre-PegIn transaction.\n *\n * The PegIn transaction has a single input spending the Pre-PegIn HTLC output\n * at `htlcVout` via the hashlock + all-party script (leaf 0).\n *\n * @param params - Same PrePeginParams used to create the Pre-PegIn transaction\n * @param timelockPegin - CSV timelock in blocks for the PegIn vault output\n * @param fundedPrePeginTxHex - Hex-encoded funded Pre-PegIn transaction\n * @param htlcVout - Index of the HTLC output to spend\n * @returns PegIn transaction details including vault output information\n */\nexport async function buildPeginTxFromPrePegin(\n params: PrePeginParams,\n timelockPegin: number,\n fundedPrePeginTxHex: string,\n htlcVout: number,\n): Promise<PeginTxResult> {\n return (await loadTbvWasm()).buildPeginTxFromPrePegin(\n params,\n timelockPegin,\n fundedPrePeginTxHex,\n htlcVout,\n );\n}\n\n/**\n * Returns HTLC connector script info for signing the PegIn transaction input.\n *\n * The depositor signs PegIn input 0 using the hashlock leaf (leaf 0) of the\n * Pre-PegIn HTLC output. Use getHashlockScript() and getHashlockControlBlock()\n * to construct the tapLeafScript entry in the PSBT.\n *\n * @param params - HTLC connector parameters (subset of PrePeginParams)\n * @returns Hashlock and refund script info for PSBT construction\n */\nexport async function getPrePeginHtlcConnectorInfo(\n params: HtlcConnectorParams,\n): Promise<HtlcConnectorInfo> {\n return (await loadTbvWasm()).getPrePeginHtlcConnectorInfo(params);\n}\n\n/**\n * Compute the minimum depositor claim value (PegIn output 1) in satoshis.\n *\n * This covers the full downstream tx graph cost (Claim → Assert → Payout)\n * based on the protocol parameters.\n */\nexport async function computeMinClaimValue(\n txGraphVersion: number,\n numLocalChallengers: number,\n numUniversalChallengers: number,\n councilQuorum: number,\n councilSize: number,\n feeRate: bigint,\n): Promise<bigint> {\n return (await loadTbvWasm()).computeMinClaimValue(\n txGraphVersion,\n numLocalChallengers,\n numUniversalChallengers,\n councilQuorum,\n councilSize,\n feeRate,\n );\n}\n\n/**\n * Compute the minimum PegIn (activation) transaction fee in satoshis.\n *\n * `minPeginFee = peginTxVsize(numVks, numUcs) × minPeginFeeRate`. Each HTLC\n * the depositor funds in the Pre-PegIn tx must reserve at least this fee\n * inside its value (`htlcValue = peginAmount + depositorClaimValue +\n * minPeginFee`), otherwise the VP cannot afford to broadcast the PegIn at\n * activation. The vsize comes from a Taproot script-path-spend weight\n * prediction whose witness shape depends on the VK + UC signer count.\n */\nexport async function computeMinPeginFee(\n txGraphVersion: number,\n numVks: number,\n numUcs: number,\n minPeginFeeRate: bigint,\n): Promise<bigint> {\n return (await loadTbvWasm()).computeMinPeginFee(\n txGraphVersion,\n numVks,\n numUcs,\n minPeginFeeRate,\n );\n}\n\n/**\n * Floor of the Payout transaction fee under `txGraphVersion`: the minimum of\n * `estimatedVsize * feeRate` across every output-sizing model a deployed\n * vault provider is known to have used (fixed-34, intermediate,\n * script-aware). A VP-built payout paying less than this is provably not\n * produced by any known VP build. `out0Len` must be the TRUSTED length of the\n * pinned outs[0] script (1..=128); `out1Len` is the measured, UNTRUSTED\n * commission-script length — safe here because padding cannot raise the floor\n * (the fixed-34 model saturates the minimum) and shortening only lowers it.\n * Pass `undefined` for `out1Len` on 2-output (non-VP-claimer) payouts.\n * `feeRate` is the vault's version-locked `offchainParams.feeRate`.\n */\nexport async function computePayoutFeeFloor(\n txGraphVersion: number,\n numVaultKeepers: number,\n numUniversalChallengers: number,\n numLocalChallengers: number,\n councilSize: number,\n out0Len: number,\n out1Len: number | null | undefined,\n feeRate: bigint,\n): Promise<bigint> {\n return (await loadTbvWasm()).computePayoutFeeFloor(\n txGraphVersion,\n numVaultKeepers,\n numUniversalChallengers,\n numLocalChallengers,\n councilSize,\n out0Len,\n out1Len,\n feeRate,\n );\n}\n\n/**\n * Tx graph versions the shipped vault-wasm binary can build. Callers must\n * preflight the required version (fresh: active; resume: stamped) against\n * this list and fail closed instead of hitting per-call errors mid-flow.\n *\n * Note: the facade constructors themselves fail closed on unsupported\n * versions, and derived objects carry the version they were built with —\n * value-level cross-checks live in `assertWasmPeginSizing` and the golden\n * byte-parity tests, not in a per-call version echo.\n */\nexport async function supportedTxGraphVersions(): Promise<number[]> {\n return (await loadTbvWasm()).supportedTxGraphVersions();\n}\n\n/**\n * The PegIn transaction's P2A (pay-to-anchor) output for a graph version, or\n * `null` when that version's PegIn carries no anchor (v1). The facade returns\n * one record per version — never a zero-valued placeholder — so an absent\n * anchor can't be mistaken for a real output. For v2/v3: 240 sats at vout 2,\n * script `51024e73`.\n */\nexport async function peginP2aAnchorOutput(\n txGraphVersion: number,\n): Promise<PeginP2aAnchorInfo | null> {\n return (await loadTbvWasm()).peginP2aAnchorOutput(txGraphVersion);\n}\n\n/**\n * Validate a PegIn transaction's P2A anchor against a graph version's rules:\n * v2 and v3 require the exact anchor (240 sats, vout 2, P2A script) and v1\n * requires that NO output carries the P2A script. Throws on any mismatch — a\n * v2 PegIn checked as v1 fails closed, and vice versa.\n */\nexport async function validatePeginP2aAnchor(\n txGraphVersion: number,\n txHex: string,\n): Promise<void> {\n return (await loadTbvWasm()).validatePeginP2aAnchor(txGraphVersion, txHex);\n}\n\n/**\n * Creates a payout connector for vault transactions.\n *\n * The payout connector generates the necessary taproot scripts and information\n * required for signing payout transactions (both optimistic and regular payout paths).\n *\n * @param params - Parameters for creating the payout connector\n * @param network - Bitcoin network\n * @returns Payout connector information including scripts, hashes, and address\n */\nexport async function createPayoutConnector(\n params: PayoutConnectorParams,\n network: Network,\n): Promise<PayoutConnectorInfo> {\n return (await loadTbvWasm()).createPayoutConnector(params, network);\n}\n\n/**\n * Get the Payout script and control block for the depositor's Assert output.\n *\n * Used to build the depositor's Payout PSBT (depositor-as-claimer path).\n *\n * @param params - Assert Payout/NoPayout connector parameters\n * @returns Payout script and control block (hex encoded)\n */\nexport async function getAssertPayoutScriptInfo(\n params: AssertPayoutNoPayoutConnectorParams,\n): Promise<AssertPayoutScriptInfo> {\n return (await loadTbvWasm()).getAssertPayoutScriptInfo(params);\n}\n\n/**\n * Get the NoPayout script and control block for a specific challenger.\n *\n * Used to build the depositor's NoPayout PSBT (depositor-as-claimer path).\n * Each challenger has a distinct NoPayout script.\n *\n * @param params - Assert Payout/NoPayout connector parameters\n * @param challengerPubkey - The challenger's x-only public key (hex encoded)\n * @returns NoPayout script and control block (hex encoded)\n */\nexport async function getAssertNoPayoutScriptInfo(\n params: AssertPayoutNoPayoutConnectorParams,\n challengerPubkey: string,\n): Promise<AssertNoPayoutScriptInfo> {\n return (await loadTbvWasm()).getAssertNoPayoutScriptInfo(\n params,\n challengerPubkey,\n );\n}\n\n/**\n * Get the ChallengeAssert script and control block.\n *\n * Used to build ChallengeAssert PSBTs for the depositor-as-claimer path.\n * Each challenger has 3 ChallengeAssert transactions, and this connector\n * generates the spending scripts using WOTS public keys from the VP.\n *\n * @param params - ChallengeAssert connector parameters\n * @returns Script and control block (hex encoded)\n */\nexport async function getChallengeAssertScriptInfo(\n params: ChallengeAssertConnectorParams,\n): Promise<ChallengeAssertScriptInfo> {\n return (await loadTbvWasm()).getChallengeAssertScriptInfo(params);\n}\n\n/**\n * Derive 32-byte `authAnchor` (OP_RETURN preimage → VP bearer token).\n * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.\n */\n/**\n * Derive 32-byte `authAnchor` (OP_RETURN preimage → VP bearer token).\n * @stability frozen — owned by btc-vault Rust via the vault-wasm pin (`VAULT_WASM_COMMIT`); rotation breaks VP auth for existing deposits.\n */\nexport async function expandAuthAnchor(root: Uint8Array): Promise<Uint8Array> {\n return (await loadTbvWasm()).expandAuthAnchor(root);\n}\n\n/**\n * Derive 32-byte `hashlockSecret` for HTLC `htlcVout` (preimage → `activateVaultWithSecret`).\n * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.\n */\n/**\n * Derive 32-byte `hashlockSecret` for HTLC `htlcVout` (preimage → `activateVaultWithSecret`).\n * @stability frozen — owned by btc-vault Rust; rotation means affected vaults can never activate.\n */\nexport async function expandHashlockSecret(\n root: Uint8Array,\n htlcVout: number,\n): Promise<Uint8Array> {\n return (await loadTbvWasm()).expandHashlockSecret(root, htlcVout);\n}\n\n/**\n * Derive 64-byte `wotsSeed` for HTLC `htlcVout` (→ WOTS keys, hashed as `depositorWotsPkHash`).\n * @stability frozen — forwards the frozen expander in `@babylonlabs-io/babylon-tbv-rust-wasm`; see CLAUDE.md §4.\n */\n/**\n * Derive 64-byte `wotsSeed` for HTLC `htlcVout` (→ WOTS keys, hashed as `depositorWotsPkHash`).\n * @stability frozen — owned by btc-vault Rust; rotation breaks existing `depositorWotsPkHash` → no claim path.\n */\nexport async function expandWotsSeed(\n root: Uint8Array,\n htlcVout: number,\n): Promise<Uint8Array> {\n return (await loadTbvWasm()).expandWotsSeed(root, htlcVout);\n}\n\n/**\n * Derives the vault ID from a PegIn transaction hash and depositor ETH address.\n *\n * Vault ID = keccak256(abi.encode(peginTxHash, depositor))\n * This matches the Solidity-side derivation in BTCVaultRegistry.\n *\n * @param peginTxHash - 32-byte PegIn tx hash in display order (big-endian), hex encoded\n * @param depositor - 20-byte Ethereum address of the depositor, hex encoded\n * @returns Hex-encoded vault ID (32 bytes)\n */\nexport async function deriveVaultId(\n peginTxHash: string,\n depositor: string,\n): Promise<string> {\n return (await loadTbvWasm()).deriveVaultId(peginTxHash, depositor);\n}\n\nexport type {\n AssertNoPayoutScriptInfo,\n AssertPayoutNoPayoutConnectorParams,\n AssertPayoutScriptInfo,\n ChallengeAssertConnectorParams,\n ChallengeAssertScriptInfo,\n HtlcConnectorInfo,\n HtlcConnectorParams,\n Network,\n PayoutConnectorInfo,\n PayoutConnectorParams,\n PeginP2aAnchorInfo,\n PeginTxResult,\n PrePeginParams,\n PrePeginResult,\n};\n"],"names":["TAP_INTERNAL_KEY","tapInternalPubkey","_","index","wasmModulePromise","rawWasmModulePromise","loadTbvWasm","error","loadRawTbvWasm","wasm","createPrePeginTransaction","params","buildPeginTxFromPrePegin","timelockPegin","fundedPrePeginTxHex","htlcVout","getPrePeginHtlcConnectorInfo","computeMinClaimValue","txGraphVersion","numLocalChallengers","numUniversalChallengers","councilQuorum","councilSize","feeRate","computeMinPeginFee","numVks","numUcs","minPeginFeeRate","computePayoutFeeFloor","numVaultKeepers","out0Len","out1Len","supportedTxGraphVersions","peginP2aAnchorOutput","validatePeginP2aAnchor","txHex","createPayoutConnector","network","getAssertPayoutScriptInfo","getAssertNoPayoutScriptInfo","challengerPubkey","getChallengeAssertScriptInfo","expandAuthAnchor","root","expandHashlockSecret","expandWotsSeed","deriveVaultId","peginTxHash","depositor"],"mappings":"AAQO,MAAMA,IACX;AAIK,MAAMC,IAAoB,WAAW;AAAA,EAC1C,EAAE,QAAQD,EAAiB,SAAS,EAAA;AAAA,EACpC,CAACE,GAAGC,MACF,OAAO;AAAA,IACLH,EAAiB;AAAA,MACfG,IAAQ;AAAA,MACRA,IAAQ,IAAqB;AAAA,IAAA;AAAA,IAE/B;AAAA,EAAA;AAEN;ACSA,IAAIC,GAGAC;AAGG,SAASC,IAAsC;AACpD,SAAAF,UAAsB,OAAO,uCAAuC,EAAE;AAAA,IACpE,CAACG,MAAmB;AAClB,YAAAH,IAAoB,QACd,IAAI;AAAA,QACR;AAAA,QAIA,EAAE,OAAOG,EAAA;AAAA,MAAM;AAAA,IAEnB;AAAA,EAAA,IAEKH;AACT;AAMO,SAASI,IAA4C;AAC1D,SAAAH,UAAyB,OAAO,2CAA2C,EACxE,MAAM,CAACE,MAAmB;AACzB,UAAAF,IAAuB,QACjB,IAAI;AAAA,MACR;AAAA,MAGA,EAAE,OAAOE,EAAA;AAAA,IAAM;AAAA,EAEnB,CAAC,EACA,KAAK,OAAOE,MAAS;AACpB,QAAI;AACF,YAAMA,EAAK,SAAA;AAAA,IACb,SAASF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;AAYA,eAAsBC,EACpBzB,GACA0B,GAC8B;AAC9B,UAAQ,MAAM/B,EAAA,GAAe,sBAAsBK,GAAQ0B,CAAO;AACpE;AAUA,eAAsBC,EACpB3B,GACiC;AACjC,UAAQ,MAAML,KAAe,0BAA0BK,CAAM;AAC/D;AAYA,eAAsB4B,EACpB5B,GACA6B,GACmC;AACnC,UAAQ,MAAMlC,KAAe;AAAA,IAC3BK;AAAA,IACA6B;AAAA,EAAA;AAEJ;AAYA,eAAsBC,EACpB9B,GACoC;AACpC,UAAQ,MAAML,KAAe,6BAA6BK,CAAM;AAClE;AAUA,eAAsB+B,EAAiBC,GAAuC;AAC5E,UAAQ,MAAMrC,KAAe,iBAAiBqC,CAAI;AACpD;AAUA,eAAsBC,EACpBD,GACA5B,GACqB;AACrB,UAAQ,MAAMT,EAAA,GAAe,qBAAqBqC,GAAM5B,CAAQ;AAClE;AAUA,eAAsB8B,EACpBF,GACA5B,GACqB;AACrB,UAAQ,MAAMT,EAAA,GAAe,eAAeqC,GAAM5B,CAAQ;AAC5D;AAYA,eAAsB+B,EACpBC,GACAC,GACiB;AACjB,UAAQ,MAAM1C,EAAA,GAAe,cAAcyC,GAAaC,CAAS;AACnE;"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Runtime guard for satoshi amounts crossing into the WASM FFI boundary.
3
+ *
4
+ * `new BigUint64Array(values)` is the only way satoshi amounts are handed to
5
+ * the constructor, and a runtime cast (`as readonly bigint[]`) lets a caller
6
+ * pass a non-bigint or non-positive element that `BigUint64Array` would either
7
+ * reject cryptically or, in its length-arg form, silently zero-fill. Values
8
+ * above the u64 maximum are worse still: `BigUint64Array` wraps them mod 2^64
9
+ * without complaint, turning an oversized amount into a small one.
10
+ * {@link assertPositiveBigintArray} validates such inputs before the
11
+ * typed-array construction.
12
+ *
13
+ * Mirrors the `assertPositiveBigintArray` half of `value-guards.ts` in
14
+ * `@babylonlabs-io/babylon-tbv-rust-wasm`; that one function is pinned to the
15
+ * engine's source copy by `__tests__/value-guards.test.ts`. The engine's other
16
+ * guard, `assertWasmBigint`, has no counterpart here: the engine applies it to
17
+ * its own WASM return values before they reach this package.
18
+ */
19
+ /**
20
+ * Assert a value is a non-empty array of strictly-positive `bigint`s and return
21
+ * it narrowed, ready to feed into `new BigUint64Array(...)`.
22
+ *
23
+ * @param values - The candidate array of satoshi amounts.
24
+ * @param label - Human-readable name used in the thrown error.
25
+ * @throws If `values` is not an array, is empty, or contains any element that is
26
+ * not a `bigint`, is not strictly greater than 0, or exceeds the u64 maximum
27
+ * (which `BigUint64Array` would otherwise wrap mod 2^64).
28
+ */
29
+ export declare function assertPositiveBigintArray(values: unknown, label: string): bigint[];
30
+ //# sourceMappingURL=value-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-guards.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/wasm/value-guards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CA2BV"}