@babylonlabs-io/ts-sdk 3.0.2 → 3.1.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 (266) hide show
  1. package/dist/ApplicationRegistry.abi-s8cQ1ooR.js +160 -0
  2. package/dist/ApplicationRegistry.abi-s8cQ1ooR.js.map +1 -0
  3. package/dist/ApplicationRegistry.abi-sMiTWmnL.cjs +2 -0
  4. package/dist/ApplicationRegistry.abi-sMiTWmnL.cjs.map +1 -0
  5. package/dist/{BTCVaultRegistry.abi-BQ5tFNSu.cjs → BTCVaultRegistry.abi-CohlJX7c.cjs} +2 -2
  6. package/dist/{BTCVaultRegistry.abi-BQ5tFNSu.cjs.map → BTCVaultRegistry.abi-CohlJX7c.cjs.map} +1 -1
  7. package/dist/{BTCVaultRegistry.abi-B0x9_Bza.js → BTCVaultRegistry.abi-DBW0dyqH.js} +63 -1
  8. package/dist/{BTCVaultRegistry.abi-B0x9_Bza.js.map → BTCVaultRegistry.abi-DBW0dyqH.js.map} +1 -1
  9. package/dist/{PayoutManager-BSwbUQeF.js → PayoutManager-BZ212yml.js} +124 -123
  10. package/dist/PayoutManager-BZ212yml.js.map +1 -0
  11. package/dist/PayoutManager-DOdsgcUR.cjs +2 -0
  12. package/dist/PayoutManager-DOdsgcUR.cjs.map +1 -0
  13. package/dist/PeginManager-8EUlm10F.cjs +2 -0
  14. package/dist/{PeginManager-IgDHy_eU.cjs.map → PeginManager-8EUlm10F.cjs.map} +1 -1
  15. package/dist/{PeginManager-D8WGB8eN.js → PeginManager-QRwMUxZg.js} +45 -43
  16. package/dist/{PeginManager-D8WGB8eN.js.map → PeginManager-QRwMUxZg.js.map} +1 -1
  17. package/dist/{ProtocolParams.abi-q0AidvYX.js → ProtocolParams.abi-CKOVqFJP.js} +2 -158
  18. package/dist/ProtocolParams.abi-CKOVqFJP.js.map +1 -0
  19. package/dist/ProtocolParams.abi-CjrT0545.cjs +2 -0
  20. package/dist/ProtocolParams.abi-CjrT0545.cjs.map +1 -0
  21. package/dist/btcTxHash-BRZ8_EZq.js +9 -0
  22. package/dist/btcTxHash-BRZ8_EZq.js.map +1 -0
  23. package/dist/btcTxHash-CGb5BqFL.cjs +2 -0
  24. package/dist/btcTxHash-CGb5BqFL.cjs.map +1 -0
  25. package/dist/buildAndBroadcastReclaim-DjX7wVb2.cjs +2 -0
  26. package/dist/buildAndBroadcastReclaim-DjX7wVb2.cjs.map +1 -0
  27. package/dist/buildAndBroadcastReclaim-DoprHX7o.js +3077 -0
  28. package/dist/buildAndBroadcastReclaim-DoprHX7o.js.map +1 -0
  29. package/dist/buildVaultContextInputForClaim-9XZaqIiw.cjs +2 -0
  30. package/dist/buildVaultContextInputForClaim-9XZaqIiw.cjs.map +1 -0
  31. package/dist/buildVaultContextInputForClaim-DhBoQKyN.js +25 -0
  32. package/dist/buildVaultContextInputForClaim-DhBoQKyN.js.map +1 -0
  33. package/dist/constants-BeYquVd-.js +36 -0
  34. package/dist/constants-BeYquVd-.js.map +1 -0
  35. package/dist/constants-BwCg5K6R.cjs +2 -0
  36. package/dist/constants-BwCg5K6R.cjs.map +1 -0
  37. package/dist/{index-D2mybjXD.js → index-CVBtBjQ5.js} +2 -2
  38. package/dist/{index-D2mybjXD.js.map → index-CVBtBjQ5.js.map} +1 -1
  39. package/dist/{index-MRdle0fs.cjs → index-DpjYs5yr.cjs} +2 -2
  40. package/dist/{index-MRdle0fs.cjs.map → index-DpjYs5yr.cjs.map} +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +288 -260
  43. package/dist/index.js.map +1 -1
  44. package/dist/{noPayout-qBXWKwav.js → noPayout-B-vGXJ-V.js} +3 -3
  45. package/dist/{noPayout-qBXWKwav.js.map → noPayout-B-vGXJ-V.js.map} +1 -1
  46. package/dist/{noPayout-DAWBQ0eG.cjs → noPayout-DOHak0ui.cjs} +2 -2
  47. package/dist/{noPayout-DAWBQ0eG.cjs.map → noPayout-DOHak0ui.cjs.map} +1 -1
  48. package/dist/pegin-registration-client-BWMwxtr8.js +718 -0
  49. package/dist/pegin-registration-client-BWMwxtr8.js.map +1 -0
  50. package/dist/pegin-registration-client-D4EguWaz.cjs +2 -0
  51. package/dist/pegin-registration-client-D4EguWaz.cjs.map +1 -0
  52. package/dist/{primeVpAuth-BDWBKYhv.cjs → primeVpAuth-BPj2TPdD.cjs} +2 -2
  53. package/dist/{primeVpAuth-BDWBKYhv.cjs.map → primeVpAuth-BPj2TPdD.cjs.map} +1 -1
  54. package/dist/{primeVpAuth-D0ZnsjRi.js → primeVpAuth-CiCdRNGf.js} +2 -2
  55. package/dist/{primeVpAuth-D0ZnsjRi.js.map → primeVpAuth-CiCdRNGf.js.map} +1 -1
  56. package/dist/registration-records-CKLAv3gw.js +447 -0
  57. package/dist/registration-records-CKLAv3gw.js.map +1 -0
  58. package/dist/registration-records-DFQgBaYi.cjs +2 -0
  59. package/dist/registration-records-DFQgBaYi.cjs.map +1 -0
  60. package/dist/{secp256k1-D-H9jmd7.js → secp256k1-BuxBFUHm.js} +3 -3
  61. package/dist/{secp256k1-D-H9jmd7.js.map → secp256k1-BuxBFUHm.js.map} +1 -1
  62. package/dist/signer-set-reader-C1VmC9_U.js +264 -0
  63. package/dist/signer-set-reader-C1VmC9_U.js.map +1 -0
  64. package/dist/signer-set-reader-C6g47hdk.cjs +2 -0
  65. package/dist/signer-set-reader-C6g47hdk.cjs.map +1 -0
  66. package/dist/{signing-Dhr2t0Z6.js → signing-C1rR4tqs.js} +9 -15
  67. package/dist/signing-C1rR4tqs.js.map +1 -0
  68. package/dist/signing-DvISftFk.cjs +2 -0
  69. package/dist/signing-DvISftFk.cjs.map +1 -0
  70. package/dist/tbv/core/clients/eth/__tests__/registration-records.test.d.ts +2 -0
  71. package/dist/tbv/core/clients/eth/__tests__/registration-records.test.d.ts.map +1 -0
  72. package/dist/tbv/core/clients/eth/claimable-event-error.d.ts +14 -0
  73. package/dist/tbv/core/clients/eth/claimable-event-error.d.ts.map +1 -0
  74. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  75. package/dist/tbv/core/clients/eth/index.d.ts +3 -1
  76. package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
  77. package/dist/tbv/core/clients/eth/index.js +27 -21
  78. package/dist/tbv/core/clients/eth/index.js.map +1 -1
  79. package/dist/tbv/core/clients/eth/payout-script.d.ts +8 -0
  80. package/dist/tbv/core/clients/eth/payout-script.d.ts.map +1 -1
  81. package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts +13 -0
  82. package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -1
  83. package/dist/tbv/core/clients/eth/registration-logs-error.d.ts +11 -1
  84. package/dist/tbv/core/clients/eth/registration-logs-error.d.ts.map +1 -1
  85. package/dist/tbv/core/clients/eth/registration-records.d.ts +29 -0
  86. package/dist/tbv/core/clients/eth/registration-records.d.ts.map +1 -0
  87. package/dist/tbv/core/clients/eth/types.d.ts +120 -3
  88. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  89. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +9 -10
  90. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  91. package/dist/tbv/core/clients/index.cjs +1 -1
  92. package/dist/tbv/core/clients/index.js +56 -50
  93. package/dist/tbv/core/clients/index.js.map +1 -1
  94. package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
  95. package/dist/tbv/core/clients/vault-provider/status/index.js +1 -1
  96. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +45 -0
  97. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  98. package/dist/tbv/core/contracts/index.cjs +1 -1
  99. package/dist/tbv/core/contracts/index.js +16 -15
  100. package/dist/tbv/core/contracts/index.js.map +1 -1
  101. package/dist/tbv/core/deposit-terms/__tests__/claimSiblings.test.d.ts +2 -0
  102. package/dist/tbv/core/deposit-terms/__tests__/claimSiblings.test.d.ts.map +1 -0
  103. package/dist/tbv/core/deposit-terms/__tests__/fixtures/realFundedPrePegin.d.ts +29 -0
  104. package/dist/tbv/core/deposit-terms/__tests__/fixtures/realFundedPrePegin.d.ts.map +1 -0
  105. package/dist/tbv/core/deposit-terms/__tests__/fundedPrePeginFee.test.d.ts +2 -0
  106. package/dist/tbv/core/deposit-terms/__tests__/fundedPrePeginFee.test.d.ts.map +1 -0
  107. package/dist/tbv/core/deposit-terms/__tests__/rebuildDepositTermsForClaim.golden.test.d.ts +2 -0
  108. package/dist/tbv/core/deposit-terms/__tests__/rebuildDepositTermsForClaim.golden.test.d.ts.map +1 -0
  109. package/dist/tbv/core/deposit-terms/__tests__/rebuildDepositTermsForClaim.test.d.ts +2 -0
  110. package/dist/tbv/core/deposit-terms/__tests__/rebuildDepositTermsForClaim.test.d.ts.map +1 -0
  111. package/dist/tbv/core/deposit-terms/claimSiblings.d.ts +23 -0
  112. package/dist/tbv/core/deposit-terms/claimSiblings.d.ts.map +1 -0
  113. package/dist/tbv/core/deposit-terms/fundedPrePeginFee.d.ts +15 -0
  114. package/dist/tbv/core/deposit-terms/fundedPrePeginFee.d.ts.map +1 -0
  115. package/dist/tbv/core/deposit-terms/index.d.ts +3 -0
  116. package/dist/tbv/core/deposit-terms/index.d.ts.map +1 -1
  117. package/dist/tbv/core/deposit-terms/rebuildDepositTermsForClaim.d.ts +40 -0
  118. package/dist/tbv/core/deposit-terms/rebuildDepositTermsForClaim.d.ts.map +1 -0
  119. package/dist/tbv/core/index.cjs +1 -1
  120. package/dist/tbv/core/index.js +287 -259
  121. package/dist/tbv/core/index.js.map +1 -1
  122. package/dist/tbv/core/managers/index.cjs +1 -1
  123. package/dist/tbv/core/managers/index.js +2 -2
  124. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts +6 -2
  125. package/dist/tbv/core/managers/pegin/signPsbtsWithFallback.d.ts.map +1 -1
  126. package/dist/tbv/core/primitives/index.cjs +1 -1
  127. package/dist/tbv/core/primitives/index.js +4 -4
  128. package/dist/tbv/core/primitives/psbt/constants.d.ts +54 -6
  129. package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
  130. package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifactsFromSignatures.test.d.ts +2 -0
  131. package/dist/tbv/core/services/delegated-claim/__tests__/assembleWatchtowerArtifactsFromSignatures.test.d.ts.map +1 -0
  132. package/dist/tbv/core/services/delegated-claim/__tests__/assertBinding.test.d.ts +2 -0
  133. package/dist/tbv/core/services/delegated-claim/__tests__/assertBinding.test.d.ts.map +1 -0
  134. package/dist/tbv/core/services/delegated-claim/__tests__/assertPayoutFeeAndTimelocks.test.d.ts +2 -0
  135. package/dist/tbv/core/services/delegated-claim/__tests__/assertPayoutFeeAndTimelocks.test.d.ts.map +1 -0
  136. package/dist/tbv/core/services/delegated-claim/__tests__/fixtures/delegatedClaimPsbts.d.ts +49 -0
  137. package/dist/tbv/core/services/delegated-claim/__tests__/fixtures/delegatedClaimPsbts.d.ts.map +1 -0
  138. package/dist/tbv/core/services/delegated-claim/__tests__/payoutBinding.test.d.ts +2 -0
  139. package/dist/tbv/core/services/delegated-claim/__tests__/payoutBinding.test.d.ts.map +1 -0
  140. package/dist/tbv/core/services/delegated-claim/__tests__/payoutInputLeaf.test.d.ts +2 -0
  141. package/dist/tbv/core/services/delegated-claim/__tests__/payoutInputLeaf.test.d.ts.map +1 -0
  142. package/dist/tbv/core/services/delegated-claim/__tests__/planDelegatedClaimSigning.test.d.ts +2 -0
  143. package/dist/tbv/core/services/delegated-claim/__tests__/planDelegatedClaimSigning.test.d.ts.map +1 -0
  144. package/dist/tbv/core/services/delegated-claim/__tests__/readDelegatedClaimVaultContext.test.d.ts +2 -0
  145. package/dist/tbv/core/services/delegated-claim/__tests__/readDelegatedClaimVaultContext.test.d.ts.map +1 -0
  146. package/dist/tbv/core/services/delegated-claim/__tests__/realSchnorrVerification.test.d.ts +2 -0
  147. package/dist/tbv/core/services/delegated-claim/__tests__/realSchnorrVerification.test.d.ts.map +1 -0
  148. package/dist/tbv/core/services/delegated-claim/__tests__/signDelegatedClaimPlan.test.d.ts +2 -0
  149. package/dist/tbv/core/services/delegated-claim/__tests__/signDelegatedClaimPlan.test.d.ts.map +1 -0
  150. package/dist/tbv/core/services/delegated-claim/__tests__/signingRequests.test.d.ts +2 -0
  151. package/dist/tbv/core/services/delegated-claim/__tests__/signingRequests.test.d.ts.map +1 -0
  152. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts +34 -9
  153. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifacts.d.ts.map +1 -1
  154. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifactsFromSignatures.d.ts +36 -0
  155. package/dist/tbv/core/services/delegated-claim/assembleWatchtowerArtifactsFromSignatures.d.ts.map +1 -0
  156. package/dist/tbv/core/services/delegated-claim/assertBinding.d.ts +37 -0
  157. package/dist/tbv/core/services/delegated-claim/assertBinding.d.ts.map +1 -0
  158. package/dist/tbv/core/services/delegated-claim/assertPayoutFeeAndTimelocks.d.ts +35 -0
  159. package/dist/tbv/core/services/delegated-claim/assertPayoutFeeAndTimelocks.d.ts.map +1 -0
  160. package/dist/tbv/core/services/delegated-claim/index.d.ts +22 -4
  161. package/dist/tbv/core/services/delegated-claim/index.d.ts.map +1 -1
  162. package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts +10 -4
  163. package/dist/tbv/core/services/delegated-claim/payoutBinding.d.ts.map +1 -1
  164. package/dist/tbv/core/services/delegated-claim/payoutInputLeaf.d.ts +34 -0
  165. package/dist/tbv/core/services/delegated-claim/payoutInputLeaf.d.ts.map +1 -0
  166. package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts +43 -0
  167. package/dist/tbv/core/services/delegated-claim/planDelegatedClaimSigning.d.ts.map +1 -0
  168. package/dist/tbv/core/services/delegated-claim/readDelegatedClaimVaultContext.d.ts +70 -0
  169. package/dist/tbv/core/services/delegated-claim/readDelegatedClaimVaultContext.d.ts.map +1 -0
  170. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts +31 -2
  171. package/dist/tbv/core/services/delegated-claim/readWatchtowerArtifacts.d.ts.map +1 -1
  172. package/dist/tbv/core/services/delegated-claim/signDelegatedClaimPlan.d.ts +110 -0
  173. package/dist/tbv/core/services/delegated-claim/signDelegatedClaimPlan.d.ts.map +1 -0
  174. package/dist/tbv/core/services/delegated-claim/signingRequests.d.ts +24 -0
  175. package/dist/tbv/core/services/delegated-claim/signingRequests.d.ts.map +1 -0
  176. package/dist/tbv/core/services/delegated-claim/types.d.ts +110 -9
  177. package/dist/tbv/core/services/delegated-claim/types.d.ts.map +1 -1
  178. package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts +16 -1
  179. package/dist/tbv/core/services/delegated-claim/vaultIdBinding.d.ts.map +1 -1
  180. package/dist/tbv/core/services/delegated-claim/verifySignatureForRequest.d.ts +19 -0
  181. package/dist/tbv/core/services/delegated-claim/verifySignatureForRequest.d.ts.map +1 -0
  182. package/dist/tbv/core/services/delegated-claim/verifyingKeyBinding.d.ts +40 -0
  183. package/dist/tbv/core/services/delegated-claim/verifyingKeyBinding.d.ts.map +1 -0
  184. package/dist/tbv/core/services/delegated-claim/walletIdentity.d.ts +23 -0
  185. package/dist/tbv/core/services/delegated-claim/walletIdentity.d.ts.map +1 -0
  186. package/dist/tbv/core/services/index.cjs +1 -1
  187. package/dist/tbv/core/services/index.js +89 -76
  188. package/dist/tbv/core/services/participants/__tests__/readStampedParticipantKeys.test.d.ts +2 -0
  189. package/dist/tbv/core/services/participants/__tests__/readStampedParticipantKeys.test.d.ts.map +1 -0
  190. package/dist/tbv/core/services/participants/index.d.ts +1 -0
  191. package/dist/tbv/core/services/participants/index.d.ts.map +1 -1
  192. package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts +29 -0
  193. package/dist/tbv/core/services/participants/readStampedParticipantKeys.d.ts.map +1 -0
  194. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts +1 -1
  195. package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts.map +1 -1
  196. package/dist/tbv/core/utils/eth/index.cjs +1 -1
  197. package/dist/tbv/core/utils/eth/index.cjs.map +1 -1
  198. package/dist/tbv/core/utils/eth/index.js +20 -20
  199. package/dist/tbv/core/utils/eth/index.js.map +1 -1
  200. package/dist/tbv/core/utils/eth/waitForTransactionReceiptSmartAware.d.ts.map +1 -1
  201. package/dist/tbv/core/utils/index.cjs +1 -1
  202. package/dist/tbv/core/utils/index.js +47 -46
  203. package/dist/tbv/core/utils/index.js.map +1 -1
  204. package/dist/tbv/core/vault-secrets/__tests__/buildVaultContextInputForClaim.test.d.ts +2 -0
  205. package/dist/tbv/core/vault-secrets/__tests__/buildVaultContextInputForClaim.test.d.ts.map +1 -0
  206. package/dist/tbv/core/vault-secrets/buildVaultContextInputForClaim.d.ts +18 -0
  207. package/dist/tbv/core/vault-secrets/buildVaultContextInputForClaim.d.ts.map +1 -0
  208. package/dist/tbv/core/vault-secrets/index.cjs +1 -1
  209. package/dist/tbv/core/vault-secrets/index.d.ts +1 -0
  210. package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
  211. package/dist/tbv/core/vault-secrets/index.js +12 -10
  212. package/dist/tbv/core/vault-secrets/index.js.map +1 -1
  213. package/dist/tbv/index.cjs +1 -1
  214. package/dist/tbv/index.js +287 -259
  215. package/dist/tbv/index.js.map +1 -1
  216. package/dist/toRefundInputs-BZXvuOMY.cjs +2 -0
  217. package/dist/toRefundInputs-BZXvuOMY.cjs.map +1 -0
  218. package/dist/toRefundInputs-dKDSvpVI.js +698 -0
  219. package/dist/toRefundInputs-dKDSvpVI.js.map +1 -0
  220. package/dist/types-Bda75Od0.cjs +2 -0
  221. package/dist/types-Bda75Od0.cjs.map +1 -0
  222. package/dist/types-C5jj3Cc-.js +198 -0
  223. package/dist/types-C5jj3Cc-.js.map +1 -0
  224. package/dist/{verifyKeyPathSchnorrSignature-Gm9EmZkx.cjs → verifyKeyPathSchnorrSignature-CQUut2-O.cjs} +2 -2
  225. package/dist/{verifyKeyPathSchnorrSignature-Gm9EmZkx.cjs.map → verifyKeyPathSchnorrSignature-CQUut2-O.cjs.map} +1 -1
  226. package/dist/{verifyKeyPathSchnorrSignature-BQHNhRj6.js → verifyKeyPathSchnorrSignature-DxPbeSdQ.js} +2 -2
  227. package/dist/{verifyKeyPathSchnorrSignature-BQHNhRj6.js.map → verifyKeyPathSchnorrSignature-DxPbeSdQ.js.map} +1 -1
  228. package/dist/{verifyScriptPathSchnorrSignature-CpjSTfMj.js → verifyScriptPathSchnorrSignature-B3-VkvnK.js} +6 -4
  229. package/dist/{verifyScriptPathSchnorrSignature-CpjSTfMj.js.map → verifyScriptPathSchnorrSignature-B3-VkvnK.js.map} +1 -1
  230. package/dist/{verifyScriptPathSchnorrSignature-BKZihCjk.cjs → verifyScriptPathSchnorrSignature-D2t1yACC.cjs} +2 -2
  231. package/dist/{verifyScriptPathSchnorrSignature-BKZihCjk.cjs.map → verifyScriptPathSchnorrSignature-D2t1yACC.cjs.map} +1 -1
  232. package/package.json +3 -3
  233. package/dist/PayoutManager-B6GFbG3X.cjs +0 -2
  234. package/dist/PayoutManager-B6GFbG3X.cjs.map +0 -1
  235. package/dist/PayoutManager-BSwbUQeF.js.map +0 -1
  236. package/dist/PeginManager-IgDHy_eU.cjs +0 -2
  237. package/dist/ProtocolParams.abi-Db2USqQm.cjs +0 -2
  238. package/dist/ProtocolParams.abi-Db2USqQm.cjs.map +0 -1
  239. package/dist/ProtocolParams.abi-q0AidvYX.js.map +0 -1
  240. package/dist/buildAndBroadcastReclaim-B8aFMGf-.cjs +0 -2
  241. package/dist/buildAndBroadcastReclaim-B8aFMGf-.cjs.map +0 -1
  242. package/dist/buildAndBroadcastReclaim-D5520lbL.js +0 -2210
  243. package/dist/buildAndBroadcastReclaim-D5520lbL.js.map +0 -1
  244. package/dist/constants-BTZdyOuk.cjs +0 -2
  245. package/dist/constants-BTZdyOuk.cjs.map +0 -1
  246. package/dist/constants-D5vORbQE.js +0 -29
  247. package/dist/constants-D5vORbQE.js.map +0 -1
  248. package/dist/onChainBtcPubkey-BlzxYImF.cjs +0 -2
  249. package/dist/onChainBtcPubkey-BlzxYImF.cjs.map +0 -1
  250. package/dist/onChainBtcPubkey-CCTdl53s.js +0 -159
  251. package/dist/onChainBtcPubkey-CCTdl53s.js.map +0 -1
  252. package/dist/pegin-registration-client-B0j6ugt9.cjs +0 -2
  253. package/dist/pegin-registration-client-B0j6ugt9.cjs.map +0 -1
  254. package/dist/pegin-registration-client-ilkV1mLP.js +0 -878
  255. package/dist/pegin-registration-client-ilkV1mLP.js.map +0 -1
  256. package/dist/signing-3l5Aqd-H.cjs +0 -2
  257. package/dist/signing-3l5Aqd-H.cjs.map +0 -1
  258. package/dist/signing-Dhr2t0Z6.js.map +0 -1
  259. package/dist/toRefundInputs-10RYIfh1.js +0 -559
  260. package/dist/toRefundInputs-10RYIfh1.js.map +0 -1
  261. package/dist/toRefundInputs-a-0HRyrl.cjs +0 -2
  262. package/dist/toRefundInputs-a-0HRyrl.cjs.map +0 -1
  263. package/dist/types-BueQoMjO.cjs +0 -2
  264. package/dist/types-BueQoMjO.cjs.map +0 -1
  265. package/dist/types-DGkejGZH.js +0 -456
  266. package/dist/types-DGkejGZH.js.map +0 -1
