/** * Kaspa Chain Adapter * * Builds Kaspa UTXO transactions, computes per-input sighashes for * BIP-340 Schnorr signing via the FROST threshold signing network, * and broadcasts via the Kaspa REST API. * * Kaspa uses secp256k1 with BIP-340 Schnorr signatures (64 bytes), * the same signature scheme as Bitcoin Taproot. FROST-secp256k1 * produces native BIP-340 compatible Schnorr signatures. * * Key features: * - UTXO-based transaction model (similar to Bitcoin) * - BIP-340 Schnorr signatures (64 bytes, same as Taproot) * - ~1 second block time (BlockDAG architecture) * - Per-input sighash computation for multi-input transactions * * No external dependencies — uses raw HTTP API calls and Node.js crypto. * * @example * ```typescript * import { KaspaAdapter } from '@sequence0/sdk'; * * const kaspa = new KaspaAdapter('mainnet'); * * // Build a transfer transaction * const unsignedTx = await kaspa.buildTransaction( * { to: 'kaspa:qr...recipient', amount: 100000000 }, // 1 KAS * 'kaspa:qr...sender' * ); * * // ... sign each sighash via FROST Schnorr ... * const signedTx = await kaspa.attachSignature(unsignedTx, signatureHex); * const txId = await kaspa.broadcast(signedTx); * ``` */ import { ChainAdapter, KaspaTransaction } from '../core/types'; export declare class KaspaAdapter implements ChainAdapter { private network; private apiUrl; /** * Create a Kaspa adapter. * * @param network - Network to connect to: 'mainnet' or 'testnet' * @param apiUrl - Custom API URL (overrides the default for the network) */ constructor(network?: 'mainnet' | 'testnet', apiUrl?: string); getRpcUrl(): string; /** * Build an unsigned Kaspa transaction. * * Fetches UTXOs for the sender, selects inputs to cover the amount * plus fees, builds outputs (payment + change), and computes * per-input sighashes for Schnorr signing. * * Returns hex-encoded JSON containing the TX data and sighashes. * Each sighash must be independently signed via FROST Schnorr. * * @param tx - Transaction parameters (to, amount, feeRate) * @param fromAddress - Sender kaspa:... address * @returns Hex-encoded payload with sighashes and TX structure */ buildTransaction(tx: KaspaTransaction, fromAddress: string): Promise; /** * Extract the signing payload from the buildTransaction output. * * Returns the primary sighash (first input). For multi-input * transactions, callers should decode the full payload to get * all sighashes from the `sighashes` array. */ getSigningPayload(unsignedTx: string): string; /** * Attach BIP-340 Schnorr signature(s) to the Kaspa transaction. * * Each input requires its own 64-byte Schnorr signature. For * multi-input transactions, pass comma-separated signatures or * concatenated 64-byte signatures. * * @param unsignedTx - Hex-encoded unsigned transaction from buildTransaction * @param signature - 64-byte Schnorr signature(s) (hex-encoded) * @returns Hex-encoded signed transaction payload */ attachSignature(unsignedTx: string, signature: string): Promise; /** * Broadcast a signed Kaspa transaction. * * Constructs the RPC-compatible transaction object with inputs, * outputs, and witness signatures, then sends it to the Kaspa * REST API for propagation to the network. * * @param signedTx - Hex-encoded signed transaction from attachSignature * @returns Transaction ID */ broadcast(signedTx: string): Promise; /** * Get the KAS balance for an address. * * Returns balance in sompi (1 KAS = 1e8 sompi). * * @param address - Kaspa kaspa:... address * @returns Balance in sompi as a string */ getBalance(address: string): Promise; /** * Fetch UTXOs for a Kaspa address from the REST API. * * @param address - kaspa:... address * @returns Array of UTXOs */ private fetchUtxos; /** * Validate a Kaspa address format. * * @param address - Address to validate * @throws Error if the address is invalid */ private validateAddress; /** * Derive a kaspa:... address from a 32-byte x-only public key. * * FROST-secp256k1 produces a group verifying key (compressed point). * Extract the x-only (32-byte) key and encode as a Kaspa P2PK Schnorr address. * * @param pubkeyHex - 32-byte x-only public key (hex-encoded), or 33-byte compressed * @returns kaspa:... address */ deriveAddress(pubkeyHex: string): string; /** * Estimate the fee for a transaction. * * @param numInputs - Number of inputs * @param numOutputs - Number of outputs * @param feeRate - Fee rate in sompi per gram (default: 1) * @returns Estimated fee in sompi */ estimateFee(numInputs: number, numOutputs: number, feeRate?: number): number; } /** * Create a Kaspa mainnet adapter * * @param apiUrl - Optional custom API URL * @returns KaspaAdapter configured for mainnet */ export declare function createKaspaAdapter(apiUrl?: string): KaspaAdapter; /** * Create a Kaspa testnet adapter * * @param apiUrl - Optional custom API URL * @returns KaspaAdapter configured for testnet */ export declare function createKaspaTestnetAdapter(apiUrl?: string): KaspaAdapter; //# sourceMappingURL=kaspa.d.ts.map