@babylonlabs-io/ts-sdk 0.58.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/BTCVaultRegistry.abi-COxUdCTR.cjs +2 -0
  2. package/dist/BTCVaultRegistry.abi-COxUdCTR.cjs.map +1 -0
  3. package/dist/{BTCVaultRegistry.abi-CixOlp3B.js → BTCVaultRegistry.abi-Ch0IiqNK.js} +19 -1
  4. package/dist/BTCVaultRegistry.abi-Ch0IiqNK.js.map +1 -0
  5. package/dist/{PeginManager-CogqZaa2.cjs → PeginManager-792nHwLl.cjs} +2 -2
  6. package/dist/{PeginManager-CogqZaa2.cjs.map → PeginManager-792nHwLl.cjs.map} +1 -1
  7. package/dist/{PeginManager-C8ixWlUM.js → PeginManager-Ddn6NDm3.js} +3 -3
  8. package/dist/{PeginManager-C8ixWlUM.js.map → PeginManager-Ddn6NDm3.js.map} +1 -1
  9. package/dist/{batchPoll-B0VxT62K.js → batchPoll-qXRNTvnR.js} +3 -3
  10. package/dist/{batchPoll-B0VxT62K.js.map → batchPoll-qXRNTvnR.js.map} +1 -1
  11. package/dist/{batchPoll-D5IDDOa8.cjs → batchPoll-xvVjiJXJ.cjs} +2 -2
  12. package/dist/{batchPoll-D5IDDOa8.cjs.map → batchPoll-xvVjiJXJ.cjs.map} +1 -1
  13. package/dist/{buildAndBroadcastRefund-DBA-Mp4I.js → buildAndBroadcastRefund-C-rbYMy6.js} +455 -428
  14. package/dist/buildAndBroadcastRefund-C-rbYMy6.js.map +1 -0
  15. package/dist/buildAndBroadcastRefund-HBOCjeUh.cjs +2 -0
  16. package/dist/buildAndBroadcastRefund-HBOCjeUh.cjs.map +1 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.js +52 -51
  19. package/dist/{mempoolApi-CMHEz4ez.js → mempoolApi-BTkbTDSY.js} +2 -2
  20. package/dist/{mempoolApi-CMHEz4ez.js.map → mempoolApi-BTkbTDSY.js.map} +1 -1
  21. package/dist/{mempoolApi-DfD3_Y6v.cjs → mempoolApi-DjwZ130O.cjs} +2 -2
  22. package/dist/{mempoolApi-DfD3_Y6v.cjs.map → mempoolApi-DjwZ130O.cjs.map} +1 -1
  23. package/dist/{peginState-BB81JI6I.js → peginState-CxDiaKuk.js} +26 -19
  24. package/dist/peginState-CxDiaKuk.js.map +1 -0
  25. package/dist/peginState-eaQ4IO_R.cjs +2 -0
  26. package/dist/peginState-eaQ4IO_R.cjs.map +1 -0
  27. package/dist/{reservation-CbAXa7VG.js → reservation-B4i_PQhY.js} +2 -2
  28. package/dist/{reservation-CbAXa7VG.js.map → reservation-B4i_PQhY.js.map} +1 -1
  29. package/dist/{reservation-RGKvg2x6.cjs → reservation-CDbInVw0.cjs} +2 -2
  30. package/dist/{reservation-RGKvg2x6.cjs.map → reservation-CDbInVw0.cjs.map} +1 -1
  31. package/dist/tbv/core/clients/index.cjs +1 -1
  32. package/dist/tbv/core/clients/index.js +2 -2
  33. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +14 -0
  34. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  35. package/dist/tbv/core/contracts/index.cjs +1 -1
  36. package/dist/tbv/core/contracts/index.js +1 -1
  37. package/dist/tbv/core/index.cjs +1 -1
  38. package/dist/tbv/core/index.js +58 -57
  39. package/dist/tbv/core/managers/index.cjs +1 -1
  40. package/dist/tbv/core/managers/index.js +1 -1
  41. package/dist/tbv/core/services/activation/activateVault.d.ts +45 -0
  42. package/dist/tbv/core/services/activation/activateVault.d.ts.map +1 -1
  43. package/dist/tbv/core/services/activation/index.d.ts +1 -1
  44. package/dist/tbv/core/services/activation/index.d.ts.map +1 -1
  45. package/dist/tbv/core/services/deposit/peginState.d.ts +24 -0
  46. package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
  47. package/dist/tbv/core/services/index.cjs +1 -1
  48. package/dist/tbv/core/services/index.js +34 -33
  49. package/dist/tbv/core/utils/index.cjs +1 -1
  50. package/dist/tbv/core/utils/index.js +1 -1
  51. package/dist/tbv/index.cjs +1 -1
  52. package/dist/tbv/index.js +58 -57
  53. package/dist/tbv/integrations/aave/index.cjs +1 -1
  54. package/dist/tbv/integrations/aave/index.cjs.map +1 -1
  55. package/dist/tbv/integrations/aave/index.d.ts +2 -0
  56. package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
  57. package/dist/tbv/integrations/aave/index.js +2 -0
  58. package/package.json +1 -1
  59. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs +0 -2
  60. package/dist/BTCVaultRegistry.abi-AUAyCHal.cjs.map +0 -1
  61. package/dist/BTCVaultRegistry.abi-CixOlp3B.js.map +0 -1
  62. package/dist/buildAndBroadcastRefund-BL8u-Ti4.cjs +0 -2
  63. package/dist/buildAndBroadcastRefund-BL8u-Ti4.cjs.map +0 -1
  64. package/dist/buildAndBroadcastRefund-DBA-Mp4I.js.map +0 -1
  65. package/dist/peginState-BB81JI6I.js.map +0 -1
  66. package/dist/peginState-CBBJw4Za.cjs +0 -2
  67. package/dist/peginState-CBBJw4Za.cjs.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";const e=[{type:"function",name:"submitPeginRequest",inputs:[{name:"depositor",type:"address",internalType:"address"},{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"btcPopSignature",type:"bytes",internalType:"bytes"},{name:"unsignedPrePeginTx",type:"bytes",internalType:"bytes"},{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"maxAcceptableCommissionBps",type:"uint16",internalType:"uint16"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"depositorPayoutBtcAddress",type:"bytes",internalType:"bytes"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"payable"},{type:"function",name:"submitPeginRequest",inputs:[{name:"depositor",type:"address",internalType:"address"},{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"btcPopSignature",type:"bytes",internalType:"bytes"},{name:"unsignedPrePeginTx",type:"bytes",internalType:"bytes"},{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"maxAcceptableCommissionBps",type:"uint16",internalType:"uint16"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"referralCode",type:"uint32",internalType:"uint32"},{name:"depositorPayoutBtcAddress",type:"bytes",internalType:"bytes"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"payable"},{type:"function",name:"submitPeginRequestBatch",inputs:[{name:"depositor",type:"address",internalType:"address"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"maxAcceptableCommissionBps",type:"uint16",internalType:"uint16"},{name:"requests",type:"tuple[]",internalType:"struct BTCVaultRegistryTypes.BatchPeginRequest[]",components:[{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"btcPopSignature",type:"bytes",internalType:"bytes"},{name:"unsignedPrePeginTx",type:"bytes",internalType:"bytes"},{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"referralCode",type:"uint32",internalType:"uint32"},{name:"depositorPayoutBtcAddress",type:"bytes",internalType:"bytes"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"}]}],outputs:[{name:"vaultIds",type:"bytes32[]",internalType:"bytes32[]"}],stateMutability:"payable"},{type:"function",name:"activateVaultWithSecret",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"},{name:"activationMetadata",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"activateVaultWithSecretAndRedeem",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"getPegInFee",inputs:[{name:"vaultProvider",type:"address",internalType:"address"}],outputs:[{name:"totalFee",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getVaultProviderBTCKey",inputs:[{name:"vpAddr",type:"address",internalType:"address"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getCurrentOperationBtcKey",inputs:[{name:"provider",type:"address",internalType:"address"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getOperationBtcKeyAtEpoch",inputs:[{name:"provider",type:"address",internalType:"address"},{name:"epoch",type:"uint64",internalType:"uint64"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getPayoutScriptAtEpoch",inputs:[{name:"provider",type:"address",internalType:"address"},{name:"epoch",type:"uint64",internalType:"uint64"}],outputs:[{name:"",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getVaultProviderCommission",inputs:[{name:"vpAddr",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"getBtcVaultBasicInfo",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"vBasic",type:"tuple",internalType:"struct BTCVaultTypes.BTCVaultBasicInfo",components:[{name:"depositor",type:"address",internalType:"address"},{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"status",type:"uint8",internalType:"enum IBTCVaultRegistry.BTCVaultStatus"},{name:"applicationEntryPoint",type:"address",internalType:"address"},{name:"createdAt",type:"uint256",internalType:"uint256"}]}],stateMutability:"view"},{type:"error",name:"InvalidPeginFee",inputs:[{name:"provided",type:"uint256",internalType:"uint256"},{name:"required",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidSecret",inputs:[]},{type:"error",name:"ActivationDeadlineExpired",inputs:[]},{type:"error",name:"InvalidHashlock",inputs:[]},{type:"error",name:"DuplicateHashlock",inputs:[]},{type:"error",name:"CapExceeded",inputs:[]},{type:"error",name:"InvalidOutputIndex",inputs:[]},{type:"error",name:"PeginSignaturesIncomplete",inputs:[]},{type:"function",name:"getBtcVaultProtocolInfo",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"vProtocol",type:"tuple",internalType:"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo",components:[{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"universalChallengersVersion",type:"uint16",internalType:"uint16"},{name:"appVaultKeepersVersion",type:"uint16",internalType:"uint16"},{name:"offchainParamsVersion",type:"uint16",internalType:"uint16"},{name:"verifiedAt",type:"uint256",internalType:"uint256"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"depositorPopSignature",type:"bytes",internalType:"bytes"},{name:"prePeginTxHash",type:"bytes32",internalType:"bytes32"},{name:"vaultProviderCommissionBps",type:"uint16",internalType:"uint16"},{name:"claimExpiredUntil",type:"uint256",internalType:"uint256"},{name:"vaultCoreVersion",type:"uint16",internalType:"uint16"}]}],stateMutability:"view"},{type:"function",name:"protocolParams",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IProtocolParams"}],stateMutability:"view"},{type:"function",name:"applicationRegistry",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IApplicationRegistry"}],stateMutability:"view"},{type:"error",name:"ZeroAddress",inputs:[]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"InvalidAmount",inputs:[]},{type:"error",name:"TransferFailed",inputs:[]},{type:"error",name:"InvalidTransaction",inputs:[]},{type:"error",name:"EmptyPayoutAddress",inputs:[]},{type:"error",name:"PayoutAddressTooLong",inputs:[]},{type:"error",name:"VaultAlreadyExists",inputs:[]},{type:"error",name:"VaultFeeAlreadyEscrowed",inputs:[]},{type:"error",name:"NoEscrowedFees",inputs:[]},{type:"error",name:"BTCVaultNotFound",inputs:[]},{type:"error",name:"InvalidBTCVaultStatus",inputs:[]},{type:"error",name:"PeginNotExpired",inputs:[]},{type:"error",name:"InvalidParticipantsList",inputs:[]},{type:"error",name:"DuplicateParticipant",inputs:[]},{type:"error",name:"ParticipantRoleOverlap",inputs:[]},{type:"error",name:"NotAuthorizedToACK",inputs:[]},{type:"error",name:"UnauthorizedVaultKeeper",inputs:[]},{type:"error",name:"BlocklistedVaultKeeper",inputs:[]},{type:"error",name:"PeginTransactionExpired",inputs:[]},{type:"error",name:"PrePeginOutputAlreadyUsed",inputs:[]},{type:"error",name:"PeginTransactionAlreadyUsed",inputs:[]},{type:"error",name:"InvalidPeginFee",inputs:[{name:"provided",type:"uint256",internalType:"uint256"},{name:"required",type:"uint256",internalType:"uint256"}]},{type:"error",name:"AmountBelowMinimumThreshold",inputs:[{name:"actual",type:"uint256",internalType:"uint256"},{name:"minimum",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidOutputIndex",inputs:[{name:"provided",type:"uint256",internalType:"uint256"},{name:"maxValid",type:"uint256",internalType:"uint256"}]},{type:"error",name:"TooManyHtlcOutputs",inputs:[{name:"outputCount",type:"uint256",internalType:"uint256"},{name:"maxAllowed",type:"uint256",internalType:"uint256"}]},{type:"error",name:"VaultBelowMinimum",inputs:[{name:"actual",type:"uint256",internalType:"uint256"},{name:"minimum",type:"uint256",internalType:"uint256"}]},{type:"error",name:"VaultAboveMaximum",inputs:[{name:"actual",type:"uint256",internalType:"uint256"},{name:"maximum",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidBTCPublicKey",inputs:[]},{type:"error",name:"InvalidDepositorWotsPkHash",inputs:[]},{type:"error",name:"InvalidBTCProofOfPossession",inputs:[]},{type:"error",name:"EthKeyAlreadyRegistered",inputs:[]},{type:"error",name:"BtcKeyAlreadyRegistered",inputs:[]},{type:"error",name:"InvalidRegistrationFee",inputs:[]},{type:"error",name:"CommissionBelowMinimum",inputs:[{name:"provided",type:"uint16",internalType:"uint16"},{name:"minimum",type:"uint16",internalType:"uint16"}]},{type:"error",name:"CommissionAboveMaximum",inputs:[{name:"provided",type:"uint16",internalType:"uint16"}]},{type:"error",name:"CommissionUnchanged",inputs:[]},{type:"error",name:"VaultProviderCommissionExceeded",inputs:[{name:"maxAcceptable",type:"uint16",internalType:"uint16"},{name:"actual",type:"uint16",internalType:"uint16"}]},{type:"error",name:"VaultProviderNotRegistered",inputs:[]},{type:"error",name:"ApplicationAlreadyRegistered",inputs:[]},{type:"error",name:"ApplicationNotRegistered",inputs:[]},{type:"error",name:"ApplicationNotActive",inputs:[]},{type:"error",name:"InvalidApplicationStatus",inputs:[]},{type:"error",name:"OnlyApplicationEntryPoint",inputs:[]},{type:"error",name:"EmptyVaultKeepers",inputs:[]},{type:"error",name:"NoUniversalChallengersConfigured",inputs:[]},{type:"error",name:"NoAppVaultKeepersConfigured",inputs:[]},{type:"error",name:"PeginSignaturesIncomplete",inputs:[]},{type:"error",name:"InvalidSignatureLength",inputs:[]},{type:"error",name:"PeginInputSignatureAlreadySubmitted",inputs:[]},{type:"error",name:"InvalidHashlock",inputs:[]},{type:"error",name:"DuplicateHashlock",inputs:[]},{type:"error",name:"InvalidSecret",inputs:[]},{type:"error",name:"ActivationDeadlineExpired",inputs:[]},{type:"error",name:"PostExpiryGraceWindowElapsed",inputs:[]},{type:"error",name:"CapExceeded",inputs:[]}];exports.BTCVaultRegistryABI=e;
2
+ //# sourceMappingURL=BTCVaultRegistry.abi-COxUdCTR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BTCVaultRegistry.abi-COxUdCTR.cjs","sources":["../src/tbv/core/contracts/abis/BTCVaultRegistry.abi.ts"],"sourcesContent":["/**\n * BTCVaultRegistry Contract ABI\n *\n * Minimal ABI containing only the functions needed by the SDK.\n * Full ABI is available in the vault service package.\n *\n * @module contracts/abis/BTCVaultRegistry\n */\n\n/**\n * Minimal ABI for BTCVaultRegistry contract.\n * Contains submitPeginRequest, submitPeginRequestBatch, activateVaultWithSecret, getPegInFee, getBtcVaultBasicInfo, and getVaultProviderCommission.\n */\nexport const BTCVaultRegistryABI = [\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"referralCode\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequestBatch\",\n inputs: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n { name: \"vaultProvider\", type: \"address\", internalType: \"address\" },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"requests\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultRegistryTypes.BatchPeginRequest[]\",\n components: [\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"btcPopSignature\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"unsignedPrePeginTx\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n { name: \"hashlock\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"htlcVout\", type: \"uint8\", internalType: \"uint8\" },\n { name: \"referralCode\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n outputs: [\n { name: \"vaultIds\", type: \"bytes32[]\", internalType: \"bytes32[]\" },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecret\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"activationMetadata\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecretAndRedeem\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"getPegInFee\",\n inputs: [\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"totalFee\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getVaultProviderBTCKey\",\n inputs: [{ name: \"vpAddr\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n // --- RFC-006 operation-key resolution ---------------------------------\n // A vault provider's BTC key is no longer the fixed registration key\n // returned by `getVaultProviderBTCKey` above: it is an append-only history\n // of *operation* keys, rotated by the provider's cold ETH admin key. Each\n // vault freezes a `vpKeyEpoch` at `submitPeginRequest` and resolves the key\n // bonded at that epoch, so a later rotation never invalidates a live vault.\n //\n // `getCurrentOperationBtcKey` falls back on-chain to the registration key at\n // version 0, so adopting it is a no-op for a provider that never rotated.\n //\n // `getPayoutScriptAtEpoch` does NOT behave that way, and assuming it did was\n // wrong in an earlier revision of this comment. A payout script is mandatory\n // at registration and stored as version 1, so on an RFC-006 registry this\n // returns the operator's own registered script from the very first epoch —\n // not a BIP-86 derivation of its key. The contract's BIP-86 branch is a\n // migration default for pre-RFC-006 rows and is not reachable from\n // registration. An operator whose registered script happens to equal\n // bip86(key) is a coincidence of what it chose to register, not a fallback.\n //\n // This is why depositor payout validation must accept the legacy BIP-86 form\n // alongside the registered one: a payout graph is built once at BaBe Setup\n // and never rebuilt, so a vault whose graph predates its network's\n // btc-vault#2440 upgrade pays BIP-86 for the rest of its life. See\n // `acceptedPayoutScriptHexes` in `primitives/psbt/payout.ts`.\n {\n type: \"function\",\n name: \"getCurrentOperationBtcKey\",\n inputs: [{ name: \"provider\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getOperationBtcKeyAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getPayoutScriptAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes\", internalType: \"bytes\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getVaultProviderCommission\",\n inputs: [{ name: \"vpAddr\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"uint16\", internalType: \"uint16\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getBtcVaultBasicInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vBasic\",\n type: \"tuple\",\n internalType: \"struct BTCVaultTypes.BTCVaultBasicInfo\",\n components: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"amount\", type: \"uint256\", internalType: \"uint256\" },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"status\",\n type: \"uint8\",\n internalType: \"enum IBTCVaultRegistry.BTCVaultStatus\",\n },\n {\n name: \"applicationEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n { name: \"createdAt\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n {\n name: \"provided\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"required\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidSecret\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"ActivationDeadlineExpired\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"DuplicateHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"CapExceeded\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"PeginSignaturesIncomplete\",\n inputs: [],\n },\n {\n type: \"function\",\n name: \"getBtcVaultProtocolInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vProtocol\",\n type: \"tuple\",\n internalType: \"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo\",\n components: [\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"universalChallengersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"appVaultKeepersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"offchainParamsVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"verifiedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"prePeginTxHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"vaultProviderCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"claimExpiredUntil\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"vaultCoreVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"protocolParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IProtocolParams\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"applicationRegistry\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IApplicationRegistry\",\n },\n ],\n stateMutability: \"view\",\n },\n // ============================================================================\n // Errors — needed so viem can decode revert data into a named error.\n // Without these, every revert surfaces as \"Execution reverted for an\n // unknown reason.\" Mirrors errors thrown from BTCVaultRegistry's reachable\n // code paths (pegin submission, ACK, activation). Source:\n // https://github.com/babylonlabs-io/vault-contracts-aave-v4/blob/652c4582/src/protocol/lib/types/Errors.sol\n // ============================================================================\n { type: \"error\", name: \"ZeroAddress\", inputs: [] },\n { type: \"error\", name: \"Unauthorized\", inputs: [] },\n { type: \"error\", name: \"InvalidAmount\", inputs: [] },\n { type: \"error\", name: \"TransferFailed\", inputs: [] },\n { type: \"error\", name: \"InvalidTransaction\", inputs: [] },\n { type: \"error\", name: \"EmptyPayoutAddress\", inputs: [] },\n { type: \"error\", name: \"PayoutAddressTooLong\", inputs: [] },\n { type: \"error\", name: \"VaultAlreadyExists\", inputs: [] },\n { type: \"error\", name: \"VaultFeeAlreadyEscrowed\", inputs: [] },\n { type: \"error\", name: \"NoEscrowedFees\", inputs: [] },\n { type: \"error\", name: \"BTCVaultNotFound\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCVaultStatus\", inputs: [] },\n { type: \"error\", name: \"PeginNotExpired\", inputs: [] },\n { type: \"error\", name: \"InvalidParticipantsList\", inputs: [] },\n { type: \"error\", name: \"DuplicateParticipant\", inputs: [] },\n { type: \"error\", name: \"ParticipantRoleOverlap\", inputs: [] },\n { type: \"error\", name: \"NotAuthorizedToACK\", inputs: [] },\n { type: \"error\", name: \"UnauthorizedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"BlocklistedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionExpired\", inputs: [] },\n { type: \"error\", name: \"PrePeginOutputAlreadyUsed\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionAlreadyUsed\", inputs: [] },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"required\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"AmountBelowMinimumThreshold\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxValid\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"TooManyHtlcOutputs\",\n inputs: [\n { name: \"outputCount\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxAllowed\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultBelowMinimum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultAboveMaximum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maximum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n { type: \"error\", name: \"InvalidBTCPublicKey\", inputs: [] },\n { type: \"error\", name: \"InvalidDepositorWotsPkHash\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCProofOfPossession\", inputs: [] },\n { type: \"error\", name: \"EthKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"BtcKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"InvalidRegistrationFee\", inputs: [] },\n {\n type: \"error\",\n name: \"CommissionBelowMinimum\",\n inputs: [\n { name: \"provided\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"minimum\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n {\n type: \"error\",\n name: \"CommissionAboveMaximum\",\n inputs: [{ name: \"provided\", type: \"uint16\", internalType: \"uint16\" }],\n },\n { type: \"error\", name: \"CommissionUnchanged\", inputs: [] },\n {\n type: \"error\",\n name: \"VaultProviderCommissionExceeded\",\n inputs: [\n { name: \"maxAcceptable\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"actual\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n { type: \"error\", name: \"VaultProviderNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotActive\", inputs: [] },\n { type: \"error\", name: \"InvalidApplicationStatus\", inputs: [] },\n { type: \"error\", name: \"OnlyApplicationEntryPoint\", inputs: [] },\n { type: \"error\", name: \"EmptyVaultKeepers\", inputs: [] },\n { type: \"error\", name: \"NoUniversalChallengersConfigured\", inputs: [] },\n { type: \"error\", name: \"NoAppVaultKeepersConfigured\", inputs: [] },\n { type: \"error\", name: \"PeginSignaturesIncomplete\", inputs: [] },\n { type: \"error\", name: \"InvalidSignatureLength\", inputs: [] },\n { type: \"error\", name: \"PeginInputSignatureAlreadySubmitted\", inputs: [] },\n { type: \"error\", name: \"InvalidHashlock\", inputs: [] },\n { type: \"error\", name: \"DuplicateHashlock\", inputs: [] },\n { type: \"error\", name: \"InvalidSecret\", inputs: [] },\n { type: \"error\", name: \"ActivationDeadlineExpired\", inputs: [] },\n { type: \"error\", name: \"PostExpiryGraceWindowElapsed\", inputs: [] },\n { type: \"error\", name: \"CapExceeded\", inputs: [] },\n] as const;\n"],"names":["BTCVaultRegistryABI"],"mappings":"aAaO,MAAMA,EAAsB,CACjC,CACE,KAAM,WACN,KAAM,qBACN,OAAQ,CACN,CACE,KAAM,YACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,qBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,kBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,qBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,yBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,gBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,6BACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,WACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,4BACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,sBACN,KAAM,UACN,aAAc,SAAA,CAChB,EAEF,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAAA,CAChB,EAEF,gB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KAAM,4BAA6B,OAAQ,CAAA,CAAC,EAC7D,CAAE,KAAM,QAAS,KAAM,yBAA0B,OAAQ,CAAA,CAAC,EAC1D,CAAE,KAAM,QAAS,KAAM,sCAAuC,OAAQ,CAAA,CAAC,EACvE,CAAE,KAAM,QAAS,KAAM,kBAAmB,OAAQ,CAAA,CAAC,EACnD,CAAE,KAAM,QAAS,KAAM,oBAAqB,OAAQ,CAAA,CAAC,EACrD,CAAE,KAAM,QAAS,KAAM,gBAAiB,OAAQ,CAAA,CAAC,EACjD,CAAE,KAAM,QAAS,KAAM,4BAA6B,OAAQ,CAAA,CAAC,EAC7D,CAAE,KAAM,QAAS,KAAM,+BAAgC,OAAQ,CAAA,CAAC,EAChE,CAAE,KAAM,QAAS,KAAM,cAAe,OAAQ,CAAA,CAAC,CACjD"}
@@ -214,6 +214,24 @@ const e = [
214
214
  outputs: [],
215
215
  stateMutability: "nonpayable"
216
216
  },
217
+ {
218
+ type: "function",
219
+ name: "activateVaultWithSecretAndRedeem",
220
+ inputs: [
221
+ {
222
+ name: "vaultId",
223
+ type: "bytes32",
224
+ internalType: "bytes32"
225
+ },
226
+ {
227
+ name: "s",
228
+ type: "bytes32",
229
+ internalType: "bytes32"
230
+ }
231
+ ],
232
+ outputs: [],
233
+ stateMutability: "nonpayable"
234
+ },
217
235
  {
218
236
  type: "function",
219
237
  name: "getPegInFee",
@@ -632,4 +650,4 @@ const e = [
632
650
  export {
633
651
  e as B
634
652
  };
635
- //# sourceMappingURL=BTCVaultRegistry.abi-CixOlp3B.js.map
653
+ //# sourceMappingURL=BTCVaultRegistry.abi-Ch0IiqNK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BTCVaultRegistry.abi-Ch0IiqNK.js","sources":["../src/tbv/core/contracts/abis/BTCVaultRegistry.abi.ts"],"sourcesContent":["/**\n * BTCVaultRegistry Contract ABI\n *\n * Minimal ABI containing only the functions needed by the SDK.\n * Full ABI is available in the vault service package.\n *\n * @module contracts/abis/BTCVaultRegistry\n */\n\n/**\n * Minimal ABI for BTCVaultRegistry contract.\n * Contains submitPeginRequest, submitPeginRequestBatch, activateVaultWithSecret, getPegInFee, getBtcVaultBasicInfo, and getVaultProviderCommission.\n */\nexport const BTCVaultRegistryABI = [\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"referralCode\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequestBatch\",\n inputs: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n { name: \"vaultProvider\", type: \"address\", internalType: \"address\" },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"requests\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultRegistryTypes.BatchPeginRequest[]\",\n components: [\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"btcPopSignature\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"unsignedPrePeginTx\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n { name: \"hashlock\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"htlcVout\", type: \"uint8\", internalType: \"uint8\" },\n { name: \"referralCode\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n outputs: [\n { name: \"vaultIds\", type: \"bytes32[]\", internalType: \"bytes32[]\" },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecret\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"activationMetadata\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecretAndRedeem\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"getPegInFee\",\n inputs: [\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"totalFee\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getVaultProviderBTCKey\",\n inputs: [{ name: \"vpAddr\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n // --- RFC-006 operation-key resolution ---------------------------------\n // A vault provider's BTC key is no longer the fixed registration key\n // returned by `getVaultProviderBTCKey` above: it is an append-only history\n // of *operation* keys, rotated by the provider's cold ETH admin key. Each\n // vault freezes a `vpKeyEpoch` at `submitPeginRequest` and resolves the key\n // bonded at that epoch, so a later rotation never invalidates a live vault.\n //\n // `getCurrentOperationBtcKey` falls back on-chain to the registration key at\n // version 0, so adopting it is a no-op for a provider that never rotated.\n //\n // `getPayoutScriptAtEpoch` does NOT behave that way, and assuming it did was\n // wrong in an earlier revision of this comment. A payout script is mandatory\n // at registration and stored as version 1, so on an RFC-006 registry this\n // returns the operator's own registered script from the very first epoch —\n // not a BIP-86 derivation of its key. The contract's BIP-86 branch is a\n // migration default for pre-RFC-006 rows and is not reachable from\n // registration. An operator whose registered script happens to equal\n // bip86(key) is a coincidence of what it chose to register, not a fallback.\n //\n // This is why depositor payout validation must accept the legacy BIP-86 form\n // alongside the registered one: a payout graph is built once at BaBe Setup\n // and never rebuilt, so a vault whose graph predates its network's\n // btc-vault#2440 upgrade pays BIP-86 for the rest of its life. See\n // `acceptedPayoutScriptHexes` in `primitives/psbt/payout.ts`.\n {\n type: \"function\",\n name: \"getCurrentOperationBtcKey\",\n inputs: [{ name: \"provider\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getOperationBtcKeyAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getPayoutScriptAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes\", internalType: \"bytes\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getVaultProviderCommission\",\n inputs: [{ name: \"vpAddr\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"uint16\", internalType: \"uint16\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getBtcVaultBasicInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vBasic\",\n type: \"tuple\",\n internalType: \"struct BTCVaultTypes.BTCVaultBasicInfo\",\n components: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"amount\", type: \"uint256\", internalType: \"uint256\" },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"status\",\n type: \"uint8\",\n internalType: \"enum IBTCVaultRegistry.BTCVaultStatus\",\n },\n {\n name: \"applicationEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n { name: \"createdAt\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n {\n name: \"provided\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"required\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidSecret\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"ActivationDeadlineExpired\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"DuplicateHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"CapExceeded\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"PeginSignaturesIncomplete\",\n inputs: [],\n },\n {\n type: \"function\",\n name: \"getBtcVaultProtocolInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vProtocol\",\n type: \"tuple\",\n internalType: \"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo\",\n components: [\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"universalChallengersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"appVaultKeepersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"offchainParamsVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"verifiedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"prePeginTxHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"vaultProviderCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"claimExpiredUntil\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"vaultCoreVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"protocolParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IProtocolParams\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"applicationRegistry\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IApplicationRegistry\",\n },\n ],\n stateMutability: \"view\",\n },\n // ============================================================================\n // Errors — needed so viem can decode revert data into a named error.\n // Without these, every revert surfaces as \"Execution reverted for an\n // unknown reason.\" Mirrors errors thrown from BTCVaultRegistry's reachable\n // code paths (pegin submission, ACK, activation). Source:\n // https://github.com/babylonlabs-io/vault-contracts-aave-v4/blob/652c4582/src/protocol/lib/types/Errors.sol\n // ============================================================================\n { type: \"error\", name: \"ZeroAddress\", inputs: [] },\n { type: \"error\", name: \"Unauthorized\", inputs: [] },\n { type: \"error\", name: \"InvalidAmount\", inputs: [] },\n { type: \"error\", name: \"TransferFailed\", inputs: [] },\n { type: \"error\", name: \"InvalidTransaction\", inputs: [] },\n { type: \"error\", name: \"EmptyPayoutAddress\", inputs: [] },\n { type: \"error\", name: \"PayoutAddressTooLong\", inputs: [] },\n { type: \"error\", name: \"VaultAlreadyExists\", inputs: [] },\n { type: \"error\", name: \"VaultFeeAlreadyEscrowed\", inputs: [] },\n { type: \"error\", name: \"NoEscrowedFees\", inputs: [] },\n { type: \"error\", name: \"BTCVaultNotFound\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCVaultStatus\", inputs: [] },\n { type: \"error\", name: \"PeginNotExpired\", inputs: [] },\n { type: \"error\", name: \"InvalidParticipantsList\", inputs: [] },\n { type: \"error\", name: \"DuplicateParticipant\", inputs: [] },\n { type: \"error\", name: \"ParticipantRoleOverlap\", inputs: [] },\n { type: \"error\", name: \"NotAuthorizedToACK\", inputs: [] },\n { type: \"error\", name: \"UnauthorizedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"BlocklistedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionExpired\", inputs: [] },\n { type: \"error\", name: \"PrePeginOutputAlreadyUsed\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionAlreadyUsed\", inputs: [] },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"required\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"AmountBelowMinimumThreshold\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxValid\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"TooManyHtlcOutputs\",\n inputs: [\n { name: \"outputCount\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxAllowed\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultBelowMinimum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultAboveMaximum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maximum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n { type: \"error\", name: \"InvalidBTCPublicKey\", inputs: [] },\n { type: \"error\", name: \"InvalidDepositorWotsPkHash\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCProofOfPossession\", inputs: [] },\n { type: \"error\", name: \"EthKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"BtcKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"InvalidRegistrationFee\", inputs: [] },\n {\n type: \"error\",\n name: \"CommissionBelowMinimum\",\n inputs: [\n { name: \"provided\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"minimum\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n {\n type: \"error\",\n name: \"CommissionAboveMaximum\",\n inputs: [{ name: \"provided\", type: \"uint16\", internalType: \"uint16\" }],\n },\n { type: \"error\", name: \"CommissionUnchanged\", inputs: [] },\n {\n type: \"error\",\n name: \"VaultProviderCommissionExceeded\",\n inputs: [\n { name: \"maxAcceptable\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"actual\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n { type: \"error\", name: \"VaultProviderNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotActive\", inputs: [] },\n { type: \"error\", name: \"InvalidApplicationStatus\", inputs: [] },\n { type: \"error\", name: \"OnlyApplicationEntryPoint\", inputs: [] },\n { type: \"error\", name: \"EmptyVaultKeepers\", inputs: [] },\n { type: \"error\", name: \"NoUniversalChallengersConfigured\", inputs: [] },\n { type: \"error\", name: \"NoAppVaultKeepersConfigured\", inputs: [] },\n { type: \"error\", name: \"PeginSignaturesIncomplete\", inputs: [] },\n { type: \"error\", name: \"InvalidSignatureLength\", inputs: [] },\n { type: \"error\", name: \"PeginInputSignatureAlreadySubmitted\", inputs: [] },\n { type: \"error\", name: \"InvalidHashlock\", inputs: [] },\n { type: \"error\", name: \"DuplicateHashlock\", inputs: [] },\n { type: \"error\", name: \"InvalidSecret\", inputs: [] },\n { type: \"error\", name: \"ActivationDeadlineExpired\", inputs: [] },\n { type: \"error\", name: \"PostExpiryGraceWindowElapsed\", inputs: [] },\n { type: \"error\", name: \"CapExceeded\", inputs: [] },\n] as const;\n"],"names":["BTCVaultRegistryABI"],"mappings":"AAaO,MAAMA,IAAsB;AAAA,EACjC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QAC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A0B,QAAQ,CAAA,EAAC;AAAA,EAC1D,EAAE,MAAM,SAAS,MAAM,uCAAuC,QAAQ,CAAA,EAAC;AAAA,EACvE,EAAE,MAAM,SAAS,MAAM,mBAAmB,QAAQ,CAAA,EAAC;AAAA,EACnD,EAAE,MAAM,SAAS,MAAM,qBAAqB,QAAQ,CAAA,EAAC;AAAA,EACrD,EAAE,MAAM,SAAS,MAAM,iBAAiB,QAAQ,CAAA,EAAC;AAAA,EACjD,EAAE,MAAM,SAAS,MAAM,6BAA6B,QAAQ,CAAA,EAAC;AAAA,EAC7D,EAAE,MAAM,SAAS,MAAM,gCAAgC,QAAQ,CAAA,EAAC;AAAA,EAChE,EAAE,MAAM,SAAS,MAAM,eAAe,QAAQ,CAAA,EAAC;AACjD;"}
@@ -1,2 +1,2 @@
1
- "use strict";var Ht=Object.defineProperty;var Rt=(s,e,t)=>e in s?Ht(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var B=(s,e,t)=>Rt(s,typeof e!="symbol"?e+"":e,t);const x=require("./sha2-DsrLC4NM.cjs"),K=require("bitcoinjs-lib"),tt=require("buffer"),V=require("viem"),R=require("./BTCVaultRegistry.abi-AUAyCHal.cjs"),O=require("./errors-CGcNP0rV.cjs"),W=require("@babylonlabs-io/babylon-tbv-rust-wasm"),$=require("./verifyScriptPathSchnorrSignature-CYjK4IP_.cjs"),z=require("./peginInput-Ci921gTl.cjs"),d=require("./bitcoin-m84N5a8o.cjs"),D=require("./constants-DU5CGcqO.cjs"),Ot=require("./signing-Bnsro0hE.cjs"),it=require("./validation-CDbOaDj7.cjs"),$t=require("./deriveVaultRoot-p4uGsM7w.cjs"),N=require("./signPsbtsWithFallback-Xs4jZw5z.cjs"),H=require("./waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs"),at=require("./fundPeginTransaction-BLD8FRL9.cjs"),et=require("./mempoolApi-DfD3_Y6v.cjs");function Vt(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const ft=Vt(K),X=BigInt(2**32-1),ct=BigInt(32);function Mt(s,e=!1){return e?{h:Number(s&X),l:Number(s>>ct&X)}:{h:Number(s>>ct&X)|0,l:Number(s&X)|0}}function Ft(s,e=!1){const t=s.length;let n=new Uint32Array(t),o=new Uint32Array(t);for(let r=0;r<t;r++){const{h:i,l:a}=Mt(s[r],e);[n[r],o[r]]=[i,a]}return[n,o]}const Ut=(s,e,t)=>s<<t|e>>>32-t,Nt=(s,e,t)=>e<<t|s>>>32-t,Wt=(s,e,t)=>e<<t-32|s>>>64-t,Dt=(s,e,t)=>s<<t-32|e>>>64-t,Xt=64;function pt(s){const e=s.prepeginTxid.toLowerCase();if(!/^[0-9a-f]+$/.test(e)||e.length!==Xt)throw new Error(`buildDepositTerms: prepeginTxid must be 64 hex chars, got "${s.prepeginTxid}"`);if(s.peginAmounts.length===0)throw new Error("buildDepositTerms: at least one pegin amount is required");if(s.timelockPegin<=0||s.timelockAssert<=0||s.timelockRefund<=0)throw new Error("buildDepositTerms: timelocks must be positive");if(!Number.isInteger(s.maxAcceptableCommissionBps)||s.maxAcceptableCommissionBps<0||s.maxAcceptableCommissionBps>=D.MAX_VP_COMMISSION_BPS_EXCLUSIVE)throw new Error(`buildDepositTerms: maxAcceptableCommissionBps must be an integer in [0, ${D.MAX_VP_COMMISSION_BPS_EXCLUSIVE}), got ${s.maxAcceptableCommissionBps}`);const t=BigInt(D.BPS_DENOMINATOR),n=s.peginAmounts.map((o,r)=>({htlcVout:r,vaultProviderBtcPubkey:s.vaultProviderBtcPubkey,peginAmount:o,commissionFee:o*BigInt(s.maxAcceptableCommissionBps)/t,depositorClaimValue:s.depositorClaimValue,peginMaxFee:s.peginMaxFee}));return{vaultCoreVersion:s.vaultCoreVersion,protocolFeeRate:s.protocolFeeRate,timelockPegin:s.timelockPegin,timelockAssert:s.timelockAssert,timelockRefund:s.timelockRefund,prepeginTxid:e,prepeginMaxFee:s.prepeginMaxFee,vaultKeeperBtcPubkeys:[...s.vaultKeeperBtcPubkeys],universalChallengerBtcPubkeys:[...s.universalChallengerBtcPubkeys],vaults:n}}const Lt=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),mt=Uint8Array.from(new Array(16).fill(0).map((s,e)=>e)),qt=mt.map(s=>(9*s+5)%16),Pt=(()=>{const t=[[mt],[qt]];for(let n=0;n<4;n++)for(let o of t)o.push(o[n].map(r=>Lt[r]));return t})(),bt=Pt[0],xt=Pt[1],wt=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(s=>Uint8Array.from(s)),Kt=bt.map((s,e)=>s.map(t=>wt[e][t])),Gt=xt.map((s,e)=>s.map(t=>wt[e][t])),zt=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),jt=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function lt(s,e,t,n){return s===0?e^t^n:s===1?e&t|~e&n:s===2?(e|~t)^n:s===3?e&n|t&~n:e^(t|~n)}const L=new Uint32Array(16);class Yt extends x.HashMD{constructor(){super(64,20,8,!0);B(this,"h0",1732584193);B(this,"h1",-271733879);B(this,"h2",-1732584194);B(this,"h3",271733878);B(this,"h4",-1009589776)}get(){const{h0:t,h1:n,h2:o,h3:r,h4:i}=this;return[t,n,o,r,i]}set(t,n,o,r,i){this.h0=t|0,this.h1=n|0,this.h2=o|0,this.h3=r|0,this.h4=i|0}process(t,n){for(let g=0;g<16;g++,n+=4)L[g]=t.getUint32(n,!0);let o=this.h0|0,r=o,i=this.h1|0,a=i,c=this.h2|0,u=c,l=this.h3|0,P=l,w=this.h4|0,y=w;for(let g=0;g<5;g++){const v=4-g,T=zt[g],p=jt[g],S=bt[g],m=xt[g],b=Kt[g],E=Gt[g];for(let h=0;h<16;h++){const k=x.rotl(o+lt(g,i,c,l)+L[S[h]]+T,b[h])+w|0;o=w,w=l,l=x.rotl(c,10)|0,c=i,i=k}for(let h=0;h<16;h++){const k=x.rotl(r+lt(v,a,u,P)+L[m[h]]+p,E[h])+y|0;r=y,y=P,P=x.rotl(u,10)|0,u=a,a=k}}this.set(this.h1+c+P|0,this.h2+l+y|0,this.h3+w+r|0,this.h4+o+a|0,this.h0+i+u|0)}roundClean(){x.clean(L)}destroy(){this.destroyed=!0,x.clean(this.buffer),this.set(0,0,0,0,0)}}const Qt=x.createHasher(()=>new Yt),Zt=BigInt(0),F=BigInt(1),Jt=BigInt(2),te=BigInt(7),ee=BigInt(256),se=BigInt(113),yt=[],kt=[],Bt=[];for(let s=0,e=F,t=1,n=0;s<24;s++){[t,n]=[n,(2*t+3*n)%5],yt.push(2*(5*n+t)),kt.push((s+1)*(s+2)/2%64);let o=Zt;for(let r=0;r<7;r++)e=(e<<F^(e>>te)*se)%ee,e&Jt&&(o^=F<<(F<<BigInt(r))-F);Bt.push(o)}const Tt=Ft(Bt,!0),ne=Tt[0],oe=Tt[1],ut=(s,e,t)=>t>32?Wt(s,e,t):Ut(s,e,t),ht=(s,e,t)=>t>32?Dt(s,e,t):Nt(s,e,t);function re(s,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)t[i]=s[i]^s[i+10]^s[i+20]^s[i+30]^s[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,c=(i+2)%10,u=t[c],l=t[c+1],P=ut(u,l,1)^t[a],w=ht(u,l,1)^t[a+1];for(let y=0;y<50;y+=10)s[i+y]^=P,s[i+y+1]^=w}let o=s[2],r=s[3];for(let i=0;i<24;i++){const a=kt[i],c=ut(o,r,a),u=ht(o,r,a),l=yt[i];o=s[l],r=s[l+1],s[l]=c,s[l+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)t[a]=s[i+a];for(let a=0;a<10;a++)s[i+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=ne[n],s[1]^=oe[n]}x.clean(t)}class ot{constructor(e,t,n,o=!1,r=24){B(this,"state");B(this,"pos",0);B(this,"posOut",0);B(this,"finished",!1);B(this,"state32");B(this,"destroyed",!1);B(this,"blockLen");B(this,"suffix");B(this,"outputLen");B(this,"enableXOF",!1);B(this,"rounds");if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=o,this.rounds=r,x.anumber(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=x.u32(this.state)}clone(){return this._cloneInto()}keccak(){x.swap32IfBE(this.state32),re(this.state32,this.rounds),x.swap32IfBE(this.state32),this.posOut=0,this.pos=0}update(e){x.aexists(this),x.abytes(e);const{blockLen:t,state:n}=this,o=e.length;for(let r=0;r<o;){const i=Math.min(t-this.pos,o-r);for(let a=0;a<i;a++)n[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:o}=this;e[n]^=t,(t&128)!==0&&n===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){x.aexists(this,!1),x.abytes(e),this.finish();const t=this.state,{blockLen:n}=this;for(let o=0,r=e.length;o<r;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,r-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return x.anumber(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(x.aoutput(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,x.clean(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:o,rounds:r,enableXOF:i}=this;return e||(e=new ot(t,n,o,i,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}const ie=(s,e,t,n={})=>x.createHasher(()=>new ot(e,s,t),n),ae=ie(1,136,32),dt=64,_=20,st=4,Et=2,ce=0,le=1,q=[64,64],ue=s=>Array.from(s).map(e=>e.toString(16).padStart(2,"0")).join("");function rt(s){return Qt(x.sha256(s))}function At(s){return(1<<s)-1}function he(s){let e=1;for(;e*e<s+1;)e++;return Math.max(e,2)}function de(s){const e=st,t=s*At(e);return{d:e,n:s,checksum_radix:he(t)}}function j(s,e){const t=[];let n=e;for(;n>0;)t.push(n&255),n>>>=8;const o=new Uint8Array(s.length+t.length);o.set(s);for(let r=0;r<t.length;r++)o[s.length+r]=t[r];return rt(o)}function Y(s,e){let t=s;for(let n=0;n<e;n++)t=rt(t);return t}function ge(s,e){const t=At(e.d),n=e.checksum_radix-1,o=Math.floor(e.n*t/e.checksum_radix),r=[];for(let l=0;l<e.n;l++){const P=j(s,l+Et),w=Y(P,t);r.push(Array.from(w))}const i=j(s,ce),a=Y(i,n),c=j(s,le),u=Y(c,o);return{config:e,message_terminals:r,checksum_major_terminal:Array.from(u),checksum_minor_terminal:Array.from(a)}}async function vt(s){try{if(s.length!==dt)throw new Error(`WOTS seed must be exactly ${dt} bytes, got ${s.length}`);const e=[];for(let t=0;t<q.length;t++){const n=q[t],o=de(n),r=new Uint8Array(s.length+1);r.set(s),r[s.length]=t;const i=rt(r);try{const a=ge(i,o);if(a.config.d!==st)throw new Error(`Block ${t}: expected d=${st}, got d=${a.config.d}`);if(a.config.n!==n)throw new Error(`Block ${t}: expected n=${n}, got n=${a.config.n}`);if(a.message_terminals.length!==n)throw new Error(`Block ${t}: expected ${n} message terminals, got ${a.message_terminals.length}`);for(let c=0;c<a.message_terminals.length;c++)if(a.message_terminals[c].length!==_)throw new Error(`Block ${t} terminal ${c}: expected ${_} bytes, got ${a.message_terminals[c].length}`);if(a.checksum_minor_terminal.length!==_)throw new Error(`Block ${t} checksum_minor: expected ${_} bytes`);if(a.checksum_major_terminal.length!==_)throw new Error(`Block ${t} checksum_major: expected ${_} bytes`);e.push(a)}finally{r.fill(0),i.fill(0)}}if(e.length!==q.length)throw new Error(`Expected ${q.length} blocks, got ${e.length}`);return e}finally{s.fill(0)}}function Q(s,e,t){if(s.length!==_)throw new Error(`Block ${e} ${t}: expected ${_} bytes, got ${s.length}`);for(let n=0;n<s.length;n++){const o=s[n];if(!Number.isInteger(o)||o<0||o>255)throw new Error(`Block ${e} ${t}[${n}]: invalid byte value ${o}`)}}function St(s){if(s.length===0)throw new Error("Public keys array must not be empty");for(let r=0;r<s.length;r++){const i=s[r];Q(i.checksum_minor_terminal,r,"checksum_minor_terminal"),Q(i.checksum_major_terminal,r,"checksum_major_terminal");for(let a=0;a<i.message_terminals.length;a++)Q(i.message_terminals[a],r,`message_terminal[${a}]`)}let e=0;for(const r of s)e+=Et+r.message_terminals.length;const t=new Uint8Array(e*_);let n=0;for(const r of s){t.set(r.checksum_minor_terminal,n),n+=_,t.set(r.checksum_major_terminal,n),n+=_;for(const i of r.message_terminals)t.set(i,n),n+=_}const o=ae(t);return`0x${ue(o)}`}async function fe(s,e){const t=[],n=[],o=[],r=[];try{for(let i=0;i<e;i++){const a=await W.expandWotsSeed(s,i);try{const u=await vt(a);t.push(u),n.push(St(u))}finally{a.fill(0)}const c=await W.expandHashlockSecret(s,i);try{const u=d.uint8ArrayToHex(c);o.push(u),r.push(N.computeHashlock(d.ensureHexPrefix(u)).slice(2))}finally{c.fill(0)}}}finally{s.fill(0)}return{perVaultWotsKeys:t,wotsPkHashes:n,htlcSecretHexes:o,hashlocks:r}}const pe=/^0x[0-9a-f]+$/i,me=/^[0-9a-f]+$/i,Pe=/^[A-Za-z0-9+/]+={0,2}$/;function U(s){if(typeof s!="string"||s.length===0)throw new Error("BTC wallet returned empty public key");return d.processPublicKeyToXOnly(s).toLowerCase()}function be(s){if(typeof s!="string"||s.length===0)throw new Error("BTC wallet returned empty BIP-322 signature");if(s.startsWith("0x")||s.startsWith("0X")){if(!pe.test(s)||s.length<4||s.length%2!==0)throw new Error("BTC wallet returned malformed hex BIP-322 signature");return s.toLowerCase()}if(me.test(s)){if(s.length%2!==0)throw new Error("BTC wallet returned malformed hex BIP-322 signature");return`0x${s.toLowerCase()}`}if(!Pe.test(s)||s.length%4!==0)throw new Error("BTC wallet returned malformed base64 BIP-322 signature");const e=tt.Buffer.from(s,"base64");if(e.length===0||e.toString("base64")!==s)throw new Error("BTC wallet returned malformed base64 BIP-322 signature");return`0x${e.toString("hex")}`}const _t=0,nt=25,Ct=9999;function Z(s){if(!Number.isInteger(s)||s<0||s>=D.MAX_VP_COMMISSION_BPS_EXCLUSIVE)throw new Error(`Quoted commissionBps must be an integer in [0, ${D.MAX_VP_COMMISSION_BPS_EXCLUSIVE}), got ${s}`);return Math.min(s+nt,Ct)}const J="00".repeat(32);function xe(s,e){const t={bitcoin:"bc",testnet:"tb",signet:"tb",regtest:"bcrt"};try{const n=ft.address.fromBech32(s);return n.prefix===t[e]&&n.version===0&&n.data.length===20}catch{return!1}}function we(s,e,t,n){const o=t==null?void 0:t[`${s}:${e}`];return o?Promise.resolve({txid:s,vout:e,value:o.value,scriptPubKey:o.scriptPubKey}):et.getUtxoInfo(s,e,n)}const gt=12e4;class ye{constructor(e){B(this,"config");this.config=e}async preparePegin(e){if(e.amounts.length===0)throw new Error("amounts must contain at least one entry");const t=await this.config.btcWallet.getPublicKeyHex(),n=U(t);if(!d.isAddressFromPublicKey(e.changeAddress,t,this.config.btcNetwork))throw new Error(`Pre-PegIn changeAddress "${e.changeAddress}" is not derived from the connected wallet's public key. Refusing to build a tx that would send change to an address the signing key doesn't control.`);const o=await this.prepareSizing(n,e),r=o.selectedUTXOs.map(p=>({txid:d.hexToUint8Array(p.txid),vout:p.vout})),i=await $t.deriveVaultRoot(this.config.btcWallet,{depositorBtcPubkey:d.hexToUint8Array(n),fundingOutpoints:r});let a,c;try{const p=await W.expandAuthAnchor(i);try{a=d.uint8ArrayToHex(p),c=d.uint8ArrayToHex(x.sha256(p))}finally{p.fill(0)}}catch(p){throw i.fill(0),p}const u=await fe(i,e.amounts.length),{perVaultWotsKeys:l,wotsPkHashes:P,htlcSecretHexes:w,hashlocks:y}=u,g=await this.preparePeginCommit({depositorBtcPubkeyRaw:t,depositorBtcPubkey:n,hashlocks:y,authAnchorHash:c,sizing:o,params:e});for(let p=0;p<g.perVault.length;p++)if(g.perVault[p].htlcVout!==p)throw new Error(`Internal invariant violation: htlcVout/index mismatch at vault ${p} (expected ${p}, got ${g.perVault[p].htlcVout})`);N.assertAuthAnchorOpReturn(g.fundedPrePeginTxHex,e.amounts.length,c);const{depositTerms:v,...T}=g;return{transaction:{...T,selectedUTXOs:o.selectedUTXOs,fee:o.fee,changeAmount:o.changeAmount},depositorBtcPubkey:n,derivedSecrets:{perVaultWotsKeys:l,wotsPkHashes:P,htlcSecretHexes:w,authAnchorHex:a},depositTerms:v}}async prepareSizing(e,t){const n=t.amounts.map(()=>J),o=t.vaultKeeperBtcPubkeys.length,r=await $.buildPrePeginPsbt({vaultCoreVersion:t.vaultCoreVersion,depositorPubkey:e,vaultProviderPubkey:d.stripHexPrefix(t.vaultProviderBtcPubkey),vaultKeeperPubkeys:t.vaultKeeperBtcPubkeys.map(d.stripHexPrefix),universalChallengerPubkeys:t.universalChallengerBtcPubkeys.map(d.stripHexPrefix),hashlocks:n,timelockRefund:t.timelockRefund,pegInAmounts:t.amounts,feeRate:t.protocolFeeRate,minPeginFeeRate:t.minPeginFeeRate,numLocalChallengers:o,councilQuorum:t.councilQuorum,councilSize:t.councilSize,network:this.config.btcNetwork,authAnchorHash:J}),i=H.selectUtxosForPegin([...t.availableUTXOs],r.totalOutputValue,t.mempoolFeeRate,at.peginOutputCount(r.htlcValues.length,!0));return{selectedUTXOs:i.selectedUTXOs,fee:i.fee,changeAmount:i.changeAmount}}async preparePeginCommit(e){const{depositorBtcPubkeyRaw:t,depositorBtcPubkey:n,hashlocks:o,authAnchorHash:r,sizing:i,params:a}=e,c=J.toLowerCase();for(let f=0;f<o.length;f++)if(o[f].toLowerCase()===c)throw new Error(`preparePeginCommit refusing to build with sizing-pass placeholder hashlock at vault ${f} — internal substitution bug`);if(r.toLowerCase()===c)throw new Error("preparePeginCommit refusing to build with sizing-pass placeholder auth-anchor hash — internal substitution bug");const u=d.stripHexPrefix(a.vaultProviderBtcPubkey),l=a.vaultKeeperBtcPubkeys.map(d.stripHexPrefix),P=a.universalChallengerBtcPubkeys.map(d.stripHexPrefix),w=l.length,y={vaultCoreVersion:a.vaultCoreVersion,depositorPubkey:n,vaultProviderPubkey:u,vaultKeeperPubkeys:l,universalChallengerPubkeys:P,hashlocks:o,timelockRefund:a.timelockRefund,pegInAmounts:a.amounts,feeRate:a.protocolFeeRate,minPeginFeeRate:a.minPeginFeeRate,numLocalChallengers:w,councilQuorum:a.councilQuorum,councilSize:a.councilSize,network:this.config.btcNetwork,authAnchorHash:r},g=await $.buildPrePeginPsbt(y),v=d.getNetwork(this.config.btcNetwork),T=at.fundPeginTransaction({unfundedTxHex:g.psbtHex,selectedUTXOs:i.selectedUTXOs,changeAddress:a.changeAddress,changeAmount:i.changeAmount,network:v}),p=i.selectedUTXOs.reduce((f,A)=>f+BigInt(A.value),0n)-g.totalOutputValue-i.changeAmount;if(p!==i.fee)throw new Error(`Pre-PegIn funded fee ${p} does not match the sizing-pass fee ${i.fee}; refusing to publish a deposit-terms fee bound the funded transaction does not pay.`);const S=d.stripHexPrefix(H.calculateBtcTxHash(T)),m=[],b=[],E=[];for(let f=0;f<o.length;f++){const A=await $.buildPeginTxFromFundedPrePegin({prePeginParams:y,timelockPegin:a.timelockPegin,fundedPrePeginTxHex:T,htlcVout:f}),I=await z.buildPeginInputPsbt({vaultCoreVersion:a.vaultCoreVersion,peginTxHex:A.txHex,fundedPrePeginTxHex:T,depositorPubkey:n,vaultProviderPubkey:u,vaultKeeperPubkeys:l,universalChallengerPubkeys:P,hashlock:o[f],timelockRefund:a.timelockRefund,network:this.config.btcNetwork});m.push(A),b.push(I.psbtHex),E.push(Ot.createTaprootScriptPathSignOptions(t,1))}const h=pt({vaultCoreVersion:a.vaultCoreVersion,protocolFeeRate:a.protocolFeeRate,timelockPegin:a.timelockPegin,timelockAssert:a.timelockAssert,timelockRefund:a.timelockRefund,prepeginTxid:S,prepeginMaxFee:i.fee,vaultProviderBtcPubkey:u,vaultKeeperBtcPubkeys:l,universalChallengerBtcPubkeys:P,maxAcceptableCommissionBps:Z(a.commissionBps),peginAmounts:a.amounts,depositorClaimValue:g.depositorClaimValue,peginMaxFee:g.minPeginFee});N.supportsDepositApproval(this.config.btcWallet)&&await this.config.btcWallet.approveDepositTerms(h);const k=await N.signPsbtsWithFallback(this.config.btcWallet,b,E),C=[];for(let f=0;f<k.length;f++){$.assertPsbtUnsignedTxMatches({requestedPsbtHex:b[f],returnedPsbtHex:k[f]});const A=z.extractPeginInputSignature(k[f],n);$.assertScriptPathSchnorrSignature({requestedPsbtHex:b[f],signatureHex:A,signerXOnlyPubkeyHex:n,inputIndex:0});const I=z.finalizePeginInputPsbt(k[f]);C.push({htlcVout:f,htlcValue:g.htlcValues[f],peginTxHex:I,peginTxid:m[f].txid,peginInputSignature:A,vaultScriptPubKey:m[f].vaultScriptPubKey})}return{fundedPrePeginTxHex:T,prePeginTxid:S,perVault:C,depositTerms:h}}async signAndBroadcast(e){const{fundedPrePeginTxHex:t,depositorBtcPubkey:n}=e,o=t.startsWith("0x")?t.slice(2):t,r=K.Transaction.fromHex(o);if(r.ins.length===0)throw new Error("Transaction has no inputs");const i=new K.Psbt;i.setVersion(r.version),i.setLocktime(r.locktime);const a=tt.Buffer.from(U(n),"hex"),c=this.config.mempoolApiUrl,u=r.ins.map(m=>{const b=tt.Buffer.from(m.hash).reverse().toString("hex"),E=m.index;return we(b,E,e.localPrevouts,c).then(h=>({input:m,utxoData:h,txid:b,vout:E}))}),l=await Promise.all(u),P=l.reduce((m,b)=>m+BigInt(b.utxoData.value),0n),w=r.outs.reduce((m,b)=>m+BigInt(b.value),0n);if(P<w)throw new Error(`UTXO value mismatch: total input value (${P} sat) is less than total output value (${w} sat). This may indicate the mempool API returned manipulated UTXO data.`);const y=P-w;if(y>it.MAX_REASONABLE_FEE_SATS)throw new Error(`Implied transaction fee (${y} sat) exceeds maximum reasonable fee (${it.MAX_REASONABLE_FEE_SATS} sat). This may indicate manipulated UTXO data.`);for(const{input:m,utxoData:b,txid:E,vout:h}of l){const k=H.getPsbtInputFields({value:b.value,scriptPubKey:b.scriptPubKey},a);i.addInput({hash:m.hash,index:m.index,sequence:m.sequence,...k})}for(const m of r.outs)i.addOutput({script:m.script,value:m.value});const g=i.toHex(),v=await this.config.btcWallet.signPsbt(g);$.assertPsbtUnsignedTxMatches({requestedPsbtHex:g,returnedPsbtHex:v});const T=K.Psbt.fromHex(v);try{T.finalizeAllInputs()}catch(m){if(!T.data.inputs.every(E=>E.finalScriptWitness||E.finalScriptSig))throw new Error(`PSBT finalization failed and wallet did not auto-finalize: ${m}`)}const p=T.extractTransaction().toHex();return await et.pushTx(p,c)}async registerPeginOnChain(e){const{unsignedPrePeginTx:t,depositorSignedPeginTx:n,vaultProvider:o,hashlock:r,htlcVout:i,depositorPayoutBtcAddress:a,depositorWotsPkHash:c,popSignature:u}=e;if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const l=this.config.ethWallet.account.address;if(!V.isAddressEqual(u.depositorEthAddress,l))throw new Error(`Proof of possession was signed for ${u.depositorEthAddress} but the Ethereum wallet is currently connected to ${l}. Reconnect the original account or call signProofOfPossession() again.`);const P=await this.assertPopMatchesBtcWallet(u),w=u.btcPopSignature,y=d.ensureHexPrefix(u.depositorBtcPubkey),g=d.ensureHexPrefix(t),v=d.ensureHexPrefix(n),T=a??await this.config.btcWallet.getAddress(),p=this.resolvePayoutScriptPubKey(P,T),S=H.calculateBtcTxHash(v),m=await W.deriveVaultId(d.stripHexPrefix(S),d.stripHexPrefix(l)),b=d.ensureHexPrefix(m);if(await this.checkVaultExists(b))throw new Error(`Vault already exists (ID: ${b}, peginTxHash: ${S}). 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.`);const h=this.config.publicClient;let k;try{k=await h.readContract({address:this.config.vaultContracts.btcVaultRegistry,abi:R.BTCVaultRegistryABI,functionName:"getPegInFee",args:[o]})}catch(M){throw new Error("Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct.",{cause:M})}const C=await this.resolveMaxAcceptableCommissionBps(o,e.quotedCommissionBps),f=V.encodeFunctionData({abi:R.BTCVaultRegistryABI,functionName:"submitPeginRequest",args:[l,y,w,g,v,o,C,r,i,p,c]});let A;try{A=await h.estimateGas({to:this.config.vaultContracts.btcVaultRegistry,data:f,value:k,account:this.config.ethWallet.account.address})}catch(M){O.handleContractError(M)}let I;try{I=await this.config.ethWallet.sendTransaction({to:this.config.vaultContracts.btcVaultRegistry,data:f,value:k,account:this.config.ethWallet.account,chain:this.config.ethChain,gas:A})}catch(M){O.handleContractError(M)}const G=await H.waitForTransactionReceiptSmartAware({publicClient:h,walletAddress:this.config.ethWallet.account.address,hash:I,timeout:gt});return G.status==="reverted"&&O.handleContractError(new Error(`Transaction reverted. Hash: ${G.transactionHash}. Check the transaction on block explorer for details.`)),{ethTxHash:G.transactionHash,vaultId:b,peginTxHash:S}}async registerPeginBatchOnChain(e){const{vaultProvider:t,unsignedPrePeginTx:n,requests:o,popSignature:r}=e;if(o.length===0)throw new Error("Batch pegin requires at least one request");if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const i=this.config.ethWallet.account.address;if(!V.isAddressEqual(r.depositorEthAddress,i))throw new Error(`Proof of possession was signed for ${r.depositorEthAddress} but the Ethereum wallet is currently connected to ${i}. Reconnect the original account or call signProofOfPossession() again.`);const a=await this.assertPopMatchesBtcWallet(r),c=r.btcPopSignature,u=o.map(h=>this.resolvePayoutScriptPubKey(a,h.depositorPayoutBtcAddress)),l=[];for(const h of o){const k=d.ensureHexPrefix(h.depositorSignedPeginTx),C=H.calculateBtcTxHash(k),f=await W.deriveVaultId(d.stripHexPrefix(C),d.stripHexPrefix(i)),A=d.ensureHexPrefix(f);if(await this.checkVaultExists(A))throw new Error(`Vault already exists (ID: ${A}, peginTxHash: ${C}). To create a new vault, use different UTXOs or a different amount.`);l.push({vaultId:A,peginTxHash:C})}const P=this.config.publicClient;let w;try{w=await P.readContract({address:this.config.vaultContracts.btcVaultRegistry,abi:R.BTCVaultRegistryABI,functionName:"getPegInFee",args:[t]})}catch(h){throw new Error("Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct.",{cause:h})}const y=w*BigInt(o.length),g=await this.resolveMaxAcceptableCommissionBps(t,e.quotedCommissionBps),v=d.ensureHexPrefix(r.depositorBtcPubkey),T=d.ensureHexPrefix(n),p=o.map((h,k)=>({depositorBtcPubKey:v,btcPopSignature:c,unsignedPrePeginTx:T,depositorSignedPeginTx:d.ensureHexPrefix(h.depositorSignedPeginTx),hashlock:h.hashlock,htlcVout:h.htlcVout,referralCode:_t,depositorPayoutBtcAddress:u[k],depositorWotsPkHash:h.depositorWotsPkHash})),S=V.encodeFunctionData({abi:R.BTCVaultRegistryABI,functionName:"submitPeginRequestBatch",args:[i,t,g,p]});let m;try{m=await P.estimateGas({to:this.config.vaultContracts.btcVaultRegistry,data:S,value:y,account:this.config.ethWallet.account.address})}catch(h){O.handleContractError(h)}let b;try{b=await this.config.ethWallet.sendTransaction({to:this.config.vaultContracts.btcVaultRegistry,data:S,value:y,account:this.config.ethWallet.account,chain:this.config.ethChain,gas:m})}catch(h){O.handleContractError(h)}const E=await H.waitForTransactionReceiptSmartAware({publicClient:P,walletAddress:this.config.ethWallet.account.address,hash:b,timeout:gt});return E.status==="reverted"&&O.handleContractError(new Error(`Batch transaction reverted. Hash: ${E.transactionHash}. Check the transaction on block explorer for details.`)),{ethTxHash:E.transactionHash,vaults:l}}async resolveMaxAcceptableCommissionBps(e,t){if(t===void 0&&N.supportsDepositApproval(this.config.btcWallet))throw new Error("quotedCommissionBps is required when the wallet approved deposit terms: the registration ceiling must anchor to the approved quote.");let n;try{n=await new et.ViemVaultRegistryReader(this.config.publicClient,this.config.vaultContracts.btcVaultRegistry).getVaultProviderCommission(e)}catch(o){throw new Error("Failed to query vault provider commission from the contract. Please check your network connection and that the contract address is correct.",{cause:o})}if(t!==void 0){if(n>t+nt)throw new Error(`Vault provider commission changed since quote: quoted ${t} bps, chain currently reports ${n} bps (allowed drift ${nt} bps). Please refresh to see the new commission and try again.`);return Z(t)}return Z(n)}async checkVaultExists(e){return(await this.config.publicClient.readContract({address:this.config.vaultContracts.btcVaultRegistry,abi:R.BTCVaultRegistryABI,functionName:"getBtcVaultBasicInfo",args:[e]})).depositor!==V.zeroAddress}resolvePayoutScriptPubKey(e,t){if(!d.isAddressFromPublicKey(t,e,this.config.btcNetwork))throw d.stripHexPrefix(e).length===d.X_ONLY_PUBKEY_HEX_LEN&&xe(t,this.config.btcNetwork)?new Error(`BTC payout address "${t}" is a P2WPKH (Native SegWit) address, but the connected wallet only exposes an x-only public key. P2WPKH validation requires a compressed key with known y-parity. Use a P2TR (Taproot) payout address instead.`):new Error(`BTC payout address "${t}" is not derived from the connected wallet's public key. The payout sink must be controlled by the same key that signs the pegin; refusing to register a mismatched address.`);const n=d.getNetwork(this.config.btcNetwork);try{return`0x${ft.address.toOutputScript(t,n).toString("hex")}`}catch{throw new Error(`Invalid BTC payout address: "${t}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`)}}async signProofOfPossession(){if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const e=this.config.ethWallet.account.address,t=U(await this.config.btcWallet.getPublicKeyHex()),n=this.config.vaultContracts.btcVaultRegistry,o=`${e.toLowerCase()}:${this.config.ethChain.id}:pegin:${n.toLowerCase()}`,r=await this.config.btcWallet.signMessage(o,"bip322-simple");return{btcPopSignature:be(r),depositorEthAddress:e,depositorBtcPubkey:t}}async assertPopMatchesBtcWallet(e){const t=await this.config.btcWallet.getPublicKeyHex(),n=U(t),o=U(e.depositorBtcPubkey);if(n!==o)throw new Error(`Proof of possession was signed with BTC pubkey ${o} but the BTC wallet is currently connected to ${n}. Reconnect the original wallet or call signProofOfPossession() again.`);return t}getNetwork(){return this.config.btcNetwork}getVaultContractAddress(){return this.config.vaultContracts.btcVaultRegistry}}const ke=80,Be=250,Te=300,Ee=22,It="ab";function Ae(s,e){const t=It.repeat(Te),n=d.stripHexPrefix(s).toLowerCase(),o=e.toString(16).padStart(8,"0"),r=`${n}${o}`,i=t.slice(r.length);return`0x${r}${i}`}function ve(s,e){const t=n=>`0x${It.repeat(n)}`;return{depositorBtcPubKey:t(32),btcPopSignature:t(ke),unsignedPrePeginTx:t(Be),depositorSignedPeginTx:Ae(s,e),hashlock:t(32),htlcVout:e,referralCode:_t,depositorPayoutBtcAddress:t(Ee),depositorWotsPkHash:t(32)}}async function Se(s){const{publicClient:e,btcVaultRegistry:t,depositorEthAddress:n,vaultProvider:o,batchSize:r}=s;if(r<=0)throw new Error(`estimateSubmitPeginRequestBatchGas requires batchSize >= 1 (received ${r})`);const a=await e.readContract({address:t,abi:R.BTCVaultRegistryABI,functionName:"getPegInFee",args:[o]})*BigInt(r),c=Array.from({length:r},(l,P)=>ve(n,P)),u=V.encodeFunctionData({abi:R.BTCVaultRegistryABI,functionName:"submitPeginRequestBatch",args:[n,o,Ct,c]});return e.estimateGas({to:t,data:u,value:a,account:n})}exports.PeginManager=ye;exports.buildDepositTerms=pt;exports.computeWotsBlockPublicKeysHash=St;exports.deriveWotsBlocksFromSeed=vt;exports.estimateSubmitPeginRequestBatchGas=Se;
2
- //# sourceMappingURL=PeginManager-CogqZaa2.cjs.map
1
+ "use strict";var Ht=Object.defineProperty;var Rt=(s,e,t)=>e in s?Ht(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var B=(s,e,t)=>Rt(s,typeof e!="symbol"?e+"":e,t);const x=require("./sha2-DsrLC4NM.cjs"),K=require("bitcoinjs-lib"),tt=require("buffer"),V=require("viem"),R=require("./BTCVaultRegistry.abi-COxUdCTR.cjs"),O=require("./errors-CGcNP0rV.cjs"),W=require("@babylonlabs-io/babylon-tbv-rust-wasm"),$=require("./verifyScriptPathSchnorrSignature-CYjK4IP_.cjs"),z=require("./peginInput-Ci921gTl.cjs"),d=require("./bitcoin-m84N5a8o.cjs"),D=require("./constants-DU5CGcqO.cjs"),Ot=require("./signing-Bnsro0hE.cjs"),it=require("./validation-CDbOaDj7.cjs"),$t=require("./deriveVaultRoot-p4uGsM7w.cjs"),N=require("./signPsbtsWithFallback-Xs4jZw5z.cjs"),H=require("./waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs"),at=require("./fundPeginTransaction-BLD8FRL9.cjs"),et=require("./mempoolApi-DjwZ130O.cjs");function Vt(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const ft=Vt(K),X=BigInt(2**32-1),ct=BigInt(32);function Mt(s,e=!1){return e?{h:Number(s&X),l:Number(s>>ct&X)}:{h:Number(s>>ct&X)|0,l:Number(s&X)|0}}function Ft(s,e=!1){const t=s.length;let n=new Uint32Array(t),o=new Uint32Array(t);for(let r=0;r<t;r++){const{h:i,l:a}=Mt(s[r],e);[n[r],o[r]]=[i,a]}return[n,o]}const Ut=(s,e,t)=>s<<t|e>>>32-t,Nt=(s,e,t)=>e<<t|s>>>32-t,Wt=(s,e,t)=>e<<t-32|s>>>64-t,Dt=(s,e,t)=>s<<t-32|e>>>64-t,Xt=64;function pt(s){const e=s.prepeginTxid.toLowerCase();if(!/^[0-9a-f]+$/.test(e)||e.length!==Xt)throw new Error(`buildDepositTerms: prepeginTxid must be 64 hex chars, got "${s.prepeginTxid}"`);if(s.peginAmounts.length===0)throw new Error("buildDepositTerms: at least one pegin amount is required");if(s.timelockPegin<=0||s.timelockAssert<=0||s.timelockRefund<=0)throw new Error("buildDepositTerms: timelocks must be positive");if(!Number.isInteger(s.maxAcceptableCommissionBps)||s.maxAcceptableCommissionBps<0||s.maxAcceptableCommissionBps>=D.MAX_VP_COMMISSION_BPS_EXCLUSIVE)throw new Error(`buildDepositTerms: maxAcceptableCommissionBps must be an integer in [0, ${D.MAX_VP_COMMISSION_BPS_EXCLUSIVE}), got ${s.maxAcceptableCommissionBps}`);const t=BigInt(D.BPS_DENOMINATOR),n=s.peginAmounts.map((o,r)=>({htlcVout:r,vaultProviderBtcPubkey:s.vaultProviderBtcPubkey,peginAmount:o,commissionFee:o*BigInt(s.maxAcceptableCommissionBps)/t,depositorClaimValue:s.depositorClaimValue,peginMaxFee:s.peginMaxFee}));return{vaultCoreVersion:s.vaultCoreVersion,protocolFeeRate:s.protocolFeeRate,timelockPegin:s.timelockPegin,timelockAssert:s.timelockAssert,timelockRefund:s.timelockRefund,prepeginTxid:e,prepeginMaxFee:s.prepeginMaxFee,vaultKeeperBtcPubkeys:[...s.vaultKeeperBtcPubkeys],universalChallengerBtcPubkeys:[...s.universalChallengerBtcPubkeys],vaults:n}}const Lt=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),mt=Uint8Array.from(new Array(16).fill(0).map((s,e)=>e)),qt=mt.map(s=>(9*s+5)%16),Pt=(()=>{const t=[[mt],[qt]];for(let n=0;n<4;n++)for(let o of t)o.push(o[n].map(r=>Lt[r]));return t})(),bt=Pt[0],xt=Pt[1],wt=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(s=>Uint8Array.from(s)),Kt=bt.map((s,e)=>s.map(t=>wt[e][t])),Gt=xt.map((s,e)=>s.map(t=>wt[e][t])),zt=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),jt=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function lt(s,e,t,n){return s===0?e^t^n:s===1?e&t|~e&n:s===2?(e|~t)^n:s===3?e&n|t&~n:e^(t|~n)}const L=new Uint32Array(16);class Yt extends x.HashMD{constructor(){super(64,20,8,!0);B(this,"h0",1732584193);B(this,"h1",-271733879);B(this,"h2",-1732584194);B(this,"h3",271733878);B(this,"h4",-1009589776)}get(){const{h0:t,h1:n,h2:o,h3:r,h4:i}=this;return[t,n,o,r,i]}set(t,n,o,r,i){this.h0=t|0,this.h1=n|0,this.h2=o|0,this.h3=r|0,this.h4=i|0}process(t,n){for(let g=0;g<16;g++,n+=4)L[g]=t.getUint32(n,!0);let o=this.h0|0,r=o,i=this.h1|0,a=i,c=this.h2|0,u=c,l=this.h3|0,P=l,w=this.h4|0,y=w;for(let g=0;g<5;g++){const v=4-g,T=zt[g],p=jt[g],S=bt[g],m=xt[g],b=Kt[g],E=Gt[g];for(let h=0;h<16;h++){const k=x.rotl(o+lt(g,i,c,l)+L[S[h]]+T,b[h])+w|0;o=w,w=l,l=x.rotl(c,10)|0,c=i,i=k}for(let h=0;h<16;h++){const k=x.rotl(r+lt(v,a,u,P)+L[m[h]]+p,E[h])+y|0;r=y,y=P,P=x.rotl(u,10)|0,u=a,a=k}}this.set(this.h1+c+P|0,this.h2+l+y|0,this.h3+w+r|0,this.h4+o+a|0,this.h0+i+u|0)}roundClean(){x.clean(L)}destroy(){this.destroyed=!0,x.clean(this.buffer),this.set(0,0,0,0,0)}}const Qt=x.createHasher(()=>new Yt),Zt=BigInt(0),F=BigInt(1),Jt=BigInt(2),te=BigInt(7),ee=BigInt(256),se=BigInt(113),yt=[],kt=[],Bt=[];for(let s=0,e=F,t=1,n=0;s<24;s++){[t,n]=[n,(2*t+3*n)%5],yt.push(2*(5*n+t)),kt.push((s+1)*(s+2)/2%64);let o=Zt;for(let r=0;r<7;r++)e=(e<<F^(e>>te)*se)%ee,e&Jt&&(o^=F<<(F<<BigInt(r))-F);Bt.push(o)}const Tt=Ft(Bt,!0),ne=Tt[0],oe=Tt[1],ut=(s,e,t)=>t>32?Wt(s,e,t):Ut(s,e,t),ht=(s,e,t)=>t>32?Dt(s,e,t):Nt(s,e,t);function re(s,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)t[i]=s[i]^s[i+10]^s[i+20]^s[i+30]^s[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,c=(i+2)%10,u=t[c],l=t[c+1],P=ut(u,l,1)^t[a],w=ht(u,l,1)^t[a+1];for(let y=0;y<50;y+=10)s[i+y]^=P,s[i+y+1]^=w}let o=s[2],r=s[3];for(let i=0;i<24;i++){const a=kt[i],c=ut(o,r,a),u=ht(o,r,a),l=yt[i];o=s[l],r=s[l+1],s[l]=c,s[l+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)t[a]=s[i+a];for(let a=0;a<10;a++)s[i+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=ne[n],s[1]^=oe[n]}x.clean(t)}class ot{constructor(e,t,n,o=!1,r=24){B(this,"state");B(this,"pos",0);B(this,"posOut",0);B(this,"finished",!1);B(this,"state32");B(this,"destroyed",!1);B(this,"blockLen");B(this,"suffix");B(this,"outputLen");B(this,"enableXOF",!1);B(this,"rounds");if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=o,this.rounds=r,x.anumber(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=x.u32(this.state)}clone(){return this._cloneInto()}keccak(){x.swap32IfBE(this.state32),re(this.state32,this.rounds),x.swap32IfBE(this.state32),this.posOut=0,this.pos=0}update(e){x.aexists(this),x.abytes(e);const{blockLen:t,state:n}=this,o=e.length;for(let r=0;r<o;){const i=Math.min(t-this.pos,o-r);for(let a=0;a<i;a++)n[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:o}=this;e[n]^=t,(t&128)!==0&&n===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){x.aexists(this,!1),x.abytes(e),this.finish();const t=this.state,{blockLen:n}=this;for(let o=0,r=e.length;o<r;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,r-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return x.anumber(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(x.aoutput(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,x.clean(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:o,rounds:r,enableXOF:i}=this;return e||(e=new ot(t,n,o,i,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=n,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}const ie=(s,e,t,n={})=>x.createHasher(()=>new ot(e,s,t),n),ae=ie(1,136,32),dt=64,_=20,st=4,Et=2,ce=0,le=1,q=[64,64],ue=s=>Array.from(s).map(e=>e.toString(16).padStart(2,"0")).join("");function rt(s){return Qt(x.sha256(s))}function At(s){return(1<<s)-1}function he(s){let e=1;for(;e*e<s+1;)e++;return Math.max(e,2)}function de(s){const e=st,t=s*At(e);return{d:e,n:s,checksum_radix:he(t)}}function j(s,e){const t=[];let n=e;for(;n>0;)t.push(n&255),n>>>=8;const o=new Uint8Array(s.length+t.length);o.set(s);for(let r=0;r<t.length;r++)o[s.length+r]=t[r];return rt(o)}function Y(s,e){let t=s;for(let n=0;n<e;n++)t=rt(t);return t}function ge(s,e){const t=At(e.d),n=e.checksum_radix-1,o=Math.floor(e.n*t/e.checksum_radix),r=[];for(let l=0;l<e.n;l++){const P=j(s,l+Et),w=Y(P,t);r.push(Array.from(w))}const i=j(s,ce),a=Y(i,n),c=j(s,le),u=Y(c,o);return{config:e,message_terminals:r,checksum_major_terminal:Array.from(u),checksum_minor_terminal:Array.from(a)}}async function vt(s){try{if(s.length!==dt)throw new Error(`WOTS seed must be exactly ${dt} bytes, got ${s.length}`);const e=[];for(let t=0;t<q.length;t++){const n=q[t],o=de(n),r=new Uint8Array(s.length+1);r.set(s),r[s.length]=t;const i=rt(r);try{const a=ge(i,o);if(a.config.d!==st)throw new Error(`Block ${t}: expected d=${st}, got d=${a.config.d}`);if(a.config.n!==n)throw new Error(`Block ${t}: expected n=${n}, got n=${a.config.n}`);if(a.message_terminals.length!==n)throw new Error(`Block ${t}: expected ${n} message terminals, got ${a.message_terminals.length}`);for(let c=0;c<a.message_terminals.length;c++)if(a.message_terminals[c].length!==_)throw new Error(`Block ${t} terminal ${c}: expected ${_} bytes, got ${a.message_terminals[c].length}`);if(a.checksum_minor_terminal.length!==_)throw new Error(`Block ${t} checksum_minor: expected ${_} bytes`);if(a.checksum_major_terminal.length!==_)throw new Error(`Block ${t} checksum_major: expected ${_} bytes`);e.push(a)}finally{r.fill(0),i.fill(0)}}if(e.length!==q.length)throw new Error(`Expected ${q.length} blocks, got ${e.length}`);return e}finally{s.fill(0)}}function Q(s,e,t){if(s.length!==_)throw new Error(`Block ${e} ${t}: expected ${_} bytes, got ${s.length}`);for(let n=0;n<s.length;n++){const o=s[n];if(!Number.isInteger(o)||o<0||o>255)throw new Error(`Block ${e} ${t}[${n}]: invalid byte value ${o}`)}}function St(s){if(s.length===0)throw new Error("Public keys array must not be empty");for(let r=0;r<s.length;r++){const i=s[r];Q(i.checksum_minor_terminal,r,"checksum_minor_terminal"),Q(i.checksum_major_terminal,r,"checksum_major_terminal");for(let a=0;a<i.message_terminals.length;a++)Q(i.message_terminals[a],r,`message_terminal[${a}]`)}let e=0;for(const r of s)e+=Et+r.message_terminals.length;const t=new Uint8Array(e*_);let n=0;for(const r of s){t.set(r.checksum_minor_terminal,n),n+=_,t.set(r.checksum_major_terminal,n),n+=_;for(const i of r.message_terminals)t.set(i,n),n+=_}const o=ae(t);return`0x${ue(o)}`}async function fe(s,e){const t=[],n=[],o=[],r=[];try{for(let i=0;i<e;i++){const a=await W.expandWotsSeed(s,i);try{const u=await vt(a);t.push(u),n.push(St(u))}finally{a.fill(0)}const c=await W.expandHashlockSecret(s,i);try{const u=d.uint8ArrayToHex(c);o.push(u),r.push(N.computeHashlock(d.ensureHexPrefix(u)).slice(2))}finally{c.fill(0)}}}finally{s.fill(0)}return{perVaultWotsKeys:t,wotsPkHashes:n,htlcSecretHexes:o,hashlocks:r}}const pe=/^0x[0-9a-f]+$/i,me=/^[0-9a-f]+$/i,Pe=/^[A-Za-z0-9+/]+={0,2}$/;function U(s){if(typeof s!="string"||s.length===0)throw new Error("BTC wallet returned empty public key");return d.processPublicKeyToXOnly(s).toLowerCase()}function be(s){if(typeof s!="string"||s.length===0)throw new Error("BTC wallet returned empty BIP-322 signature");if(s.startsWith("0x")||s.startsWith("0X")){if(!pe.test(s)||s.length<4||s.length%2!==0)throw new Error("BTC wallet returned malformed hex BIP-322 signature");return s.toLowerCase()}if(me.test(s)){if(s.length%2!==0)throw new Error("BTC wallet returned malformed hex BIP-322 signature");return`0x${s.toLowerCase()}`}if(!Pe.test(s)||s.length%4!==0)throw new Error("BTC wallet returned malformed base64 BIP-322 signature");const e=tt.Buffer.from(s,"base64");if(e.length===0||e.toString("base64")!==s)throw new Error("BTC wallet returned malformed base64 BIP-322 signature");return`0x${e.toString("hex")}`}const _t=0,nt=25,Ct=9999;function Z(s){if(!Number.isInteger(s)||s<0||s>=D.MAX_VP_COMMISSION_BPS_EXCLUSIVE)throw new Error(`Quoted commissionBps must be an integer in [0, ${D.MAX_VP_COMMISSION_BPS_EXCLUSIVE}), got ${s}`);return Math.min(s+nt,Ct)}const J="00".repeat(32);function xe(s,e){const t={bitcoin:"bc",testnet:"tb",signet:"tb",regtest:"bcrt"};try{const n=ft.address.fromBech32(s);return n.prefix===t[e]&&n.version===0&&n.data.length===20}catch{return!1}}function we(s,e,t,n){const o=t==null?void 0:t[`${s}:${e}`];return o?Promise.resolve({txid:s,vout:e,value:o.value,scriptPubKey:o.scriptPubKey}):et.getUtxoInfo(s,e,n)}const gt=12e4;class ye{constructor(e){B(this,"config");this.config=e}async preparePegin(e){if(e.amounts.length===0)throw new Error("amounts must contain at least one entry");const t=await this.config.btcWallet.getPublicKeyHex(),n=U(t);if(!d.isAddressFromPublicKey(e.changeAddress,t,this.config.btcNetwork))throw new Error(`Pre-PegIn changeAddress "${e.changeAddress}" is not derived from the connected wallet's public key. Refusing to build a tx that would send change to an address the signing key doesn't control.`);const o=await this.prepareSizing(n,e),r=o.selectedUTXOs.map(p=>({txid:d.hexToUint8Array(p.txid),vout:p.vout})),i=await $t.deriveVaultRoot(this.config.btcWallet,{depositorBtcPubkey:d.hexToUint8Array(n),fundingOutpoints:r});let a,c;try{const p=await W.expandAuthAnchor(i);try{a=d.uint8ArrayToHex(p),c=d.uint8ArrayToHex(x.sha256(p))}finally{p.fill(0)}}catch(p){throw i.fill(0),p}const u=await fe(i,e.amounts.length),{perVaultWotsKeys:l,wotsPkHashes:P,htlcSecretHexes:w,hashlocks:y}=u,g=await this.preparePeginCommit({depositorBtcPubkeyRaw:t,depositorBtcPubkey:n,hashlocks:y,authAnchorHash:c,sizing:o,params:e});for(let p=0;p<g.perVault.length;p++)if(g.perVault[p].htlcVout!==p)throw new Error(`Internal invariant violation: htlcVout/index mismatch at vault ${p} (expected ${p}, got ${g.perVault[p].htlcVout})`);N.assertAuthAnchorOpReturn(g.fundedPrePeginTxHex,e.amounts.length,c);const{depositTerms:v,...T}=g;return{transaction:{...T,selectedUTXOs:o.selectedUTXOs,fee:o.fee,changeAmount:o.changeAmount},depositorBtcPubkey:n,derivedSecrets:{perVaultWotsKeys:l,wotsPkHashes:P,htlcSecretHexes:w,authAnchorHex:a},depositTerms:v}}async prepareSizing(e,t){const n=t.amounts.map(()=>J),o=t.vaultKeeperBtcPubkeys.length,r=await $.buildPrePeginPsbt({vaultCoreVersion:t.vaultCoreVersion,depositorPubkey:e,vaultProviderPubkey:d.stripHexPrefix(t.vaultProviderBtcPubkey),vaultKeeperPubkeys:t.vaultKeeperBtcPubkeys.map(d.stripHexPrefix),universalChallengerPubkeys:t.universalChallengerBtcPubkeys.map(d.stripHexPrefix),hashlocks:n,timelockRefund:t.timelockRefund,pegInAmounts:t.amounts,feeRate:t.protocolFeeRate,minPeginFeeRate:t.minPeginFeeRate,numLocalChallengers:o,councilQuorum:t.councilQuorum,councilSize:t.councilSize,network:this.config.btcNetwork,authAnchorHash:J}),i=H.selectUtxosForPegin([...t.availableUTXOs],r.totalOutputValue,t.mempoolFeeRate,at.peginOutputCount(r.htlcValues.length,!0));return{selectedUTXOs:i.selectedUTXOs,fee:i.fee,changeAmount:i.changeAmount}}async preparePeginCommit(e){const{depositorBtcPubkeyRaw:t,depositorBtcPubkey:n,hashlocks:o,authAnchorHash:r,sizing:i,params:a}=e,c=J.toLowerCase();for(let f=0;f<o.length;f++)if(o[f].toLowerCase()===c)throw new Error(`preparePeginCommit refusing to build with sizing-pass placeholder hashlock at vault ${f} — internal substitution bug`);if(r.toLowerCase()===c)throw new Error("preparePeginCommit refusing to build with sizing-pass placeholder auth-anchor hash — internal substitution bug");const u=d.stripHexPrefix(a.vaultProviderBtcPubkey),l=a.vaultKeeperBtcPubkeys.map(d.stripHexPrefix),P=a.universalChallengerBtcPubkeys.map(d.stripHexPrefix),w=l.length,y={vaultCoreVersion:a.vaultCoreVersion,depositorPubkey:n,vaultProviderPubkey:u,vaultKeeperPubkeys:l,universalChallengerPubkeys:P,hashlocks:o,timelockRefund:a.timelockRefund,pegInAmounts:a.amounts,feeRate:a.protocolFeeRate,minPeginFeeRate:a.minPeginFeeRate,numLocalChallengers:w,councilQuorum:a.councilQuorum,councilSize:a.councilSize,network:this.config.btcNetwork,authAnchorHash:r},g=await $.buildPrePeginPsbt(y),v=d.getNetwork(this.config.btcNetwork),T=at.fundPeginTransaction({unfundedTxHex:g.psbtHex,selectedUTXOs:i.selectedUTXOs,changeAddress:a.changeAddress,changeAmount:i.changeAmount,network:v}),p=i.selectedUTXOs.reduce((f,A)=>f+BigInt(A.value),0n)-g.totalOutputValue-i.changeAmount;if(p!==i.fee)throw new Error(`Pre-PegIn funded fee ${p} does not match the sizing-pass fee ${i.fee}; refusing to publish a deposit-terms fee bound the funded transaction does not pay.`);const S=d.stripHexPrefix(H.calculateBtcTxHash(T)),m=[],b=[],E=[];for(let f=0;f<o.length;f++){const A=await $.buildPeginTxFromFundedPrePegin({prePeginParams:y,timelockPegin:a.timelockPegin,fundedPrePeginTxHex:T,htlcVout:f}),I=await z.buildPeginInputPsbt({vaultCoreVersion:a.vaultCoreVersion,peginTxHex:A.txHex,fundedPrePeginTxHex:T,depositorPubkey:n,vaultProviderPubkey:u,vaultKeeperPubkeys:l,universalChallengerPubkeys:P,hashlock:o[f],timelockRefund:a.timelockRefund,network:this.config.btcNetwork});m.push(A),b.push(I.psbtHex),E.push(Ot.createTaprootScriptPathSignOptions(t,1))}const h=pt({vaultCoreVersion:a.vaultCoreVersion,protocolFeeRate:a.protocolFeeRate,timelockPegin:a.timelockPegin,timelockAssert:a.timelockAssert,timelockRefund:a.timelockRefund,prepeginTxid:S,prepeginMaxFee:i.fee,vaultProviderBtcPubkey:u,vaultKeeperBtcPubkeys:l,universalChallengerBtcPubkeys:P,maxAcceptableCommissionBps:Z(a.commissionBps),peginAmounts:a.amounts,depositorClaimValue:g.depositorClaimValue,peginMaxFee:g.minPeginFee});N.supportsDepositApproval(this.config.btcWallet)&&await this.config.btcWallet.approveDepositTerms(h);const k=await N.signPsbtsWithFallback(this.config.btcWallet,b,E),C=[];for(let f=0;f<k.length;f++){$.assertPsbtUnsignedTxMatches({requestedPsbtHex:b[f],returnedPsbtHex:k[f]});const A=z.extractPeginInputSignature(k[f],n);$.assertScriptPathSchnorrSignature({requestedPsbtHex:b[f],signatureHex:A,signerXOnlyPubkeyHex:n,inputIndex:0});const I=z.finalizePeginInputPsbt(k[f]);C.push({htlcVout:f,htlcValue:g.htlcValues[f],peginTxHex:I,peginTxid:m[f].txid,peginInputSignature:A,vaultScriptPubKey:m[f].vaultScriptPubKey})}return{fundedPrePeginTxHex:T,prePeginTxid:S,perVault:C,depositTerms:h}}async signAndBroadcast(e){const{fundedPrePeginTxHex:t,depositorBtcPubkey:n}=e,o=t.startsWith("0x")?t.slice(2):t,r=K.Transaction.fromHex(o);if(r.ins.length===0)throw new Error("Transaction has no inputs");const i=new K.Psbt;i.setVersion(r.version),i.setLocktime(r.locktime);const a=tt.Buffer.from(U(n),"hex"),c=this.config.mempoolApiUrl,u=r.ins.map(m=>{const b=tt.Buffer.from(m.hash).reverse().toString("hex"),E=m.index;return we(b,E,e.localPrevouts,c).then(h=>({input:m,utxoData:h,txid:b,vout:E}))}),l=await Promise.all(u),P=l.reduce((m,b)=>m+BigInt(b.utxoData.value),0n),w=r.outs.reduce((m,b)=>m+BigInt(b.value),0n);if(P<w)throw new Error(`UTXO value mismatch: total input value (${P} sat) is less than total output value (${w} sat). This may indicate the mempool API returned manipulated UTXO data.`);const y=P-w;if(y>it.MAX_REASONABLE_FEE_SATS)throw new Error(`Implied transaction fee (${y} sat) exceeds maximum reasonable fee (${it.MAX_REASONABLE_FEE_SATS} sat). This may indicate manipulated UTXO data.`);for(const{input:m,utxoData:b,txid:E,vout:h}of l){const k=H.getPsbtInputFields({value:b.value,scriptPubKey:b.scriptPubKey},a);i.addInput({hash:m.hash,index:m.index,sequence:m.sequence,...k})}for(const m of r.outs)i.addOutput({script:m.script,value:m.value});const g=i.toHex(),v=await this.config.btcWallet.signPsbt(g);$.assertPsbtUnsignedTxMatches({requestedPsbtHex:g,returnedPsbtHex:v});const T=K.Psbt.fromHex(v);try{T.finalizeAllInputs()}catch(m){if(!T.data.inputs.every(E=>E.finalScriptWitness||E.finalScriptSig))throw new Error(`PSBT finalization failed and wallet did not auto-finalize: ${m}`)}const p=T.extractTransaction().toHex();return await et.pushTx(p,c)}async registerPeginOnChain(e){const{unsignedPrePeginTx:t,depositorSignedPeginTx:n,vaultProvider:o,hashlock:r,htlcVout:i,depositorPayoutBtcAddress:a,depositorWotsPkHash:c,popSignature:u}=e;if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const l=this.config.ethWallet.account.address;if(!V.isAddressEqual(u.depositorEthAddress,l))throw new Error(`Proof of possession was signed for ${u.depositorEthAddress} but the Ethereum wallet is currently connected to ${l}. Reconnect the original account or call signProofOfPossession() again.`);const P=await this.assertPopMatchesBtcWallet(u),w=u.btcPopSignature,y=d.ensureHexPrefix(u.depositorBtcPubkey),g=d.ensureHexPrefix(t),v=d.ensureHexPrefix(n),T=a??await this.config.btcWallet.getAddress(),p=this.resolvePayoutScriptPubKey(P,T),S=H.calculateBtcTxHash(v),m=await W.deriveVaultId(d.stripHexPrefix(S),d.stripHexPrefix(l)),b=d.ensureHexPrefix(m);if(await this.checkVaultExists(b))throw new Error(`Vault already exists (ID: ${b}, peginTxHash: ${S}). 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.`);const h=this.config.publicClient;let k;try{k=await h.readContract({address:this.config.vaultContracts.btcVaultRegistry,abi:R.BTCVaultRegistryABI,functionName:"getPegInFee",args:[o]})}catch(M){throw new Error("Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct.",{cause:M})}const C=await this.resolveMaxAcceptableCommissionBps(o,e.quotedCommissionBps),f=V.encodeFunctionData({abi:R.BTCVaultRegistryABI,functionName:"submitPeginRequest",args:[l,y,w,g,v,o,C,r,i,p,c]});let A;try{A=await h.estimateGas({to:this.config.vaultContracts.btcVaultRegistry,data:f,value:k,account:this.config.ethWallet.account.address})}catch(M){O.handleContractError(M)}let I;try{I=await this.config.ethWallet.sendTransaction({to:this.config.vaultContracts.btcVaultRegistry,data:f,value:k,account:this.config.ethWallet.account,chain:this.config.ethChain,gas:A})}catch(M){O.handleContractError(M)}const G=await H.waitForTransactionReceiptSmartAware({publicClient:h,walletAddress:this.config.ethWallet.account.address,hash:I,timeout:gt});return G.status==="reverted"&&O.handleContractError(new Error(`Transaction reverted. Hash: ${G.transactionHash}. Check the transaction on block explorer for details.`)),{ethTxHash:G.transactionHash,vaultId:b,peginTxHash:S}}async registerPeginBatchOnChain(e){const{vaultProvider:t,unsignedPrePeginTx:n,requests:o,popSignature:r}=e;if(o.length===0)throw new Error("Batch pegin requires at least one request");if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const i=this.config.ethWallet.account.address;if(!V.isAddressEqual(r.depositorEthAddress,i))throw new Error(`Proof of possession was signed for ${r.depositorEthAddress} but the Ethereum wallet is currently connected to ${i}. Reconnect the original account or call signProofOfPossession() again.`);const a=await this.assertPopMatchesBtcWallet(r),c=r.btcPopSignature,u=o.map(h=>this.resolvePayoutScriptPubKey(a,h.depositorPayoutBtcAddress)),l=[];for(const h of o){const k=d.ensureHexPrefix(h.depositorSignedPeginTx),C=H.calculateBtcTxHash(k),f=await W.deriveVaultId(d.stripHexPrefix(C),d.stripHexPrefix(i)),A=d.ensureHexPrefix(f);if(await this.checkVaultExists(A))throw new Error(`Vault already exists (ID: ${A}, peginTxHash: ${C}). To create a new vault, use different UTXOs or a different amount.`);l.push({vaultId:A,peginTxHash:C})}const P=this.config.publicClient;let w;try{w=await P.readContract({address:this.config.vaultContracts.btcVaultRegistry,abi:R.BTCVaultRegistryABI,functionName:"getPegInFee",args:[t]})}catch(h){throw new Error("Failed to query pegin fee from the contract. Please check your network connection and that the contract address is correct.",{cause:h})}const y=w*BigInt(o.length),g=await this.resolveMaxAcceptableCommissionBps(t,e.quotedCommissionBps),v=d.ensureHexPrefix(r.depositorBtcPubkey),T=d.ensureHexPrefix(n),p=o.map((h,k)=>({depositorBtcPubKey:v,btcPopSignature:c,unsignedPrePeginTx:T,depositorSignedPeginTx:d.ensureHexPrefix(h.depositorSignedPeginTx),hashlock:h.hashlock,htlcVout:h.htlcVout,referralCode:_t,depositorPayoutBtcAddress:u[k],depositorWotsPkHash:h.depositorWotsPkHash})),S=V.encodeFunctionData({abi:R.BTCVaultRegistryABI,functionName:"submitPeginRequestBatch",args:[i,t,g,p]});let m;try{m=await P.estimateGas({to:this.config.vaultContracts.btcVaultRegistry,data:S,value:y,account:this.config.ethWallet.account.address})}catch(h){O.handleContractError(h)}let b;try{b=await this.config.ethWallet.sendTransaction({to:this.config.vaultContracts.btcVaultRegistry,data:S,value:y,account:this.config.ethWallet.account,chain:this.config.ethChain,gas:m})}catch(h){O.handleContractError(h)}const E=await H.waitForTransactionReceiptSmartAware({publicClient:P,walletAddress:this.config.ethWallet.account.address,hash:b,timeout:gt});return E.status==="reverted"&&O.handleContractError(new Error(`Batch transaction reverted. Hash: ${E.transactionHash}. Check the transaction on block explorer for details.`)),{ethTxHash:E.transactionHash,vaults:l}}async resolveMaxAcceptableCommissionBps(e,t){if(t===void 0&&N.supportsDepositApproval(this.config.btcWallet))throw new Error("quotedCommissionBps is required when the wallet approved deposit terms: the registration ceiling must anchor to the approved quote.");let n;try{n=await new et.ViemVaultRegistryReader(this.config.publicClient,this.config.vaultContracts.btcVaultRegistry).getVaultProviderCommission(e)}catch(o){throw new Error("Failed to query vault provider commission from the contract. Please check your network connection and that the contract address is correct.",{cause:o})}if(t!==void 0){if(n>t+nt)throw new Error(`Vault provider commission changed since quote: quoted ${t} bps, chain currently reports ${n} bps (allowed drift ${nt} bps). Please refresh to see the new commission and try again.`);return Z(t)}return Z(n)}async checkVaultExists(e){return(await this.config.publicClient.readContract({address:this.config.vaultContracts.btcVaultRegistry,abi:R.BTCVaultRegistryABI,functionName:"getBtcVaultBasicInfo",args:[e]})).depositor!==V.zeroAddress}resolvePayoutScriptPubKey(e,t){if(!d.isAddressFromPublicKey(t,e,this.config.btcNetwork))throw d.stripHexPrefix(e).length===d.X_ONLY_PUBKEY_HEX_LEN&&xe(t,this.config.btcNetwork)?new Error(`BTC payout address "${t}" is a P2WPKH (Native SegWit) address, but the connected wallet only exposes an x-only public key. P2WPKH validation requires a compressed key with known y-parity. Use a P2TR (Taproot) payout address instead.`):new Error(`BTC payout address "${t}" is not derived from the connected wallet's public key. The payout sink must be controlled by the same key that signs the pegin; refusing to register a mismatched address.`);const n=d.getNetwork(this.config.btcNetwork);try{return`0x${ft.address.toOutputScript(t,n).toString("hex")}`}catch{throw new Error(`Invalid BTC payout address: "${t}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`)}}async signProofOfPossession(){if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const e=this.config.ethWallet.account.address,t=U(await this.config.btcWallet.getPublicKeyHex()),n=this.config.vaultContracts.btcVaultRegistry,o=`${e.toLowerCase()}:${this.config.ethChain.id}:pegin:${n.toLowerCase()}`,r=await this.config.btcWallet.signMessage(o,"bip322-simple");return{btcPopSignature:be(r),depositorEthAddress:e,depositorBtcPubkey:t}}async assertPopMatchesBtcWallet(e){const t=await this.config.btcWallet.getPublicKeyHex(),n=U(t),o=U(e.depositorBtcPubkey);if(n!==o)throw new Error(`Proof of possession was signed with BTC pubkey ${o} but the BTC wallet is currently connected to ${n}. Reconnect the original wallet or call signProofOfPossession() again.`);return t}getNetwork(){return this.config.btcNetwork}getVaultContractAddress(){return this.config.vaultContracts.btcVaultRegistry}}const ke=80,Be=250,Te=300,Ee=22,It="ab";function Ae(s,e){const t=It.repeat(Te),n=d.stripHexPrefix(s).toLowerCase(),o=e.toString(16).padStart(8,"0"),r=`${n}${o}`,i=t.slice(r.length);return`0x${r}${i}`}function ve(s,e){const t=n=>`0x${It.repeat(n)}`;return{depositorBtcPubKey:t(32),btcPopSignature:t(ke),unsignedPrePeginTx:t(Be),depositorSignedPeginTx:Ae(s,e),hashlock:t(32),htlcVout:e,referralCode:_t,depositorPayoutBtcAddress:t(Ee),depositorWotsPkHash:t(32)}}async function Se(s){const{publicClient:e,btcVaultRegistry:t,depositorEthAddress:n,vaultProvider:o,batchSize:r}=s;if(r<=0)throw new Error(`estimateSubmitPeginRequestBatchGas requires batchSize >= 1 (received ${r})`);const a=await e.readContract({address:t,abi:R.BTCVaultRegistryABI,functionName:"getPegInFee",args:[o]})*BigInt(r),c=Array.from({length:r},(l,P)=>ve(n,P)),u=V.encodeFunctionData({abi:R.BTCVaultRegistryABI,functionName:"submitPeginRequestBatch",args:[n,o,Ct,c]});return e.estimateGas({to:t,data:u,value:a,account:n})}exports.PeginManager=ye;exports.buildDepositTerms=pt;exports.computeWotsBlockPublicKeysHash=St;exports.deriveWotsBlocksFromSeed=vt;exports.estimateSubmitPeginRequestBatchGas=Se;
2
+ //# sourceMappingURL=PeginManager-792nHwLl.cjs.map