@@ -0,0 +1,718 @@
1
+ import { getAbiItem as V, encodeFunctionData as E, isAddressEqual as R, zeroAddress as K } from "viem";
2
+ import { B as a } from "./BTCVaultRegistry.abi-DBW0dyqH.js";
3
+ import { B as v, h as b } from "./BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js";
4
+ import { M as x } from "./constants-BeYquVd-.js";
5
+ import { waitForTransactionReceiptSmartAware as N } from "./tbv/core/utils/eth/index.js";
6
+ import { a as P, R as T, g as H, V as _, j as M, h as q, k as F, d as O } from "./registration-records-CKLAv3gw.js";
7
+ const y = 25, L = 9999;
8
+ function S(o) {
9
+ if (!Number.isInteger(o) || o < 0 || o >= x)
10
+ throw new Error(
11
+ `Quoted commissionBps must be an integer in [0, ${x}), got ${o}`
12
+ );
13
+ return Math.min(
14
+ o + y,
15
+ L
16
+ );
17
+ }
18
+ const A = 9999;
19
+ function I(o) {
20
+ return {
21
+ depositor: o.depositor,
22
+ depositorBtcPubKey: o.depositorBtcPubKey,
23
+ amount: o.amount,
24
+ vaultProvider: o.vaultProvider,
25
+ status: o.status,
26
+ applicationEntryPoint: o.applicationEntryPoint,
27
+ createdAt: o.createdAt
28
+ };
29
+ }
30
+ function w(o) {
31
+ const t = Number(o.offchainParamsVersion);
32
+ return M(t), {
33
+ depositorSignedPeginTx: o.depositorSignedPeginTx,
34
+ universalChallengersVersion: o.universalChallengersVersion,
35
+ appVaultKeepersVersion: o.appVaultKeepersVersion,
36
+ offchainParamsVersion: t,
37
+ verifiedAt: o.verifiedAt,
38
+ depositorWotsPkHash: o.depositorWotsPkHash,
39
+ hashlock: o.hashlock,
40
+ htlcVout: o.htlcVout,
41
+ depositorPopSignature: o.depositorPopSignature,
42
+ prePeginTxHash: o.prePeginTxHash,
43
+ vaultProviderCommissionBps: o.vaultProviderCommissionBps,
44
+ vaultCoreVersion: o.vaultCoreVersion
45
+ };
46
+ }
47
+ const z = 1n << 64n, W = 0n, U = [
48
+ V({ abi: a, name: "PegInSubmitted" }),
49
+ V({ abi: a, name: "PegInSubmittedV2" })
50
+ ], D = V({
51
+ abi: a,
52
+ name: "VaultClaimableBy"
53
+ }), X = 7200n;
54
+ function Q(o, t) {
55
+ return o > t ? o : t;
56
+ }
57
+ function Y(o, t) {
58
+ return {
59
+ vaultId: o.vaultId.toLowerCase(),
60
+ depositor: o.depositor,
61
+ vaultProvider: o.vaultProvider,
62
+ amount: o.amount,
63
+ vaultCoreVersion: o.vaultCoreVersion,
64
+ universalChallengersVersion: o.universalChallengersVersion,
65
+ appVaultKeepersVersion: o.appVaultKeepersVersion,
66
+ proverCircuitVersion: o.proverCircuitVersion,
67
+ offchainParamsVersion: o.offchainParamsVersion,
68
+ peginTxHash: o.peginTxHash.toLowerCase(),
69
+ depositorPayoutScriptPubKey: o.depositorPayoutBtcAddress.toLowerCase(),
70
+ unsignedPrePeginTx: o.unsignedPrePeginTx,
71
+ maxAcceptableCommissionBps: o.maxAcceptableCommissionBps,
72
+ blockNumber: t
73
+ };
74
+ }
75
+ function C(o, t, e) {
76
+ if (o < 0n || o >= z)
77
+ throw new Error(
78
+ `getBtcVaultProtocolInfo returned ${t}=${o} for vault ${e}, outside the uint64 range — the registry may predate RFC-006`
79
+ );
80
+ return o;
81
+ }
82
+ function k(o, t) {
83
+ return {
84
+ vpKeyEpoch: C(o.vpKeyEpoch, "vpKeyEpoch", t),
85
+ appKeeperKeyEpoch: C(
86
+ o.appKeeperKeyEpoch,
87
+ "appKeeperKeyEpoch",
88
+ t
89
+ ),
90
+ ucKeyEpoch: C(o.ucKeyEpoch, "ucKeyEpoch", t)
91
+ };
92
+ }
93
+ class G {
94
+ constructor(t, e) {
95
+ this.publicClient = t, this.contractAddress = e;
96
+ }
97
+ /**
98
+ * Read the VP's **genesis** (registration) x-only BTC pubkey — the key bonded
99
+ * at version 0, which never moves when the operator rotates.
100
+ *
101
+ * Resolved as "the operation key at epoch 0" rather than through the
102
+ * dedicated `getVaultProviderBTCKey` getter, which
103
+ * https://github.com/babylonlabs-io/vault-contracts-aave-v4/pull/539 removes.
104
+ * Epoch 0 predates any rotation — appended versions are stamped at epoch 1 or
105
+ * later — so it resolves to the registration key, and the contracts team has
106
+ * confirmed that is a property we can rely on rather than an implementation
107
+ * detail. The devnet comparison behind that claim — both getters returning the
108
+ * identical key for a provider that *has* rotated, while
109
+ * `getCurrentOperationBtcKey` differed — is recorded in
110
+ * https://github.com/babylonlabs-io/babylon-toolkit/issues/2188.
111
+ *
112
+ * This makes the read RFC-006-only, where the removed getter also existed on a
113
+ * legacy registry. That costs nothing: every caller of this method already
114
+ * resolves participant keys through `OperationKeyReader`, so all of them
115
+ * require an RFC-006 registry regardless.
116
+ *
117
+ * Validates length, hex form, and secp256k1 curve membership before minting
118
+ * the brand. Returns 64-char lowercase hex without the `0x` prefix.
119
+ */
120
+ async getVaultProviderGenesisBtcPubKey(t, e) {
121
+ return this.getVaultProviderOperationBtcKeyAtEpoch(
122
+ t,
123
+ W,
124
+ e
125
+ );
126
+ }
127
+ /**
128
+ * Read the VP operation key selected by `epoch`.
129
+ *
130
+ * This is public rather than hidden inside `OperationKeyReader` because
131
+ * subject-specific VP authentication needs exactly one participant: the
132
+ * gRPC bootstrap is signed by the key frozen into the vault, while the
133
+ * JSON-RPC bootstrap is signed by the provider's live key.
134
+ */
135
+ async getVaultProviderOperationBtcKeyAtEpoch(t, e, r) {
136
+ const s = await this.publicClient.readContract({
137
+ address: this.contractAddress,
138
+ abi: a,
139
+ functionName: "getOperationBtcKeyAtEpoch",
140
+ args: [t, e],
141
+ blockNumber: r
142
+ });
143
+ return P(
144
+ s,
145
+ `getOperationBtcKeyAtEpoch (vp=${t}, epoch=${e})`
146
+ );
147
+ }
148
+ /**
149
+ * Read the application entry point a vault provider is registered for.
150
+ *
151
+ * This is the registry's own `vaultProviders[vp].applicationEntryPoint`, and
152
+ * it is the value the peg-in submit path resolves internally — it selects
153
+ * which application's vault-keeper roster, roster version and keeper key
154
+ * epoch a deposit is bonded to. The dApp separately carries an entry point
155
+ * from its own configuration; the two agree today, but they are different
156
+ * sources of truth, so the build path reads this one and asserts the
157
+ * configured value matches it rather than trusting either alone.
158
+ */
159
+ async getVaultProviderApplication(t, e) {
160
+ return await this.publicClient.readContract({
161
+ address: this.contractAddress,
162
+ abi: a,
163
+ functionName: "getVaultProviderApplication",
164
+ args: [t],
165
+ blockNumber: e
166
+ });
167
+ }
168
+ /**
169
+ * Read a vault provider's *current* RFC-006 operation BTC key.
170
+ *
171
+ * Falls back on-chain to the registration key when the provider has never
172
+ * rotated, so this returns the same value as
173
+ * `getVaultProviderGenesisBtcPubKey` until the first rotation.
174
+ *
175
+ * This is the key the VP's server uses for JSON-RPC-subject authentication.
176
+ * The gRPC-subject bootstrap is instead bound to the existing vault's frozen
177
+ * epoch and resolves through `getVaultProviderOperationBtcKeyAtEpoch`.
178
+ */
179
+ async getCurrentVaultProviderOperationBtcKey(t) {
180
+ const e = await this.publicClient.readContract({
181
+ address: this.contractAddress,
182
+ abi: a,
183
+ functionName: "getCurrentOperationBtcKey",
184
+ args: [t]
185
+ });
186
+ return P(
187
+ e,
188
+ `getCurrentOperationBtcKey (vp=${t})`
189
+ );
190
+ }
191
+ /**
192
+ * Read a vault's frozen RFC-006 operation-key epochs.
193
+ *
194
+ * Reads `getBtcVaultProtocolInfo` through the **extended** ABI, which is only
195
+ * valid against an RFC-006 registry: against one whose `BTCVaultProtocolInfo`
196
+ * struct is not extended this call does not fail for a populated vault, it
197
+ * silently returns three words of tail data as epochs. Nothing here can detect
198
+ * that, so the guarantee is a deployment one — every network this ships to has
199
+ * the RFC-006 getters, and mainnet is a fresh RFC-006 deploy.
200
+ *
201
+ * A registry missing the operation-key getters entirely is the *safer* of the
202
+ * two cases: `resolveParticipantKeysAtEpochs` reverts downstream and these
203
+ * epochs never reach key resolution. See {@link UINT64_EXCLUSIVE_UPPER_BOUND}
204
+ * for which state the range check actually guards, and
205
+ * `BTCVaultRegistryKeyEpochs.abi.ts` for the decode hazard.
206
+ */
207
+ async getVaultKeyEpochs(t) {
208
+ const e = await this.publicClient.readContract({
209
+ address: this.contractAddress,
210
+ abi: v,
211
+ functionName: "getBtcVaultProtocolInfo",
212
+ args: [t]
213
+ });
214
+ return k(e, t);
215
+ }
216
+ async getVaultKeyEpochsBatch(t) {
217
+ return t.length === 0 ? [] : (await this.publicClient.multicall({
218
+ contracts: t.map((r) => ({
219
+ address: this.contractAddress,
220
+ abi: v,
221
+ functionName: "getBtcVaultProtocolInfo",
222
+ args: [r]
223
+ })),
224
+ allowFailure: !1
225
+ })).map(
226
+ (r, s) => k(r, t[s])
227
+ );
228
+ }
229
+ async getVaultBasicInfo(t) {
230
+ const e = await this.publicClient.readContract({
231
+ address: this.contractAddress,
232
+ abi: a,
233
+ functionName: "getBtcVaultBasicInfo",
234
+ args: [t]
235
+ });
236
+ return I(e);
237
+ }
238
+ async getVaultProtocolInfo(t) {
239
+ const e = await this.publicClient.readContract({
240
+ address: this.contractAddress,
241
+ abi: a,
242
+ functionName: "getBtcVaultProtocolInfo",
243
+ args: [t]
244
+ });
245
+ return w(e);
246
+ }
247
+ async getProtocolInfoBatch(t) {
248
+ return t.length === 0 ? [] : (await this.publicClient.multicall({
249
+ contracts: t.map((r) => ({
250
+ address: this.contractAddress,
251
+ abi: a,
252
+ functionName: "getBtcVaultProtocolInfo",
253
+ args: [r]
254
+ })),
255
+ allowFailure: !1
256
+ })).map((r, s) => {
257
+ const i = r;
258
+ if (!i.depositorSignedPeginTx || i.depositorSignedPeginTx === "0x")
259
+ throw new Error(
260
+ `Vault ${t[s]} not found on-chain or has no pegin transaction`
261
+ );
262
+ return w(i);
263
+ });
264
+ }
265
+ /**
266
+ * Read the protocol pegin fee (in wei) for a given vault provider.
267
+ * Mirrors the `getPegInFee(address)` view on BTCVaultRegistry.
268
+ */
269
+ async getPegInFee(t) {
270
+ return await this.publicClient.readContract({
271
+ address: this.contractAddress,
272
+ abi: a,
273
+ functionName: "getPegInFee",
274
+ args: [t]
275
+ });
276
+ }
277
+ /**
278
+ * Read a vault provider's current commission in basis points from
279
+ * BTCVaultRegistry. The contract enforces `commissionBps < 10000`, so the
280
+ * legitimate range is `[0, 9999]`; anything outside indicates a wrong
281
+ * contract address or ABI drift and is surfaced as an error rather than
282
+ * trusted.
283
+ */
284
+ async getVaultProviderCommission(t) {
285
+ const e = await this.publicClient.readContract({
286
+ address: this.contractAddress,
287
+ abi: a,
288
+ functionName: "getVaultProviderCommission",
289
+ args: [t]
290
+ });
291
+ if (!Number.isInteger(e) || e < 0 || e > A)
292
+ throw new Error(
293
+ `getVaultProviderCommission returned ${e} bps for ${t}, outside the protocol range [0, ${A}]`
294
+ );
295
+ return e;
296
+ }
297
+ async getVaultData(t) {
298
+ const [e, r] = await this.publicClient.multicall({
299
+ contracts: [
300
+ {
301
+ address: this.contractAddress,
302
+ abi: a,
303
+ functionName: "getBtcVaultBasicInfo",
304
+ args: [t]
305
+ },
306
+ {
307
+ address: this.contractAddress,
308
+ abi: a,
309
+ functionName: "getBtcVaultProtocolInfo",
310
+ args: [t]
311
+ }
312
+ ],
313
+ allowFailure: !1
314
+ }), s = I(e), i = w(r);
315
+ if (!i.depositorSignedPeginTx || i.depositorSignedPeginTx === "0x")
316
+ throw new Error(
317
+ `Vault ${t} not found on-chain or has no pegin transaction`
318
+ );
319
+ return { basic: s, protocol: i };
320
+ }
321
+ /** @inheritdoc */
322
+ async getRegistrationRecordsAtBlock(t) {
323
+ const e = await this.publicClient.getLogs({
324
+ address: this.contractAddress,
325
+ events: U,
326
+ fromBlock: t,
327
+ toBlock: t,
328
+ strict: !0
329
+ });
330
+ if (e.length === 0)
331
+ throw new T(t);
332
+ const r = /* @__PURE__ */ new Map();
333
+ for (const s of e) {
334
+ if (s.eventName !== "PegInSubmittedV2") continue;
335
+ const i = Y(s.args, s.blockNumber);
336
+ if (r.has(i.vaultId))
337
+ throw new Error(
338
+ `Expected one PegInSubmittedV2 log for vault ${i.vaultId} at block ${t}, found more than one`
339
+ );
340
+ r.set(i.vaultId, i);
341
+ }
342
+ if (r.size === 0)
343
+ throw new T(
344
+ t,
345
+ `Block ${t} holds ${e.length} PegInSubmitted registration log(s) but no PegInSubmittedV2 log: either the node served a partial answer for block ${t} (retry, preferably another node) or the registry predates the depositor's commission ceiling (vault-contracts-aave-v4 #548) and the ceiling cannot be recovered on-chain`
346
+ );
347
+ return [...r.values()];
348
+ }
349
+ /**
350
+ * Read the depositor's commission ceiling (`maxAcceptableCommissionBps`)
351
+ * for vaults registered in the same block, from their `PegInSubmittedV2`
352
+ * logs. Returned in `vaultIds` order.
353
+ *
354
+ * The contract bound-checks the ceiling and discards it (PeginLogic.sol,
355
+ * `VaultProviderCommissionExceeded`), so the registration log is its only
356
+ * on-chain source. Vault ids are matched case-insensitively.
357
+ *
358
+ * @throws As {@link getRegistrationRecordsAtBlock}, plus the same typed
359
+ * transient error when a vault has no registration log in its own
360
+ * `createdAt` block.
361
+ */
362
+ async getMaxAcceptableCommissionBpsBatch(t, e) {
363
+ if (t.length === 0) return [];
364
+ const r = await this.getRegistrationRecordsAtBlock(e);
365
+ return t.map(
366
+ (s) => H(r, s, e).maxAcceptableCommissionBps
367
+ );
368
+ }
369
+ /** @inheritdoc */
370
+ async getVaultClaimableBy(t, e, r) {
371
+ const i = `0x${P(
372
+ e,
373
+ `getVaultClaimableBy claimer (vault=${t})`
374
+ )}`, n = t.toLowerCase(), { number: c } = await this.publicClient.getBlock({
375
+ blockTag: "finalized"
376
+ });
377
+ if (c < r)
378
+ throw new Error(
379
+ `Finalized block ${c} is below vault ${t}'s registration block ${r}; the registration is not finalized yet, or the node is behind it`
380
+ );
381
+ let u = c;
382
+ for (; ; ) {
383
+ const l = Q(
384
+ r,
385
+ u - X + 1n
386
+ ), p = await this.publicClient.getLogs({
387
+ address: this.contractAddress,
388
+ event: D,
389
+ args: { vaultId: n, claimerPK: i },
390
+ fromBlock: l,
391
+ toBlock: u,
392
+ strict: !0
393
+ });
394
+ if (p.length > 1) {
395
+ const d = new Set(p.map((f) => f.transactionHash));
396
+ if (d.size > 1)
397
+ throw new Error(
398
+ `Found ${p.length} VaultClaimableBy logs for vault ${t} and claimer ${i} across ${d.size} transactions in blocks ${l}..${u}; a vault is redeemed once, so the node's answer is inconsistent`
399
+ );
400
+ }
401
+ if (p.length >= 1) {
402
+ const d = p[0];
403
+ return {
404
+ blockNumber: d.blockNumber,
405
+ claimerPk: P(
406
+ d.args.claimerPK,
407
+ `VaultClaimableBy.claimerPK (vault=${t})`
408
+ ),
409
+ peginTxHash: d.args.peginTxHash,
410
+ vaultCoreVersion: d.args.vaultCoreVersion,
411
+ proverCircuitVersion: d.args.proverCircuitVersion,
412
+ offchainParamsVersion: d.args.offchainParamsVersion,
413
+ universalChallengersVersion: d.args.universalChallengersVersion,
414
+ appVaultKeepersVersion: d.args.appVaultKeepersVersion
415
+ };
416
+ }
417
+ if (l === r)
418
+ throw new _(
419
+ t,
420
+ i,
421
+ r,
422
+ c
423
+ );
424
+ u = l - 1n;
425
+ }
426
+ }
427
+ }
428
+ const j = 0, Z = 255, J = 12e4;
429
+ function m(o, t) {
430
+ const e = o.startsWith("0x") ? o : o.startsWith("0X") ? `0x${o.slice(2)}` : `0x${o}`;
431
+ if (!/^0x(?:[0-9a-fA-F]{2})+$/.test(e))
432
+ throw new Error(`${t} must be non-empty, even-length hex`);
433
+ return e;
434
+ }
435
+ function B(o, t) {
436
+ if (!/^0x[0-9a-fA-F]{64}$/.test(o))
437
+ throw new Error(`${t} must be a 32-byte hex value`);
438
+ }
439
+ const tt = "0x0000000000000000000000000000000000000000000000000000000000000000";
440
+ function $(o) {
441
+ if (B(o, "expectedFingerprint"), o.toLowerCase() === tt)
442
+ throw new Error(
443
+ "expectedFingerprint must not be zero: the registry cannot resolve a zero fingerprint, so this submission would always revert"
444
+ );
445
+ }
446
+ function et(o) {
447
+ if (!Number.isInteger(o) || o < 0 || o > Z)
448
+ throw new Error(`htlcVout must be a uint8, got ${o}`);
449
+ }
450
+ class ut {
451
+ constructor(t) {
452
+ this.config = t;
453
+ }
454
+ async registerPeginOnChain(t) {
455
+ const e = {
456
+ ...t,
457
+ popSignature: { ...t.popSignature }
458
+ };
459
+ this.assertQuotedCommissionPresentWhenRequired(e.quotedCommissionBps), $(e.expectedFingerprint);
460
+ const r = this.assertPopMatchesEthAccount(e.popSignature), s = this.normalizeBtcPubkey(e.popSignature), i = m(
461
+ e.popSignature.btcPopSignature,
462
+ "btcPopSignature"
463
+ ), n = this.normalizeRequest(
464
+ e,
465
+ r,
466
+ s
467
+ );
468
+ await this.assertVaultDoesNotExist(
469
+ n.vaultId,
470
+ n.peginTxHash
471
+ );
472
+ const c = await this.readPeginFee(e.vaultProvider), u = await this.resolveMaxAcceptableCommissionBps(
473
+ e.vaultProvider,
474
+ e.quotedCommissionBps
475
+ ), l = E({
476
+ abi: a,
477
+ functionName: "submitPeginRequest",
478
+ args: [
479
+ r,
480
+ s,
481
+ i,
482
+ n.unsignedPrePeginTx,
483
+ n.depositorSignedPeginTx,
484
+ e.vaultProvider,
485
+ u,
486
+ e.hashlock,
487
+ e.htlcVout,
488
+ n.payoutScript,
489
+ e.depositorWotsPkHash,
490
+ // Appended last on the singular overload; the batch takes it at
491
+ // position 4 instead. Order is the selector, so do not "tidy" either.
492
+ e.expectedFingerprint
493
+ ]
494
+ });
495
+ return {
496
+ ethTxHash: await this.sendAndWait(
497
+ l,
498
+ c,
499
+ !1,
500
+ r
501
+ ),
502
+ vaultId: n.vaultId,
503
+ peginTxHash: n.peginTxHash
504
+ };
505
+ }
506
+ async registerPeginBatchOnChain(t) {
507
+ const e = {
508
+ ...t,
509
+ popSignature: { ...t.popSignature },
510
+ requests: t.requests.map((h) => ({ ...h }))
511
+ };
512
+ if (e.requests.length === 0)
513
+ throw new Error("Batch pegin requires at least one request");
514
+ this.assertQuotedCommissionPresentWhenRequired(e.quotedCommissionBps), $(e.expectedFingerprint);
515
+ const r = this.assertPopMatchesEthAccount(e.popSignature), s = m(
516
+ e.unsignedPrePeginTx,
517
+ "unsignedPrePeginTx"
518
+ ), i = this.normalizeBtcPubkey(e.popSignature), n = m(
519
+ e.popSignature.btcPopSignature,
520
+ "btcPopSignature"
521
+ ), c = [], u = [], l = /* @__PURE__ */ new Set();
522
+ for (const h of e.requests) {
523
+ const g = this.normalizeRequest(
524
+ {
525
+ ...h,
526
+ unsignedPrePeginTx: e.unsignedPrePeginTx,
527
+ vaultProvider: e.vaultProvider,
528
+ depositorBtcPubkeyRaw: e.depositorBtcPubkeyRaw
529
+ },
530
+ r,
531
+ i
532
+ );
533
+ if (l.has(g.vaultId))
534
+ throw new Error(`Duplicate vault in batch: ${g.vaultId}`);
535
+ l.add(g.vaultId), c.push({
536
+ vaultId: g.vaultId,
537
+ peginTxHash: g.peginTxHash
538
+ }), u.push({
539
+ depositorBtcPubKey: i,
540
+ btcPopSignature: n,
541
+ unsignedPrePeginTx: s,
542
+ depositorSignedPeginTx: g.depositorSignedPeginTx,
543
+ hashlock: h.hashlock,
544
+ htlcVout: h.htlcVout,
545
+ referralCode: j,
546
+ depositorPayoutBtcAddress: g.payoutScript,
547
+ depositorWotsPkHash: h.depositorWotsPkHash
548
+ });
549
+ }
550
+ for (const h of c)
551
+ await this.assertVaultDoesNotExist(h.vaultId, h.peginTxHash);
552
+ const p = await this.readPeginFee(e.vaultProvider), d = await this.resolveMaxAcceptableCommissionBps(
553
+ e.vaultProvider,
554
+ e.quotedCommissionBps
555
+ ), f = E({
556
+ abi: a,
557
+ functionName: "submitPeginRequestBatch",
558
+ // `expectedFingerprint` sits BEFORE `requests`, not appended. Reordering
559
+ // these five changes the selector and the call stops existing.
560
+ args: [
561
+ r,
562
+ e.vaultProvider,
563
+ d,
564
+ e.expectedFingerprint,
565
+ u
566
+ ]
567
+ });
568
+ return { ethTxHash: await this.sendAndWait(
569
+ f,
570
+ p * BigInt(e.requests.length),
571
+ !0,
572
+ r
573
+ ), vaults: c };
574
+ }
575
+ assertQuotedCommissionPresentWhenRequired(t) {
576
+ if (t === void 0 && this.config.requireQuotedCommissionBps)
577
+ throw new Error(
578
+ "quotedCommissionBps is required when the wallet approved deposit terms: the registration ceiling must anchor to the approved quote."
579
+ );
580
+ }
581
+ assertPopMatchesEthAccount(t) {
582
+ return this.assertEthAccount(t.depositorEthAddress);
583
+ }
584
+ assertEthAccount(t) {
585
+ const e = this.config.ethWallet.account;
586
+ if (!e) throw new Error("Ethereum wallet account not found");
587
+ if (!R(t, e.address))
588
+ throw new Error(
589
+ `Proof of possession was signed for ${t} but the Ethereum wallet is currently connected to ${e.address}. Reconnect the original account or sign a new proof of possession.`
590
+ );
591
+ return e.address;
592
+ }
593
+ normalizeBtcPubkey(t) {
594
+ return `0x${P(
595
+ m(t.depositorBtcPubkey, "Proof of possession BTC pubkey"),
596
+ "Proof of possession BTC pubkey"
597
+ )}`;
598
+ }
599
+ // `expectedFingerprint` is omitted rather than accepted and ignored: nothing
600
+ // here normalizes it, and requiring it would force the batch loop to thread a
601
+ // value through a per-request helper that has no use for it. It is validated
602
+ // once per call, at the top of each public method.
603
+ normalizeRequest(t, e, r) {
604
+ B(t.hashlock, "hashlock"), B(t.depositorWotsPkHash, "depositorWotsPkHash"), et(t.htlcVout);
605
+ const s = m(
606
+ t.unsignedPrePeginTx,
607
+ "unsignedPrePeginTx"
608
+ ), i = m(
609
+ t.depositorSignedPeginTx,
610
+ "depositorSignedPeginTx"
611
+ ), n = q(i);
612
+ return {
613
+ unsignedPrePeginTx: s,
614
+ depositorSignedPeginTx: i,
615
+ payoutScript: F(
616
+ t.depositorPayoutScriptPubKey,
617
+ r,
618
+ t.depositorBtcPubkeyRaw
619
+ ),
620
+ peginTxHash: n,
621
+ vaultId: m(O(n, e), "vaultId")
622
+ };
623
+ }
624
+ async assertVaultDoesNotExist(t, e) {
625
+ if ((await this.config.publicClient.readContract({
626
+ address: this.config.btcVaultRegistry,
627
+ abi: a,
628
+ functionName: "getBtcVaultBasicInfo",
629
+ args: [t]
630
+ })).depositor !== K)
631
+ throw new Error(
632
+ `Vault already exists (ID: ${t}, peginTxHash: ${e}). Vault IDs are derived from the pegin transaction hash and depositor address. To create a new vault, use different UTXOs or a different amount to generate a unique transaction.`
633
+ );
634
+ }
635
+ async readPeginFee(t) {
636
+ try {
637
+ return await this.config.publicClient.readContract({
638
+ address: this.config.btcVaultRegistry,
639
+ abi: a,
640
+ functionName: "getPegInFee",
641
+ args: [t]
642
+ });
643
+ } catch (e) {
644
+ throw new Error(
645
+ "Failed to query pegin fee from the contract. Please check your network connection and contract address.",
646
+ { cause: e }
647
+ );
648
+ }
649
+ }
650
+ async resolveMaxAcceptableCommissionBps(t, e) {
651
+ let r;
652
+ try {
653
+ r = await new G(
654
+ this.config.publicClient,
655
+ this.config.btcVaultRegistry
656
+ ).getVaultProviderCommission(t);
657
+ } catch (s) {
658
+ throw new Error(
659
+ "Failed to query vault provider commission from the contract. Please check your network connection and contract address.",
660
+ { cause: s }
661
+ );
662
+ }
663
+ if (e !== void 0) {
664
+ if (r > e + y)
665
+ throw new Error(
666
+ `Vault provider commission changed since quote: quoted ${e} bps, chain currently reports ${r} bps (allowed drift ${y} bps). Please refresh and try again.`
667
+ );
668
+ return S(e);
669
+ }
670
+ return S(r);
671
+ }
672
+ async sendAndWait(t, e, r, s) {
673
+ let i = this.assertEthAccount(s), n;
674
+ try {
675
+ n = await this.config.publicClient.estimateGas({
676
+ to: this.config.btcVaultRegistry,
677
+ data: t,
678
+ value: e,
679
+ account: i
680
+ });
681
+ } catch (l) {
682
+ b(l);
683
+ }
684
+ i = this.assertEthAccount(s);
685
+ let c;
686
+ try {
687
+ c = await this.config.ethWallet.sendTransaction({
688
+ to: this.config.btcVaultRegistry,
689
+ data: t,
690
+ value: e,
691
+ gas: n,
692
+ account: i,
693
+ chain: this.config.ethChain
694
+ });
695
+ } catch (l) {
696
+ b(l);
697
+ }
698
+ const u = await N({
699
+ publicClient: this.config.publicClient,
700
+ walletAddress: s,
701
+ hash: c,
702
+ timeout: this.config.receiptTimeoutMs ?? J
703
+ });
704
+ return u.status === "reverted" && b(
705
+ new Error(
706
+ `${r ? "Batch transaction" : "Transaction"} reverted. Hash: ${u.transactionHash}. Check a block explorer for details.`
707
+ )
708
+ ), u.transactionHash;
709
+ }
710
+ }
711
+ export {
712
+ y as C,
713
+ L as M,
714
+ ut as V,
715
+ G as a,
716
+ S as c
717
+ };
718
+ //# sourceMappingURL=pegin-registration-client-BWMwxtr8.js.map