/** * Stacks (STX) Chain Adapter * * Builds Stacks SIP-005 token transfer transactions, attaches secp256k1 ECDSA * signatures from the FROST threshold signing network, and broadcasts via * Stacks node HTTP API. * * Uses @stacks/transactions if available, falls back to manual serialization * using native fetch and Node.js crypto (no external deps required). * * Stacks uses secp256k1 (same curve as Bitcoin/Ethereum). * * Optional: npm install @stacks/transactions */ import { ChainAdapter, StacksTransaction } from '../core/types'; export declare class StacksAdapter implements ChainAdapter { private rpcUrl; private network; private stacksLib; private useNativeLib; constructor(network?: 'mainnet' | 'testnet', rpcUrl?: string); getRpcUrl(): string; /** * Build an unsigned Stacks token transfer transaction (SIP-005). * * The returned hex string encodes a JSON payload containing: * - signingHash: SHA-512/256 digest of the transaction with auth cleared * - serializedTx: hex-encoded unsigned transaction bytes * - nonce, fee, and other metadata needed for signature attachment */ buildTransaction(tx: StacksTransaction, fromAddress: string): Promise; getSigningPayload(unsignedTx: string): string; /** * Attach a secp256k1 ECDSA signature to the Stacks transaction. * * Stacks requires a 65-byte recoverable signature in the auth spending condition: * [recovery_id (1 byte)] [r (32 bytes)] [s (32 bytes)] * * The FROST signature is expected as 65 bytes: r (32) + s (32) + v (1), * matching the EVM convention. We reorder to Stacks format. */ attachSignature(unsignedTx: string, signature: string): Promise; /** * Broadcast a signed Stacks transaction via /v2/transactions */ broadcast(signedTx: string): Promise; /** * Get STX balance in microSTX */ getBalance(address: string): Promise; private buildWithLib; private attachWithLib; private buildManual; private attachManual; /** * Serialize a standard single-sig authorization (P2PKH). * * Layout: * auth_type (1) + hash_mode (1) + signer_hash160 (20) + nonce (8) + fee (8) * + key_encoding (1) + signature (65, zeroed for unsigned) */ private serializeAuth; /** * Serialize token transfer payload. * * Layout: * payload_type (1) + recipient_principal + amount (8) + memo_length_type (1) + memo (34) */ private serializeTokenTransferPayload; /** * Serialize a Stacks principal address. * * Standard principal: type_id (1) + version (1) + hash160 (20) * Contract principal: type_id (1) + version (1) + hash160 (20) + name_length (1) + name */ private serializePrincipal; /** * Compute the sighash for a Stacks transaction. * * The sighash is SHA-512/256 of the serialized transaction with the * auth signature field cleared (set to zeros). This is the digest * that needs to be signed by the secp256k1 key. * * Per SIP-005, the initial sighash is computed over the transaction * with auth cleared, then wrapped: * sighash = SHA-512/256(sighash_presign + auth_type + fee + nonce + key_encoding) * * For simplicity, we compute the presign sighash (SHA-512/256 of the * unsigned serialized tx), which is what the auth spending condition signs. */ private computeSighash; /** * Embed a recoverable signature into the serialized transaction. * * The auth section layout (starting after version + chain_id = offset 5): * auth_type (1) + hash_mode (1) + signer_hash160 (20) + nonce (8) + fee (8) * + key_encoding (1) + signature (65) * * Signature starts at offset 5 + 1 + 1 + 20 + 8 + 8 + 1 = offset 44. * Stacks signature format: [recovery_id (1)] [r (32)] [s (32)] = 65 bytes. */ private embedSignatureInSerialized; /** * Parse a 65-byte signature from FROST (r[32] + s[32] + v[1]) * into Stacks format (recovery_id, r, s). */ private parseSignature; private fetchNonce; private estimateFee; } export declare function createStacksAdapter(rpcUrl?: string): StacksAdapter; export declare function createStacksTestnetAdapter(rpcUrl?: string): StacksAdapter; //# sourceMappingURL=stacks.d.ts.map