{"version":3,"file":"constants-DU5CGcqO.cjs","sources":["../src/tbv/core/primitives/vaultCoreVersion.ts","../src/tbv/core/primitives/psbt/constants.ts"],"sourcesContent":["/**\n * Vault core version — the on-chain version axis that selects which tx graph\n * the vault-wasm facade builds.\n *\n * One number, two names: the contract calls it `vaultCoreVersion`\n * (`ProtocolParams.activeVaultCoreVersion()` for fresh deposits, the vault's\n * stamped `BTCVaultProtocolInfo.vaultCoreVersion` for resume), while the\n * vault-wasm facade calls the same axis `txGraphVersion`. SDK params carry\n * `vaultCoreVersion` and map it to `txGraphVersion` at each WASM call site.\n */\n\n/** `vaultCoreVersion` is `uint16` on-chain (see `IProtocolParams.sol`). */\nconst VAULT_CORE_VERSION_UINT16_MAX = 65_535;\n\n/**\n * Assert a vault core version is a well-formed on-chain value: an integer in\n * `[1, 65535]`. Mirrors the contract (`uint16`, setter rejects 0) and vaultd\n * (`SUPPORTED_CORE_VERSIONS` never contains 0). A `0` here means the vault\n * predates the `vaultCoreVersion` contract field or the read was mis-decoded —\n * fail closed rather than guess a graph version.\n *\n * Whether the version is *buildable* by the bundled WASM is a separate\n * question — the facade fails closed on unsupported versions at construction.\n *\n * @param version - The value to validate.\n * @param source - Where the value came from, for the error message\n *   (e.g. `\"ProtocolParams.activeVaultCoreVersion()\"`).\n */\nexport function assertValidVaultCoreVersion(\n  version: number,\n  source: string,\n): void {\n  if (\n    !Number.isInteger(version) ||\n    version < 1 ||\n    version > VAULT_CORE_VERSION_UINT16_MAX\n  ) {\n    throw new Error(\n      `Invalid vaultCoreVersion ${version} from ${source}: expected an ` +\n        `integer in [1, ${VAULT_CORE_VERSION_UINT16_MAX}].`,\n    );\n  }\n}\n","/**\n * Protocol invariants for depositor graph transactions.\n *\n * These indices and counts encode the on-chain vault protocol layout\n * (which output of PegIn/Assert each child transaction spends, and how\n * many inputs each transaction has). Consumed by the PSBT builders and\n * the depositor graph signing service; a drift between copies of these\n * values would silently change validation behaviour.\n *\n * @module primitives/psbt/constants\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md\n */\n\n/**\n * Depositor Payout transaction input count.\n * Input 0: PegIn:0 (signed). Input 1: Assert:0 (in sighash, not signed).\n */\nexport const DEPOSITOR_PAYOUT_INPUT_COUNT = 2;\n\n/** PegIn vault output index spent by the depositor's Payout input 0. */\nexport const PEGIN_VAULT_OUTPUT_INDEX = 0;\n\n/** Assert output index spent by the depositor's Payout input 1 (NOT signed). */\nexport const ASSERT_PAYOUT_OUTPUT_INDEX = 0;\n\n/**\n * Dust amount (sats) for the payout CPFP anchor output. Matches `DUST_AMOUNT`\n * in `btc-vault crates/vault/src/lib.rs`.\n */\nexport const PAYOUT_ANCHOR_DUST_SATS = 546;\n\n/**\n * Payout transaction literals btc-vault builds deterministically\n * (`crates/vault/src/transactions/payout.rs`: `Version::TWO`,\n * `LockTime::ZERO`). The depositor's signature commits to both, so a\n * VP-supplied payout that deviates would produce a signature over a\n * transaction the protocol never constructs.\n */\nexport const PAYOUT_TX_VERSION = 2;\nexport const PAYOUT_TX_LOCKTIME = 0;\n\n/** VP-claimer payout output count: [depositor payout, VP commission, CPFP anchor]. */\nexport const VP_CLAIMER_PAYOUT_OUTPUT_COUNT = 3;\n\n/** Depositor/VK-claimer payout output count: [claimer payout, CPFP anchor]. */\nexport const NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT = 2;\n\n/**\n * ChallengeAssert connectors the VP returns per challenger: one for the\n * ChallengeAssertX transaction and one for ChallengeAssertY — two single-input\n * transactions, not a single multi-input one. This is a per-challenger array\n * cardinality, NOT a count of inputs in one transaction.\n * @see btc-vault crates/vault/docs/btc-transactions-spec.md (ChallengeAssertX / ChallengeAssertY)\n */\nexport const CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER = 2;\n\n/**\n * Exclusive upper bound on VP commission (bps). Matches\n * `VPKeyRegistryLogic.sol` (`commissionBps >= 10000` reverts).\n * The minimum is version-locked (`minVpCommissionBps`) and enforced upstream,\n * not here.\n */\nexport const MAX_VP_COMMISSION_BPS_EXCLUSIVE = 10_000;\n\n/**\n * Basis-points denominator for commission math:\n * `floor(value * bps / BPS_DENOMINATOR)`. Numerically equal to\n * {@link MAX_VP_COMMISSION_BPS_EXCLUSIVE} but a distinct concept — tightening\n * the accepted bps range must never change the arithmetic.\n */\nexport const BPS_DENOMINATOR = 10_000;\n\n/**\n * Contract cap on a registered payout/commission scriptPubKey's byte length\n * (`MAX_PAYOUT_ADDRESS_LENGTH`, Constants.sol; empty scripts are rejected at\n * registration, so valid lengths are `[1, 128]`). A measured length outside\n * this range is provably not a registered script.\n */\nexport const MAX_PAYOUT_SCRIPT_LEN = 128;\n"],"names":["assertValidVaultCoreVersion","version","source","DEPOSITOR_PAYOUT_INPUT_COUNT","PEGIN_VAULT_OUTPUT_INDEX","ASSERT_PAYOUT_OUTPUT_INDEX","PAYOUT_ANCHOR_DUST_SATS","PAYOUT_TX_VERSION","PAYOUT_TX_LOCKTIME","VP_CLAIMER_PAYOUT_OUTPUT_COUNT","NON_VP_CLAIMER_PAYOUT_OUTPUT_COUNT","CHALLENGE_ASSERT_CONNECTORS_PER_CHALLENGER","MAX_VP_COMMISSION_BPS_EXCLUSIVE","BPS_DENOMINATOR","MAX_PAYOUT_SCRIPT_LEN"],"mappings":"aA4BO,SAASA,EACdC,EACAC,EACM,CACN,GACE,CAAC,OAAO,UAAUD,CAAO,GACzBA,EAAU,GACVA,EAAU,MAEV,MAAM,IAAI,MACR,4BAA4BA,CAAO,SAASC,CAAM,sCACD,CAGvD,CCzBO,MAAMC,EAA+B,EAG/BC,EAA2B,EAG3BC,EAA6B,EAM7BC,EAA0B,IAS1BC,EAAoB,EACpBC,EAAqB,EAGrBC,EAAiC,EAGjCC,EAAqC,EASrCC,EAA6C,EAQ7CC,EAAkC,IAQlCC,EAAkB,IAQlBC,EAAwB"}