@babylonlabs-io/ts-sdk 0.27.0 → 0.28.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.
- package/dist/{buildAndBroadcastRefund-BzYJv-Fv.js → buildAndBroadcastRefund-Cc4-L7gX.js} +32 -31
- package/dist/buildAndBroadcastRefund-Cc4-L7gX.js.map +1 -0
- package/dist/buildAndBroadcastRefund-OoaQaNqn.cjs +2 -0
- package/dist/buildAndBroadcastRefund-OoaQaNqn.cjs.map +1 -0
- package/dist/deriveVaultRoot-B4gnRbW_.cjs +2 -0
- package/dist/deriveVaultRoot-B4gnRbW_.cjs.map +1 -0
- package/dist/{context-CClNOyD3.js → deriveVaultRoot-DAMZDqg-.js} +495 -541
- package/dist/deriveVaultRoot-DAMZDqg-.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +55 -55
- package/dist/psbtInputFields-CB8hqjQ5.cjs +2 -0
- package/dist/psbtInputFields-CB8hqjQ5.cjs.map +1 -0
- package/dist/{psbtInputFields-C3dqKWjQ.js → psbtInputFields-DeTFSJOq.js} +70 -64
- package/dist/psbtInputFields-DeTFSJOq.js.map +1 -0
- package/dist/sha2-CPdTLk1u.js +280 -0
- package/dist/sha2-CPdTLk1u.js.map +1 -0
- package/dist/sha2-CsTynrfJ.cjs +2 -0
- package/dist/sha2-CsTynrfJ.cjs.map +1 -0
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/wallets/index.d.ts +2 -1
- package/dist/shared/wallets/index.d.ts.map +1 -1
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +8 -0
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -1
- package/dist/signing-BZigafm0.js.map +1 -1
- package/dist/signing-DHSXjhLM.cjs.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +2 -2
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.js +52 -52
- package/dist/tbv/core/services/deposit/peginState.d.ts +1 -1
- package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +1 -1
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +1 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts +5 -0
- package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts +13 -0
- package/dist/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/context.d.ts +9 -0
- package/dist/tbv/core/vault-secrets/context.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts +56 -0
- package/dist/tbv/core/vault-secrets/deriveVaultRoot.d.ts.map +1 -0
- package/dist/tbv/core/vault-secrets/expand.d.ts +18 -3
- package/dist/tbv/core/vault-secrets/expand.d.ts.map +1 -1
- package/dist/tbv/core/vault-secrets/index.d.ts +6 -3
- package/dist/tbv/core/vault-secrets/index.d.ts.map +1 -1
- package/dist/tbv/core/wots/blockDerivation.d.ts +20 -24
- package/dist/tbv/core/wots/blockDerivation.d.ts.map +1 -1
- package/dist/tbv/core/wots/errors.d.ts +3 -1
- package/dist/tbv/core/wots/errors.d.ts.map +1 -1
- package/dist/tbv/core/wots/index.d.ts +1 -2
- package/dist/tbv/core/wots/index.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +52 -52
- package/dist/testing/MockBitcoinWallet.d.ts +9 -3
- package/dist/testing/MockBitcoinWallet.d.ts.map +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js +65 -54
- package/dist/testing/index.js.map +1 -1
- package/dist/types-CQ86O7NX.js +650 -0
- package/dist/types-CQ86O7NX.js.map +1 -0
- package/dist/types-CcwaEPE1.cjs +2 -0
- package/dist/types-CcwaEPE1.cjs.map +1 -0
- package/dist/{vault-registry-reader-CpCOte7w.js → vault-registry-reader-CshEgmS0.js} +31 -30
- package/dist/{vault-registry-reader-CpCOte7w.js.map → vault-registry-reader-CshEgmS0.js.map} +1 -1
- package/dist/vault-registry-reader-_2BjSjoN.cjs +2 -0
- package/dist/{vault-registry-reader-BizmBSBV.cjs.map → vault-registry-reader-_2BjSjoN.cjs.map} +1 -1
- package/package.json +3 -3
- package/dist/buildAndBroadcastRefund-BEASMFsz.cjs +0 -2
- package/dist/buildAndBroadcastRefund-BEASMFsz.cjs.map +0 -1
- package/dist/buildAndBroadcastRefund-BzYJv-Fv.js.map +0 -1
- package/dist/context-BSdcD4J_.cjs +0 -2
- package/dist/context-BSdcD4J_.cjs.map +0 -1
- package/dist/context-CClNOyD3.js.map +0 -1
- package/dist/psbtInputFields-C3dqKWjQ.js.map +0 -1
- package/dist/psbtInputFields-DhGm77bP.cjs +0 -2
- package/dist/psbtInputFields-DhGm77bP.cjs.map +0 -1
- package/dist/sha2-1XZuToHP.cjs +0 -2
- package/dist/sha2-1XZuToHP.cjs.map +0 -1
- package/dist/sha2-ZzfZqQSw.js +0 -1123
- package/dist/sha2-ZzfZqQSw.js.map +0 -1
- package/dist/tbv/core/wots/deriveWotsPkHash.d.ts +0 -9
- package/dist/tbv/core/wots/deriveWotsPkHash.d.ts.map +0 -1
- package/dist/vault-registry-reader-BizmBSBV.cjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing-BZigafm0.js","sources":["../src/tbv/core/services/deposit/peginState.ts","../src/tbv/core/utils/signing.ts"],"sourcesContent":["// ============================================================================\n// State Definitions\n// ============================================================================\n\n/**\n * Vault status — combines on-chain contract status (0-4) with indexer-derived\n * statuses (5-7). The contract enum (BTCVaultRegistry.sol BTCVaultStatus) only\n * has: Pending(0), Verified(1), Active(2), Redeemed(3), Expired(4).\n * The indexer maps these and adds extra statuses for UI display.\n *\n * IMPORTANT: With the new contract architecture:\n * - Core vault status (BTCVaultRegistry) does NOT change when used by applications\n * - Vaults remain at ACTIVE status even when used in DeFi positions\n * - Application usage status is tracked separately by each integration controller\n */\nexport enum ContractStatus {\n /** Status 0: Request submitted, waiting for ACKs */\n PENDING = 0,\n /** Status 1: All ACKs collected, ready for secret activation */\n VERIFIED = 1,\n /** Status 2: HTLC secret revealed, vault is active and usable (stays here even when used by apps) */\n ACTIVE = 2,\n /** Status 3: Vault has been redeemed, BTC is claimable */\n REDEEMED = 3,\n /** Status 4 (indexer-only): Vault was liquidated (collateral seized due to unpaid debt) */\n LIQUIDATED = 4,\n /** Status 5 (indexer-only): Vault is invalid — BTC UTXOs were spent in a different transaction */\n INVALID = 5,\n /** Status 6 (indexer-only): Depositor has withdrawn their BTC (redemption complete) */\n DEPOSITOR_WITHDRAWN = 6,\n /** Status 7 (indexer-only): Vault expired due to AckTimeout or ActivationTimeout */\n EXPIRED = 7,\n}\n\n/** Reason why a vault expired */\nexport type ExpirationReason =\n | \"ack_timeout\"\n | \"proof_timeout\"\n | \"activation_timeout\";\n\n// ============================================================================\n// Protocol State Model\n// ============================================================================\n\n/**\n * Available actions user can take\n */\nexport enum PeginAction {\n /** Submit WOTS key (re-enter mnemonic) */\n SUBMIT_WOTS_KEY = \"SUBMIT_WOTS_KEY\",\n /** Sign payout transactions */\n SIGN_PAYOUT_TRANSACTIONS = \"SIGN_PAYOUT_TRANSACTIONS\",\n /** Sign and broadcast peg-in transaction to Bitcoin */\n SIGN_AND_BROADCAST_TO_BITCOIN = \"SIGN_AND_BROADCAST_TO_BITCOIN\",\n /** Reveal HTLC secret on Ethereum to activate vault */\n ACTIVATE_VAULT = \"ACTIVATE_VAULT\",\n /** Sign and broadcast HTLC refund transaction for an expired vault */\n REFUND_HTLC = \"REFUND_HTLC\",\n}\n\n/**\n * Protocol-level peg-in state (framework-agnostic)\n */\nexport interface PeginProtocolState {\n /** Smart contract status (source of truth for on-chain state) */\n contractStatus: ContractStatus;\n /** Available user actions (empty array when no action is available) */\n availableActions: PeginAction[];\n}\n\n/**\n * Options for getPeginProtocolState function.\n *\n * All fields represent protocol-level state from the vault provider or\n * on-chain contracts. Client-side tracking (localStorage, polling state)\n * is NOT included — consumers handle that in their own layer.\n */\nexport interface GetPeginProtocolStateOptions {\n /** Whether claim/payout transactions are ready from VP */\n transactionsReady?: boolean;\n /** Whether the vault provider is waiting for the depositor's WOTS public key */\n needsWotsKey?: boolean;\n /** Whether the vault provider hasn't ingested this peg-in yet */\n pendingIngestion?: boolean;\n /** Whether the depositor can refund the HTLC (Pre-PegIn tx available) */\n canRefund?: boolean;\n /** Whether the vault provider reported a terminal failure */\n hasProviderTerminalFailure?: boolean;\n}\n\n// ============================================================================\n// State Machine Logic\n// ============================================================================\n\n/**\n * Determine the current protocol state and available actions based on contract\n * status and vault provider state. Framework-agnostic: returns only\n * protocol-level data with no display labels, messages, or UI concerns.\n *\n * Client-side tracking overrides (e.g. suppressing actions after the user\n * has already acted but on-chain state hasn't caught up) are the caller's\n * responsibility.\n *\n * @param contractStatus - On-chain contract status (source of truth)\n * @param options - Vault provider state\n * @returns Protocol state with available actions\n */\nexport function getPeginProtocolState(\n contractStatus: ContractStatus,\n options: GetPeginProtocolStateOptions = {},\n): PeginProtocolState {\n const {\n transactionsReady,\n needsWotsKey,\n pendingIngestion,\n canRefund,\n hasProviderTerminalFailure,\n } = options;\n\n if (contractStatus === ContractStatus.PENDING) {\n if (hasProviderTerminalFailure) {\n return { contractStatus, availableActions: [] };\n }\n\n if (needsWotsKey) {\n return {\n contractStatus,\n availableActions: [PeginAction.SUBMIT_WOTS_KEY],\n };\n }\n\n if (pendingIngestion === true && !transactionsReady) {\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_AND_BROADCAST_TO_BITCOIN],\n };\n }\n\n if (pendingIngestion === undefined && !transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n if (!transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_PAYOUT_TRANSACTIONS],\n };\n }\n\n if (contractStatus === ContractStatus.VERIFIED) {\n return {\n contractStatus,\n availableActions: [PeginAction.ACTIVATE_VAULT],\n };\n }\n\n if (contractStatus === ContractStatus.ACTIVE) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.REDEEMED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.LIQUIDATED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.EXPIRED) {\n return {\n contractStatus,\n availableActions: canRefund ? [PeginAction.REFUND_HTLC] : [],\n };\n }\n\n if (contractStatus === ContractStatus.INVALID) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.DEPOSITOR_WITHDRAWN) {\n return { contractStatus, availableActions: [] };\n }\n\n return { contractStatus, availableActions: [] };\n}\n\n/**\n * Check if a specific action is available in the current state\n */\nexport function canPerformAction(\n state: PeginProtocolState,\n action: PeginAction,\n): boolean {\n return state.availableActions.includes(action);\n}\n","import type { SignPsbtOptions } from \"../../../shared/wallets/interfaces\";\n\n/**\n * Create SignPsbtOptions for Taproot script-path PSBT signing.\n *\n * All vault protocol signing operations are Taproot script-path spends that\n * require `useTweakedSigner: false` (untweaked key) and `autoFinalized: false`\n * (to preserve tapScriptSig for Schnorr signature extraction).\n *\n * @param publicKey - Signer's BTC public key (hex). Accepts both compressed\n * (66-char) and x-only (64-char) formats — the wallet connector handles both.\n * @param inputCount - Number of inputs to sign. Generates entries\n * for indices 0 through inputCount-1.\n */\nexport function createTaprootScriptPathSignOptions(\n publicKey: string,\n inputCount: number,\n): SignPsbtOptions {\n if (!Number.isInteger(inputCount) || inputCount < 1) {\n throw new Error(`inputCount must be a positive integer, got ${inputCount}`);\n }\n\n return {\n autoFinalized: false,\n signInputs: Array.from({ length: inputCount }, (_, i) => ({\n index: i,\n publicKey,\n useTweakedSigner: false,\n })),\n };\n}\n"],"names":["ContractStatus","PeginAction","getPeginProtocolState","contractStatus","options","transactionsReady","needsWotsKey","pendingIngestion","canRefund","hasProviderTerminalFailure","canPerformAction","state","action","createTaprootScriptPathSignOptions","publicKey","inputCount","_","i"],"mappings":"AAeO,IAAKA,sBAAAA,OAEVA,EAAAA,EAAA,UAAU,CAAA,IAAV,WAEAA,EAAAA,EAAA,WAAW,CAAA,IAAX,YAEAA,EAAAA,EAAA,SAAS,CAAA,IAAT,UAEAA,EAAAA,EAAA,WAAW,CAAA,IAAX,YAEAA,EAAAA,EAAA,aAAa,CAAA,IAAb,cAEAA,EAAAA,EAAA,UAAU,CAAA,IAAV,WAEAA,EAAAA,EAAA,sBAAsB,CAAA,IAAtB,uBAEAA,EAAAA,EAAA,UAAU,CAAA,IAAV,WAhBUA,IAAAA,KAAA,CAAA,CAAA,GAgCAC,sBAAAA,OAEVA,EAAA,kBAAkB,mBAElBA,EAAA,2BAA2B,4BAE3BA,EAAA,gCAAgC,iCAEhCA,EAAA,iBAAiB,kBAEjBA,EAAA,cAAc,eAVJA,IAAAA,KAAA,CAAA,CAAA;AA4DL,SAASC,EACdC,GACAC,IAAwC,IACpB;AACpB,QAAM;AAAA,IACJ,mBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,4BAAAC;AAAA,EAAA,IACEL;AAEJ,SAAID,MAAmB,IACjBM,IACK,EAAE,gBAAAN,GAAgB,kBAAkB,GAAC,IAG1CG,IACK;AAAA,IACL,gBAAAH;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAA2B,IAI9CI,MAAqB,MAAQ,CAACF,IACzB;AAAA,IACL,gBAAAF;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAAyC,IAI5DI,MAAqB,UAAa,CAACF,IAC9B,EAAE,gBAAAF,GAAgB,kBAAkB,GAAC,IAGzCE,IAIE;AAAA,IACL,gBAAAF;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAAoC,IALhD,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAS5CA,MAAmB,IACd;AAAA,IACL,gBAAAA;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAA0B,IAI7CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd;AAAA,IACL,gBAAAA;AAAA,IACA,kBAAkBK,IAAY;AAAA,MAAC;AAAA;AAAA,QAA2B,CAAA;AAAA,EAAC,IAI3DL,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAGvC,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC;AAC9C;AAKO,SAASO,EACdC,GACAC,GACS;AACT,SAAOD,EAAM,iBAAiB,SAASC,CAAM;AAC/C;ACvLO,SAASC,EACdC,GACAC,GACiB;AACjB,MAAI,CAAC,OAAO,UAAUA,CAAU,KAAKA,IAAa;AAChD,UAAM,IAAI,MAAM,8CAA8CA,CAAU,EAAE;AAG5E,SAAO;AAAA,IACL,eAAe;AAAA,IACf,YAAY,MAAM,KAAK,EAAE,QAAQA,KAAc,CAACC,GAAGC,OAAO;AAAA,MACxD,OAAOA;AAAA,MACP,WAAAH;AAAA,MACA,kBAAkB;AAAA,IAAA,EAClB;AAAA,EAAA;AAEN;"}
|
|
1
|
+
{"version":3,"file":"signing-BZigafm0.js","sources":["../src/tbv/core/services/deposit/peginState.ts","../src/tbv/core/utils/signing.ts"],"sourcesContent":["// ============================================================================\n// State Definitions\n// ============================================================================\n\n/**\n * Vault status — combines on-chain contract status (0-4) with indexer-derived\n * statuses (5-7). The contract enum (BTCVaultRegistry.sol BTCVaultStatus) only\n * has: Pending(0), Verified(1), Active(2), Redeemed(3), Expired(4).\n * The indexer maps these and adds extra statuses for UI display.\n *\n * IMPORTANT: With the new contract architecture:\n * - Core vault status (BTCVaultRegistry) does NOT change when used by applications\n * - Vaults remain at ACTIVE status even when used in DeFi positions\n * - Application usage status is tracked separately by each integration controller\n */\nexport enum ContractStatus {\n /** Status 0: Request submitted, waiting for ACKs */\n PENDING = 0,\n /** Status 1: All ACKs collected, ready for secret activation */\n VERIFIED = 1,\n /** Status 2: HTLC secret revealed, vault is active and usable (stays here even when used by apps) */\n ACTIVE = 2,\n /** Status 3: Vault has been redeemed, BTC is claimable */\n REDEEMED = 3,\n /** Status 4 (indexer-only): Vault was liquidated (collateral seized due to unpaid debt) */\n LIQUIDATED = 4,\n /** Status 5 (indexer-only): Vault is invalid — BTC UTXOs were spent in a different transaction */\n INVALID = 5,\n /** Status 6 (indexer-only): Depositor has withdrawn their BTC (redemption complete) */\n DEPOSITOR_WITHDRAWN = 6,\n /** Status 7 (indexer-only): Vault expired due to AckTimeout or ActivationTimeout */\n EXPIRED = 7,\n}\n\n/** Reason why a vault expired */\nexport type ExpirationReason =\n | \"ack_timeout\"\n | \"proof_timeout\"\n | \"activation_timeout\";\n\n// ============================================================================\n// Protocol State Model\n// ============================================================================\n\n/**\n * Available actions user can take\n */\nexport enum PeginAction {\n /** Submit WOTS key (re-derives via wallet `deriveContextHash`) */\n SUBMIT_WOTS_KEY = \"SUBMIT_WOTS_KEY\",\n /** Sign payout transactions */\n SIGN_PAYOUT_TRANSACTIONS = \"SIGN_PAYOUT_TRANSACTIONS\",\n /** Sign and broadcast peg-in transaction to Bitcoin */\n SIGN_AND_BROADCAST_TO_BITCOIN = \"SIGN_AND_BROADCAST_TO_BITCOIN\",\n /** Reveal HTLC secret on Ethereum to activate vault */\n ACTIVATE_VAULT = \"ACTIVATE_VAULT\",\n /** Sign and broadcast HTLC refund transaction for an expired vault */\n REFUND_HTLC = \"REFUND_HTLC\",\n}\n\n/**\n * Protocol-level peg-in state (framework-agnostic)\n */\nexport interface PeginProtocolState {\n /** Smart contract status (source of truth for on-chain state) */\n contractStatus: ContractStatus;\n /** Available user actions (empty array when no action is available) */\n availableActions: PeginAction[];\n}\n\n/**\n * Options for getPeginProtocolState function.\n *\n * All fields represent protocol-level state from the vault provider or\n * on-chain contracts. Client-side tracking (localStorage, polling state)\n * is NOT included — consumers handle that in their own layer.\n */\nexport interface GetPeginProtocolStateOptions {\n /** Whether claim/payout transactions are ready from VP */\n transactionsReady?: boolean;\n /** Whether the vault provider is waiting for the depositor's WOTS public key */\n needsWotsKey?: boolean;\n /** Whether the vault provider hasn't ingested this peg-in yet */\n pendingIngestion?: boolean;\n /** Whether the depositor can refund the HTLC (Pre-PegIn tx available) */\n canRefund?: boolean;\n /** Whether the vault provider reported a terminal failure */\n hasProviderTerminalFailure?: boolean;\n}\n\n// ============================================================================\n// State Machine Logic\n// ============================================================================\n\n/**\n * Determine the current protocol state and available actions based on contract\n * status and vault provider state. Framework-agnostic: returns only\n * protocol-level data with no display labels, messages, or UI concerns.\n *\n * Client-side tracking overrides (e.g. suppressing actions after the user\n * has already acted but on-chain state hasn't caught up) are the caller's\n * responsibility.\n *\n * @param contractStatus - On-chain contract status (source of truth)\n * @param options - Vault provider state\n * @returns Protocol state with available actions\n */\nexport function getPeginProtocolState(\n contractStatus: ContractStatus,\n options: GetPeginProtocolStateOptions = {},\n): PeginProtocolState {\n const {\n transactionsReady,\n needsWotsKey,\n pendingIngestion,\n canRefund,\n hasProviderTerminalFailure,\n } = options;\n\n if (contractStatus === ContractStatus.PENDING) {\n if (hasProviderTerminalFailure) {\n return { contractStatus, availableActions: [] };\n }\n\n if (needsWotsKey) {\n return {\n contractStatus,\n availableActions: [PeginAction.SUBMIT_WOTS_KEY],\n };\n }\n\n if (pendingIngestion === true && !transactionsReady) {\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_AND_BROADCAST_TO_BITCOIN],\n };\n }\n\n if (pendingIngestion === undefined && !transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n if (!transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_PAYOUT_TRANSACTIONS],\n };\n }\n\n if (contractStatus === ContractStatus.VERIFIED) {\n return {\n contractStatus,\n availableActions: [PeginAction.ACTIVATE_VAULT],\n };\n }\n\n if (contractStatus === ContractStatus.ACTIVE) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.REDEEMED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.LIQUIDATED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.EXPIRED) {\n return {\n contractStatus,\n availableActions: canRefund ? [PeginAction.REFUND_HTLC] : [],\n };\n }\n\n if (contractStatus === ContractStatus.INVALID) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.DEPOSITOR_WITHDRAWN) {\n return { contractStatus, availableActions: [] };\n }\n\n return { contractStatus, availableActions: [] };\n}\n\n/**\n * Check if a specific action is available in the current state\n */\nexport function canPerformAction(\n state: PeginProtocolState,\n action: PeginAction,\n): boolean {\n return state.availableActions.includes(action);\n}\n","import type { SignPsbtOptions } from \"../../../shared/wallets/interfaces\";\n\n/**\n * Create SignPsbtOptions for Taproot script-path PSBT signing.\n *\n * All vault protocol signing operations are Taproot script-path spends that\n * require `useTweakedSigner: false` (untweaked key) and `autoFinalized: false`\n * (to preserve tapScriptSig for Schnorr signature extraction).\n *\n * @param publicKey - Signer's BTC public key (hex). Accepts both compressed\n * (66-char) and x-only (64-char) formats — the wallet connector handles both.\n * @param inputCount - Number of inputs to sign. Generates entries\n * for indices 0 through inputCount-1.\n */\nexport function createTaprootScriptPathSignOptions(\n publicKey: string,\n inputCount: number,\n): SignPsbtOptions {\n if (!Number.isInteger(inputCount) || inputCount < 1) {\n throw new Error(`inputCount must be a positive integer, got ${inputCount}`);\n }\n\n return {\n autoFinalized: false,\n signInputs: Array.from({ length: inputCount }, (_, i) => ({\n index: i,\n publicKey,\n useTweakedSigner: false,\n })),\n };\n}\n"],"names":["ContractStatus","PeginAction","getPeginProtocolState","contractStatus","options","transactionsReady","needsWotsKey","pendingIngestion","canRefund","hasProviderTerminalFailure","canPerformAction","state","action","createTaprootScriptPathSignOptions","publicKey","inputCount","_","i"],"mappings":"AAeO,IAAKA,sBAAAA,OAEVA,EAAAA,EAAA,UAAU,CAAA,IAAV,WAEAA,EAAAA,EAAA,WAAW,CAAA,IAAX,YAEAA,EAAAA,EAAA,SAAS,CAAA,IAAT,UAEAA,EAAAA,EAAA,WAAW,CAAA,IAAX,YAEAA,EAAAA,EAAA,aAAa,CAAA,IAAb,cAEAA,EAAAA,EAAA,UAAU,CAAA,IAAV,WAEAA,EAAAA,EAAA,sBAAsB,CAAA,IAAtB,uBAEAA,EAAAA,EAAA,UAAU,CAAA,IAAV,WAhBUA,IAAAA,KAAA,CAAA,CAAA,GAgCAC,sBAAAA,OAEVA,EAAA,kBAAkB,mBAElBA,EAAA,2BAA2B,4BAE3BA,EAAA,gCAAgC,iCAEhCA,EAAA,iBAAiB,kBAEjBA,EAAA,cAAc,eAVJA,IAAAA,KAAA,CAAA,CAAA;AA4DL,SAASC,EACdC,GACAC,IAAwC,IACpB;AACpB,QAAM;AAAA,IACJ,mBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,4BAAAC;AAAA,EAAA,IACEL;AAEJ,SAAID,MAAmB,IACjBM,IACK,EAAE,gBAAAN,GAAgB,kBAAkB,GAAC,IAG1CG,IACK;AAAA,IACL,gBAAAH;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAA2B,IAI9CI,MAAqB,MAAQ,CAACF,IACzB;AAAA,IACL,gBAAAF;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAAyC,IAI5DI,MAAqB,UAAa,CAACF,IAC9B,EAAE,gBAAAF,GAAgB,kBAAkB,GAAC,IAGzCE,IAIE;AAAA,IACL,gBAAAF;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAAoC,IALhD,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAS5CA,MAAmB,IACd;AAAA,IACL,gBAAAA;AAAA,IACA,kBAAkB;AAAA,MAAC;AAAA;AAAA,IAAA;AAAA,EAA0B,IAI7CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd;AAAA,IACL,gBAAAA;AAAA,IACA,kBAAkBK,IAAY;AAAA,MAAC;AAAA;AAAA,QAA2B,CAAA;AAAA,EAAC,IAI3DL,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAG1CA,MAAmB,IACd,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC,IAGvC,EAAE,gBAAAA,GAAgB,kBAAkB,GAAC;AAC9C;AAKO,SAASO,EACdC,GACAC,GACS;AACT,SAAOD,EAAM,iBAAiB,SAASC,CAAM;AAC/C;ACvLO,SAASC,EACdC,GACAC,GACiB;AACjB,MAAI,CAAC,OAAO,UAAUA,CAAU,KAAKA,IAAa;AAChD,UAAM,IAAI,MAAM,8CAA8CA,CAAU,EAAE;AAG5E,SAAO;AAAA,IACL,eAAe;AAAA,IACf,YAAY,MAAM,KAAK,EAAE,QAAQA,KAAc,CAACC,GAAGC,OAAO;AAAA,MACxD,OAAOA;AAAA,MACP,WAAAH;AAAA,MACA,kBAAkB;AAAA,IAAA,EAClB;AAAA,EAAA;AAEN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing-DHSXjhLM.cjs","sources":["../src/tbv/core/services/deposit/peginState.ts","../src/tbv/core/utils/signing.ts"],"sourcesContent":["// ============================================================================\n// State Definitions\n// ============================================================================\n\n/**\n * Vault status — combines on-chain contract status (0-4) with indexer-derived\n * statuses (5-7). The contract enum (BTCVaultRegistry.sol BTCVaultStatus) only\n * has: Pending(0), Verified(1), Active(2), Redeemed(3), Expired(4).\n * The indexer maps these and adds extra statuses for UI display.\n *\n * IMPORTANT: With the new contract architecture:\n * - Core vault status (BTCVaultRegistry) does NOT change when used by applications\n * - Vaults remain at ACTIVE status even when used in DeFi positions\n * - Application usage status is tracked separately by each integration controller\n */\nexport enum ContractStatus {\n /** Status 0: Request submitted, waiting for ACKs */\n PENDING = 0,\n /** Status 1: All ACKs collected, ready for secret activation */\n VERIFIED = 1,\n /** Status 2: HTLC secret revealed, vault is active and usable (stays here even when used by apps) */\n ACTIVE = 2,\n /** Status 3: Vault has been redeemed, BTC is claimable */\n REDEEMED = 3,\n /** Status 4 (indexer-only): Vault was liquidated (collateral seized due to unpaid debt) */\n LIQUIDATED = 4,\n /** Status 5 (indexer-only): Vault is invalid — BTC UTXOs were spent in a different transaction */\n INVALID = 5,\n /** Status 6 (indexer-only): Depositor has withdrawn their BTC (redemption complete) */\n DEPOSITOR_WITHDRAWN = 6,\n /** Status 7 (indexer-only): Vault expired due to AckTimeout or ActivationTimeout */\n EXPIRED = 7,\n}\n\n/** Reason why a vault expired */\nexport type ExpirationReason =\n | \"ack_timeout\"\n | \"proof_timeout\"\n | \"activation_timeout\";\n\n// ============================================================================\n// Protocol State Model\n// ============================================================================\n\n/**\n * Available actions user can take\n */\nexport enum PeginAction {\n /** Submit WOTS key (re-enter mnemonic) */\n SUBMIT_WOTS_KEY = \"SUBMIT_WOTS_KEY\",\n /** Sign payout transactions */\n SIGN_PAYOUT_TRANSACTIONS = \"SIGN_PAYOUT_TRANSACTIONS\",\n /** Sign and broadcast peg-in transaction to Bitcoin */\n SIGN_AND_BROADCAST_TO_BITCOIN = \"SIGN_AND_BROADCAST_TO_BITCOIN\",\n /** Reveal HTLC secret on Ethereum to activate vault */\n ACTIVATE_VAULT = \"ACTIVATE_VAULT\",\n /** Sign and broadcast HTLC refund transaction for an expired vault */\n REFUND_HTLC = \"REFUND_HTLC\",\n}\n\n/**\n * Protocol-level peg-in state (framework-agnostic)\n */\nexport interface PeginProtocolState {\n /** Smart contract status (source of truth for on-chain state) */\n contractStatus: ContractStatus;\n /** Available user actions (empty array when no action is available) */\n availableActions: PeginAction[];\n}\n\n/**\n * Options for getPeginProtocolState function.\n *\n * All fields represent protocol-level state from the vault provider or\n * on-chain contracts. Client-side tracking (localStorage, polling state)\n * is NOT included — consumers handle that in their own layer.\n */\nexport interface GetPeginProtocolStateOptions {\n /** Whether claim/payout transactions are ready from VP */\n transactionsReady?: boolean;\n /** Whether the vault provider is waiting for the depositor's WOTS public key */\n needsWotsKey?: boolean;\n /** Whether the vault provider hasn't ingested this peg-in yet */\n pendingIngestion?: boolean;\n /** Whether the depositor can refund the HTLC (Pre-PegIn tx available) */\n canRefund?: boolean;\n /** Whether the vault provider reported a terminal failure */\n hasProviderTerminalFailure?: boolean;\n}\n\n// ============================================================================\n// State Machine Logic\n// ============================================================================\n\n/**\n * Determine the current protocol state and available actions based on contract\n * status and vault provider state. Framework-agnostic: returns only\n * protocol-level data with no display labels, messages, or UI concerns.\n *\n * Client-side tracking overrides (e.g. suppressing actions after the user\n * has already acted but on-chain state hasn't caught up) are the caller's\n * responsibility.\n *\n * @param contractStatus - On-chain contract status (source of truth)\n * @param options - Vault provider state\n * @returns Protocol state with available actions\n */\nexport function getPeginProtocolState(\n contractStatus: ContractStatus,\n options: GetPeginProtocolStateOptions = {},\n): PeginProtocolState {\n const {\n transactionsReady,\n needsWotsKey,\n pendingIngestion,\n canRefund,\n hasProviderTerminalFailure,\n } = options;\n\n if (contractStatus === ContractStatus.PENDING) {\n if (hasProviderTerminalFailure) {\n return { contractStatus, availableActions: [] };\n }\n\n if (needsWotsKey) {\n return {\n contractStatus,\n availableActions: [PeginAction.SUBMIT_WOTS_KEY],\n };\n }\n\n if (pendingIngestion === true && !transactionsReady) {\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_AND_BROADCAST_TO_BITCOIN],\n };\n }\n\n if (pendingIngestion === undefined && !transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n if (!transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_PAYOUT_TRANSACTIONS],\n };\n }\n\n if (contractStatus === ContractStatus.VERIFIED) {\n return {\n contractStatus,\n availableActions: [PeginAction.ACTIVATE_VAULT],\n };\n }\n\n if (contractStatus === ContractStatus.ACTIVE) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.REDEEMED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.LIQUIDATED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.EXPIRED) {\n return {\n contractStatus,\n availableActions: canRefund ? [PeginAction.REFUND_HTLC] : [],\n };\n }\n\n if (contractStatus === ContractStatus.INVALID) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.DEPOSITOR_WITHDRAWN) {\n return { contractStatus, availableActions: [] };\n }\n\n return { contractStatus, availableActions: [] };\n}\n\n/**\n * Check if a specific action is available in the current state\n */\nexport function canPerformAction(\n state: PeginProtocolState,\n action: PeginAction,\n): boolean {\n return state.availableActions.includes(action);\n}\n","import type { SignPsbtOptions } from \"../../../shared/wallets/interfaces\";\n\n/**\n * Create SignPsbtOptions for Taproot script-path PSBT signing.\n *\n * All vault protocol signing operations are Taproot script-path spends that\n * require `useTweakedSigner: false` (untweaked key) and `autoFinalized: false`\n * (to preserve tapScriptSig for Schnorr signature extraction).\n *\n * @param publicKey - Signer's BTC public key (hex). Accepts both compressed\n * (66-char) and x-only (64-char) formats — the wallet connector handles both.\n * @param inputCount - Number of inputs to sign. Generates entries\n * for indices 0 through inputCount-1.\n */\nexport function createTaprootScriptPathSignOptions(\n publicKey: string,\n inputCount: number,\n): SignPsbtOptions {\n if (!Number.isInteger(inputCount) || inputCount < 1) {\n throw new Error(`inputCount must be a positive integer, got ${inputCount}`);\n }\n\n return {\n autoFinalized: false,\n signInputs: Array.from({ length: inputCount }, (_, i) => ({\n index: i,\n publicKey,\n useTweakedSigner: false,\n })),\n };\n}\n"],"names":["ContractStatus","PeginAction","getPeginProtocolState","contractStatus","options","transactionsReady","needsWotsKey","pendingIngestion","canRefund","hasProviderTerminalFailure","canPerformAction","state","action","createTaprootScriptPathSignOptions","publicKey","inputCount","_","i"],"mappings":"aAeO,IAAKA,GAAAA,IAEVA,EAAAA,EAAA,QAAU,CAAA,EAAV,UAEAA,EAAAA,EAAA,SAAW,CAAA,EAAX,WAEAA,EAAAA,EAAA,OAAS,CAAA,EAAT,SAEAA,EAAAA,EAAA,SAAW,CAAA,EAAX,WAEAA,EAAAA,EAAA,WAAa,CAAA,EAAb,aAEAA,EAAAA,EAAA,QAAU,CAAA,EAAV,UAEAA,EAAAA,EAAA,oBAAsB,CAAA,EAAtB,sBAEAA,EAAAA,EAAA,QAAU,CAAA,EAAV,UAhBUA,IAAAA,GAAA,CAAA,CAAA,EAgCAC,GAAAA,IAEVA,EAAA,gBAAkB,kBAElBA,EAAA,yBAA2B,2BAE3BA,EAAA,8BAAgC,gCAEhCA,EAAA,eAAiB,iBAEjBA,EAAA,YAAc,cAVJA,IAAAA,GAAA,CAAA,CAAA,EA4DL,SAASC,EACdC,EACAC,EAAwC,GACpB,CACpB,KAAM,CACJ,kBAAAC,EACA,aAAAC,EACA,iBAAAC,EACA,UAAAC,EACA,2BAAAC,CAAA,EACEL,EAEJ,OAAID,IAAmB,EACjBM,EACK,CAAE,eAAAN,EAAgB,iBAAkB,EAAC,EAG1CG,EACK,CACL,eAAAH,EACA,iBAAkB,CAAC,iBAAA,CAA2B,EAI9CI,IAAqB,IAAQ,CAACF,EACzB,CACL,eAAAF,EACA,iBAAkB,CAAC,+BAAA,CAAyC,EAI5DI,IAAqB,QAAa,CAACF,EAC9B,CAAE,eAAAF,EAAgB,iBAAkB,EAAC,EAGzCE,EAIE,CACL,eAAAF,EACA,iBAAkB,CAAC,0BAAA,CAAoC,EALhD,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAS5CA,IAAmB,EACd,CACL,eAAAA,EACA,iBAAkB,CAAC,gBAAA,CAA0B,EAI7CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CACL,eAAAA,EACA,iBAAkBK,EAAY,CAAC,eAA2B,CAAA,CAAC,EAI3DL,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAGvC,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,CAC9C,CAKO,SAASO,EACdC,EACAC,EACS,CACT,OAAOD,EAAM,iBAAiB,SAASC,CAAM,CAC/C,CCvLO,SAASC,EACdC,EACAC,EACiB,CACjB,GAAI,CAAC,OAAO,UAAUA,CAAU,GAAKA,EAAa,EAChD,MAAM,IAAI,MAAM,8CAA8CA,CAAU,EAAE,EAG5E,MAAO,CACL,cAAe,GACf,WAAY,MAAM,KAAK,CAAE,OAAQA,GAAc,CAACC,EAAGC,KAAO,CACxD,MAAOA,EACP,UAAAH,EACA,iBAAkB,EAAA,EAClB,CAAA,CAEN"}
|
|
1
|
+
{"version":3,"file":"signing-DHSXjhLM.cjs","sources":["../src/tbv/core/services/deposit/peginState.ts","../src/tbv/core/utils/signing.ts"],"sourcesContent":["// ============================================================================\n// State Definitions\n// ============================================================================\n\n/**\n * Vault status — combines on-chain contract status (0-4) with indexer-derived\n * statuses (5-7). The contract enum (BTCVaultRegistry.sol BTCVaultStatus) only\n * has: Pending(0), Verified(1), Active(2), Redeemed(3), Expired(4).\n * The indexer maps these and adds extra statuses for UI display.\n *\n * IMPORTANT: With the new contract architecture:\n * - Core vault status (BTCVaultRegistry) does NOT change when used by applications\n * - Vaults remain at ACTIVE status even when used in DeFi positions\n * - Application usage status is tracked separately by each integration controller\n */\nexport enum ContractStatus {\n /** Status 0: Request submitted, waiting for ACKs */\n PENDING = 0,\n /** Status 1: All ACKs collected, ready for secret activation */\n VERIFIED = 1,\n /** Status 2: HTLC secret revealed, vault is active and usable (stays here even when used by apps) */\n ACTIVE = 2,\n /** Status 3: Vault has been redeemed, BTC is claimable */\n REDEEMED = 3,\n /** Status 4 (indexer-only): Vault was liquidated (collateral seized due to unpaid debt) */\n LIQUIDATED = 4,\n /** Status 5 (indexer-only): Vault is invalid — BTC UTXOs were spent in a different transaction */\n INVALID = 5,\n /** Status 6 (indexer-only): Depositor has withdrawn their BTC (redemption complete) */\n DEPOSITOR_WITHDRAWN = 6,\n /** Status 7 (indexer-only): Vault expired due to AckTimeout or ActivationTimeout */\n EXPIRED = 7,\n}\n\n/** Reason why a vault expired */\nexport type ExpirationReason =\n | \"ack_timeout\"\n | \"proof_timeout\"\n | \"activation_timeout\";\n\n// ============================================================================\n// Protocol State Model\n// ============================================================================\n\n/**\n * Available actions user can take\n */\nexport enum PeginAction {\n /** Submit WOTS key (re-derives via wallet `deriveContextHash`) */\n SUBMIT_WOTS_KEY = \"SUBMIT_WOTS_KEY\",\n /** Sign payout transactions */\n SIGN_PAYOUT_TRANSACTIONS = \"SIGN_PAYOUT_TRANSACTIONS\",\n /** Sign and broadcast peg-in transaction to Bitcoin */\n SIGN_AND_BROADCAST_TO_BITCOIN = \"SIGN_AND_BROADCAST_TO_BITCOIN\",\n /** Reveal HTLC secret on Ethereum to activate vault */\n ACTIVATE_VAULT = \"ACTIVATE_VAULT\",\n /** Sign and broadcast HTLC refund transaction for an expired vault */\n REFUND_HTLC = \"REFUND_HTLC\",\n}\n\n/**\n * Protocol-level peg-in state (framework-agnostic)\n */\nexport interface PeginProtocolState {\n /** Smart contract status (source of truth for on-chain state) */\n contractStatus: ContractStatus;\n /** Available user actions (empty array when no action is available) */\n availableActions: PeginAction[];\n}\n\n/**\n * Options for getPeginProtocolState function.\n *\n * All fields represent protocol-level state from the vault provider or\n * on-chain contracts. Client-side tracking (localStorage, polling state)\n * is NOT included — consumers handle that in their own layer.\n */\nexport interface GetPeginProtocolStateOptions {\n /** Whether claim/payout transactions are ready from VP */\n transactionsReady?: boolean;\n /** Whether the vault provider is waiting for the depositor's WOTS public key */\n needsWotsKey?: boolean;\n /** Whether the vault provider hasn't ingested this peg-in yet */\n pendingIngestion?: boolean;\n /** Whether the depositor can refund the HTLC (Pre-PegIn tx available) */\n canRefund?: boolean;\n /** Whether the vault provider reported a terminal failure */\n hasProviderTerminalFailure?: boolean;\n}\n\n// ============================================================================\n// State Machine Logic\n// ============================================================================\n\n/**\n * Determine the current protocol state and available actions based on contract\n * status and vault provider state. Framework-agnostic: returns only\n * protocol-level data with no display labels, messages, or UI concerns.\n *\n * Client-side tracking overrides (e.g. suppressing actions after the user\n * has already acted but on-chain state hasn't caught up) are the caller's\n * responsibility.\n *\n * @param contractStatus - On-chain contract status (source of truth)\n * @param options - Vault provider state\n * @returns Protocol state with available actions\n */\nexport function getPeginProtocolState(\n contractStatus: ContractStatus,\n options: GetPeginProtocolStateOptions = {},\n): PeginProtocolState {\n const {\n transactionsReady,\n needsWotsKey,\n pendingIngestion,\n canRefund,\n hasProviderTerminalFailure,\n } = options;\n\n if (contractStatus === ContractStatus.PENDING) {\n if (hasProviderTerminalFailure) {\n return { contractStatus, availableActions: [] };\n }\n\n if (needsWotsKey) {\n return {\n contractStatus,\n availableActions: [PeginAction.SUBMIT_WOTS_KEY],\n };\n }\n\n if (pendingIngestion === true && !transactionsReady) {\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_AND_BROADCAST_TO_BITCOIN],\n };\n }\n\n if (pendingIngestion === undefined && !transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n if (!transactionsReady) {\n return { contractStatus, availableActions: [] };\n }\n\n return {\n contractStatus,\n availableActions: [PeginAction.SIGN_PAYOUT_TRANSACTIONS],\n };\n }\n\n if (contractStatus === ContractStatus.VERIFIED) {\n return {\n contractStatus,\n availableActions: [PeginAction.ACTIVATE_VAULT],\n };\n }\n\n if (contractStatus === ContractStatus.ACTIVE) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.REDEEMED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.LIQUIDATED) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.EXPIRED) {\n return {\n contractStatus,\n availableActions: canRefund ? [PeginAction.REFUND_HTLC] : [],\n };\n }\n\n if (contractStatus === ContractStatus.INVALID) {\n return { contractStatus, availableActions: [] };\n }\n\n if (contractStatus === ContractStatus.DEPOSITOR_WITHDRAWN) {\n return { contractStatus, availableActions: [] };\n }\n\n return { contractStatus, availableActions: [] };\n}\n\n/**\n * Check if a specific action is available in the current state\n */\nexport function canPerformAction(\n state: PeginProtocolState,\n action: PeginAction,\n): boolean {\n return state.availableActions.includes(action);\n}\n","import type { SignPsbtOptions } from \"../../../shared/wallets/interfaces\";\n\n/**\n * Create SignPsbtOptions for Taproot script-path PSBT signing.\n *\n * All vault protocol signing operations are Taproot script-path spends that\n * require `useTweakedSigner: false` (untweaked key) and `autoFinalized: false`\n * (to preserve tapScriptSig for Schnorr signature extraction).\n *\n * @param publicKey - Signer's BTC public key (hex). Accepts both compressed\n * (66-char) and x-only (64-char) formats — the wallet connector handles both.\n * @param inputCount - Number of inputs to sign. Generates entries\n * for indices 0 through inputCount-1.\n */\nexport function createTaprootScriptPathSignOptions(\n publicKey: string,\n inputCount: number,\n): SignPsbtOptions {\n if (!Number.isInteger(inputCount) || inputCount < 1) {\n throw new Error(`inputCount must be a positive integer, got ${inputCount}`);\n }\n\n return {\n autoFinalized: false,\n signInputs: Array.from({ length: inputCount }, (_, i) => ({\n index: i,\n publicKey,\n useTweakedSigner: false,\n })),\n };\n}\n"],"names":["ContractStatus","PeginAction","getPeginProtocolState","contractStatus","options","transactionsReady","needsWotsKey","pendingIngestion","canRefund","hasProviderTerminalFailure","canPerformAction","state","action","createTaprootScriptPathSignOptions","publicKey","inputCount","_","i"],"mappings":"aAeO,IAAKA,GAAAA,IAEVA,EAAAA,EAAA,QAAU,CAAA,EAAV,UAEAA,EAAAA,EAAA,SAAW,CAAA,EAAX,WAEAA,EAAAA,EAAA,OAAS,CAAA,EAAT,SAEAA,EAAAA,EAAA,SAAW,CAAA,EAAX,WAEAA,EAAAA,EAAA,WAAa,CAAA,EAAb,aAEAA,EAAAA,EAAA,QAAU,CAAA,EAAV,UAEAA,EAAAA,EAAA,oBAAsB,CAAA,EAAtB,sBAEAA,EAAAA,EAAA,QAAU,CAAA,EAAV,UAhBUA,IAAAA,GAAA,CAAA,CAAA,EAgCAC,GAAAA,IAEVA,EAAA,gBAAkB,kBAElBA,EAAA,yBAA2B,2BAE3BA,EAAA,8BAAgC,gCAEhCA,EAAA,eAAiB,iBAEjBA,EAAA,YAAc,cAVJA,IAAAA,GAAA,CAAA,CAAA,EA4DL,SAASC,EACdC,EACAC,EAAwC,GACpB,CACpB,KAAM,CACJ,kBAAAC,EACA,aAAAC,EACA,iBAAAC,EACA,UAAAC,EACA,2BAAAC,CAAA,EACEL,EAEJ,OAAID,IAAmB,EACjBM,EACK,CAAE,eAAAN,EAAgB,iBAAkB,EAAC,EAG1CG,EACK,CACL,eAAAH,EACA,iBAAkB,CAAC,iBAAA,CAA2B,EAI9CI,IAAqB,IAAQ,CAACF,EACzB,CACL,eAAAF,EACA,iBAAkB,CAAC,+BAAA,CAAyC,EAI5DI,IAAqB,QAAa,CAACF,EAC9B,CAAE,eAAAF,EAAgB,iBAAkB,EAAC,EAGzCE,EAIE,CACL,eAAAF,EACA,iBAAkB,CAAC,0BAAA,CAAoC,EALhD,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAS5CA,IAAmB,EACd,CACL,eAAAA,EACA,iBAAkB,CAAC,gBAAA,CAA0B,EAI7CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CACL,eAAAA,EACA,iBAAkBK,EAAY,CAAC,eAA2B,CAAA,CAAC,EAI3DL,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAG1CA,IAAmB,EACd,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,EAGvC,CAAE,eAAAA,EAAgB,iBAAkB,EAAC,CAC9C,CAKO,SAASO,EACdC,EACAC,EACS,CACT,OAAOD,EAAM,iBAAiB,SAASC,CAAM,CAC/C,CCvLO,SAASC,EACdC,EACAC,EACiB,CACjB,GAAI,CAAC,OAAO,UAAUA,CAAU,GAAKA,EAAa,EAChD,MAAM,IAAI,MAAM,8CAA8CA,CAAU,EAAE,EAG5E,MAAO,CACL,cAAe,GACf,WAAY,MAAM,KAAK,CAAE,OAAQA,GAAc,CAACC,EAAGC,KAAO,CACxD,MAAOA,EACP,UAAAH,EACA,iBAAkB,EAAA,EAClB,CAAA,CAEN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../vault-registry-reader-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../vault-registry-reader-_2BjSjoN.cjs"),r=require("../../../types-CcwaEPE1.cjs");exports.MEMPOOL_API_URLS=e.MEMPOOL_API_URLS;exports.ServerIdentityError=e.ServerIdentityError;exports.VaultProviderRpcClient=e.VaultProviderRpcClient;exports.ViemProtocolParamsReader=e.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=e.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=e.ViemVaultKeeperReader;exports.ViemVaultRegistryReader=e.ViemVaultRegistryReader;exports.VpResponseValidationError=e.VpResponseValidationError;exports.VpTokenProvider=e.VpTokenProvider;exports.getAddressTxs=e.getAddressTxs;exports.getAddressUtxos=e.getAddressUtxos;exports.getMempoolApiUrl=e.getMempoolApiUrl;exports.getNetworkFees=e.getNetworkFees;exports.getTxHex=e.getTxHex;exports.getTxInfo=e.getTxInfo;exports.getUtxoInfo=e.getUtxoInfo;exports.pushTx=e.pushTx;exports.resolveProtocolAddresses=e.resolveProtocolAddresses;exports.validateRequestDepositorClaimerArtifactsResponse=e.validateRequestDepositorClaimerArtifactsResponse;exports.verifyServerIdentity=e.verifyServerIdentity;exports.DaemonStatus=r.DaemonStatus;exports.JSON_RPC_ERROR_CODES=r.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=r.JsonRpcClient;exports.JsonRpcError=r.JsonRpcError;exports.POST_WOTS_STATUSES=r.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=r.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=r.RpcErrorCode;exports.VP_TERMINAL_STATUSES=r.VP_TERMINAL_STATUSES;exports.VP_TRANSIENT_STATUSES=r.VP_TRANSIENT_STATUSES;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as a, S as r, V as o, k as t, l as S, m as R, n as i, h as T, j as d, g as l, a as n, b as p, c as E, d as P, e as V, f as _, p as A, r as m, v as g, i as c } from "../../../vault-registry-reader-
|
|
2
|
-
import { D as x, b as I, J as O, a as U, d as f, P as C, R as u, c as N, V as D } from "../../../
|
|
1
|
+
import { M as a, S as r, V as o, k as t, l as S, m as R, n as i, h as T, j as d, g as l, a as n, b as p, c as E, d as P, e as V, f as _, p as A, r as m, v as g, i as c } from "../../../vault-registry-reader-CshEgmS0.js";
|
|
2
|
+
import { D as x, b as I, J as O, a as U, d as f, P as C, R as u, c as N, V as D } from "../../../types-CQ86O7NX.js";
|
|
3
3
|
export {
|
|
4
4
|
x as DaemonStatus,
|
|
5
5
|
I as JSON_RPC_ERROR_CODES,
|
package/dist/tbv/core/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../challengeAssert-BM8m9gPM.cjs"),P=require("@babylonlabs-io/babylon-tbv-rust-wasm"),d=require("../../payout-DP6KMFP1.cjs"),a=require("../../bitcoin-DIN0OupO.cjs"),l=require("../../signing-DHSXjhLM.cjs"),u=require("../../validation-u8W7Lp2x.cjs"),t=require("../../buildAndBroadcastRefund-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../challengeAssert-BM8m9gPM.cjs"),P=require("@babylonlabs-io/babylon-tbv-rust-wasm"),d=require("../../payout-DP6KMFP1.cjs"),a=require("../../bitcoin-DIN0OupO.cjs"),l=require("../../signing-DHSXjhLM.cjs"),u=require("../../validation-u8W7Lp2x.cjs"),t=require("../../buildAndBroadcastRefund-OoaQaNqn.cjs"),o=require("../../fundPeginTransaction-DaWoYCgO.cjs"),i=require("../../psbtInputFields-CB8hqjQ5.cjs"),r=require("../../deriveVaultRoot-B4gnRbW_.cjs"),e=require("../../vault-registry-reader-_2BjSjoN.cjs"),s=require("../../types-CcwaEPE1.cjs");exports.buildChallengeAssertPsbt=n.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=n.buildDepositorPayoutPsbt;exports.buildNoPayoutPsbt=n.buildNoPayoutPsbt;exports.buildPeginInputPsbt=n.buildPeginInputPsbt;exports.buildPeginTxFromFundedPrePegin=n.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=n.buildPrePeginPsbt;exports.computeNumLocalChallengers=n.computeNumLocalChallengers;exports.extractPeginInputSignature=n.extractPeginInputSignature;exports.finalizePeginInputPsbt=n.finalizePeginInputPsbt;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>P.computeMinClaimValue});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>P.deriveVaultId});exports.buildPayoutPsbt=d.buildPayoutPsbt;exports.buildRefundPsbt=d.buildRefundPsbt;exports.createPayoutScript=d.createPayoutScript;exports.extractPayoutSignature=d.extractPayoutSignature;exports.deriveNativeSegwitAddress=a.deriveNativeSegwitAddress;exports.deriveTaprootAddress=a.deriveTaprootAddress;exports.ensureHexPrefix=a.ensureHexPrefix;exports.formatSatoshisToBtc=a.formatSatoshisToBtc;exports.getNetwork=a.getNetwork;exports.hexToUint8Array=a.hexToUint8Array;exports.isAddressFromPublicKey=a.isAddressFromPublicKey;exports.isValidHex=a.isValidHex;exports.processPublicKeyToXOnly=a.processPublicKeyToXOnly;exports.stripHexPrefix=a.stripHexPrefix;exports.toXOnly=a.toXOnly;exports.uint8ArrayToHex=a.uint8ArrayToHex;exports.validateWalletPubkey=a.validateWalletPubkey;exports.ContractStatus=l.ContractStatus;exports.PeginAction=l.PeginAction;exports.canPerformAction=l.canPerformAction;exports.createTaprootScriptPathSignOptions=l.createTaprootScriptPathSignOptions;exports.getPeginProtocolState=l.getPeginProtocolState;exports.BITCOIN_ADDRESS_RE=u.BITCOIN_ADDRESS_RE;exports.HEX_RE=u.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=u.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=u.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=u.TXID_RE;exports.BIP68NotMatureError=t.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=t.ClaimerPegoutStatusValue;exports.PayoutManager=t.PayoutManager;exports.activateVault=t.activateVault;exports.buildAndBroadcastRefund=t.buildAndBroadcastRefund;exports.computeHashlock=t.computeHashlock;exports.isDepositAmountValid=t.isDepositAmountValid;exports.isPegoutTerminalStatus=t.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=t.isRecognizedPegoutStatus;exports.pollAndSignPayouts=t.pollAndSignPayouts;exports.signDepositorGraph=t.signDepositorGraph;exports.submitWotsPublicKey=t.submitWotsPublicKey;exports.validateDepositAmount=t.validateDepositAmount;exports.validateMultiVaultDepositInputs=t.validateMultiVaultDepositInputs;exports.validateProviderSelection=t.validateProviderSelection;exports.validateRemainingCapacity=t.validateRemainingCapacity;exports.validateSecretAgainstHashlock=t.validateSecretAgainstHashlock;exports.validateVaultAmounts=t.validateVaultAmounts;exports.validateVaultProviderPubkey=t.validateVaultProviderPubkey;exports.waitForPeginStatus=t.waitForPeginStatus;exports.BTC_DUST_SAT=o.BTC_DUST_SAT;exports.DUST_THRESHOLD=o.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=o.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=o.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=o.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=o.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=o.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=o.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=o.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=o.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=o.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=o.fundPeginTransaction;exports.parseUnfundedWasmTransaction=o.parseUnfundedWasmTransaction;exports.peginOutputCount=o.peginOutputCount;exports.rateBasedTxBufferFee=o.rateBasedTxBufferFee;exports.BitcoinScriptType=i.BitcoinScriptType;exports.UtxoNotAvailableError=i.UtxoNotAvailableError;exports.assertUtxosAvailable=i.assertUtxosAvailable;exports.calculateBtcTxHash=i.calculateBtcTxHash;exports.collectReservedUtxoRefs=i.collectReservedUtxoRefs;exports.extractInputsFromTransaction=i.extractInputsFromTransaction;exports.getDustThreshold=i.getDustThreshold;exports.getPsbtInputFields=i.getPsbtInputFields;exports.getScriptType=i.getScriptType;exports.selectUtxosForDeposit=i.selectUtxosForDeposit;exports.selectUtxosForPegin=i.selectUtxosForPegin;exports.shouldAddChangeOutput=i.shouldAddChangeOutput;exports.validateUtxosAvailable=i.validateUtxosAvailable;exports.CONTRACT_ERRORS=r.CONTRACT_ERRORS;exports.PeginManager=r.PeginManager;exports.VAULT_APP_NAME=r.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=r.buildFundingOutpointsCommitment;exports.buildVaultContext=r.buildVaultContext;exports.computeWotsBlockPublicKeysHash=r.computeWotsBlockPublicKeysHash;exports.deriveVaultRoot=r.deriveVaultRoot;exports.deriveWotsBlocksFromSeed=r.deriveWotsBlocksFromSeed;exports.expandAuthAnchor=r.expandAuthAnchor;exports.expandHashlockSecret=r.expandHashlockSecret;exports.expandWotsSeed=r.expandWotsSeed;exports.extractErrorData=r.extractErrorData;exports.getContractErrorMessage=r.getContractErrorMessage;exports.handleContractError=r.handleContractError;exports.isKnownContractError=r.isKnownContractError;exports.isWotsMismatchError=r.isWotsMismatchError;exports.ApplicationRegistryABI=e.ApplicationRegistryABI;exports.MEMPOOL_API_URLS=e.MEMPOOL_API_URLS;exports.ProtocolParamsABI=e.ProtocolParamsABI;exports.ServerIdentityError=e.ServerIdentityError;exports.VaultProviderRpcClient=e.VaultProviderRpcClient;exports.ViemProtocolParamsReader=e.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=e.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=e.ViemVaultKeeperReader;exports.ViemVaultRegistryReader=e.ViemVaultRegistryReader;exports.VpResponseValidationError=e.VpResponseValidationError;exports.VpTokenProvider=e.VpTokenProvider;exports.getAddressTxs=e.getAddressTxs;exports.getAddressUtxos=e.getAddressUtxos;exports.getMempoolApiUrl=e.getMempoolApiUrl;exports.getNetworkFees=e.getNetworkFees;exports.getTxHex=e.getTxHex;exports.getTxInfo=e.getTxInfo;exports.getUtxoInfo=e.getUtxoInfo;exports.pushTx=e.pushTx;exports.resolveProtocolAddresses=e.resolveProtocolAddresses;exports.validateRequestDepositorClaimerArtifactsResponse=e.validateRequestDepositorClaimerArtifactsResponse;exports.verifyServerIdentity=e.verifyServerIdentity;exports.BTCVaultRegistryABI=s.BTCVaultRegistryABI;exports.DaemonStatus=s.DaemonStatus;exports.JSON_RPC_ERROR_CODES=s.JSON_RPC_ERROR_CODES;exports.JsonRpcClient=s.JsonRpcClient;exports.JsonRpcError=s.JsonRpcError;exports.POST_WOTS_STATUSES=s.POST_WOTS_STATUSES;exports.PRE_DEPOSITOR_SIGNATURES_STATES=s.PRE_DEPOSITOR_SIGNATURES_STATES;exports.RpcErrorCode=s.RpcErrorCode;exports.VP_TERMINAL_STATUSES=s.VP_TERMINAL_STATUSES;exports.VP_TRANSIENT_STATUSES=s.VP_TRANSIENT_STATUSES;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/tbv/core/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { i as e, g as t, h as r, d as o, a as i, b as n, c as l, e as u, f as d } from "../../challengeAssert-j2Vwqo0-.js";
|
|
2
2
|
import { computeMinClaimValue as c, deriveVaultId as T } from "@babylonlabs-io/babylon-tbv-rust-wasm";
|
|
3
|
-
import { a as S, b as
|
|
4
|
-
import { d as
|
|
5
|
-
import { C as F, P as B, a as D, c as
|
|
3
|
+
import { a as S, b as A, c as E, e as _ } from "../../payout-B_fvQU3q.js";
|
|
4
|
+
import { d as R, a as m, e as x, f as b, g as I, h as f, i as v, b as C, p as U, s as O, t as V, u as h, v as y } from "../../bitcoin-B-Y0DlqR.js";
|
|
5
|
+
import { C as F, P as B, a as D, c as M, g as H } from "../../signing-BZigafm0.js";
|
|
6
6
|
import { B as k, H as W, K as X, M as K, T as w } from "../../validation-CxqROCno.js";
|
|
7
|
-
import { B as Y, C as J, P as j, a as Z, m as z, h as q, i as Q, l as $, k as aa, p as sa, b as ea, s as ta, v as ra, g as oa, d as ia, c as na, j as la, e as ua, f as da, w as Pa } from "../../buildAndBroadcastRefund-
|
|
8
|
-
import { B as Ta, D as pa, F as Sa, L as
|
|
9
|
-
import { B as Oa, U as
|
|
10
|
-
import { C as Ka, P as wa,
|
|
11
|
-
import { A as is, M as ns, P as ls, S as us, V as ds, k as Ps, l as cs, m as Ts, n as ps, h as Ss, j as
|
|
12
|
-
import { B as Os, D as
|
|
7
|
+
import { B as Y, C as J, P as j, a as Z, m as z, h as q, i as Q, l as $, k as aa, p as sa, b as ea, s as ta, v as ra, g as oa, d as ia, c as na, j as la, e as ua, f as da, w as Pa } from "../../buildAndBroadcastRefund-Cc4-L7gX.js";
|
|
8
|
+
import { B as Ta, D as pa, F as Sa, L as Aa, M as Ea, P as _a, b as ga, a as Ra, S as ma, T as xa, W as ba, f as Ia, c as fa, p as va, r as Ca } from "../../fundPeginTransaction-oV-dNJOU.js";
|
|
9
|
+
import { B as Oa, U as Va, a as ha, f as ya, c as Na, e as Fa, g as Ba, i as Da, h as Ma, s as Ha, b as La, d as ka, v as Wa } from "../../psbtInputFields-DeTFSJOq.js";
|
|
10
|
+
import { C as Ka, P as wa, V as Ga, k as Ya, l as Ja, c as ja, m as Za, d as za, b as qa, f as Qa, j as $a, e as as, g as ss, h as es, i as ts, a as rs } from "../../deriveVaultRoot-DAMZDqg-.js";
|
|
11
|
+
import { A as is, M as ns, P as ls, S as us, V as ds, k as Ps, l as cs, m as Ts, n as ps, h as Ss, j as As, g as Es, a as _s, b as gs, c as Rs, d as ms, e as xs, f as bs, p as Is, r as fs, v as vs, i as Cs } from "../../vault-registry-reader-CshEgmS0.js";
|
|
12
|
+
import { B as Os, D as Vs, b as hs, J as ys, a as Ns, d as Fs, P as Bs, R as Ds, c as Ms, V as Hs } from "../../types-CQ86O7NX.js";
|
|
13
13
|
export {
|
|
14
14
|
is as ApplicationRegistryABI,
|
|
15
15
|
Y as BIP68NotMatureError,
|
|
@@ -21,20 +21,20 @@ export {
|
|
|
21
21
|
J as ClaimerPegoutStatusValue,
|
|
22
22
|
F as ContractStatus,
|
|
23
23
|
pa as DUST_THRESHOLD,
|
|
24
|
-
|
|
24
|
+
Vs as DaemonStatus,
|
|
25
25
|
Sa as FEE_SAFETY_MARGIN,
|
|
26
26
|
W as HEX_RE,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
hs as JSON_RPC_ERROR_CODES,
|
|
28
|
+
ys as JsonRpcClient,
|
|
29
29
|
Ns as JsonRpcError,
|
|
30
30
|
X as KNOWN_SCRIPT_PREFIXES,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
Aa as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
|
|
32
|
+
Ea as MAX_NON_LEGACY_OUTPUT_SIZE,
|
|
33
33
|
K as MAX_REASONABLE_FEE_SATS,
|
|
34
34
|
ns as MEMPOOL_API_URLS,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
_a as P2TR_INPUT_SIZE,
|
|
36
|
+
ga as PEGIN_AUTH_ANCHOR_OUTPUTS,
|
|
37
|
+
Ra as PEGIN_FIXED_OUTPUTS,
|
|
38
38
|
Fs as POST_WOTS_STATUSES,
|
|
39
39
|
Bs as PRE_DEPOSITOR_SIGNATURES_STATES,
|
|
40
40
|
j as PayoutManager,
|
|
@@ -46,78 +46,78 @@ export {
|
|
|
46
46
|
us as ServerIdentityError,
|
|
47
47
|
w as TXID_RE,
|
|
48
48
|
xa as TX_BUFFER_SIZE_OVERHEAD,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Ms as
|
|
49
|
+
Va as UtxoNotAvailableError,
|
|
50
|
+
Ga as VAULT_APP_NAME,
|
|
51
|
+
Ms as VP_TERMINAL_STATUSES,
|
|
52
|
+
Hs as VP_TRANSIENT_STATUSES,
|
|
52
53
|
ds as VaultProviderRpcClient,
|
|
53
54
|
Ps as ViemProtocolParamsReader,
|
|
54
55
|
cs as ViemUniversalChallengerReader,
|
|
55
56
|
Ts as ViemVaultKeeperReader,
|
|
56
57
|
ps as ViemVaultRegistryReader,
|
|
57
58
|
Ss as VpResponseValidationError,
|
|
58
|
-
|
|
59
|
+
As as VpTokenProvider,
|
|
59
60
|
ba as WALLET_RELAY_FEE_RATE_THRESHOLD,
|
|
60
61
|
Z as activateVault,
|
|
61
|
-
|
|
62
|
+
ha as assertUtxosAvailable,
|
|
62
63
|
z as buildAndBroadcastRefund,
|
|
63
64
|
e as buildChallengeAssertPsbt,
|
|
64
65
|
t as buildDepositorPayoutPsbt,
|
|
65
|
-
|
|
66
|
+
Ya as buildFundingOutpointsCommitment,
|
|
66
67
|
r as buildNoPayoutPsbt,
|
|
67
68
|
S as buildPayoutPsbt,
|
|
68
69
|
o as buildPeginInputPsbt,
|
|
69
70
|
i as buildPeginTxFromFundedPrePegin,
|
|
70
71
|
n as buildPrePeginPsbt,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
A as buildRefundPsbt,
|
|
73
|
+
Ja as buildVaultContext,
|
|
74
|
+
ya as calculateBtcTxHash,
|
|
74
75
|
D as canPerformAction,
|
|
75
76
|
Na as collectReservedUtxoRefs,
|
|
76
77
|
q as computeHashlock,
|
|
77
78
|
c as computeMinClaimValue,
|
|
78
79
|
l as computeNumLocalChallengers,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
ja as computeWotsBlockPublicKeysHash,
|
|
81
|
+
E as createPayoutScript,
|
|
82
|
+
M as createTaprootScriptPathSignOptions,
|
|
83
|
+
R as deriveNativeSegwitAddress,
|
|
83
84
|
m as deriveTaprootAddress,
|
|
84
85
|
T as deriveVaultId,
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
Za as deriveVaultRoot,
|
|
87
|
+
za as deriveWotsBlocksFromSeed,
|
|
87
88
|
x as ensureHexPrefix,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
qa as expandAuthAnchor,
|
|
90
|
+
Qa as expandHashlockSecret,
|
|
91
|
+
$a as expandWotsSeed,
|
|
92
|
+
as as extractErrorData,
|
|
92
93
|
Fa as extractInputsFromTransaction,
|
|
93
|
-
|
|
94
|
+
_ as extractPayoutSignature,
|
|
94
95
|
u as extractPeginInputSignature,
|
|
95
96
|
d as finalizePeginInputPsbt,
|
|
96
97
|
b as formatSatoshisToBtc,
|
|
97
98
|
Ia as fundPeginTransaction,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
Es as getAddressTxs,
|
|
100
|
+
_s as getAddressUtxos,
|
|
101
|
+
ss as getContractErrorMessage,
|
|
101
102
|
Ba as getDustThreshold,
|
|
102
|
-
|
|
103
|
+
gs as getMempoolApiUrl,
|
|
103
104
|
I as getNetwork,
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
Rs as getNetworkFees,
|
|
106
|
+
H as getPeginProtocolState,
|
|
106
107
|
Da as getPsbtInputFields,
|
|
107
|
-
|
|
108
|
+
Ma as getScriptType,
|
|
108
109
|
ms as getTxHex,
|
|
109
110
|
xs as getTxInfo,
|
|
110
111
|
bs as getUtxoInfo,
|
|
111
|
-
|
|
112
|
+
es as handleContractError,
|
|
112
113
|
f as hexToUint8Array,
|
|
113
114
|
v as isAddressFromPublicKey,
|
|
114
115
|
Q as isDepositAmountValid,
|
|
115
|
-
|
|
116
|
+
ts as isKnownContractError,
|
|
116
117
|
$ as isPegoutTerminalStatus,
|
|
117
118
|
aa as isRecognizedPegoutStatus,
|
|
118
119
|
C as isValidHex,
|
|
119
|
-
|
|
120
|
-
rs as mnemonicToWotsSeed,
|
|
120
|
+
rs as isWotsMismatchError,
|
|
121
121
|
fa as parseUnfundedWasmTransaction,
|
|
122
122
|
va as peginOutputCount,
|
|
123
123
|
sa as pollAndSignPayouts,
|
|
@@ -125,14 +125,14 @@ export {
|
|
|
125
125
|
Is as pushTx,
|
|
126
126
|
Ca as rateBasedTxBufferFee,
|
|
127
127
|
fs as resolveProtocolAddresses,
|
|
128
|
-
|
|
128
|
+
Ha as selectUtxosForDeposit,
|
|
129
129
|
La as selectUtxosForPegin,
|
|
130
130
|
ka as shouldAddChangeOutput,
|
|
131
131
|
ea as signDepositorGraph,
|
|
132
132
|
O as stripHexPrefix,
|
|
133
133
|
ta as submitWotsPublicKey,
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
V as toXOnly,
|
|
135
|
+
h as uint8ArrayToHex,
|
|
136
136
|
ra as validateDepositAmount,
|
|
137
137
|
oa as validateMultiVaultDepositInputs,
|
|
138
138
|
ia as validateProviderSelection,
|
|
@@ -142,7 +142,7 @@ export {
|
|
|
142
142
|
Wa as validateUtxosAvailable,
|
|
143
143
|
ua as validateVaultAmounts,
|
|
144
144
|
da as validateVaultProviderPubkey,
|
|
145
|
-
|
|
145
|
+
y as validateWalletPubkey,
|
|
146
146
|
Cs as verifyServerIdentity,
|
|
147
147
|
Pa as waitForPeginStatus
|
|
148
148
|
};
|
|
@@ -33,7 +33,7 @@ export type ExpirationReason = "ack_timeout" | "proof_timeout" | "activation_tim
|
|
|
33
33
|
* Available actions user can take
|
|
34
34
|
*/
|
|
35
35
|
export declare enum PeginAction {
|
|
36
|
-
/** Submit WOTS key (re-
|
|
36
|
+
/** Submit WOTS key (re-derives via wallet `deriveContextHash`) */
|
|
37
37
|
SUBMIT_WOTS_KEY = "SUBMIT_WOTS_KEY",
|
|
38
38
|
/** Sign payout transactions */
|
|
39
39
|
SIGN_PAYOUT_TRANSACTIONS = "SIGN_PAYOUT_TRANSACTIONS",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peginState.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/services/deposit/peginState.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,oBAAY,cAAc;IACxB,oDAAoD;IACpD,OAAO,IAAI;IACX,gEAAgE;IAChE,QAAQ,IAAI;IACZ,qGAAqG;IACrG,MAAM,IAAI;IACV,0DAA0D;IAC1D,QAAQ,IAAI;IACZ,2FAA2F;IAC3F,UAAU,IAAI;IACd,kGAAkG;IAClG,OAAO,IAAI;IACX,uFAAuF;IACvF,mBAAmB,IAAI;IACvB,oFAAoF;IACpF,OAAO,IAAI;CACZ;AAED,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,eAAe,GACf,oBAAoB,CAAC;AAMzB;;GAEG;AACH,oBAAY,WAAW;IACrB,
|
|
1
|
+
{"version":3,"file":"peginState.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/services/deposit/peginState.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,oBAAY,cAAc;IACxB,oDAAoD;IACpD,OAAO,IAAI;IACX,gEAAgE;IAChE,QAAQ,IAAI;IACZ,qGAAqG;IACrG,MAAM,IAAI;IACV,0DAA0D;IAC1D,QAAQ,IAAI;IACZ,2FAA2F;IAC3F,UAAU,IAAI;IACd,kGAAkG;IAClG,OAAO,IAAI;IACX,uFAAuF;IACvF,mBAAmB,IAAI;IACvB,oFAAoF;IACpF,OAAO,IAAI;CACZ;AAED,iCAAiC;AACjC,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,eAAe,GACf,oBAAoB,CAAC;AAMzB;;GAEG;AACH,oBAAY,WAAW;IACrB,kEAAkE;IAClE,eAAe,oBAAoB;IACnC,+BAA+B;IAC/B,wBAAwB,6BAA6B;IACrD,uDAAuD;IACvD,6BAA6B,kCAAkC;IAC/D,uDAAuD;IACvD,cAAc,mBAAmB;IACjC,sEAAsE;IACtE,WAAW,gBAAgB;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,cAAc,EAAE,cAAc,CAAC;IAC/B,uEAAuE;IACvE,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACjC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,4BAA4B;IAC3C,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gFAAgF;IAChF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,cAAc,EAC9B,OAAO,GAAE,4BAAiC,GACzC,kBAAkB,CA6EpB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,WAAW,GAClB,OAAO,CAET"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../buildAndBroadcastRefund-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../buildAndBroadcastRefund-OoaQaNqn.cjs"),a=require("../../../signing-DHSXjhLM.cjs");exports.BIP68NotMatureError=t.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=t.ClaimerPegoutStatusValue;exports.activateVault=t.activateVault;exports.buildAndBroadcastRefund=t.buildAndBroadcastRefund;exports.computeHashlock=t.computeHashlock;exports.isDepositAmountValid=t.isDepositAmountValid;exports.isPegoutTerminalStatus=t.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=t.isRecognizedPegoutStatus;exports.pollAndSignPayouts=t.pollAndSignPayouts;exports.signDepositorGraph=t.signDepositorGraph;exports.submitWotsPublicKey=t.submitWotsPublicKey;exports.validateDepositAmount=t.validateDepositAmount;exports.validateMultiVaultDepositInputs=t.validateMultiVaultDepositInputs;exports.validateProviderSelection=t.validateProviderSelection;exports.validateRemainingCapacity=t.validateRemainingCapacity;exports.validateSecretAgainstHashlock=t.validateSecretAgainstHashlock;exports.validateVaultAmounts=t.validateVaultAmounts;exports.validateVaultProviderPubkey=t.validateVaultProviderPubkey;exports.waitForPeginStatus=t.waitForPeginStatus;exports.ContractStatus=a.ContractStatus;exports.PeginAction=a.PeginAction;exports.canPerformAction=a.canPerformAction;exports.getPeginProtocolState=a.getPeginProtocolState;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as s, C as e, a as i, m as o, h as u, i as l, l as r, k as n, p as d, b as c, s as P, v as g, g as m, d as p, c as v, j as S, e as A, f as V, w as b } from "../../../buildAndBroadcastRefund-
|
|
1
|
+
import { B as s, C as e, a as i, m as o, h as u, i as l, l as r, k as n, p as d, b as c, s as P, v as g, g as m, d as p, c as v, j as S, e as A, f as V, w as b } from "../../../buildAndBroadcastRefund-Cc4-L7gX.js";
|
|
2
2
|
import { C, P as h, a as k, g as y } from "../../../signing-BZigafm0.js";
|
|
3
3
|
export {
|
|
4
4
|
s as BIP68NotMatureError,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../../../signing-DHSXjhLM.cjs"),T=require("../../../validation-u8W7Lp2x.cjs"),t=require("../../../fundPeginTransaction-DaWoYCgO.cjs"),e=require("../../../psbtInputFields-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("../../../signing-DHSXjhLM.cjs"),T=require("../../../validation-u8W7Lp2x.cjs"),t=require("../../../fundPeginTransaction-DaWoYCgO.cjs"),e=require("../../../psbtInputFields-CB8hqjQ5.cjs"),E=require("../../../bitcoin-DIN0OupO.cjs");exports.createTaprootScriptPathSignOptions=_.createTaprootScriptPathSignOptions;exports.BITCOIN_ADDRESS_RE=T.BITCOIN_ADDRESS_RE;exports.HEX_RE=T.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=T.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=T.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=T.TXID_RE;exports.BTC_DUST_SAT=t.BTC_DUST_SAT;exports.DUST_THRESHOLD=t.DUST_THRESHOLD;exports.FEE_SAFETY_MARGIN=t.FEE_SAFETY_MARGIN;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=t.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=t.MAX_NON_LEGACY_OUTPUT_SIZE;exports.P2TR_INPUT_SIZE=t.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=t.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=t.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=t.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=t.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=t.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=t.fundPeginTransaction;exports.parseUnfundedWasmTransaction=t.parseUnfundedWasmTransaction;exports.peginOutputCount=t.peginOutputCount;exports.rateBasedTxBufferFee=t.rateBasedTxBufferFee;exports.BitcoinScriptType=e.BitcoinScriptType;exports.UtxoNotAvailableError=e.UtxoNotAvailableError;exports.assertUtxosAvailable=e.assertUtxosAvailable;exports.calculateBtcTxHash=e.calculateBtcTxHash;exports.collectReservedUtxoRefs=e.collectReservedUtxoRefs;exports.extractInputsFromTransaction=e.extractInputsFromTransaction;exports.getDustThreshold=e.getDustThreshold;exports.getPsbtInputFields=e.getPsbtInputFields;exports.getScriptType=e.getScriptType;exports.selectUtxosForDeposit=e.selectUtxosForDeposit;exports.selectUtxosForPegin=e.selectUtxosForPegin;exports.shouldAddChangeOutput=e.shouldAddChangeOutput;exports.validateUtxosAvailable=e.validateUtxosAvailable;exports.getNetwork=E.getNetwork;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as t } from "../../../signing-BZigafm0.js";
|
|
2
2
|
import { B as T, H as _, K as E, M as o, T as r } from "../../../validation-CxqROCno.js";
|
|
3
3
|
import { B as A, D as R, F as U, L as i, M as p, P as I, b as c, a as n, S as F, T as l, W as O, f as P, c as x, p as N, r as u } from "../../../fundPeginTransaction-oV-dNJOU.js";
|
|
4
|
-
import { B as f, U as B, a as D, f as L, c as g, e as C, g as H, i as X, h, s as m, b as M, d as b, v } from "../../../psbtInputFields-
|
|
4
|
+
import { B as f, U as B, a as D, f as L, c as g, e as C, g as H, i as X, h, s as m, b as M, d as b, v } from "../../../psbtInputFields-DeTFSJOq.js";
|
|
5
5
|
import { g as Y } from "../../../bitcoin-B-Y0DlqR.js";
|
|
6
6
|
export {
|
|
7
7
|
T as BITCOIN_ADDRESS_RE,
|
|
@@ -47,9 +47,14 @@ export interface SelectUtxosForDepositParams<T extends {
|
|
|
47
47
|
/** Fee rate in sat/vB. Used to estimate fee buffer for sufficiency check. */
|
|
48
48
|
feeRate: number;
|
|
49
49
|
}
|
|
50
|
+
/** Narrow structural type for early UTXO reservations (pre-ETH-registration). */
|
|
51
|
+
export interface UtxoReservationLike {
|
|
52
|
+
unsignedTxHex: string;
|
|
53
|
+
}
|
|
50
54
|
export interface CollectReservedUtxoRefsParams {
|
|
51
55
|
vaults?: VaultLike[];
|
|
52
56
|
pendingPegins?: PendingPeginLike[];
|
|
57
|
+
utxoReservations?: UtxoReservationLike[];
|
|
53
58
|
}
|
|
54
59
|
/**
|
|
55
60
|
* Collect UTXO refs from in-flight deposits (PENDING/VERIFIED vaults and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reservation.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/utxo/reservation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,+DAA+D;AAC/D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,2BAA2B,CAC1C,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;IAEvD,2CAA2C;IAC3C,cAAc,EAAE,CAAC,EAAE,CAAC;IACpB,2EAA2E;IAC3E,gBAAgB,EAAE,OAAO,EAAE,CAAC;IAC5B,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B;IAC5C,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"reservation.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/utils/utxo/reservation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,+DAA+D;AAC/D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,2BAA2B,CAC1C,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;IAEvD,2CAA2C;IAC3C,cAAc,EAAE,CAAC,EAAE,CAAC;IACpB,2EAA2E;IAC3E,gBAAgB,EAAE,OAAO,EAAE,CAAC;IAC5B,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,iFAAiF;AACjF,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,6BAA6B;IAC5C,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACnC,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC1C;AA2ED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,6BAA6B,GACpC,OAAO,EAAE,CAwCX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACvD,MAAM,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAuC7C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for `deriveVaultRoot` — the SDK helper that wires a wallet's
|
|
3
|
+
* `deriveContextHash` API to the canonical `vaultContext` encoding.
|
|
4
|
+
*
|
|
5
|
+
* The helper is a thin pass-through; tests pin the wiring contract:
|
|
6
|
+
* - Forwards the hardcoded `appName` "babylon-vault" verbatim.
|
|
7
|
+
* - Forwards the hex of the 72-byte `vaultContext` (lowercase, 144 chars).
|
|
8
|
+
* - Decodes the wallet's 64-char hex output to 32 bytes.
|
|
9
|
+
* - Rejects malformed wallet output (wrong length / non-hex / uppercase).
|
|
10
|
+
* - Propagates wallet errors unchanged (user rejection, not-supported, etc.).
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=deriveVaultRoot.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveVaultRoot.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/vault-secrets/__tests__/deriveVaultRoot.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -38,6 +38,10 @@ export interface VaultContextInput {
|
|
|
38
38
|
* Outpoints are serialized as 36-byte `txid || vout_BE`, sorted
|
|
39
39
|
* ascending lexicographically, concatenated, then hashed.
|
|
40
40
|
*
|
|
41
|
+
* @stability frozen — on-chain-binding. Any change to layout, sort
|
|
42
|
+
* order, or serialization is a hard fork; existing deposits would no
|
|
43
|
+
* longer match their committed `depositorWotsPkHash`.
|
|
44
|
+
*
|
|
41
45
|
* @throws If `outpoints` is empty or contains duplicates.
|
|
42
46
|
*/
|
|
43
47
|
export declare function buildFundingOutpointsCommitment(outpoints: readonly FundingOutpoint[]): Uint8Array;
|
|
@@ -47,6 +51,11 @@ export declare function buildFundingOutpointsCommitment(outpoints: readonly Fund
|
|
|
47
51
|
* app side).
|
|
48
52
|
*
|
|
49
53
|
* Output length is always 72 bytes.
|
|
54
|
+
*
|
|
55
|
+
* @stability frozen — on-chain-binding. The 72-byte layout is the
|
|
56
|
+
* input to `deriveContextHash`; any change rotates the vault root and
|
|
57
|
+
* therefore every WOTS key, hashlock secret, and auth anchor derived
|
|
58
|
+
* from it. Existing deposits cannot be recovered after a layout change.
|
|
50
59
|
*/
|
|
51
60
|
export declare function buildVaultContext(input: VaultContextInput): Uint8Array;
|
|
52
61
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAeH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,kBAAkB,EAAE,UAAU,CAAC;IAC/B,yEAAyE;IACzE,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAoCD
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAeH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,kBAAkB,EAAE,UAAU,CAAC;IAC/B,yEAAyE;IACzE,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAoCD;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,SAAS,eAAe,EAAE,GACpC,UAAU,CAsBZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,CAqBtE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { VaultContextInput } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* The fixed `appName` passed to the wallet's `deriveContextHash` for
|
|
4
|
+
* Babylon vault derivations. The wallet displays this in its approval
|
|
5
|
+
* dialog. Defined by `derive-vault-secrets.md` §2.2 — must not be
|
|
6
|
+
* changed without coordinating a spec revision and a downstream
|
|
7
|
+
* migration plan, as it provides app-level domain separation across
|
|
8
|
+
* applications using the same wallet.
|
|
9
|
+
*/
|
|
10
|
+
export declare const VAULT_APP_NAME = "babylon-vault";
|
|
11
|
+
/**
|
|
12
|
+
* Minimal structural shape for the wallet capability needed by this
|
|
13
|
+
* helper. Typed against the method directly so callers can pass any
|
|
14
|
+
* value that implements `deriveContextHash` — `BitcoinWallet` from
|
|
15
|
+
* this SDK, `IBTCProvider` from `@babylonlabs-io/wallet-connector`,
|
|
16
|
+
* or a test mock — without depending on the rest of either interface.
|
|
17
|
+
*/
|
|
18
|
+
export interface DeriveContextHashCapableWallet {
|
|
19
|
+
deriveContextHash(appName: string, context: string): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Derive the 32-byte vault root from a wallet by encoding the
|
|
23
|
+
* canonical {@link VaultContextInput} and forwarding to
|
|
24
|
+
* `wallet.deriveContextHash`.
|
|
25
|
+
*
|
|
26
|
+
* Validates the wallet's output strictly: must be exactly 64
|
|
27
|
+
* lowercase hex characters per `derive-context-hash.md` §2.1. A
|
|
28
|
+
* conformant wallet always satisfies this, but we re-check at the
|
|
29
|
+
* SDK boundary so a non-conformant wallet (or a wallet returning a
|
|
30
|
+
* malformed value through a buggy adapter) fails loud here rather
|
|
31
|
+
* than producing silently-wrong derived secrets downstream.
|
|
32
|
+
*
|
|
33
|
+
* The helper itself produces only valid spec inputs (`appName` is
|
|
34
|
+
* the hardcoded `VAULT_APP_NAME`; `context` is hex of the 72-byte
|
|
35
|
+
* `vaultContext`, always 144 chars lowercase), so input-side
|
|
36
|
+
* validation is unnecessary.
|
|
37
|
+
*
|
|
38
|
+
* @param wallet - Any value implementing `deriveContextHash`.
|
|
39
|
+
* @param input - The canonical {@link VaultContextInput} that
|
|
40
|
+
* uniquely identifies the vault. Encoded by
|
|
41
|
+
* {@link buildVaultContext} into a 72-byte structure
|
|
42
|
+
* before being hex-encoded for the wallet.
|
|
43
|
+
* @stability frozen — on-chain-binding. The pair (`VAULT_APP_NAME`,
|
|
44
|
+
* `vaultContext` encoding) is the wallet's input space; changing
|
|
45
|
+
* either rotates the root and invalidates every secret derived from
|
|
46
|
+
* it. `VAULT_APP_NAME` is fixed by `derive-vault-secrets.md` §2.2
|
|
47
|
+
* and must never change without a coordinated spec revision.
|
|
48
|
+
*
|
|
49
|
+
* @returns 32-byte root suitable for {@link expandAuthAnchor},
|
|
50
|
+
* {@link expandHashlockSecret}, {@link expandWotsSeed}.
|
|
51
|
+
* @throws If the wallet returns a non-64-char or non-lowercase-hex
|
|
52
|
+
* string. Errors from the wallet (user rejection,
|
|
53
|
+
* method-not-supported, etc.) propagate unchanged.
|
|
54
|
+
*/
|
|
55
|
+
export declare function deriveVaultRoot(wallet: DeriveContextHashCapableWallet, input: VaultContextInput): Promise<Uint8Array>;
|
|
56
|
+
//# sourceMappingURL=deriveVaultRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveVaultRoot.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEtE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAU9C;;;;;;GAMG;AACH,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,8BAA8B,EACtC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,UAAU,CAAC,CAuBrB"}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* `derive-vault-secrets.md` §2.2.
|
|
4
4
|
*
|
|
5
5
|
* Pure, synchronous expanders that derive three domain-separated
|
|
6
|
-
* secrets from a 32-byte `root`. The root is spec-opaque —
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* secrets from a 32-byte `root`. The root is spec-opaque — typically
|
|
7
|
+
* obtained via `deriveVaultRoot(wallet, vaultContextInput)` (which
|
|
8
|
+
* forwards to the wallet's `deriveContextHash`), but any 32-byte
|
|
9
|
+
* pseudorandom source satisfies the contract.
|
|
9
10
|
*
|
|
10
11
|
* All expand calls use HKDF-Expand-SHA-256 with `root` directly as the
|
|
11
12
|
* PRK (RFC 5869 §3.3: the Extract step is omitted when the input is
|
|
@@ -20,6 +21,10 @@
|
|
|
20
21
|
* `SHA256(authAnchor)` is committed as the OP_RETURN preimage hash in
|
|
21
22
|
* the Pre-PegIn; the raw preimage is revealed to the vault provider's
|
|
22
23
|
* `auth_createDepositorToken` RPC in exchange for a CWT bearer token.
|
|
24
|
+
*
|
|
25
|
+
* @stability frozen — on-chain-binding. Changing the HKDF info encoding
|
|
26
|
+
* (label or argument order) rotates the anchor and invalidates the VP
|
|
27
|
+
* bearer-token flow for existing deposits.
|
|
23
28
|
*/
|
|
24
29
|
export declare function expandAuthAnchor(root: Uint8Array): Uint8Array;
|
|
25
30
|
/**
|
|
@@ -29,6 +34,10 @@ export declare function expandAuthAnchor(root: Uint8Array): Uint8Array;
|
|
|
29
34
|
* `SHA256(hashlockSecret)` is committed as the HTLC taproot hashlock
|
|
30
35
|
* at vout = `htlcVout` in the Pre-PegIn. The raw preimage is revealed
|
|
31
36
|
* on Ethereum via `activateVaultWithSecret`.
|
|
37
|
+
*
|
|
38
|
+
* @stability frozen — on-chain-binding. Changing the HKDF info
|
|
39
|
+
* encoding produces a different secret whose SHA-256 will not match
|
|
40
|
+
* the on-chain hashlock; affected vaults can never be activated.
|
|
32
41
|
*/
|
|
33
42
|
export declare function expandHashlockSecret(root: Uint8Array, htlcVout: number): Uint8Array;
|
|
34
43
|
/**
|
|
@@ -38,6 +47,12 @@ export declare function expandHashlockSecret(root: Uint8Array, htlcVout: number)
|
|
|
38
47
|
* Fed into the per-vault WOTS block-keypair derivation. Only the
|
|
39
48
|
* `keccak256` hash of the derived public keys appears on-chain
|
|
40
49
|
* (committed as `depositorWotsPkHash`).
|
|
50
|
+
*
|
|
51
|
+
* @stability frozen — on-chain-binding. Changing the HKDF info
|
|
52
|
+
* encoding (label or htlcVout serialization) rotates the seed and
|
|
53
|
+
* therefore the WOTS keys; existing `depositorWotsPkHash` commitments
|
|
54
|
+
* would no longer match. Per-vault domain separation depends on the
|
|
55
|
+
* `i2osp4(htlcVout)` argument: do not change its encoding.
|
|
41
56
|
*/
|
|
42
57
|
export declare function expandWotsSeed(root: Uint8Array, htlcVout: number): Uint8Array;
|
|
43
58
|
//# sourceMappingURL=expand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/expand.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/vault-secrets/expand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0BH;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAQ7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,GACf,UAAU,CAQZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAQ7E"}
|