@babylonlabs-io/ts-sdk 0.57.1 → 0.57.2

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 (90) hide show
  1. package/dist/{PeginManager-iDbqXsKD.cjs → PeginManager-DOmyNYT-.cjs} +2 -2
  2. package/dist/{PeginManager-iDbqXsKD.cjs.map → PeginManager-DOmyNYT-.cjs.map} +1 -1
  3. package/dist/{PeginManager-CnX3uFb0.js → PeginManager-DbMFLh-1.js} +7 -7
  4. package/dist/{PeginManager-CnX3uFb0.js.map → PeginManager-DbMFLh-1.js.map} +1 -1
  5. package/dist/{batchPoll-BXIy3R7h.cjs → batchPoll-D2OuUee1.cjs} +2 -2
  6. package/dist/{batchPoll-BXIy3R7h.cjs.map → batchPoll-D2OuUee1.cjs.map} +1 -1
  7. package/dist/{batchPoll-DTYXoTEc.js → batchPoll-X7D7OIcu.js} +3 -3
  8. package/dist/{batchPoll-DTYXoTEc.js.map → batchPoll-X7D7OIcu.js.map} +1 -1
  9. package/dist/{bitcoin-B5aNKtsk.js → bitcoin-CHzNE-rS.js} +39 -35
  10. package/dist/bitcoin-CHzNE-rS.js.map +1 -0
  11. package/dist/bitcoin-Dpcfff7b.cjs +2 -0
  12. package/dist/bitcoin-Dpcfff7b.cjs.map +1 -0
  13. package/dist/buildAndBroadcastRefund-COinY4dk.cjs +2 -0
  14. package/dist/buildAndBroadcastRefund-COinY4dk.cjs.map +1 -0
  15. package/dist/{buildAndBroadcastRefund-Bo3AlqCk.js → buildAndBroadcastRefund-D_l93Gln.js} +491 -448
  16. package/dist/buildAndBroadcastRefund-D_l93Gln.js.map +1 -0
  17. package/dist/{challengeAssert-Cu-PtJ1g.cjs → challengeAssert-CIHykYs3.cjs} +2 -2
  18. package/dist/{challengeAssert-Cu-PtJ1g.cjs.map → challengeAssert-CIHykYs3.cjs.map} +1 -1
  19. package/dist/{challengeAssert-BVQq50su.js → challengeAssert-XeAql2fF.js} +2 -2
  20. package/dist/{challengeAssert-BVQq50su.js.map → challengeAssert-XeAql2fF.js.map} +1 -1
  21. package/dist/{deriveVaultRoot-B_gEOTD6.js → deriveVaultRoot-B5G8y6HJ.js} +2 -2
  22. package/dist/{deriveVaultRoot-B_gEOTD6.js.map → deriveVaultRoot-B5G8y6HJ.js.map} +1 -1
  23. package/dist/{deriveVaultRoot-CebLadyJ.cjs → deriveVaultRoot-DH0kEyaS.cjs} +2 -2
  24. package/dist/{deriveVaultRoot-CebLadyJ.cjs.map → deriveVaultRoot-DH0kEyaS.cjs.map} +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +185 -180
  27. package/dist/{mempoolApi-C0olk43O.js → mempoolApi-4T6J5oxg.js} +2 -2
  28. package/dist/{mempoolApi-C0olk43O.js.map → mempoolApi-4T6J5oxg.js.map} +1 -1
  29. package/dist/{mempoolApi-Dsm2VPXp.cjs → mempoolApi-BtIABIAQ.cjs} +2 -2
  30. package/dist/{mempoolApi-Dsm2VPXp.cjs.map → mempoolApi-BtIABIAQ.cjs.map} +1 -1
  31. package/dist/{noPayout-Djrv31V5.cjs → noPayout-BkXzkhU1.cjs} +2 -2
  32. package/dist/{noPayout-Djrv31V5.cjs.map → noPayout-BkXzkhU1.cjs.map} +1 -1
  33. package/dist/{noPayout-CI4l1qu2.js → noPayout-DCf1xoJn.js} +5 -5
  34. package/dist/{noPayout-CI4l1qu2.js.map → noPayout-DCf1xoJn.js.map} +1 -1
  35. package/dist/{onChainBtcPubkey-Cd9kpz-S.cjs → onChainBtcPubkey-DqYufM7j.cjs} +2 -2
  36. package/dist/{onChainBtcPubkey-Cd9kpz-S.cjs.map → onChainBtcPubkey-DqYufM7j.cjs.map} +1 -1
  37. package/dist/{onChainBtcPubkey-aPY5ib3Q.js → onChainBtcPubkey-mP95j21Z.js} +2 -2
  38. package/dist/{onChainBtcPubkey-aPY5ib3Q.js.map → onChainBtcPubkey-mP95j21Z.js.map} +1 -1
  39. package/dist/{peginInput-CAiiDZeO.cjs → peginInput-CAYuE_5F.cjs} +2 -2
  40. package/dist/{peginInput-CAiiDZeO.cjs.map → peginInput-CAYuE_5F.cjs.map} +1 -1
  41. package/dist/{peginInput-BKD_b3gq.js → peginInput-DRUm164W.js} +2 -2
  42. package/dist/{peginInput-BKD_b3gq.js.map → peginInput-DRUm164W.js.map} +1 -1
  43. package/dist/{reservation-cHDRn4DA.js → reservation-4F9XCk0v.js} +2 -2
  44. package/dist/{reservation-cHDRn4DA.js.map → reservation-4F9XCk0v.js.map} +1 -1
  45. package/dist/{reservation-ClEs2X0H.cjs → reservation-B_7tzSwY.cjs} +2 -2
  46. package/dist/{reservation-ClEs2X0H.cjs.map → reservation-B_7tzSwY.cjs.map} +1 -1
  47. package/dist/{signPsbtsWithFallback-CzZFZf0I.js → signPsbtsWithFallback-DxG_APbS.js} +3 -3
  48. package/dist/{signPsbtsWithFallback-CzZFZf0I.js.map → signPsbtsWithFallback-DxG_APbS.js.map} +1 -1
  49. package/dist/{signPsbtsWithFallback-C01N6Kdo.cjs → signPsbtsWithFallback-r3bC-CfM.cjs} +2 -2
  50. package/dist/{signPsbtsWithFallback-C01N6Kdo.cjs.map → signPsbtsWithFallback-r3bC-CfM.cjs.map} +1 -1
  51. package/dist/tbv/core/clients/index.cjs +1 -1
  52. package/dist/tbv/core/clients/index.js +3 -3
  53. package/dist/tbv/core/index.cjs +1 -1
  54. package/dist/tbv/core/index.js +181 -176
  55. package/dist/tbv/core/managers/index.cjs +1 -1
  56. package/dist/tbv/core/managers/index.js +2 -2
  57. package/dist/tbv/core/primitives/index.cjs +1 -1
  58. package/dist/tbv/core/primitives/index.d.ts +1 -1
  59. package/dist/tbv/core/primitives/index.d.ts.map +1 -1
  60. package/dist/tbv/core/primitives/index.js +15 -14
  61. package/dist/tbv/core/primitives/utils/bitcoin.d.ts +14 -0
  62. package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
  63. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
  64. package/dist/tbv/core/services/index.cjs +1 -1
  65. package/dist/tbv/core/services/index.js +35 -31
  66. package/dist/tbv/core/services/participants/__tests__/indexerKeyHint.test.d.ts +9 -0
  67. package/dist/tbv/core/services/participants/__tests__/indexerKeyHint.test.d.ts.map +1 -0
  68. package/dist/tbv/core/services/participants/index.d.ts +2 -0
  69. package/dist/tbv/core/services/participants/index.d.ts.map +1 -1
  70. package/dist/tbv/core/services/participants/indexerKeyHint.d.ts +61 -0
  71. package/dist/tbv/core/services/participants/indexerKeyHint.d.ts.map +1 -0
  72. package/dist/tbv/core/utils/index.cjs +1 -1
  73. package/dist/tbv/core/utils/index.js +3 -3
  74. package/dist/tbv/core/vault-secrets/index.cjs +1 -1
  75. package/dist/tbv/core/vault-secrets/index.js +1 -1
  76. package/dist/tbv/index.cjs +1 -1
  77. package/dist/tbv/index.js +181 -176
  78. package/dist/testing/index.cjs +1 -1
  79. package/dist/testing/index.js +1 -1
  80. package/dist/{verifyScriptPathSchnorrSignature-C-84KJ6U.cjs → verifyScriptPathSchnorrSignature-fhjfNoHK.cjs} +2 -2
  81. package/dist/{verifyScriptPathSchnorrSignature-C-84KJ6U.cjs.map → verifyScriptPathSchnorrSignature-fhjfNoHK.cjs.map} +1 -1
  82. package/dist/{verifyScriptPathSchnorrSignature-Xoo9DOHW.js → verifyScriptPathSchnorrSignature-wwa1JhiB.js} +2 -2
  83. package/dist/{verifyScriptPathSchnorrSignature-Xoo9DOHW.js.map → verifyScriptPathSchnorrSignature-wwa1JhiB.js.map} +1 -1
  84. package/package.json +1 -1
  85. package/dist/bitcoin-B5aNKtsk.js.map +0 -1
  86. package/dist/bitcoin-CHfKAhcI.cjs +0 -2
  87. package/dist/bitcoin-CHfKAhcI.cjs.map +0 -1
  88. package/dist/buildAndBroadcastRefund-4uAl7OIk.cjs +0 -2
  89. package/dist/buildAndBroadcastRefund-4uAl7OIk.cjs.map +0 -1
  90. package/dist/buildAndBroadcastRefund-Bo3AlqCk.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"deriveVaultRoot-B_gEOTD6.js","sources":["../src/tbv/core/vault-secrets/context.ts","../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"sourcesContent":["/**\n * Canonical `vaultContext` byte encoding per\n * `derive-vault-secrets.md` §2.3.\n *\n * ```\n * vaultContext :=\n * I2OSP(32, 4) || depositorBtcPubkey // 32B x-only\n * || I2OSP(32, 4) || fundingOutpointsCommitment // 32B SHA-256\n * ```\n *\n * `fundingOutpointsCommitment` is SHA-256 over the canonically-sorted\n * funding outpoints of the Pre-PegIn transaction, serialized as\n * `txid (32B display/RPC order) || vout (4B u32 big-endian)` per\n * outpoint. Sorting by 36-byte lex order makes the commitment\n * invariant under tx-level input reordering, so same-inputs RBF and\n * reorg rebroadcasts yield the same context.\n *\n * @module vault-secrets/context\n */\n\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n\nconst DEPOSITOR_PUBKEY_SIZE = 32;\nconst TXID_SIZE = 32;\nconst OUTPOINT_SIZE = 36;\nconst COMMITMENT_SIZE = 32;\nconst FIELD_LEN_PREFIX_SIZE = 4;\nconst VAULT_CONTEXT_SIZE =\n FIELD_LEN_PREFIX_SIZE +\n DEPOSITOR_PUBKEY_SIZE +\n FIELD_LEN_PREFIX_SIZE +\n COMMITMENT_SIZE;\n\nexport interface FundingOutpoint {\n /**\n * Bitcoin txid in **display / RPC order** (byte-reversed from the\n * internal little-endian wire form used when hashing a raw tx).\n */\n txid: Uint8Array;\n /** Output index within the referenced transaction (u32). */\n vout: number;\n}\n\nexport interface VaultContextInput {\n /** Depositor's x-only BTC public key (32 bytes). */\n depositorBtcPubkey: Uint8Array;\n /** Funding outpoints of the Pre-PegIn transaction. MUST be non-empty. */\n fundingOutpoints: readonly FundingOutpoint[];\n}\n\nfunction writeUint32BE(out: Uint8Array, offset: number, value: number): void {\n out[offset] = (value >>> 24) & 0xff;\n out[offset + 1] = (value >>> 16) & 0xff;\n out[offset + 2] = (value >>> 8) & 0xff;\n out[offset + 3] = value & 0xff;\n}\n\nfunction serializeOutpoint(outpoint: FundingOutpoint): Uint8Array {\n if (outpoint.txid.length !== TXID_SIZE) {\n throw new Error(\n `outpoint.txid must be exactly ${TXID_SIZE} bytes, got ${outpoint.txid.length}`,\n );\n }\n if (\n !Number.isInteger(outpoint.vout) ||\n outpoint.vout < 0 ||\n outpoint.vout > 0xffffffff\n ) {\n throw new Error(`outpoint.vout must be a u32, got ${outpoint.vout}`);\n }\n const out = new Uint8Array(OUTPOINT_SIZE);\n out.set(outpoint.txid, 0);\n writeUint32BE(out, TXID_SIZE, outpoint.vout);\n return out;\n}\n\nfunction compareBytes(a: Uint8Array, b: Uint8Array): number {\n const len = Math.min(a.length, b.length);\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) return a[i] - b[i];\n }\n return a.length - b.length;\n}\n\n/**\n * Compute SHA-256 over canonically-sorted funding outpoints.\n *\n * Outpoints are serialized as 36-byte `txid || vout_BE`, sorted\n * ascending lexicographically, concatenated, then hashed.\n *\n * @stability frozen — on-chain-binding. Any change to layout, sort\n * order, or serialization is a hard fork; existing deposits would no\n * longer match their committed `depositorWotsPkHash`.\n *\n * @throws If `outpoints` is empty or contains duplicates.\n */\nexport function buildFundingOutpointsCommitment(\n outpoints: readonly FundingOutpoint[],\n): Uint8Array {\n if (outpoints.length === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: outpoints must be non-empty\",\n );\n }\n const serialized = outpoints.map(serializeOutpoint);\n serialized.sort(compareBytes);\n\n for (let i = 1; i < serialized.length; i++) {\n if (compareBytes(serialized[i - 1], serialized[i]) === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: duplicate outpoint detected\",\n );\n }\n }\n\n const flat = new Uint8Array(serialized.length * OUTPOINT_SIZE);\n for (let i = 0; i < serialized.length; i++) {\n flat.set(serialized[i], i * OUTPOINT_SIZE);\n }\n return sha256(flat);\n}\n\n/**\n * Build the canonical `vaultContext` byte string fed into the wallet's\n * `deriveContextHash` (or a locally-implemented equivalent on the\n * app side).\n *\n * Output length is always 72 bytes.\n *\n * @stability frozen — on-chain-binding. The 72-byte layout is the\n * input to `deriveContextHash`; any change rotates the vault root and\n * therefore every WOTS key, hashlock secret, and auth anchor derived\n * from it. Existing deposits cannot be recovered after a layout change.\n */\nexport function buildVaultContext(input: VaultContextInput): Uint8Array {\n if (input.depositorBtcPubkey.length !== DEPOSITOR_PUBKEY_SIZE) {\n throw new Error(\n `vaultContext: depositorBtcPubkey must be exactly ${DEPOSITOR_PUBKEY_SIZE} bytes, got ${input.depositorBtcPubkey.length}`,\n );\n }\n const commitment = buildFundingOutpointsCommitment(input.fundingOutpoints);\n\n const out = new Uint8Array(VAULT_CONTEXT_SIZE);\n let offset = 0;\n\n writeUint32BE(out, offset, DEPOSITOR_PUBKEY_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(input.depositorBtcPubkey, offset);\n offset += DEPOSITOR_PUBKEY_SIZE;\n\n writeUint32BE(out, offset, COMMITMENT_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(commitment, offset);\n\n return out;\n}\n","/**\n * Vault-root derivation via the wallet's `deriveContextHash` API.\n *\n * Implements the canonical root source from `derive-vault-secrets.md`\n * §2.2:\n *\n * ```\n * rootDerivation = deriveContextHash(\"babylon-btc-vault\", hex(vaultContext))\n * ```\n *\n * The 32-byte output is fed directly into the {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, and {@link expandWotsSeed} functions in\n * this module.\n *\n * @module vault-secrets/deriveVaultRoot\n */\n\nimport { hexToUint8Array, uint8ArrayToHex } from \"../primitives/utils/bitcoin\";\n\nimport { buildVaultContext, type VaultContextInput } from \"./context\";\n\n/**\n * The fixed `appName` passed to the wallet's `deriveContextHash` for\n * Babylon vault derivations. The wallet displays this in its approval\n * dialog. Defined by `derive-vault-secrets.md` §2.2 — must not be\n * changed without coordinating a spec revision and a downstream\n * migration plan, as it provides app-level domain separation across\n * applications using the same wallet.\n */\nexport const VAULT_APP_NAME = \"babylon-btc-vault\";\n\n/** Expected length of the wallet output in bytes per spec §2.1. */\nconst ROOT_OUTPUT_BYTES = 32;\n\n/** Expected length of the wallet output in lowercase hex chars. */\nconst ROOT_OUTPUT_HEX_LEN = ROOT_OUTPUT_BYTES * 2;\n\nconst LOWERCASE_HEX_RE = /^[0-9a-f]+$/;\n\n/**\n * Minimal structural shape for the wallet capability needed by this\n * helper. Typed against the method directly so callers can pass any\n * value that implements `deriveContextHash` — `BitcoinWallet` from\n * this SDK, `IBTCProvider` from `@babylonlabs-io/wallet-connector`,\n * or a test mock — without depending on the rest of either interface.\n */\nexport interface DeriveContextHashCapableWallet {\n deriveContextHash(appName: string, context: string): Promise<string>;\n}\n\n/**\n * Derive the 32-byte vault root from a wallet by encoding the\n * canonical {@link VaultContextInput} and forwarding to\n * `wallet.deriveContextHash`.\n *\n * Validates the wallet's output strictly: must be exactly 64\n * lowercase hex characters per `derive-context-hash.md` §2.1. A\n * conformant wallet always satisfies this, but we re-check at the\n * SDK boundary so a non-conformant wallet (or a wallet returning a\n * malformed value through a buggy adapter) fails loud here rather\n * than producing silently-wrong derived secrets downstream.\n *\n * The helper itself produces only valid spec inputs (`appName` is\n * the hardcoded `VAULT_APP_NAME`; `context` is hex of the 72-byte\n * `vaultContext`, always 144 chars lowercase), so input-side\n * validation is unnecessary.\n *\n * @param wallet - Any value implementing `deriveContextHash`.\n * @param input - The canonical {@link VaultContextInput} that\n * uniquely identifies the vault. Encoded by\n * {@link buildVaultContext} into a 72-byte structure\n * before being hex-encoded for the wallet.\n * @stability frozen — on-chain-binding. The pair (`VAULT_APP_NAME`,\n * `vaultContext` encoding) is the wallet's input space; changing\n * either rotates the root and invalidates every secret derived from\n * it. `VAULT_APP_NAME` is fixed by `derive-vault-secrets.md` §2.2\n * and must never change without a coordinated spec revision.\n *\n * @returns 32-byte root suitable for {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, {@link expandWotsSeed}.\n * @throws If the wallet returns a non-64-char or non-lowercase-hex\n * string. Errors from the wallet (user rejection,\n * method-not-supported, etc.) propagate unchanged.\n */\nexport async function deriveVaultRoot(\n wallet: DeriveContextHashCapableWallet,\n input: VaultContextInput,\n): Promise<Uint8Array> {\n const vaultContext = buildVaultContext(input);\n const contextHex = uint8ArrayToHex(vaultContext);\n\n const rootHex = await wallet.deriveContextHash(VAULT_APP_NAME, contextHex);\n\n if (typeof rootHex !== \"string\") {\n throw new Error(\n `deriveVaultRoot: wallet must return a string, got ${typeof rootHex}`,\n );\n }\n if (rootHex.length !== ROOT_OUTPUT_HEX_LEN) {\n throw new Error(\n `deriveVaultRoot: wallet must return a ${ROOT_OUTPUT_HEX_LEN}-character hex string (${ROOT_OUTPUT_BYTES} bytes), got length ${rootHex.length}`,\n );\n }\n if (!LOWERCASE_HEX_RE.test(rootHex)) {\n throw new Error(\n \"deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters\",\n );\n }\n\n return hexToUint8Array(rootHex);\n}\n"],"names":["DEPOSITOR_PUBKEY_SIZE","TXID_SIZE","OUTPOINT_SIZE","COMMITMENT_SIZE","FIELD_LEN_PREFIX_SIZE","VAULT_CONTEXT_SIZE","writeUint32BE","out","offset","value","serializeOutpoint","outpoint","compareBytes","a","b","len","i","buildFundingOutpointsCommitment","outpoints","serialized","flat","sha256","buildVaultContext","input","commitment","VAULT_APP_NAME","ROOT_OUTPUT_BYTES","ROOT_OUTPUT_HEX_LEN","LOWERCASE_HEX_RE","deriveVaultRoot","wallet","vaultContext","contextHex","uint8ArrayToHex","rootHex","hexToUint8Array"],"mappings":"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"}
