import type { SignerConfig, SignerVaultInfo } from '../types/signers'; /** * Bitcoin address types */ export type BitcoinAddressType = 'p2pkh' | 'p2wpkh' | 'p2tr' | 'p2sh'; /** * Bitcoin network type */ export type BitcoinNetwork = 'mainnet' | 'testnet'; /** * Input signing instruction for PSBTs * Compatible with UniSat wallet-api's UserToSignInput format */ export interface BitcoinToSignInput { /** Input index in the PSBT */ index: number; /** Bitcoin address associated with this input */ address?: string; /** Public key (hex) for this input */ publicKey?: string; /** Sighash types for signing */ sighashTypes?: number[]; /** Tap leaf hash to sign (hex) for Taproot script path spending */ tapLeafHashToSign?: string; /** Use tweaked signer for Taproot */ useTweakedSigner?: boolean; /** Disable tweak signer for Taproot */ disableTweakSigner?: boolean; } /** * Bitcoin sign transaction options */ export interface BitcoinSignOptions { /** Transaction type determines signing algorithm (ECDSA for p2pkh/p2wpkh, Schnorr for p2tr) */ transactionType: 'p2pkh' | 'p2wpkh' | 'p2tr'; /** Per-input signing instructions for complex PSBTs */ toSignInputs?: BitcoinToSignInput[]; } /** * Response from signing a Bitcoin PSBT */ export interface BitcoinSignResult { success: boolean; /** Signed PSBT in base64 format */ signedPsbt: string; /** Final transaction hex (ready for broadcast) */ signedTxHex: string; /** Raw signature */ signature: string; } /** * Extended vault info including Bitcoin public key and derived addresses */ export interface BitcoinVaultInfo extends SignerVaultInfo { /** Bitcoin public key (compressed, hex) */ btcPubkey: string; /** Derived Bitcoin addresses */ btcAddresses?: { /** Legacy (1...) */ p2pkh: string; /** Native SegWit (bc1q...) */ p2wpkh: string; /** Taproot (bc1p...) */ p2tr: string; }; } /** * Bitcoin signer interface compatible with common Bitcoin libraries */ export interface BitcoinSignerInterface { /** Bitcoin public key (compressed, hex) */ publicKey: string; /** Derived Bitcoin addresses */ addresses: { p2pkh: string; p2wpkh: string; p2tr: string; }; /** Sign a PSBT */ signPsbt(psbtBase64: string, options: BitcoinSignOptions): Promise; /** Sign multiple PSBTs */ signAllPsbts(psbts: Array<{ psbt: string; options: BitcoinSignOptions; }>): Promise; /** Get the vault ID */ getVaultId(): string; /** Get public key as hex */ getPublicKey(): string; } /** * Constants for Bitcoin calculations */ export declare const SATS_PER_BTC = 100000000; /** * Emblem Bitcoin Signer implementation */ export declare class EmblemBitcoinSigner implements BitcoinSignerInterface { readonly publicKey: string; readonly addresses: { p2pkh: string; p2wpkh: string; p2tr: string; }; private readonly config; private readonly vaultId; constructor(config: SignerConfig, vaultInfo: BitcoinVaultInfo); /** * Sign a Bitcoin PSBT * @param psbtBase64 - PSBT in base64 format * @param options - Signing options including transaction type and per-input instructions */ signPsbt(psbtBase64: string, options: BitcoinSignOptions): Promise; /** * Sign multiple PSBTs * @param psbts - Array of PSBTs with their signing options */ signAllPsbts(psbts: Array<{ psbt: string; options: BitcoinSignOptions; }>): Promise; /** * Get the vault ID */ getVaultId(): string; /** * Get public key as hex */ getPublicKey(): string; /** * Check if a given address belongs to this signer */ ownsAddress(address: string): boolean; /** * Get the appropriate address for a given type */ getAddress(type?: BitcoinAddressType): string; /** * Normalize a value to hex string (handles string, Buffer, Uint8Array) */ private normalizeToHex; } /** * Create an Emblem Bitcoin signer from config * @param config - Signer configuration with authentication * @param infoOverride - Optional vault info to skip API call */ export declare function toBitcoinSigner(config: SignerConfig, infoOverride?: BitcoinVaultInfo): Promise; /** * Fetch vault info with Bitcoin-specific fields */ export declare function fetchBitcoinVaultInfo(config: SignerConfig): Promise; /** * Utility: Detect Bitcoin address type from address string */ export declare function detectAddressType(address: string): BitcoinAddressType | 'unknown'; /** * Utility: Convert satoshis to BTC */ export declare function satsToBTC(sats: number): number; /** * Utility: Convert BTC to satoshis */ export declare function btcToSats(btc: number): number; /** * Utility: Format satoshis for display */ export declare function formatSats(sats: number): string; /** * Utility: Estimate transaction size in vbytes */ export declare function estimateTransactionSize(inputCount: number, outputCount: number, inputType?: BitcoinAddressType): number; /** * Utility: Calculate estimated fee */ export declare function calculateFee(vsize: number, feeRate: number): number; /** * Utility: Check if amount is above dust threshold */ export declare function isDust(sats: number, addressType?: BitcoinAddressType): boolean; //# sourceMappingURL=bitcoin.d.ts.map