UNPKG

cashtab-connect

Version:

A developer-friendly API for integrating with the Cashtab browser extension

86 lines 3.02 kB
export interface CashtabMessage { text?: string; type?: string; addressRequest?: boolean; txInfo?: Record<string, string>; id?: string; txResponse?: { approved: boolean; txid?: string; reason?: string; }; } export interface AddressResponse { success: boolean; address?: string; reason?: string; } export interface TransactionResponse { success: boolean; txid?: string; reason?: string; } export declare class CashtabExtensionUnavailableError extends Error { constructor(message?: string); } export declare class CashtabAddressDeniedError extends Error { constructor(reason?: string); } export declare class CashtabTransactionDeniedError extends Error { constructor(reason?: string); } export declare class CashtabTimeoutError extends Error { constructor(); } export declare class CashtabConnect { private timeout; private messageListeners; constructor(timeout?: number); private setupMessageListener; private checkExtensionAvailability; private sendMessage; private sendTransactionMessage; private sendMessageNoResponse; requestAddress(): Promise<string>; /** * Create a transaction using a BIP21 URI directly * @param bip21Uri - The BIP21 URI (e.g., "ecash:address?amount=0.001&memo=Payment") * @returns Promise that resolves with transaction response */ createTransactionFromBip21(bip21Uri: string): Promise<TransactionResponse>; /** * Send XEC to an address using Cashtab (dev-friendly) * @param address - eCash address * @param amount - Amount in XEC (string or number) * @returns Promise that resolves with transaction response */ sendXec(address: string, amount: string | number): Promise<TransactionResponse>; /** * Send a token using Cashtab (dev-friendly) * @param address - eCash address * @param tokenId - Token ID * @param tokenDecimalizedQty - Decimalized token quantity (string or number) * @returns Promise that resolves with transaction response */ sendToken(address: string, tokenId: string, tokenDecimalizedQty: string | number): Promise<TransactionResponse>; /** * Send a raw BIP21 string using Cashtab * @param bip21 - BIP21 URI string * @returns Promise that resolves with transaction response */ sendBip21(bip21: string): Promise<TransactionResponse>; destroy(): void; /** * Wait for the extension to become available * In practice this takes less than 1s * @param timeout - Maximum time to wait in milliseconds (default: 3000) * @returns Promise that resolves when extension is available or rejects on timeout */ waitForExtension(timeout?: number): Promise<void>; /** * Check if the extension is currently available * @returns Promise that resolves to true if extension is available, false otherwise */ isExtensionAvailable(): Promise<boolean>; } //# sourceMappingURL=index.d.ts.map