1
+ {"version":3,"file":"deriveVaultRoot-B5G8y6HJ.js","sources":["../src/tbv/core/vault-secrets/context.ts","../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"sourcesContent":["/**\n * Canonical `vaultContext` byte encoding per\n * `derive-vault-secrets.md` §2.3.\n *\n * ```\n * vaultContext :=\n * I2OSP(32, 4) || depositorBtcPubkey // 32B x-only\n * || I2OSP(32, 4) || fundingOutpointsCommitment // 32B SHA-256\n * ```\n *\n * `fundingOutpointsCommitment` is SHA-256 over the canonically-sorted\n * funding outpoints of the Pre-PegIn transaction, serialized as\n * `txid (32B display/RPC order) || vout (4B u32 big-endian)` per\n * outpoint. Sorting by 36-byte lex order makes the commitment\n * invariant under tx-level input reordering, so same-inputs RBF and\n * reorg rebroadcasts yield the same context.\n *\n * @module vault-secrets/context\n */\n\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n\nconst DEPOSITOR_PUBKEY_SIZE = 32;\nconst TXID_SIZE = 32;\nconst OUTPOINT_SIZE = 36;\nconst COMMITMENT_SIZE = 32;\nconst FIELD_LEN_PREFIX_SIZE = 4;\nconst VAULT_CONTEXT_SIZE =\n FIELD_LEN_PREFIX_SIZE +\n DEPOSITOR_PUBKEY_SIZE +\n FIELD_LEN_PREFIX_SIZE +\n COMMITMENT_SIZE;\n\nexport interface FundingOutpoint {\n /**\n * Bitcoin txid in **display / RPC order** (byte-reversed from the\n * internal little-endian wire form used when hashing a raw tx).\n */\n txid: Uint8Array;\n /** Output index within the referenced transaction (u32). */\n vout: number;\n}\n\nexport interface VaultContextInput {\n /** Depositor's x-only BTC public key (32 bytes). */\n depositorBtcPubkey: Uint8Array;\n /** Funding outpoints of the Pre-PegIn transaction. MUST be non-empty. */\n fundingOutpoints: readonly FundingOutpoint[];\n}\n\nfunction writeUint32BE(out: Uint8Array, offset: number, value: number): void {\n out[offset] = (value >>> 24) & 0xff;\n out[offset + 1] = (value >>> 16) & 0xff;\n out[offset + 2] = (value >>> 8) & 0xff;\n out[offset + 3] = value & 0xff;\n}\n\nfunction serializeOutpoint(outpoint: FundingOutpoint): Uint8Array {\n if (outpoint.txid.length !== TXID_SIZE) {\n throw new Error(\n `outpoint.txid must be exactly ${TXID_SIZE} bytes, got ${outpoint.txid.length}`,\n );\n }\n if (\n !Number.isInteger(outpoint.vout) ||\n outpoint.vout < 0 ||\n outpoint.vout > 0xffffffff\n ) {\n throw new Error(`outpoint.vout must be a u32, got ${outpoint.vout}`);\n }\n const out = new Uint8Array(OUTPOINT_SIZE);\n out.set(outpoint.txid, 0);\n writeUint32BE(out, TXID_SIZE, outpoint.vout);\n return out;\n}\n\nfunction compareBytes(a: Uint8Array, b: Uint8Array): number {\n const len = Math.min(a.length, b.length);\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) return a[i] - b[i];\n }\n return a.length - b.length;\n}\n\n/**\n * Compute SHA-256 over canonically-sorted funding outpoints.\n *\n * Outpoints are serialized as 36-byte `txid || vout_BE`, sorted\n * ascending lexicographically, concatenated, then hashed.\n *\n * @stability frozen — on-chain-binding. Any change to layout, sort\n * order, or serialization is a hard fork; existing deposits would no\n * longer match their committed `depositorWotsPkHash`.\n *\n * @throws If `outpoints` is empty or contains duplicates.\n */\nexport function buildFundingOutpointsCommitment(\n outpoints: readonly FundingOutpoint[],\n): Uint8Array {\n if (outpoints.length === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: outpoints must be non-empty\",\n );\n }\n const serialized = outpoints.map(serializeOutpoint);\n serialized.sort(compareBytes);\n\n for (let i = 1; i < serialized.length; i++) {\n if (compareBytes(serialized[i - 1], serialized[i]) === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: duplicate outpoint detected\",\n );\n }\n }\n\n const flat = new Uint8Array(serialized.length * OUTPOINT_SIZE);\n for (let i = 0; i < serialized.length; i++) {\n flat.set(serialized[i], i * OUTPOINT_SIZE);\n }\n return sha256(flat);\n}\n\n/**\n * Build the canonical `vaultContext` byte string fed into the wallet's\n * `deriveContextHash` (or a locally-implemented equivalent on the\n * app side).\n *\n * Output length is always 72 bytes.\n *\n * @stability frozen — on-chain-binding. The 72-byte layout is the\n * input to `deriveContextHash`; any change rotates the vault root and\n * therefore every WOTS key, hashlock secret, and auth anchor derived\n * from it. Existing deposits cannot be recovered after a layout change.\n */\nexport function buildVaultContext(input: VaultContextInput): Uint8Array {\n if (input.depositorBtcPubkey.length !== DEPOSITOR_PUBKEY_SIZE) {\n throw new Error(\n `vaultContext: depositorBtcPubkey must be exactly ${DEPOSITOR_PUBKEY_SIZE} bytes, got ${input.depositorBtcPubkey.length}`,\n );\n }\n const commitment = buildFundingOutpointsCommitment(input.fundingOutpoints);\n\n const out = new Uint8Array(VAULT_CONTEXT_SIZE);\n let offset = 0;\n\n writeUint32BE(out, offset, DEPOSITOR_PUBKEY_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(input.depositorBtcPubkey, offset);\n offset += DEPOSITOR_PUBKEY_SIZE;\n\n writeUint32BE(out, offset, COMMITMENT_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(commitment, offset);\n\n return out;\n}\n","/**\n * Vault-root derivation via the wallet's `deriveContextHash` API.\n *\n * Implements the canonical root source from `derive-vault-secrets.md`\n * §2.2:\n *\n * ```\n * rootDerivation = deriveContextHash(\"babylon-btc-vault\", hex(vaultContext))\n * ```\n *\n * The 32-byte output is fed directly into the {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, and {@link expandWotsSeed} functions in\n * this module.\n *\n * @module vault-secrets/deriveVaultRoot\n */\n\nimport { hexToUint8Array, uint8ArrayToHex } from \"../primitives/utils/bitcoin\";\n\nimport { buildVaultContext, type VaultContextInput } from \"./context\";\n\n/**\n * The fixed `appName` passed to the wallet's `deriveContextHash` for\n * Babylon vault derivations. The wallet displays this in its approval\n * dialog. Defined by `derive-vault-secrets.md` §2.2 — must not be\n * changed without coordinating a spec revision and a downstream\n * migration plan, as it provides app-level domain separation across\n * applications using the same wallet.\n */\nexport const VAULT_APP_NAME = \"babylon-btc-vault\";\n\n/** Expected length of the wallet output in bytes per spec §2.1. */\nconst ROOT_OUTPUT_BYTES = 32;\n\n/** Expected length of the wallet output in lowercase hex chars. */\nconst ROOT_OUTPUT_HEX_LEN = ROOT_OUTPUT_BYTES * 2;\n\nconst LOWERCASE_HEX_RE = /^[0-9a-f]+$/;\n\n/**\n * Minimal structural shape for the wallet capability needed by this\n * helper. Typed against the method directly so callers can pass any\n * value that implements `deriveContextHash` — `BitcoinWallet` from\n * this SDK, `IBTCProvider` from `@babylonlabs-io/wallet-connector`,\n * or a test mock — without depending on the rest of either interface.\n */\nexport interface DeriveContextHashCapableWallet {\n deriveContextHash(appName: string, context: string): Promise<string>;\n}\n\n/**\n * Derive the 32-byte vault root from a wallet by encoding the\n * canonical {@link VaultContextInput} and forwarding to\n * `wallet.deriveContextHash`.\n *\n * Validates the wallet's output strictly: must be exactly 64\n * lowercase hex characters per `derive-context-hash.md` §2.1. A\n * conformant wallet always satisfies this, but we re-check at the\n * SDK boundary so a non-conformant wallet (or a wallet returning a\n * malformed value through a buggy adapter) fails loud here rather\n * than producing silently-wrong derived secrets downstream.\n *\n * The helper itself produces only valid spec inputs (`appName` is\n * the hardcoded `VAULT_APP_NAME`; `context` is hex of the 72-byte\n * `vaultContext`, always 144 chars lowercase), so input-side\n * validation is unnecessary.\n *\n * @param wallet - Any value implementing `deriveContextHash`.\n * @param input - The canonical {@link VaultContextInput} that\n * uniquely identifies the vault. Encoded by\n * {@link buildVaultContext} into a 72-byte structure\n * before being hex-encoded for the wallet.\n * @stability frozen — on-chain-binding. The pair (`VAULT_APP_NAME`,\n * `vaultContext` encoding) is the wallet's input space; changing\n * either rotates the root and invalidates every secret derived from\n * it. `VAULT_APP_NAME` is fixed by `derive-vault-secrets.md` §2.2\n * and must never change without a coordinated spec revision.\n *\n * @returns 32-byte root suitable for {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, {@link expandWotsSeed}.\n * @throws If the wallet returns a non-64-char or non-lowercase-hex\n * string. Errors from the wallet (user rejection,\n * method-not-supported, etc.) propagate unchanged.\n */\nexport async function deriveVaultRoot(\n wallet: DeriveContextHashCapableWallet,\n input: VaultContextInput,\n): Promise<Uint8Array> {\n const vaultContext = buildVaultContext(input);\n const contextHex = uint8ArrayToHex(vaultContext);\n\n const rootHex = await wallet.deriveContextHash(VAULT_APP_NAME, contextHex);\n\n if (typeof rootHex !== \"string\") {\n throw new Error(\n `deriveVaultRoot: wallet must return a string, got ${typeof rootHex}`,\n );\n }\n if (rootHex.length !== ROOT_OUTPUT_HEX_LEN) {\n throw new Error(\n `deriveVaultRoot: wallet must return a ${ROOT_OUTPUT_HEX_LEN}-character hex string (${ROOT_OUTPUT_BYTES} bytes), got length ${rootHex.length}`,\n );\n }\n if (!LOWERCASE_HEX_RE.test(rootHex)) {\n throw new Error(\n \"deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters\",\n );\n }\n\n return hexToUint8Array(rootHex);\n}\n"],"names":["DEPOSITOR_PUBKEY_SIZE","TXID_SIZE","OUTPOINT_SIZE","COMMITMENT_SIZE","FIELD_LEN_PREFIX_SIZE","VAULT_CONTEXT_SIZE","writeUint32BE","out","offset","value","serializeOutpoint","outpoint","compareBytes","a","b","len","i","buildFundingOutpointsCommitment","outpoints","serialized","flat","sha256","buildVaultContext","input","commitment","VAULT_APP_NAME","ROOT_OUTPUT_BYTES","ROOT_OUTPUT_HEX_LEN","LOWERCASE_HEX_RE","deriveVaultRoot","wallet","vaultContext","contextHex","uint8ArrayToHex","rootHex","hexToUint8Array"],"mappings":";;AAsBA,MAAMA,IAAwB,IACxBC,IAAY,IACZC,IAAgB,IAChBC,IAAkB,IAClBC,IAAwB,GACxBC,IACJD,IACAJ,IACAI,IACAD;AAmBF,SAASG,EAAcC,GAAiBC,GAAgBC,GAAqB;AAC3E,EAAAF,EAAIC,CAAM,IAAKC,MAAU,KAAM,KAC/BF,EAAIC,IAAS,CAAC,IAAKC,MAAU,KAAM,KACnCF,EAAIC,IAAS,CAAC,IAAKC,MAAU,IAAK,KAClCF,EAAIC,IAAS,CAAC,IAAIC,IAAQ;AAC5B;AAEA,SAASC,EAAkBC,GAAuC;AAChE,MAAIA,EAAS,KAAK,WAAWV;AAC3B,UAAM,IAAI;AAAA,MACR,iCAAiCA,CAAS,eAAeU,EAAS,KAAK,MAAM;AAAA,IAAA;AAGjF,MACE,CAAC,OAAO,UAAUA,EAAS,IAAI,KAC/BA,EAAS,OAAO,KAChBA,EAAS,OAAO;AAEhB,UAAM,IAAI,MAAM,oCAAoCA,EAAS,IAAI,EAAE;AAErE,QAAMJ,IAAM,IAAI,WAAWL,CAAa;AACxC,SAAAK,EAAI,IAAII,EAAS,MAAM,CAAC,GACxBL,EAAcC,GAAKN,GAAWU,EAAS,IAAI,GACpCJ;AACT;AAEA,SAASK,EAAaC,GAAeC,GAAuB;AAC1D,QAAMC,IAAM,KAAK,IAAIF,EAAE,QAAQC,EAAE,MAAM;AACvC,WAASE,IAAI,GAAGA,IAAID,GAAKC;AACvB,QAAIH,EAAEG,CAAC,MAAMF,EAAEE,CAAC,EAAG,QAAOH,EAAEG,CAAC,IAAIF,EAAEE,CAAC;AAEtC,SAAOH,EAAE,SAASC,EAAE;AACtB;AAcO,SAASG,EACdC,GACY;AACZ,MAAIA,EAAU,WAAW;AACvB,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAGJ,QAAMC,IAAaD,EAAU,IAAIR,CAAiB;AAClD,EAAAS,EAAW,KAAKP,CAAY;AAE5B,WAASI,IAAI,GAAGA,IAAIG,EAAW,QAAQH;AACrC,QAAIJ,EAAaO,EAAWH,IAAI,CAAC,GAAGG,EAAWH,CAAC,CAAC,MAAM;AACrD,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAKN,QAAMI,IAAO,IAAI,WAAWD,EAAW,SAASjB,CAAa;AAC7D,WAASc,IAAI,GAAGA,IAAIG,EAAW,QAAQH;AACrC,IAAAI,EAAK,IAAID,EAAWH,CAAC,GAAGA,IAAId,CAAa;AAE3C,SAAOmB,EAAOD,CAAI;AACpB;AAcO,SAASE,EAAkBC,GAAsC;AACtE,MAAIA,EAAM,mBAAmB,WAAWvB;AACtC,UAAM,IAAI;AAAA,MACR,oDAAoDA,CAAqB,eAAeuB,EAAM,mBAAmB,MAAM;AAAA,IAAA;AAG3H,QAAMC,IAAaP,EAAgCM,EAAM,gBAAgB,GAEnEhB,IAAM,IAAI,WAAWF,CAAkB;AAC7C,MAAIG,IAAS;AAEb,SAAAF,EAAcC,GAAKC,GAAQR,CAAqB,GAChDQ,KAAUJ,GACVG,EAAI,IAAIgB,EAAM,oBAAoBf,CAAM,GACxCA,KAAUR,GAEVM,EAAcC,GAAKC,GAAQL,CAAe,GAC1CK,KAAUJ,GACVG,EAAI,IAAIiB,GAAYhB,CAAM,GAEnBD;AACT;AC9HO,MAAMkB,IAAiB,qBAGxBC,IAAoB,IAGpBC,IAAsBD,IAAoB,GAE1CE,IAAmB;AA+CzB,eAAsBC,EACpBC,GACAP,GACqB;AACrB,QAAMQ,IAAeT,EAAkBC,CAAK,GACtCS,IAAaC,EAAgBF,CAAY,GAEzCG,IAAU,MAAMJ,EAAO,kBAAkBL,GAAgBO,CAAU;AAEzE,MAAI,OAAOE,KAAY;AACrB,UAAM,IAAI;AAAA,MACR,qDAAqD,OAAOA,CAAO;AAAA,IAAA;AAGvE,MAAIA,EAAQ,WAAWP;AACrB,UAAM,IAAI;AAAA,MACR,yCAAyCA,CAAmB,0BAA0BD,CAAiB,uBAAuBQ,EAAQ,MAAM;AAAA,IAAA;AAGhJ,MAAI,CAACN,EAAiB,KAAKM,CAAO;AAChC,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAIJ,SAAOC,EAAgBD,CAAO;AAChC;"}
@@ -1,2 +1,2 @@
1
- "use strict";const a=require("./bitcoin-CHfKAhcI.cjs"),x=require("./sha2-DsrLC4NM.cjs"),i=32,u=32,c=36,E=32,s=4,y=s+i+s+E;function l(t,n,o){t[n]=o>>>24&255,t[n+1]=o>>>16&255,t[n+2]=o>>>8&255,t[n+3]=o&255}function T(t){if(t.txid.length!==u)throw new Error(`outpoint.txid must be exactly ${u} bytes, got ${t.txid.length}`);if(!Number.isInteger(t.vout)||t.vout<0||t.vout>4294967295)throw new Error(`outpoint.vout must be a u32, got ${t.vout}`);const n=new Uint8Array(c);return n.set(t.txid,0),l(n,u,t.vout),n}function h(t,n){const o=Math.min(t.length,n.length);for(let e=0;e<o;e++)if(t[e]!==n[e])return t[e]-n[e];return t.length-n.length}function g(t){if(t.length===0)throw new Error("buildFundingOutpointsCommitment: outpoints must be non-empty");const n=t.map(T);n.sort(h);for(let e=1;e<n.length;e++)if(h(n[e-1],n[e])===0)throw new Error("buildFundingOutpointsCommitment: duplicate outpoint detected");const o=new Uint8Array(n.length*c);for(let e=0;e<n.length;e++)o.set(n[e],e*c);return x.sha256(o)}function m(t){if(t.depositorBtcPubkey.length!==i)throw new Error(`vaultContext: depositorBtcPubkey must be exactly ${i} bytes, got ${t.depositorBtcPubkey.length}`);const n=g(t.fundingOutpoints),o=new Uint8Array(y);let e=0;return l(o,e,i),e+=s,o.set(t.depositorBtcPubkey,e),e+=i,l(o,e,E),e+=s,o.set(n,e),o}const w="babylon-btc-vault",_=32,d=_*2,b=/^[0-9a-f]+$/;async function f(t,n){const o=m(n),e=a.uint8ArrayToHex(o),r=await t.deriveContextHash(w,e);if(typeof r!="string")throw new Error(`deriveVaultRoot: wallet must return a string, got ${typeof r}`);if(r.length!==d)throw new Error(`deriveVaultRoot: wallet must return a ${d}-character hex string (${_} bytes), got length ${r.length}`);if(!b.test(r))throw new Error("deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters");return a.hexToUint8Array(r)}exports.VAULT_APP_NAME=w;exports.buildFundingOutpointsCommitment=g;exports.buildVaultContext=m;exports.deriveVaultRoot=f;
2
- //# sourceMappingURL=deriveVaultRoot-CebLadyJ.cjs.map
1
+ "use strict";const a=require("./bitcoin-Dpcfff7b.cjs"),x=require("./sha2-DsrLC4NM.cjs"),i=32,u=32,c=36,E=32,s=4,y=s+i+s+E;function l(t,n,o){t[n]=o>>>24&255,t[n+1]=o>>>16&255,t[n+2]=o>>>8&255,t[n+3]=o&255}function T(t){if(t.txid.length!==u)throw new Error(`outpoint.txid must be exactly ${u} bytes, got ${t.txid.length}`);if(!Number.isInteger(t.vout)||t.vout<0||t.vout>4294967295)throw new Error(`outpoint.vout must be a u32, got ${t.vout}`);const n=new Uint8Array(c);return n.set(t.txid,0),l(n,u,t.vout),n}function h(t,n){const o=Math.min(t.length,n.length);for(let e=0;e<o;e++)if(t[e]!==n[e])return t[e]-n[e];return t.length-n.length}function g(t){if(t.length===0)throw new Error("buildFundingOutpointsCommitment: outpoints must be non-empty");const n=t.map(T);n.sort(h);for(let e=1;e<n.length;e++)if(h(n[e-1],n[e])===0)throw new Error("buildFundingOutpointsCommitment: duplicate outpoint detected");const o=new Uint8Array(n.length*c);for(let e=0;e<n.length;e++)o.set(n[e],e*c);return x.sha256(o)}function m(t){if(t.depositorBtcPubkey.length!==i)throw new Error(`vaultContext: depositorBtcPubkey must be exactly ${i} bytes, got ${t.depositorBtcPubkey.length}`);const n=g(t.fundingOutpoints),o=new Uint8Array(y);let e=0;return l(o,e,i),e+=s,o.set(t.depositorBtcPubkey,e),e+=i,l(o,e,E),e+=s,o.set(n,e),o}const w="babylon-btc-vault",_=32,d=_*2,b=/^[0-9a-f]+$/;async function f(t,n){const o=m(n),e=a.uint8ArrayToHex(o),r=await t.deriveContextHash(w,e);if(typeof r!="string")throw new Error(`deriveVaultRoot: wallet must return a string, got ${typeof r}`);if(r.length!==d)throw new Error(`deriveVaultRoot: wallet must return a ${d}-character hex string (${_} bytes), got length ${r.length}`);if(!b.test(r))throw new Error("deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters");return a.hexToUint8Array(r)}exports.VAULT_APP_NAME=w;exports.buildFundingOutpointsCommitment=g;exports.buildVaultContext=m;exports.deriveVaultRoot=f;
2
+ //# sourceMappingURL=deriveVaultRoot-DH0kEyaS.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deriveVaultRoot-CebLadyJ.cjs","sources":["../src/tbv/core/vault-secrets/context.ts","../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"sourcesContent":["/**\n * Canonical `vaultContext` byte encoding per\n * `derive-vault-secrets.md` §2.3.\n *\n * ```\n * vaultContext :=\n * I2OSP(32, 4) || depositorBtcPubkey // 32B x-only\n * || I2OSP(32, 4) || fundingOutpointsCommitment // 32B SHA-256\n * ```\n *\n * `fundingOutpointsCommitment` is SHA-256 over the canonically-sorted\n * funding outpoints of the Pre-PegIn transaction, serialized as\n * `txid (32B display/RPC order) || vout (4B u32 big-endian)` per\n * outpoint. Sorting by 36-byte lex order makes the commitment\n * invariant under tx-level input reordering, so same-inputs RBF and\n * reorg rebroadcasts yield the same context.\n *\n * @module vault-secrets/context\n */\n\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n\nconst DEPOSITOR_PUBKEY_SIZE = 32;\nconst TXID_SIZE = 32;\nconst OUTPOINT_SIZE = 36;\nconst COMMITMENT_SIZE = 32;\nconst FIELD_LEN_PREFIX_SIZE = 4;\nconst VAULT_CONTEXT_SIZE =\n FIELD_LEN_PREFIX_SIZE +\n DEPOSITOR_PUBKEY_SIZE +\n FIELD_LEN_PREFIX_SIZE +\n COMMITMENT_SIZE;\n\nexport interface FundingOutpoint {\n /**\n * Bitcoin txid in **display / RPC order** (byte-reversed from the\n * internal little-endian wire form used when hashing a raw tx).\n */\n txid: Uint8Array;\n /** Output index within the referenced transaction (u32). */\n vout: number;\n}\n\nexport interface VaultContextInput {\n /** Depositor's x-only BTC public key (32 bytes). */\n depositorBtcPubkey: Uint8Array;\n /** Funding outpoints of the Pre-PegIn transaction. MUST be non-empty. */\n fundingOutpoints: readonly FundingOutpoint[];\n}\n\nfunction writeUint32BE(out: Uint8Array, offset: number, value: number): void {\n out[offset] = (value >>> 24) & 0xff;\n out[offset + 1] = (value >>> 16) & 0xff;\n out[offset + 2] = (value >>> 8) & 0xff;\n out[offset + 3] = value & 0xff;\n}\n\nfunction serializeOutpoint(outpoint: FundingOutpoint): Uint8Array {\n if (outpoint.txid.length !== TXID_SIZE) {\n throw new Error(\n `outpoint.txid must be exactly ${TXID_SIZE} bytes, got ${outpoint.txid.length}`,\n );\n }\n if (\n !Number.isInteger(outpoint.vout) ||\n outpoint.vout < 0 ||\n outpoint.vout > 0xffffffff\n ) {\n throw new Error(`outpoint.vout must be a u32, got ${outpoint.vout}`);\n }\n const out = new Uint8Array(OUTPOINT_SIZE);\n out.set(outpoint.txid, 0);\n writeUint32BE(out, TXID_SIZE, outpoint.vout);\n return out;\n}\n\nfunction compareBytes(a: Uint8Array, b: Uint8Array): number {\n const len = Math.min(a.length, b.length);\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) return a[i] - b[i];\n }\n return a.length - b.length;\n}\n\n/**\n * Compute SHA-256 over canonically-sorted funding outpoints.\n *\n * Outpoints are serialized as 36-byte `txid || vout_BE`, sorted\n * ascending lexicographically, concatenated, then hashed.\n *\n * @stability frozen — on-chain-binding. Any change to layout, sort\n * order, or serialization is a hard fork; existing deposits would no\n * longer match their committed `depositorWotsPkHash`.\n *\n * @throws If `outpoints` is empty or contains duplicates.\n */\nexport function buildFundingOutpointsCommitment(\n outpoints: readonly FundingOutpoint[],\n): Uint8Array {\n if (outpoints.length === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: outpoints must be non-empty\",\n );\n }\n const serialized = outpoints.map(serializeOutpoint);\n serialized.sort(compareBytes);\n\n for (let i = 1; i < serialized.length; i++) {\n if (compareBytes(serialized[i - 1], serialized[i]) === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: duplicate outpoint detected\",\n );\n }\n }\n\n const flat = new Uint8Array(serialized.length * OUTPOINT_SIZE);\n for (let i = 0; i < serialized.length; i++) {\n flat.set(serialized[i], i * OUTPOINT_SIZE);\n }\n return sha256(flat);\n}\n\n/**\n * Build the canonical `vaultContext` byte string fed into the wallet's\n * `deriveContextHash` (or a locally-implemented equivalent on the\n * app side).\n *\n * Output length is always 72 bytes.\n *\n * @stability frozen — on-chain-binding. The 72-byte layout is the\n * input to `deriveContextHash`; any change rotates the vault root and\n * therefore every WOTS key, hashlock secret, and auth anchor derived\n * from it. Existing deposits cannot be recovered after a layout change.\n */\nexport function buildVaultContext(input: VaultContextInput): Uint8Array {\n if (input.depositorBtcPubkey.length !== DEPOSITOR_PUBKEY_SIZE) {\n throw new Error(\n `vaultContext: depositorBtcPubkey must be exactly ${DEPOSITOR_PUBKEY_SIZE} bytes, got ${input.depositorBtcPubkey.length}`,\n );\n }\n const commitment = buildFundingOutpointsCommitment(input.fundingOutpoints);\n\n const out = new Uint8Array(VAULT_CONTEXT_SIZE);\n let offset = 0;\n\n writeUint32BE(out, offset, DEPOSITOR_PUBKEY_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(input.depositorBtcPubkey, offset);\n offset += DEPOSITOR_PUBKEY_SIZE;\n\n writeUint32BE(out, offset, COMMITMENT_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(commitment, offset);\n\n return out;\n}\n","/**\n * Vault-root derivation via the wallet's `deriveContextHash` API.\n *\n * Implements the canonical root source from `derive-vault-secrets.md`\n * §2.2:\n *\n * ```\n * rootDerivation = deriveContextHash(\"babylon-btc-vault\", hex(vaultContext))\n * ```\n *\n * The 32-byte output is fed directly into the {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, and {@link expandWotsSeed} functions in\n * this module.\n *\n * @module vault-secrets/deriveVaultRoot\n */\n\nimport { hexToUint8Array, uint8ArrayToHex } from \"../primitives/utils/bitcoin\";\n\nimport { buildVaultContext, type VaultContextInput } from \"./context\";\n\n/**\n * The fixed `appName` passed to the wallet's `deriveContextHash` for\n * Babylon vault derivations. The wallet displays this in its approval\n * dialog. Defined by `derive-vault-secrets.md` §2.2 — must not be\n * changed without coordinating a spec revision and a downstream\n * migration plan, as it provides app-level domain separation across\n * applications using the same wallet.\n */\nexport const VAULT_APP_NAME = \"babylon-btc-vault\";\n\n/** Expected length of the wallet output in bytes per spec §2.1. */\nconst ROOT_OUTPUT_BYTES = 32;\n\n/** Expected length of the wallet output in lowercase hex chars. */\nconst ROOT_OUTPUT_HEX_LEN = ROOT_OUTPUT_BYTES * 2;\n\nconst LOWERCASE_HEX_RE = /^[0-9a-f]+$/;\n\n/**\n * Minimal structural shape for the wallet capability needed by this\n * helper. Typed against the method directly so callers can pass any\n * value that implements `deriveContextHash` — `BitcoinWallet` from\n * this SDK, `IBTCProvider` from `@babylonlabs-io/wallet-connector`,\n * or a test mock — without depending on the rest of either interface.\n */\nexport interface DeriveContextHashCapableWallet {\n deriveContextHash(appName: string, context: string): Promise<string>;\n}\n\n/**\n * Derive the 32-byte vault root from a wallet by encoding the\n * canonical {@link VaultContextInput} and forwarding to\n * `wallet.deriveContextHash`.\n *\n * Validates the wallet's output strictly: must be exactly 64\n * lowercase hex characters per `derive-context-hash.md` §2.1. A\n * conformant wallet always satisfies this, but we re-check at the\n * SDK boundary so a non-conformant wallet (or a wallet returning a\n * malformed value through a buggy adapter) fails loud here rather\n * than producing silently-wrong derived secrets downstream.\n *\n * The helper itself produces only valid spec inputs (`appName` is\n * the hardcoded `VAULT_APP_NAME`; `context` is hex of the 72-byte\n * `vaultContext`, always 144 chars lowercase), so input-side\n * validation is unnecessary.\n *\n * @param wallet - Any value implementing `deriveContextHash`.\n * @param input - The canonical {@link VaultContextInput} that\n * uniquely identifies the vault. Encoded by\n * {@link buildVaultContext} into a 72-byte structure\n * before being hex-encoded for the wallet.\n * @stability frozen — on-chain-binding. The pair (`VAULT_APP_NAME`,\n * `vaultContext` encoding) is the wallet's input space; changing\n * either rotates the root and invalidates every secret derived from\n * it. `VAULT_APP_NAME` is fixed by `derive-vault-secrets.md` §2.2\n * and must never change without a coordinated spec revision.\n *\n * @returns 32-byte root suitable for {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, {@link expandWotsSeed}.\n * @throws If the wallet returns a non-64-char or non-lowercase-hex\n * string. Errors from the wallet (user rejection,\n * method-not-supported, etc.) propagate unchanged.\n */\nexport async function deriveVaultRoot(\n wallet: DeriveContextHashCapableWallet,\n input: VaultContextInput,\n): Promise<Uint8Array> {\n const vaultContext = buildVaultContext(input);\n const contextHex = uint8ArrayToHex(vaultContext);\n\n const rootHex = await wallet.deriveContextHash(VAULT_APP_NAME, contextHex);\n\n if (typeof rootHex !== \"string\") {\n throw new Error(\n `deriveVaultRoot: wallet must return a string, got ${typeof rootHex}`,\n );\n }\n if (rootHex.length !== ROOT_OUTPUT_HEX_LEN) {\n throw new Error(\n `deriveVaultRoot: wallet must return a ${ROOT_OUTPUT_HEX_LEN}-character hex string (${ROOT_OUTPUT_BYTES} bytes), got length ${rootHex.length}`,\n );\n }\n if (!LOWERCASE_HEX_RE.test(rootHex)) {\n throw new Error(\n \"deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters\",\n );\n }\n\n return hexToUint8Array(rootHex);\n}\n"],"names":["DEPOSITOR_PUBKEY_SIZE","TXID_SIZE","OUTPOINT_SIZE","COMMITMENT_SIZE","FIELD_LEN_PREFIX_SIZE","VAULT_CONTEXT_SIZE","writeUint32BE","out","offset","value","serializeOutpoint","outpoint","compareBytes","a","b","len","i","buildFundingOutpointsCommitment","outpoints","serialized","flat","sha256","buildVaultContext","input","commitment","VAULT_APP_NAME","ROOT_OUTPUT_BYTES","ROOT_OUTPUT_HEX_LEN","LOWERCASE_HEX_RE","deriveVaultRoot","wallet","vaultContext","contextHex","uint8ArrayToHex","rootHex","hexToUint8Array"],"mappings":"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"}
1
+ {"version":3,"file":"deriveVaultRoot-DH0kEyaS.cjs","sources":["../src/tbv/core/vault-secrets/context.ts","../src/tbv/core/vault-secrets/deriveVaultRoot.ts"],"sourcesContent":["/**\n * Canonical `vaultContext` byte encoding per\n * `derive-vault-secrets.md` §2.3.\n *\n * ```\n * vaultContext :=\n * I2OSP(32, 4) || depositorBtcPubkey // 32B x-only\n * || I2OSP(32, 4) || fundingOutpointsCommitment // 32B SHA-256\n * ```\n *\n * `fundingOutpointsCommitment` is SHA-256 over the canonically-sorted\n * funding outpoints of the Pre-PegIn transaction, serialized as\n * `txid (32B display/RPC order) || vout (4B u32 big-endian)` per\n * outpoint. Sorting by 36-byte lex order makes the commitment\n * invariant under tx-level input reordering, so same-inputs RBF and\n * reorg rebroadcasts yield the same context.\n *\n * @module vault-secrets/context\n */\n\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n\nconst DEPOSITOR_PUBKEY_SIZE = 32;\nconst TXID_SIZE = 32;\nconst OUTPOINT_SIZE = 36;\nconst COMMITMENT_SIZE = 32;\nconst FIELD_LEN_PREFIX_SIZE = 4;\nconst VAULT_CONTEXT_SIZE =\n FIELD_LEN_PREFIX_SIZE +\n DEPOSITOR_PUBKEY_SIZE +\n FIELD_LEN_PREFIX_SIZE +\n COMMITMENT_SIZE;\n\nexport interface FundingOutpoint {\n /**\n * Bitcoin txid in **display / RPC order** (byte-reversed from the\n * internal little-endian wire form used when hashing a raw tx).\n */\n txid: Uint8Array;\n /** Output index within the referenced transaction (u32). */\n vout: number;\n}\n\nexport interface VaultContextInput {\n /** Depositor's x-only BTC public key (32 bytes). */\n depositorBtcPubkey: Uint8Array;\n /** Funding outpoints of the Pre-PegIn transaction. MUST be non-empty. */\n fundingOutpoints: readonly FundingOutpoint[];\n}\n\nfunction writeUint32BE(out: Uint8Array, offset: number, value: number): void {\n out[offset] = (value >>> 24) & 0xff;\n out[offset + 1] = (value >>> 16) & 0xff;\n out[offset + 2] = (value >>> 8) & 0xff;\n out[offset + 3] = value & 0xff;\n}\n\nfunction serializeOutpoint(outpoint: FundingOutpoint): Uint8Array {\n if (outpoint.txid.length !== TXID_SIZE) {\n throw new Error(\n `outpoint.txid must be exactly ${TXID_SIZE} bytes, got ${outpoint.txid.length}`,\n );\n }\n if (\n !Number.isInteger(outpoint.vout) ||\n outpoint.vout < 0 ||\n outpoint.vout > 0xffffffff\n ) {\n throw new Error(`outpoint.vout must be a u32, got ${outpoint.vout}`);\n }\n const out = new Uint8Array(OUTPOINT_SIZE);\n out.set(outpoint.txid, 0);\n writeUint32BE(out, TXID_SIZE, outpoint.vout);\n return out;\n}\n\nfunction compareBytes(a: Uint8Array, b: Uint8Array): number {\n const len = Math.min(a.length, b.length);\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) return a[i] - b[i];\n }\n return a.length - b.length;\n}\n\n/**\n * Compute SHA-256 over canonically-sorted funding outpoints.\n *\n * Outpoints are serialized as 36-byte `txid || vout_BE`, sorted\n * ascending lexicographically, concatenated, then hashed.\n *\n * @stability frozen — on-chain-binding. Any change to layout, sort\n * order, or serialization is a hard fork; existing deposits would no\n * longer match their committed `depositorWotsPkHash`.\n *\n * @throws If `outpoints` is empty or contains duplicates.\n */\nexport function buildFundingOutpointsCommitment(\n outpoints: readonly FundingOutpoint[],\n): Uint8Array {\n if (outpoints.length === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: outpoints must be non-empty\",\n );\n }\n const serialized = outpoints.map(serializeOutpoint);\n serialized.sort(compareBytes);\n\n for (let i = 1; i < serialized.length; i++) {\n if (compareBytes(serialized[i - 1], serialized[i]) === 0) {\n throw new Error(\n \"buildFundingOutpointsCommitment: duplicate outpoint detected\",\n );\n }\n }\n\n const flat = new Uint8Array(serialized.length * OUTPOINT_SIZE);\n for (let i = 0; i < serialized.length; i++) {\n flat.set(serialized[i], i * OUTPOINT_SIZE);\n }\n return sha256(flat);\n}\n\n/**\n * Build the canonical `vaultContext` byte string fed into the wallet's\n * `deriveContextHash` (or a locally-implemented equivalent on the\n * app side).\n *\n * Output length is always 72 bytes.\n *\n * @stability frozen — on-chain-binding. The 72-byte layout is the\n * input to `deriveContextHash`; any change rotates the vault root and\n * therefore every WOTS key, hashlock secret, and auth anchor derived\n * from it. Existing deposits cannot be recovered after a layout change.\n */\nexport function buildVaultContext(input: VaultContextInput): Uint8Array {\n if (input.depositorBtcPubkey.length !== DEPOSITOR_PUBKEY_SIZE) {\n throw new Error(\n `vaultContext: depositorBtcPubkey must be exactly ${DEPOSITOR_PUBKEY_SIZE} bytes, got ${input.depositorBtcPubkey.length}`,\n );\n }\n const commitment = buildFundingOutpointsCommitment(input.fundingOutpoints);\n\n const out = new Uint8Array(VAULT_CONTEXT_SIZE);\n let offset = 0;\n\n writeUint32BE(out, offset, DEPOSITOR_PUBKEY_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(input.depositorBtcPubkey, offset);\n offset += DEPOSITOR_PUBKEY_SIZE;\n\n writeUint32BE(out, offset, COMMITMENT_SIZE);\n offset += FIELD_LEN_PREFIX_SIZE;\n out.set(commitment, offset);\n\n return out;\n}\n","/**\n * Vault-root derivation via the wallet's `deriveContextHash` API.\n *\n * Implements the canonical root source from `derive-vault-secrets.md`\n * §2.2:\n *\n * ```\n * rootDerivation = deriveContextHash(\"babylon-btc-vault\", hex(vaultContext))\n * ```\n *\n * The 32-byte output is fed directly into the {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, and {@link expandWotsSeed} functions in\n * this module.\n *\n * @module vault-secrets/deriveVaultRoot\n */\n\nimport { hexToUint8Array, uint8ArrayToHex } from \"../primitives/utils/bitcoin\";\n\nimport { buildVaultContext, type VaultContextInput } from \"./context\";\n\n/**\n * The fixed `appName` passed to the wallet's `deriveContextHash` for\n * Babylon vault derivations. The wallet displays this in its approval\n * dialog. Defined by `derive-vault-secrets.md` §2.2 — must not be\n * changed without coordinating a spec revision and a downstream\n * migration plan, as it provides app-level domain separation across\n * applications using the same wallet.\n */\nexport const VAULT_APP_NAME = \"babylon-btc-vault\";\n\n/** Expected length of the wallet output in bytes per spec §2.1. */\nconst ROOT_OUTPUT_BYTES = 32;\n\n/** Expected length of the wallet output in lowercase hex chars. */\nconst ROOT_OUTPUT_HEX_LEN = ROOT_OUTPUT_BYTES * 2;\n\nconst LOWERCASE_HEX_RE = /^[0-9a-f]+$/;\n\n/**\n * Minimal structural shape for the wallet capability needed by this\n * helper. Typed against the method directly so callers can pass any\n * value that implements `deriveContextHash` — `BitcoinWallet` from\n * this SDK, `IBTCProvider` from `@babylonlabs-io/wallet-connector`,\n * or a test mock — without depending on the rest of either interface.\n */\nexport interface DeriveContextHashCapableWallet {\n deriveContextHash(appName: string, context: string): Promise<string>;\n}\n\n/**\n * Derive the 32-byte vault root from a wallet by encoding the\n * canonical {@link VaultContextInput} and forwarding to\n * `wallet.deriveContextHash`.\n *\n * Validates the wallet's output strictly: must be exactly 64\n * lowercase hex characters per `derive-context-hash.md` §2.1. A\n * conformant wallet always satisfies this, but we re-check at the\n * SDK boundary so a non-conformant wallet (or a wallet returning a\n * malformed value through a buggy adapter) fails loud here rather\n * than producing silently-wrong derived secrets downstream.\n *\n * The helper itself produces only valid spec inputs (`appName` is\n * the hardcoded `VAULT_APP_NAME`; `context` is hex of the 72-byte\n * `vaultContext`, always 144 chars lowercase), so input-side\n * validation is unnecessary.\n *\n * @param wallet - Any value implementing `deriveContextHash`.\n * @param input - The canonical {@link VaultContextInput} that\n * uniquely identifies the vault. Encoded by\n * {@link buildVaultContext} into a 72-byte structure\n * before being hex-encoded for the wallet.\n * @stability frozen — on-chain-binding. The pair (`VAULT_APP_NAME`,\n * `vaultContext` encoding) is the wallet's input space; changing\n * either rotates the root and invalidates every secret derived from\n * it. `VAULT_APP_NAME` is fixed by `derive-vault-secrets.md` §2.2\n * and must never change without a coordinated spec revision.\n *\n * @returns 32-byte root suitable for {@link expandAuthAnchor},\n * {@link expandHashlockSecret}, {@link expandWotsSeed}.\n * @throws If the wallet returns a non-64-char or non-lowercase-hex\n * string. Errors from the wallet (user rejection,\n * method-not-supported, etc.) propagate unchanged.\n */\nexport async function deriveVaultRoot(\n wallet: DeriveContextHashCapableWallet,\n input: VaultContextInput,\n): Promise<Uint8Array> {\n const vaultContext = buildVaultContext(input);\n const contextHex = uint8ArrayToHex(vaultContext);\n\n const rootHex = await wallet.deriveContextHash(VAULT_APP_NAME, contextHex);\n\n if (typeof rootHex !== \"string\") {\n throw new Error(\n `deriveVaultRoot: wallet must return a string, got ${typeof rootHex}`,\n );\n }\n if (rootHex.length !== ROOT_OUTPUT_HEX_LEN) {\n throw new Error(\n `deriveVaultRoot: wallet must return a ${ROOT_OUTPUT_HEX_LEN}-character hex string (${ROOT_OUTPUT_BYTES} bytes), got length ${rootHex.length}`,\n );\n }\n if (!LOWERCASE_HEX_RE.test(rootHex)) {\n throw new Error(\n \"deriveVaultRoot: wallet must return lowercase hex per derive-context-hash.md §2.1; got value with non-lowercase or non-hex characters\",\n );\n }\n\n return hexToUint8Array(rootHex);\n}\n"],"names":["DEPOSITOR_PUBKEY_SIZE","TXID_SIZE","OUTPOINT_SIZE","COMMITMENT_SIZE","FIELD_LEN_PREFIX_SIZE","VAULT_CONTEXT_SIZE","writeUint32BE","out","offset","value","serializeOutpoint","outpoint","compareBytes","a","b","len","i","buildFundingOutpointsCommitment","outpoints","serialized","flat","sha256","buildVaultContext","input","commitment","VAULT_APP_NAME","ROOT_OUTPUT_BYTES","ROOT_OUTPUT_HEX_LEN","LOWERCASE_HEX_RE","deriveVaultRoot","wallet","vaultContext","contextHex","uint8ArrayToHex","rootHex","hexToUint8Array"],"mappings":"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"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./challengeAssert-Cu-PtJ1g.cjs"),_=require("./constants-BqU1Uz15.cjs"),n=require("@babylonlabs-io/babylon-tbv-rust-wasm"),u=require("./verifyScriptPathSchnorrSignature-C-84KJ6U.cjs"),g=require("./peginInput-CAiiDZeO.cjs"),S=require("./noPayout-Djrv31V5.cjs"),r=require("./bitcoin-CHfKAhcI.cjs"),l=require("./validation-CDbOaDj7.cjs"),m=require("./signing-Bnsro0hE.cjs"),c=require("./PeginManager-iDbqXsKD.cjs"),d=require("./signPsbtsWithFallback-C01N6Kdo.cjs"),R=require("./ProtocolParams.abi-C8U7BHCS.cjs"),O=require("./BTCVaultRegistry.abi-AUAyCHal.cjs"),b=require("./BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs"),P=require("./errors-CGcNP0rV.cjs"),T=require("./deriveVaultRoot-CebLadyJ.cjs"),y=require("./parseFundingOutpoints-C_-PT9BT.cjs"),C=require("./shared/index.cjs"),o=require("./waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs"),i=require("./fundPeginTransaction-BLD8FRL9.cjs"),p=require("./reservation-ClEs2X0H.cjs"),a=require("./mempoolApi-Dsm2VPXp.cjs"),t=require("./batchPoll-BXIy3R7h.cjs"),s=require("./json-rpc-client-BiAmg_ho.cjs"),V=require("./onChainBtcPubkey-Cd9kpz-S.cjs"),h=require("./errors-Bfjxg_iJ.cjs"),e=require("./buildAndBroadcastRefund-4uAl7OIk.cjs"),E=require("./peginState-CBBJw4Za.cjs");exports.buildChallengeAssertPsbt=A.buildChallengeAssertPsbt;exports.computeNumLocalChallengers=A.computeNumLocalChallengers;exports.assertValidVaultCoreVersion=_.assertValidVaultCoreVersion;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>n.computeMinClaimValue});Object.defineProperty(exports,"computeMinPeginFee",{enumerable:!0,get:()=>n.computeMinPeginFee});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>n.deriveVaultId});Object.defineProperty(exports,"expandAuthAnchor",{enumerable:!0,get:()=>n.expandAuthAnchor});Object.defineProperty(exports,"expandHashlockSecret",{enumerable:!0,get:()=>n.expandHashlockSecret});Object.defineProperty(exports,"expandWotsSeed",{enumerable:!0,get:()=>n.expandWotsSeed});Object.defineProperty(exports,"peginP2aAnchorOutput",{enumerable:!0,get:()=>n.peginP2aAnchorOutput});Object.defineProperty(exports,"supportedTxGraphVersions",{enumerable:!0,get:()=>n.supportedTxGraphVersions});Object.defineProperty(exports,"validatePeginP2aAnchor",{enumerable:!0,get:()=>n.validatePeginP2aAnchor});exports.PsbtSubstitutionError=u.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=u.assertPsbtUnsignedTxMatches;exports.assertScriptPathSchnorrSignature=u.assertScriptPathSchnorrSignature;exports.buildPayoutPsbt=u.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=u.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=u.buildPrePeginPsbt;exports.createPayoutScript=u.createPayoutScript;exports.extractPayoutSignature=u.extractPayoutSignature;exports.buildPeginInputPsbt=g.buildPeginInputPsbt;exports.extractPeginInputSignature=g.extractPeginInputSignature;exports.finalizePeginInputPsbt=g.finalizePeginInputPsbt;exports.buildNoPayoutPsbt=S.buildNoPayoutPsbt;exports.buildRefundPsbt=S.buildRefundPsbt;exports.deriveBip86ScriptPubKeyHex=r.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=r.deriveNativeSegwitAddress;exports.deriveTaprootAddress=r.deriveTaprootAddress;exports.ensureHexPrefix=r.ensureHexPrefix;exports.formatSatoshisToBtc=r.formatSatoshisToBtc;exports.getNetwork=r.getNetwork;exports.getSortedXOnlyPubkeys=r.getSortedXOnlyPubkeys;exports.hexToUint8Array=r.hexToUint8Array;exports.isAddressFromPublicKey=r.isAddressFromPublicKey;exports.isValidHex=r.isValidHex;exports.processPublicKeyToXOnly=r.processPublicKeyToXOnly;exports.stripHexPrefix=r.stripHexPrefix;exports.toXOnly=r.toXOnly;exports.uint8ArrayToHex=r.uint8ArrayToHex;exports.validateWalletPubkey=r.validateWalletPubkey;exports.BITCOIN_ADDRESS_RE=l.BITCOIN_ADDRESS_RE;exports.HEX_RE=l.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=l.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=l.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=l.TXID_RE;exports.combineAbortSignals=l.combineAbortSignals;exports.createTaprootScriptPathSignOptions=m.createTaprootScriptPathSignOptions;exports.PeginManager=c.PeginManager;exports.buildDepositTerms=c.buildDepositTerms;exports.computeWotsBlockPublicKeysHash=c.computeWotsBlockPublicKeysHash;exports.deriveWotsBlocksFromSeed=c.deriveWotsBlocksFromSeed;exports.estimateSubmitPeginRequestBatchGas=c.estimateSubmitPeginRequestBatchGas;exports.PayoutManager=d.PayoutManager;exports.computeHashlock=d.computeHashlock;exports.forwardDepositApproval=d.forwardDepositApproval;exports.supportsDepositApproval=d.supportsDepositApproval;exports.validateSecretAgainstHashlock=d.validateSecretAgainstHashlock;exports.ApplicationRegistryABI=R.ApplicationRegistryABI;exports.ProtocolParamsABI=R.ProtocolParamsABI;exports.BTCVaultRegistryABI=O.BTCVaultRegistryABI;exports.BTCVaultRegistryKeyEpochsABI=b.BTCVaultRegistryKeyEpochsABI;exports.CONTRACT_ERRORS=P.CONTRACT_ERRORS;exports.extractErrorData=P.extractErrorData;exports.getContractErrorMessage=P.getContractErrorMessage;exports.handleContractError=P.handleContractError;exports.isKnownContractError=P.isKnownContractError;exports.VAULT_APP_NAME=T.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=T.buildFundingOutpointsCommitment;exports.buildVaultContext=T.buildVaultContext;exports.deriveVaultRoot=T.deriveVaultRoot;exports.parseFundingOutpointsFromTx=y.parseFundingOutpointsFromTx;exports.BitcoinNetworks=C.BitcoinNetworks;exports.BitcoinScriptType=o.BitcoinScriptType;exports.applyChangeOutputPolicy=o.applyChangeOutputPolicy;exports.calculateBtcTxHash=o.calculateBtcTxHash;exports.computeChangeOutputFeeSats=o.computeChangeOutputFeeSats;exports.computeMaxDeposit=o.computeMaxDeposit;exports.computePeginBaseFeeSats=o.computePeginBaseFeeSats;exports.getDustThreshold=o.getDustThreshold;exports.getPsbtInputFields=o.getPsbtInputFields;exports.getScriptType=o.getScriptType;exports.selectUtxosForPegin=o.selectUtxosForPegin;exports.shouldAddChangeOutput=o.shouldAddChangeOutput;exports.waitForTransactionReceiptSmartAware=o.waitForTransactionReceiptSmartAware;exports.BTC_DUST_SAT=i.BTC_DUST_SAT;exports.DUST_THRESHOLD=i.DUST_THRESHOLD;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=i.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=i.MAX_NON_LEGACY_OUTPUT_SIZE;exports.MAX_REASONABLE_PEGIN_VBYTES=i.MAX_REASONABLE_PEGIN_VBYTES;exports.P2TR_INPUT_SIZE=i.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=i.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=i.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=i.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=i.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=i.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=i.fundPeginTransaction;exports.parseUnfundedWasmTransaction=i.parseUnfundedWasmTransaction;exports.peginOutputCount=i.peginOutputCount;exports.rateBasedTxBufferFee=i.rateBasedTxBufferFee;exports.UtxoNotAvailableError=p.UtxoNotAvailableError;exports.assertUtxosAvailable=p.assertUtxosAvailable;exports.extractInputsFromTransaction=p.extractInputsFromTransaction;exports.findOverlappingPendingVaults=p.findOverlappingPendingVaults;exports.validateUtxosAvailable=p.validateUtxosAvailable;exports.MEMPOOL_API_URLS=a.MEMPOOL_API_URLS;exports.ViemVaultRegistryReader=a.ViemVaultRegistryReader;exports.getAddressTxs=a.getAddressTxs;exports.getAddressUtxos=a.getAddressUtxos;exports.getMempoolApiUrl=a.getMempoolApiUrl;exports.getNetworkFees=a.getNetworkFees;exports.getOutspend=a.getOutspend;exports.getTipHeight=a.getTipHeight;exports.getTxHex=a.getTxHex;exports.getTxInfo=a.getTxInfo;exports.getUtxoInfo=a.getUtxoInfo;exports.pushTx=a.pushTx;exports.validateOffchainParams=a.validateOffchainParams;exports.validatePegInConfiguration=a.validatePegInConfiguration;exports.validateTBVProtocolParams=a.validateTBVProtocolParams;exports.OnChainBtcVaultStatus=t.OnChainBtcVaultStatus;exports.ServerIdentityError=t.ServerIdentityError;exports.VaultProviderRpcClient=t.VaultProviderRpcClient;exports.ViemOperationKeyReader=t.ViemOperationKeyReader;exports.ViemProtocolParamsReader=t.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=t.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=t.ViemVaultKeeperReader;exports.VpResponseValidationError=t.VpResponseValidationError;exports.VpTokenRegistry=t.VpTokenRegistry;exports.batchPollByProvider=t.batchPollByProvider;exports.createAuthenticatedVpClient=t.createAuthenticatedVpClient;exports.primeVpTokenRegistry=t.primeVpTokenRegistry;exports.resolveProtocolAddresses=t.resolveProtocolAddresses;exports.validateRequestDepositorClaimerArtifactsResponse=t.validateRequestDepositorClaimerArtifactsResponse;exports.verifyServerIdentity=t.verifyServerIdentity;exports.vpTokenRegistry=t.vpTokenRegistry;exports.AUTH_REJECTED_RPC_CODE=s.AUTH_REJECTED_RPC_CODE;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_BATCH_MAX_SIZE=s.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=s.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=s.VP_TRANSIENT_STATUSES;exports.isAuthRejectedError=s.isAuthRejectedError;exports.assertOnChainBtcPubkey=V.assertOnChainBtcPubkey;exports.isWotsMismatchError=h.isWotsMismatchError;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=e.ClaimerPegoutStatusValue;exports.ParticipantKeyDriftError=e.ParticipantKeyDriftError;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.activateVault=e.activateVault;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isParticipantKeyDriftError=e.isParticipantKeyDriftError;exports.isPegoutTerminalStatus=e.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=e.isRecognizedPegoutStatus;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.resolveCurrentParticipantKeys=e.resolveCurrentParticipantKeys;exports.resolveParticipantKeysAtEpochs=e.resolveParticipantKeysAtEpochs;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredParticipantKeys=e.verifyRegisteredParticipantKeys;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=E.ContractStatus;exports.PeginAction=E.PeginAction;exports.canPerformAction=E.canPerformAction;exports.getPeginProtocolState=E.getPeginProtocolState;exports.isActivationDeadlinePassedOnChain=E.isActivationDeadlinePassedOnChain;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./challengeAssert-CIHykYs3.cjs"),_=require("./constants-BqU1Uz15.cjs"),n=require("@babylonlabs-io/babylon-tbv-rust-wasm"),u=require("./verifyScriptPathSchnorrSignature-fhjfNoHK.cjs"),A=require("./peginInput-CAYuE_5F.cjs"),S=require("./noPayout-BkXzkhU1.cjs"),t=require("./bitcoin-Dpcfff7b.cjs"),l=require("./validation-CDbOaDj7.cjs"),m=require("./signing-Bnsro0hE.cjs"),c=require("./PeginManager-DOmyNYT-.cjs"),d=require("./signPsbtsWithFallback-r3bC-CfM.cjs"),R=require("./ProtocolParams.abi-C8U7BHCS.cjs"),y=require("./BTCVaultRegistry.abi-AUAyCHal.cjs"),b=require("./BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs"),P=require("./errors-CGcNP0rV.cjs"),T=require("./deriveVaultRoot-DH0kEyaS.cjs"),O=require("./parseFundingOutpoints-C_-PT9BT.cjs"),C=require("./shared/index.cjs"),o=require("./waitForTransactionReceiptSmartAware-AgZ-3WV_.cjs"),i=require("./fundPeginTransaction-BLD8FRL9.cjs"),p=require("./reservation-B_7tzSwY.cjs"),a=require("./mempoolApi-BtIABIAQ.cjs"),r=require("./batchPoll-D2OuUee1.cjs"),s=require("./json-rpc-client-BiAmg_ho.cjs"),V=require("./onChainBtcPubkey-DqYufM7j.cjs"),h=require("./errors-Bfjxg_iJ.cjs"),e=require("./buildAndBroadcastRefund-COinY4dk.cjs"),E=require("./peginState-CBBJw4Za.cjs");exports.buildChallengeAssertPsbt=g.buildChallengeAssertPsbt;exports.computeNumLocalChallengers=g.computeNumLocalChallengers;exports.assertValidVaultCoreVersion=_.assertValidVaultCoreVersion;Object.defineProperty(exports,"computeMinClaimValue",{enumerable:!0,get:()=>n.computeMinClaimValue});Object.defineProperty(exports,"computeMinPeginFee",{enumerable:!0,get:()=>n.computeMinPeginFee});Object.defineProperty(exports,"deriveVaultId",{enumerable:!0,get:()=>n.deriveVaultId});Object.defineProperty(exports,"expandAuthAnchor",{enumerable:!0,get:()=>n.expandAuthAnchor});Object.defineProperty(exports,"expandHashlockSecret",{enumerable:!0,get:()=>n.expandHashlockSecret});Object.defineProperty(exports,"expandWotsSeed",{enumerable:!0,get:()=>n.expandWotsSeed});Object.defineProperty(exports,"peginP2aAnchorOutput",{enumerable:!0,get:()=>n.peginP2aAnchorOutput});Object.defineProperty(exports,"supportedTxGraphVersions",{enumerable:!0,get:()=>n.supportedTxGraphVersions});Object.defineProperty(exports,"validatePeginP2aAnchor",{enumerable:!0,get:()=>n.validatePeginP2aAnchor});exports.PsbtSubstitutionError=u.PsbtSubstitutionError;exports.assertPsbtUnsignedTxMatches=u.assertPsbtUnsignedTxMatches;exports.assertScriptPathSchnorrSignature=u.assertScriptPathSchnorrSignature;exports.buildPayoutPsbt=u.buildPayoutPsbt;exports.buildPeginTxFromFundedPrePegin=u.buildPeginTxFromFundedPrePegin;exports.buildPrePeginPsbt=u.buildPrePeginPsbt;exports.createPayoutScript=u.createPayoutScript;exports.extractPayoutSignature=u.extractPayoutSignature;exports.buildPeginInputPsbt=A.buildPeginInputPsbt;exports.extractPeginInputSignature=A.extractPeginInputSignature;exports.finalizePeginInputPsbt=A.finalizePeginInputPsbt;exports.buildNoPayoutPsbt=S.buildNoPayoutPsbt;exports.buildRefundPsbt=S.buildRefundPsbt;exports.canonicalizeBtcPubkey=t.canonicalizeBtcPubkey;exports.deriveBip86ScriptPubKeyHex=t.deriveBip86ScriptPubKeyHex;exports.deriveNativeSegwitAddress=t.deriveNativeSegwitAddress;exports.deriveTaprootAddress=t.deriveTaprootAddress;exports.ensureHexPrefix=t.ensureHexPrefix;exports.formatSatoshisToBtc=t.formatSatoshisToBtc;exports.getNetwork=t.getNetwork;exports.getSortedXOnlyPubkeys=t.getSortedXOnlyPubkeys;exports.hexToUint8Array=t.hexToUint8Array;exports.isAddressFromPublicKey=t.isAddressFromPublicKey;exports.isValidHex=t.isValidHex;exports.processPublicKeyToXOnly=t.processPublicKeyToXOnly;exports.stripHexPrefix=t.stripHexPrefix;exports.toXOnly=t.toXOnly;exports.uint8ArrayToHex=t.uint8ArrayToHex;exports.validateWalletPubkey=t.validateWalletPubkey;exports.BITCOIN_ADDRESS_RE=l.BITCOIN_ADDRESS_RE;exports.HEX_RE=l.HEX_RE;exports.KNOWN_SCRIPT_PREFIXES=l.KNOWN_SCRIPT_PREFIXES;exports.MAX_REASONABLE_FEE_SATS=l.MAX_REASONABLE_FEE_SATS;exports.TXID_RE=l.TXID_RE;exports.combineAbortSignals=l.combineAbortSignals;exports.createTaprootScriptPathSignOptions=m.createTaprootScriptPathSignOptions;exports.PeginManager=c.PeginManager;exports.buildDepositTerms=c.buildDepositTerms;exports.computeWotsBlockPublicKeysHash=c.computeWotsBlockPublicKeysHash;exports.deriveWotsBlocksFromSeed=c.deriveWotsBlocksFromSeed;exports.estimateSubmitPeginRequestBatchGas=c.estimateSubmitPeginRequestBatchGas;exports.PayoutManager=d.PayoutManager;exports.computeHashlock=d.computeHashlock;exports.forwardDepositApproval=d.forwardDepositApproval;exports.supportsDepositApproval=d.supportsDepositApproval;exports.validateSecretAgainstHashlock=d.validateSecretAgainstHashlock;exports.ApplicationRegistryABI=R.ApplicationRegistryABI;exports.ProtocolParamsABI=R.ProtocolParamsABI;exports.BTCVaultRegistryABI=y.BTCVaultRegistryABI;exports.BTCVaultRegistryKeyEpochsABI=b.BTCVaultRegistryKeyEpochsABI;exports.CONTRACT_ERRORS=P.CONTRACT_ERRORS;exports.extractErrorData=P.extractErrorData;exports.getContractErrorMessage=P.getContractErrorMessage;exports.handleContractError=P.handleContractError;exports.isKnownContractError=P.isKnownContractError;exports.VAULT_APP_NAME=T.VAULT_APP_NAME;exports.buildFundingOutpointsCommitment=T.buildFundingOutpointsCommitment;exports.buildVaultContext=T.buildVaultContext;exports.deriveVaultRoot=T.deriveVaultRoot;exports.parseFundingOutpointsFromTx=O.parseFundingOutpointsFromTx;exports.BitcoinNetworks=C.BitcoinNetworks;exports.BitcoinScriptType=o.BitcoinScriptType;exports.applyChangeOutputPolicy=o.applyChangeOutputPolicy;exports.calculateBtcTxHash=o.calculateBtcTxHash;exports.computeChangeOutputFeeSats=o.computeChangeOutputFeeSats;exports.computeMaxDeposit=o.computeMaxDeposit;exports.computePeginBaseFeeSats=o.computePeginBaseFeeSats;exports.getDustThreshold=o.getDustThreshold;exports.getPsbtInputFields=o.getPsbtInputFields;exports.getScriptType=o.getScriptType;exports.selectUtxosForPegin=o.selectUtxosForPegin;exports.shouldAddChangeOutput=o.shouldAddChangeOutput;exports.waitForTransactionReceiptSmartAware=o.waitForTransactionReceiptSmartAware;exports.BTC_DUST_SAT=i.BTC_DUST_SAT;exports.DUST_THRESHOLD=i.DUST_THRESHOLD;exports.LOW_RATE_ESTIMATION_ACCURACY_BUFFER=i.LOW_RATE_ESTIMATION_ACCURACY_BUFFER;exports.MAX_NON_LEGACY_OUTPUT_SIZE=i.MAX_NON_LEGACY_OUTPUT_SIZE;exports.MAX_REASONABLE_PEGIN_VBYTES=i.MAX_REASONABLE_PEGIN_VBYTES;exports.P2TR_INPUT_SIZE=i.P2TR_INPUT_SIZE;exports.PEGIN_AUTH_ANCHOR_OUTPUTS=i.PEGIN_AUTH_ANCHOR_OUTPUTS;exports.PEGIN_FIXED_OUTPUTS=i.PEGIN_FIXED_OUTPUTS;exports.SPLIT_TX_FEE_SAFETY_MULTIPLIER=i.SPLIT_TX_FEE_SAFETY_MULTIPLIER;exports.TX_BUFFER_SIZE_OVERHEAD=i.TX_BUFFER_SIZE_OVERHEAD;exports.WALLET_RELAY_FEE_RATE_THRESHOLD=i.WALLET_RELAY_FEE_RATE_THRESHOLD;exports.fundPeginTransaction=i.fundPeginTransaction;exports.parseUnfundedWasmTransaction=i.parseUnfundedWasmTransaction;exports.peginOutputCount=i.peginOutputCount;exports.rateBasedTxBufferFee=i.rateBasedTxBufferFee;exports.UtxoNotAvailableError=p.UtxoNotAvailableError;exports.assertUtxosAvailable=p.assertUtxosAvailable;exports.extractInputsFromTransaction=p.extractInputsFromTransaction;exports.findOverlappingPendingVaults=p.findOverlappingPendingVaults;exports.validateUtxosAvailable=p.validateUtxosAvailable;exports.MEMPOOL_API_URLS=a.MEMPOOL_API_URLS;exports.ViemVaultRegistryReader=a.ViemVaultRegistryReader;exports.getAddressTxs=a.getAddressTxs;exports.getAddressUtxos=a.getAddressUtxos;exports.getMempoolApiUrl=a.getMempoolApiUrl;exports.getNetworkFees=a.getNetworkFees;exports.getOutspend=a.getOutspend;exports.getTipHeight=a.getTipHeight;exports.getTxHex=a.getTxHex;exports.getTxInfo=a.getTxInfo;exports.getUtxoInfo=a.getUtxoInfo;exports.pushTx=a.pushTx;exports.validateOffchainParams=a.validateOffchainParams;exports.validatePegInConfiguration=a.validatePegInConfiguration;exports.validateTBVProtocolParams=a.validateTBVProtocolParams;exports.OnChainBtcVaultStatus=r.OnChainBtcVaultStatus;exports.ServerIdentityError=r.ServerIdentityError;exports.VaultProviderRpcClient=r.VaultProviderRpcClient;exports.ViemOperationKeyReader=r.ViemOperationKeyReader;exports.ViemProtocolParamsReader=r.ViemProtocolParamsReader;exports.ViemUniversalChallengerReader=r.ViemUniversalChallengerReader;exports.ViemVaultKeeperReader=r.ViemVaultKeeperReader;exports.VpResponseValidationError=r.VpResponseValidationError;exports.VpTokenRegistry=r.VpTokenRegistry;exports.batchPollByProvider=r.batchPollByProvider;exports.createAuthenticatedVpClient=r.createAuthenticatedVpClient;exports.primeVpTokenRegistry=r.primeVpTokenRegistry;exports.resolveProtocolAddresses=r.resolveProtocolAddresses;exports.validateRequestDepositorClaimerArtifactsResponse=r.validateRequestDepositorClaimerArtifactsResponse;exports.verifyServerIdentity=r.verifyServerIdentity;exports.vpTokenRegistry=r.vpTokenRegistry;exports.AUTH_REJECTED_RPC_CODE=s.AUTH_REJECTED_RPC_CODE;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_BATCH_MAX_SIZE=s.VP_BATCH_MAX_SIZE;exports.VP_TERMINAL_FAILURE_STATUSES=s.VP_TERMINAL_FAILURE_STATUSES;exports.VP_TRANSIENT_STATUSES=s.VP_TRANSIENT_STATUSES;exports.isAuthRejectedError=s.isAuthRejectedError;exports.assertOnChainBtcPubkey=V.assertOnChainBtcPubkey;exports.isWotsMismatchError=h.isWotsMismatchError;exports.BIP68NotMatureError=e.BIP68NotMatureError;exports.ClaimerPegoutStatusValue=e.ClaimerPegoutStatusValue;exports.ParticipantKeyDriftError=e.ParticipantKeyDriftError;exports.REFUND_MAX_FEE_FRACTION_DENOMINATOR=e.REFUND_MAX_FEE_FRACTION_DENOMINATOR;exports.REFUND_MAX_FEE_FRACTION_NUMERATOR=e.REFUND_MAX_FEE_FRACTION_NUMERATOR;exports.REFUND_MAX_FEE_RATE_SATS_VB=e.REFUND_MAX_FEE_RATE_SATS_VB;exports.REFUND_VSIZE=e.REFUND_VSIZE;exports.RegisteredVaultVersionMismatchError=e.RegisteredVaultVersionMismatchError;exports.activateVault=e.activateVault;exports.assertVaultProviderHintAccepted=e.assertVaultProviderHintAccepted;exports.buildAndBroadcastRefund=e.buildAndBroadcastRefund;exports.estimateRefundFeeSats=e.estimateRefundFeeSats;exports.isDepositAmountValid=e.isDepositAmountValid;exports.isHintAccepted=e.isHintAccepted;exports.isParticipantKeyDriftError=e.isParticipantKeyDriftError;exports.isPegoutTerminalStatus=e.isPegoutTerminalStatus;exports.isRecognizedPegoutStatus=e.isRecognizedPegoutStatus;exports.isRegisteredVaultVersionMismatchError=e.isRegisteredVaultVersionMismatchError;exports.matchKeyHint=e.matchKeyHint;exports.matchKeySetHint=e.matchKeySetHint;exports.resolveCurrentParticipantKeys=e.resolveCurrentParticipantKeys;exports.resolveParticipantKeysAtEpochs=e.resolveParticipantKeysAtEpochs;exports.runDepositorPresignFlow=e.runDepositorPresignFlow;exports.signDepositorGraph=e.signDepositorGraph;exports.submitWotsPublicKey=e.submitWotsPublicKey;exports.validateDepositAmount=e.validateDepositAmount;exports.validateMultiVaultDepositInputs=e.validateMultiVaultDepositInputs;exports.validateOnChainParticipantKeys=e.validateOnChainParticipantKeys;exports.validateProviderSelection=e.validateProviderSelection;exports.validateRemainingCapacity=e.validateRemainingCapacity;exports.validateVaultAmounts=e.validateVaultAmounts;exports.validateVaultProviderPubkey=e.validateVaultProviderPubkey;exports.verifyRegisteredParticipantKeys=e.verifyRegisteredParticipantKeys;exports.verifyRegisteredVaultVersions=e.verifyRegisteredVaultVersions;exports.waitForPeginStatus=e.waitForPeginStatus;exports.ContractStatus=E.ContractStatus;exports.PeginAction=E.PeginAction;exports.canPerformAction=E.canPerformAction;exports.getPeginProtocolState=E.getPeginProtocolState;exports.isActivationDeadlinePassedOnChain=E.isActivationDeadlinePassedOnChain;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,216 +1,221 @@
1
- import { b as s, c as t } from "./challengeAssert-BVQq50su.js";
1
+ import { b as s, c as t } from "./challengeAssert-XeAql2fF.js";
2
2
  import { a as o } from "./constants-CDQE812z.js";
