{"version":3,"file":"index.cjs","sources":["../../src/shared/wallets/interfaces/BitcoinWallet.ts"],"sourcesContent":["/**\n * Bitcoin network types.\n * Using string literal union for maximum compatibility with wallet providers.\n */\nexport type BitcoinNetwork = \"mainnet\" | \"testnet\" | \"signet\";\n\n/**\n * Bitcoin network constants\n */\nexport const BitcoinNetworks = {\n  MAINNET: \"mainnet\",\n  TESTNET: \"testnet\",\n  SIGNET: \"signet\",\n} as const;\n\n/**\n * Options for signing a specific input in a PSBT.\n */\nexport interface SignInputOptions {\n  /** Input index to sign */\n  index: number;\n  /** Address for signing (optional) */\n  address?: string;\n  /** Public key for signing (optional, hex string) */\n  publicKey?: string;\n  /** Sighash types (optional) */\n  sighashTypes?: number[];\n  /**\n   * Whether the wallet should sign with the tweaked (key-path) signer.\n   * Set `false` for Taproot script-path spends, where signing uses the\n   * untweaked internal key. If omitted, the wallet's default behavior\n   * applies.\n   */\n  useTweakedSigner?: boolean;\n  /**\n   * @deprecated Use `useTweakedSigner` instead. `disableTweakSigner: true`\n   * is equivalent to `useTweakedSigner: false`; `useTweakedSigner` takes\n   * precedence when both are set.\n   *\n   * `useTweakedSigner` is the canonical field used by UniSat and newer OKX\n   * wallet versions. Migrating aligns our interface with the wallet-side\n   * convention and avoids the historical divergence in OKX's\n   * `disableTweakSigner` implementation.\n   */\n  disableTweakSigner?: boolean;\n}\n\n/**\n * SignPsbt options for advanced signing scenarios.\n */\nexport interface SignPsbtOptions {\n  /** Whether to automatically finalize the PSBT after signing */\n  autoFinalized?: boolean;\n  /**\n   * Specific inputs to sign.\n   * If not provided, wallet will attempt to sign all inputs it can.\n   * Use this to restrict signing to specific inputs (e.g., only depositor's input).\n   */\n  signInputs?: SignInputOptions[];\n  /** Contract information for the signing operation. */\n  contracts?: Array<{\n    /** Contract identifier. */\n    id: string;\n    /** Contract parameters. */\n    params: Record<string, string | number | string[] | number[]>;\n  }>;\n  /** Action metadata. */\n  action?: {\n    /** Action name for tracking. */\n    name: string;\n  };\n}\n\n/**\n * This interface is designed to be compatible with @babylonlabs-io/wallet-connector's IBTCProvider\n *\n * Supports Unisat, Ledger, OKX, OneKey, Keystone, and other Bitcoin wallets.\n */\nexport interface BitcoinWallet {\n  /**\n   * Returns the wallet's public key as a hex string.\n   *\n   * For Taproot addresses, this should return the x-only public key\n   * (32 bytes = 64 hex characters without 0x prefix).\n   *\n   * For compressed public keys (33 bytes = 66 hex characters),\n   * consumers should strip the first byte to get x-only format.\n   */\n  getPublicKeyHex(): Promise<string>;\n\n  /**\n   * Returns the wallet's Bitcoin address.\n   */\n  getAddress(): Promise<string>;\n\n  /**\n   * Signs a PSBT and returns the signed PSBT as hex.\n   *\n   * @param psbtHex - The PSBT to sign in hex format\n   * @param options - Optional signing parameters (e.g., autoFinalized, contracts)\n   * @throws {Error} If the PSBT is invalid or signing fails\n   */\n  signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;\n\n  /**\n   * Signs multiple PSBTs and returns the signed PSBTs as hex.\n   * This allows batch signing with a single wallet interaction.\n   *\n   * @param psbtsHexes - Array of PSBTs to sign in hex format\n   * @param options - Optional array of signing parameters for each PSBT\n   * @throws {Error} If any PSBT is invalid or signing fails\n   */\n  signPsbts(\n    psbtsHexes: string[],\n    options?: SignPsbtOptions[],\n  ): Promise<string[]>;\n\n  /**\n   * Signs a message for authentication or proof of ownership.\n   *\n   * @param message - The message to sign\n   * @param type - The signing method: \"ecdsa\" for standard signatures, \"bip322-simple\" for BIP-322\n   * @returns Base64-encoded signature\n   */\n  signMessage(\n    message: string,\n    type: \"bip322-simple\" | \"ecdsa\",\n  ): Promise<string>;\n\n  /**\n   * Returns the Bitcoin network the wallet is connected to.\n   *\n   * @returns BitcoinNetwork enum value (MAINNET, TESTNET, SIGNET)\n   */\n  getNetwork(): Promise<BitcoinNetwork>;\n\n  /**\n   * Derives a deterministic 32-byte value per\n   * `docs/specs/derive-context-hash.md` rev 1.0. Throws with code\n   * `WALLET_METHOD_NOT_SUPPORTED` if unimplemented.\n   *\n   * @returns 64-char lowercase hex (32 bytes).\n   */\n  deriveContextHash(appName: string, context: string): Promise<string>;\n}\n"],"names":["BitcoinNetworks"],"mappings":"gFASO,MAAMA,EAAkB,CAC7B,QAAS,UACT,QAAS,UACT,OAAQ,QACV"}