3
- import { computeMinClaimValue as n, computeMinPeginFee as p, deriveVaultId as u, expandAuthAnchor as l, expandHashlockSecret as d, expandWotsSeed as P, peginP2aAnchorOutput as c, supportedTxGraphVersions as E, validatePeginP2aAnchor as T } from "@babylonlabs-io/babylon-tbv-rust-wasm";
4
- import { P as S, d as g, f as R, c as m, b as _, a as f, g as x, e as b } from "./verifyScriptPathSchnorrSignature-Xoo9DOHW.js";
5
- import { b as O, e as V, f as v } from "./peginInput-BKD_b3gq.js";
6
- import { a as y, b as I } from "./noPayout-CI4l1qu2.js";
7
- import { d as U, a as B, b as N, e as D, f as M, j as H, g as L, h as k, i as K, c as X, p as w, s as W, t as G, u as j, v as J } from "./bitcoin-B5aNKtsk.js";
8
- import { B as Z, H as q, K as z, M as Q, T as $, c as aa } from "./validation-Dj3dqYtl.js";
9
- import { c as sa } from "./signing-DaLvGwQe.js";
10
- import { P as ra, b as oa, c as ia, d as na, e as pa } from "./PeginManager-CnX3uFb0.js";
11
- import { P as la, c as da, f as Pa, s as ca, v as Ea } from "./signPsbtsWithFallback-CzZFZf0I.js";
12
- import { A as Aa, P as Sa } from "./ProtocolParams.abi-CV938AYZ.js";
3
+ import { computeMinClaimValue as n, computeMinPeginFee as p, deriveVaultId as u, expandAuthAnchor as l, expandHashlockSecret as c, expandWotsSeed as d, peginP2aAnchorOutput as P, supportedTxGraphVersions as E, validatePeginP2aAnchor as A } from "@babylonlabs-io/babylon-tbv-rust-wasm";
4
+ import { P as S, d as g, f as m, c as R, b as _, a as f, g as x, e as b } from "./verifyScriptPathSchnorrSignature-wwa1JhiB.js";
5
+ import { b as h, e as v, f as C } from "./peginInput-DRUm164W.js";
6
+ import { a as y, b as I } from "./noPayout-DCf1xoJn.js";
7
+ import { c as B, d as U, a as D, b as N, e as M, f as H, k, g as K, h as L, i as X, j as w, p as W, s as G, t as j, u as J, v as Y } from "./bitcoin-CHzNE-rS.js";
8
+ import { B as z, H as q, K as Q, M as $, T as aa, c as ea } from "./validation-Dj3dqYtl.js";
9
+ import { c as ta } from "./signing-DaLvGwQe.js";
10
+ import { P as oa, b as ia, c as na, d as pa, e as ua } from "./PeginManager-DbMFLh-1.js";
11
+ import { P as ca, c as da, f as Pa, s as Ea, v as Aa } from "./signPsbtsWithFallback-DxG_APbS.js";
12
+ import { A as Sa, P as ga } from "./ProtocolParams.abi-CV938AYZ.js";
13
13
  import { B as Ra } from "./BTCVaultRegistry.abi-CixOlp3B.js";
14
- import { B as _a } from "./BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js";
15
- import { C as xa, e as ba, g as Ca, h as Oa, i as Va } from "./errors-Blc-JWnI.js";
16
- import { V as ha, b as ya, a as Ia, d as Fa } from "./deriveVaultRoot-B_gEOTD6.js";
17
- import { p as Ba } from "./parseFundingOutpoints-GSM-IaaK.js";
18
- import { BitcoinNetworks as Da } from "./shared/index.js";
19
- import { B as Ha, a as La, f as ka, c as Ka, b as Xa, d as wa, g as Wa, i as Ga, h as ja, s as Ja, e as Ya, w as Za } from "./waitForTransactionReceiptSmartAware-lobLm0q0.js";
20
- import { B as za, D as Qa, L as $a, M as ae, c as ee, P as se, b as te, a as re, S as oe, T as ie, W as ne, f as pe, d as ue, p as le, r as de } from "./fundPeginTransaction-B2wyjqp0.js";
21
- import { U as ce, a as Ee, e as Te, f as Ae, v as Se } from "./reservation-cHDRn4DA.js";
22
- import { M as Re, V as me, g as _e, a as fe, b as xe, c as be, d as Ce, e as Oe, f as Ve, h as ve, i as he, p as ye, v as Ie, j as Fe, k as Ue } from "./mempoolApi-C0olk43O.js";
23
- import { O as Ne, S as De, V as Me, g as He, h as Le, i as ke, j as Ke, a as Xe, d as we, b as We, f as Ge, p as je, r as Je, v as Ye, c as Ze, e as qe } from "./batchPoll-DTYXoTEc.js";
24
- import { A as Qe, D as $e, J as as, a as es, b as ss, d as ts, P as rs, R as os, e as is, c as ns, V as ps, i as us } from "./json-rpc-client-DuUARJvV.js";
25
- import { a as ds } from "./onChainBtcPubkey-aPY5ib3Q.js";
26
- import { i as cs } from "./errors-B-H0seUG.js";
27
- import { B as Ts, C as As, P as Ss, x as gs, y as Rs, z as ms, A as _s, R as fs, a as xs, t as bs, u as Cs, i as Os, j as Vs, q as vs, p as hs, l as ys, n as Is, o as Fs, r as Us, s as Bs, b as Ns, c as Ds, d as Ms, v as Hs, e as Ls, f as ks, g as Ks, h as Xs, k as ws, m as Ws, w as Gs } from "./buildAndBroadcastRefund-Bo3AlqCk.js";
28
- import { C as Js, P as Ys, c as Zs, g as qs, i as zs } from "./peginState-BB81JI6I.js";
14
+ import { B as fa } from "./BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js";
15
+ import { C as ba, e as Va, g as ha, h as va, i as Ca } from "./errors-Blc-JWnI.js";
16
+ import { V as ya, b as Ia, a as Fa, d as Ba } from "./deriveVaultRoot-B5G8y6HJ.js";
17
+ import { p as Da } from "./parseFundingOutpoints-GSM-IaaK.js";
18
+ import { BitcoinNetworks as Ma } from "./shared/index.js";
19
+ import { B as ka, a as Ka, f as La, c as Xa, b as wa, d as Wa, g as Ga, i as ja, h as Ja, s as Ya, e as Za, w as za } from "./waitForTransactionReceiptSmartAware-lobLm0q0.js";
20
+ import { B as Qa, D as $a, L as ae, M as ee, c as se, P as te, b as re, a as oe, S as ie, T as ne, W as pe, f as ue, d as le, p as ce, r as de } from "./fundPeginTransaction-B2wyjqp0.js";
21
+ import { U as Ee, a as Ae, e as Te, f as Se, v as ge } from "./reservation-4F9XCk0v.js";
22
+ import { M as Re, V as _e, g as fe, a as xe, b as be, c as Ve, d as he, e as ve, f as Ce, h as Oe, i as ye, p as Ie, v as Fe, j as Be, k as Ue } from "./mempoolApi-4T6J5oxg.js";
23
+ import { O as Ne, S as Me, V as He, g as ke, h as Ke, i as Le, j as Xe, a as we, d as We, b as Ge, f as je, p as Je, r as Ye, v as Ze, c as ze, e as qe } from "./batchPoll-X7D7OIcu.js";
24
+ import { A as $e, D as as, J as es, a as ss, b as ts, d as rs, P as os, R as is, e as ns, c as ps, V as us, i as ls } from "./json-rpc-client-DuUARJvV.js";
25
+ import { a as ds } from "./onChainBtcPubkey-mP95j21Z.js";
26
+ import { i as Es } from "./errors-B-H0seUG.js";
27
+ import { B as Ts, C as Ss, P as gs, D as ms, E as Rs, F as _s, G as fs, R as xs, a as bs, n as Vs, z as hs, A as vs, i as Cs, o as Os, j as ys, y as Is, x as Fs, l as Bs, p as Us, q as Ds, t as Ns, u as Ms, r as Hs, s as ks, b as Ks, c as Ls, d as Xs, v as ws, e as Ws, f as Gs, g as js, h as Js, k as Ys, m as Zs, w as zs } from "./buildAndBroadcastRefund-D_l93Gln.js";
28
+ import { C as Qs, P as $s, c as at, g as et, i as st } from "./peginState-BB81JI6I.js";
29
29
  export {
30
- Qe as AUTH_REJECTED_RPC_CODE,
31
- Aa as ApplicationRegistryABI,
30
+ $e as AUTH_REJECTED_RPC_CODE,
31
+ Sa as ApplicationRegistryABI,
32
32
  Ts as BIP68NotMatureError,
33
- Z as BITCOIN_ADDRESS_RE,
33
+ z as BITCOIN_ADDRESS_RE,
34
34
  Ra as BTCVaultRegistryABI,
35
- _a as BTCVaultRegistryKeyEpochsABI,
36
- za as BTC_DUST_SAT,
37
- Da as BitcoinNetworks,
38
- Ha as BitcoinScriptType,
39
- xa as CONTRACT_ERRORS,
40
- As as ClaimerPegoutStatusValue,
41
- Js as ContractStatus,
42
- Qa as DUST_THRESHOLD,
43
- $e as DaemonStatus,
35
+ fa as BTCVaultRegistryKeyEpochsABI,
36
+ Qa as BTC_DUST_SAT,
37
+ Ma as BitcoinNetworks,
38
+ ka as BitcoinScriptType,
39
+ ba as CONTRACT_ERRORS,
40
+ Ss as ClaimerPegoutStatusValue,
41
+ Qs as ContractStatus,
42
+ $a as DUST_THRESHOLD,
43
+ as as DaemonStatus,
44
44
  q as HEX_RE,
45
- as as JSON_RPC_ERROR_CODES,
46
- es as JsonRpcClient,
47
- ss as JsonRpcError,
48
- z as KNOWN_SCRIPT_PREFIXES,
49
- $a as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
50
- ae as MAX_NON_LEGACY_OUTPUT_SIZE,
51
- Q as MAX_REASONABLE_FEE_SATS,
52
- ee as MAX_REASONABLE_PEGIN_VBYTES,
45
+ es as JSON_RPC_ERROR_CODES,
46
+ ss as JsonRpcClient,
47
+ ts as JsonRpcError,
48
+ Q as KNOWN_SCRIPT_PREFIXES,
49
+ ae as LOW_RATE_ESTIMATION_ACCURACY_BUFFER,
50
+ ee as MAX_NON_LEGACY_OUTPUT_SIZE,
51
+ $ as MAX_REASONABLE_FEE_SATS,
52
+ se as MAX_REASONABLE_PEGIN_VBYTES,
53
53
  Re as MEMPOOL_API_URLS,
54
54
  Ne as OnChainBtcVaultStatus,
55
- se as P2TR_INPUT_SIZE,
56
- te as PEGIN_AUTH_ANCHOR_OUTPUTS,
57
- re as PEGIN_FIXED_OUTPUTS,
58
- ts as POST_WOTS_STATUSES,
59
- rs as PRE_DEPOSITOR_SIGNATURES_STATES,
60
- Ss as ParticipantKeyDriftError,
61
- la as PayoutManager,
62
- Ys as PeginAction,
63
- ra as PeginManager,
64
- Sa as ProtocolParamsABI,
55
+ te as P2TR_INPUT_SIZE,
56
+ re as PEGIN_AUTH_ANCHOR_OUTPUTS,
57
+ oe as PEGIN_FIXED_OUTPUTS,
58
+ rs as POST_WOTS_STATUSES,
59
+ os as PRE_DEPOSITOR_SIGNATURES_STATES,
60
+ gs as ParticipantKeyDriftError,
61
+ ca as PayoutManager,
62
+ $s as PeginAction,
63
+ oa as PeginManager,
64
+ ga as ProtocolParamsABI,
65
65
  S as PsbtSubstitutionError,
66
- gs as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
66
+ ms as REFUND_MAX_FEE_FRACTION_DENOMINATOR,
67
67
  Rs as REFUND_MAX_FEE_FRACTION_NUMERATOR,
68
- ms as REFUND_MAX_FEE_RATE_SATS_VB,
69
- _s as REFUND_VSIZE,
70
- fs as RegisteredVaultVersionMismatchError,
71
- os as RpcErrorCode,
72
- oe as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
73
- De as ServerIdentityError,
74
- $ as TXID_RE,
75
- ie as TX_BUFFER_SIZE_OVERHEAD,
76
- ce as UtxoNotAvailableError,
77
- ha as VAULT_APP_NAME,
78
- is as VP_BATCH_MAX_SIZE,
79
- ns as VP_TERMINAL_FAILURE_STATUSES,
80
- ps as VP_TRANSIENT_STATUSES,
81
- Me as VaultProviderRpcClient,
82
- He as ViemOperationKeyReader,
83
- Le as ViemProtocolParamsReader,
84
- ke as ViemUniversalChallengerReader,
85
- Ke as ViemVaultKeeperReader,
86
- me as ViemVaultRegistryReader,
87
- Xe as VpResponseValidationError,
88
- we as VpTokenRegistry,
89
- ne as WALLET_RELAY_FEE_RATE_THRESHOLD,
90
- xs as activateVault,
91
- La as applyChangeOutputPolicy,
68
+ _s as REFUND_MAX_FEE_RATE_SATS_VB,
69
+ fs as REFUND_VSIZE,
70
+ xs as RegisteredVaultVersionMismatchError,
71
+ is as RpcErrorCode,
72
+ ie as SPLIT_TX_FEE_SAFETY_MULTIPLIER,
73
+ Me as ServerIdentityError,
74
+ aa as TXID_RE,
75
+ ne as TX_BUFFER_SIZE_OVERHEAD,
76
+ Ee as UtxoNotAvailableError,
77
+ ya as VAULT_APP_NAME,
78
+ ns as VP_BATCH_MAX_SIZE,
79
+ ps as VP_TERMINAL_FAILURE_STATUSES,
80
+ us as VP_TRANSIENT_STATUSES,
81
+ He as VaultProviderRpcClient,
82
+ ke as ViemOperationKeyReader,
83
+ Ke as ViemProtocolParamsReader,
84
+ Le as ViemUniversalChallengerReader,
85
+ Xe as ViemVaultKeeperReader,
86
+ _e as ViemVaultRegistryReader,
87
+ we as VpResponseValidationError,
88
+ We as VpTokenRegistry,
89
+ pe as WALLET_RELAY_FEE_RATE_THRESHOLD,
90
+ bs as activateVault,
91
+ Ka as applyChangeOutputPolicy,
92
92
  ds as assertOnChainBtcPubkey,
93
93
  g as assertPsbtUnsignedTxMatches,
94
- R as assertScriptPathSchnorrSignature,
95
- Ee as assertUtxosAvailable,
94
+ m as assertScriptPathSchnorrSignature,
95
+ Ae as assertUtxosAvailable,
96
96
  o as assertValidVaultCoreVersion,
97
- We as batchPollByProvider,
98
- bs as buildAndBroadcastRefund,
97
+ Vs as assertVaultProviderHintAccepted,
98
+ Ge as batchPollByProvider,
99
+ hs as buildAndBroadcastRefund,
99
100
  s as buildChallengeAssertPsbt,
100
- oa as buildDepositTerms,
101
- ya as buildFundingOutpointsCommitment,
101
+ ia as buildDepositTerms,
102
+ Ia as buildFundingOutpointsCommitment,
102
103
  y as buildNoPayoutPsbt,
103
- m as buildPayoutPsbt,
104
- O as buildPeginInputPsbt,
104
+ R as buildPayoutPsbt,
105
+ h as buildPeginInputPsbt,
105
106
  _ as buildPeginTxFromFundedPrePegin,
106
107
  f as buildPrePeginPsbt,
107
108
  I as buildRefundPsbt,
108
- Ia as buildVaultContext,
109
- ka as calculateBtcTxHash,
110
- Zs as canPerformAction,
111
- aa as combineAbortSignals,
112
- Ka as computeChangeOutputFeeSats,
109
+ Fa as buildVaultContext,
110
+ La as calculateBtcTxHash,
111
+ at as canPerformAction,
112
+ B as canonicalizeBtcPubkey,
113
+ ea as combineAbortSignals,
114
+ Xa as computeChangeOutputFeeSats,
113
115
  da as computeHashlock,
114
- Xa as computeMaxDeposit,
116
+ wa as computeMaxDeposit,
115
117
  n as computeMinClaimValue,
116
118
  p as computeMinPeginFee,
117
119
  t as computeNumLocalChallengers,
118
- wa as computePeginBaseFeeSats,
119
- ia as computeWotsBlockPublicKeysHash,
120
- Ge as createAuthenticatedVpClient,
120
+ Wa as computePeginBaseFeeSats,
121
+ na as computeWotsBlockPublicKeysHash,
122
+ je as createAuthenticatedVpClient,
121
123
  x as createPayoutScript,
122
- sa as createTaprootScriptPathSignOptions,
124
+ ta as createTaprootScriptPathSignOptions,
123
125
  U as deriveBip86ScriptPubKeyHex,
124
- B as deriveNativeSegwitAddress,
126
+ D as deriveNativeSegwitAddress,
125
127
  N as deriveTaprootAddress,
126
128
  u as deriveVaultId,
127
- Fa as deriveVaultRoot,
128
- na as deriveWotsBlocksFromSeed,
129
- D as ensureHexPrefix,
130
- Cs as estimateRefundFeeSats,
131
- pa as estimateSubmitPeginRequestBatchGas,
129
+ Ba as deriveVaultRoot,
130
+ pa as deriveWotsBlocksFromSeed,
131
+ M as ensureHexPrefix,
132
+ vs as estimateRefundFeeSats,
133
+ ua as estimateSubmitPeginRequestBatchGas,
132
134
  l as expandAuthAnchor,
133
- d as expandHashlockSecret,
134
- P as expandWotsSeed,
135
- ba as extractErrorData,
135
+ c as expandHashlockSecret,
136
+ d as expandWotsSeed,
137
+ Va as extractErrorData,
136
138
  Te as extractInputsFromTransaction,
137
139
  b as extractPayoutSignature,
138
- V as extractPeginInputSignature,
139
- v as finalizePeginInputPsbt,
140
- Ae as findOverlappingPendingVaults,
141
- M as formatSatoshisToBtc,
140
+ v as extractPeginInputSignature,
141
+ C as finalizePeginInputPsbt,
142
+ Se as findOverlappingPendingVaults,
143
+ H as formatSatoshisToBtc,
142
144
  Pa as forwardDepositApproval,
143
- pe as fundPeginTransaction,
144
- _e as getAddressTxs,
145
- fe as getAddressUtxos,
146
- Ca as getContractErrorMessage,
147
- Wa as getDustThreshold,
148
- xe as getMempoolApiUrl,
149
- H as getNetwork,
150
- be as getNetworkFees,
151
- Ce as getOutspend,
152
- qs as getPeginProtocolState,
153
- Ga as getPsbtInputFields,
154
- ja as getScriptType,
155
- L as getSortedXOnlyPubkeys,
156
- Oe as getTipHeight,
157
- Ve as getTxHex,
158
- ve as getTxInfo,
159
- he as getUtxoInfo,
160
- Oa as handleContractError,
161
- k as hexToUint8Array,
162
- zs as isActivationDeadlinePassedOnChain,
163
- K as isAddressFromPublicKey,
164
- us as isAuthRejectedError,
165
- Os as isDepositAmountValid,
166
- Va as isKnownContractError,
167
- Vs as isParticipantKeyDriftError,
168
- vs as isPegoutTerminalStatus,
169
- hs as isRecognizedPegoutStatus,
170
- ys as isRegisteredVaultVersionMismatchError,
171
- X as isValidHex,
172
- cs as isWotsMismatchError,
173
- Ba as parseFundingOutpointsFromTx,
174
- ue as parseUnfundedWasmTransaction,
175
- le as peginOutputCount,
176
- c as peginP2aAnchorOutput,
177
- je as primeVpTokenRegistry,
178
- w as processPublicKeyToXOnly,
179
- ye as pushTx,
145
+ ue as fundPeginTransaction,
146
+ fe as getAddressTxs,
147
+ xe as getAddressUtxos,
148
+ ha as getContractErrorMessage,
149
+ Ga as getDustThreshold,
150
+ be as getMempoolApiUrl,
151
+ k as getNetwork,
152
+ Ve as getNetworkFees,
153
+ he as getOutspend,
154
+ et as getPeginProtocolState,
155
+ ja as getPsbtInputFields,
156
+ Ja as getScriptType,
157
+ K as getSortedXOnlyPubkeys,
158
+ ve as getTipHeight,
159
+ Ce as getTxHex,
160
+ Oe as getTxInfo,
161
+ ye as getUtxoInfo,
162
+ va as handleContractError,
163
+ L as hexToUint8Array,
164
+ st as isActivationDeadlinePassedOnChain,
165
+ X as isAddressFromPublicKey,
166
+ ls as isAuthRejectedError,
167
+ Cs as isDepositAmountValid,
168
+ Os as isHintAccepted,
169
+ Ca as isKnownContractError,
170
+ ys as isParticipantKeyDriftError,
171
+ Is as isPegoutTerminalStatus,
172
+ Fs as isRecognizedPegoutStatus,
173
+ Bs as isRegisteredVaultVersionMismatchError,
174
+ w as isValidHex,
175
+ Es as isWotsMismatchError,
176
+ Us as matchKeyHint,
177
+ Ds as matchKeySetHint,
178
+ Da as parseFundingOutpointsFromTx,
179
+ le as parseUnfundedWasmTransaction,
180
+ ce as peginOutputCount,
181
+ P as peginP2aAnchorOutput,
182
+ Je as primeVpTokenRegistry,
183
+ W as processPublicKeyToXOnly,
184
+ Ie as pushTx,
180
185
  de as rateBasedTxBufferFee,
181
- Is as resolveCurrentParticipantKeys,
182
- Fs as resolveParticipantKeysAtEpochs,
183
- Je as resolveProtocolAddresses,
184
- Us as runDepositorPresignFlow,
185
- Ja as selectUtxosForPegin,
186
- Ya as shouldAddChangeOutput,
187
- Bs as signDepositorGraph,
188
- W as stripHexPrefix,
189
- Ns as submitWotsPublicKey,
186
+ Ns as resolveCurrentParticipantKeys,
187
+ Ms as resolveParticipantKeysAtEpochs,
188
+ Ye as resolveProtocolAddresses,
189
+ Hs as runDepositorPresignFlow,
190
+ Ya as selectUtxosForPegin,
191
+ Za as shouldAddChangeOutput,
192
+ ks as signDepositorGraph,
193
+ G as stripHexPrefix,
194
+ Ks as submitWotsPublicKey,
190
195
  E as supportedTxGraphVersions,
191
- ca as supportsDepositApproval,
192
- G as toXOnly,
193
- j as uint8ArrayToHex,
194
- Ds as validateDepositAmount,
195
- Ms as validateMultiVaultDepositInputs,
196
- Ie as validateOffchainParams,
197
- Hs as validateOnChainParticipantKeys,
198
- Fe as validatePegInConfiguration,
199
- T as validatePeginP2aAnchor,
200
- Ls as validateProviderSelection,
201
- ks as validateRemainingCapacity,
202
- Ye as validateRequestDepositorClaimerArtifactsResponse,
203
- Ea as validateSecretAgainstHashlock,
196
+ Ea as supportsDepositApproval,
197
+ j as toXOnly,
198
+ J as uint8ArrayToHex,
199
+ Ls as validateDepositAmount,
200
+ Xs as validateMultiVaultDepositInputs,
201
+ Fe as validateOffchainParams,
202
+ ws as validateOnChainParticipantKeys,
203
+ Be as validatePegInConfiguration,
204
+ A as validatePeginP2aAnchor,
205
+ Ws as validateProviderSelection,
206
+ Gs as validateRemainingCapacity,
207
+ Ze as validateRequestDepositorClaimerArtifactsResponse,
208
+ Aa as validateSecretAgainstHashlock,
204
209
  Ue as validateTBVProtocolParams,
205
- Se as validateUtxosAvailable,
206
- Ks as validateVaultAmounts,
207
- Xs as validateVaultProviderPubkey,
208
- J as validateWalletPubkey,
209
- ws as verifyRegisteredParticipantKeys,
210
- Ws as verifyRegisteredVaultVersions,
211
- Ze as verifyServerIdentity,
210
+ ge as validateUtxosAvailable,
211
+ js as validateVaultAmounts,
212
+ Js as validateVaultProviderPubkey,
213
+ Y as validateWalletPubkey,
214
+ Ys as verifyRegisteredParticipantKeys,
215
+ Zs as verifyRegisteredVaultVersions,
216
+ ze as verifyServerIdentity,
212
217
  qe as vpTokenRegistry,
213
- Gs as waitForPeginStatus,
214
- Za as waitForTransactionReceiptSmartAware
218
+ zs as waitForPeginStatus,
219
+ za as waitForTransactionReceiptSmartAware
215
220
  };
216
221
  //# sourceMappingURL=index.js.map