chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
74 lines (73 loc) • 3.08 kB
TypeScript
import type { UtxoNetwork } from '../../Explorer/UtxoExplorer';
import type { MarketsResponse } from '../../Client';
import type { TTLCache } from '../../utils/TTLCache';
import { NetworkDescriptor } from './NetworkDescriptor';
import type { NetworkInfoInternal, UtxoNetworkParams, UtxoAddressType } from './types';
import type { DetailedUtxoAddressType } from './types';
/** A {@link NetworkDescriptor} whose {@link id} is a UTXO network. */
export declare class UtxoNetworkDescriptor extends NetworkDescriptor<UtxoAddressType> {
readonly id: UtxoNetwork;
readonly networkParams: UtxoNetworkParams;
/** @internal */
constructor(id: UtxoNetwork, info: NetworkInfoInternal, marketsCache: TTLCache<MarketsResponse>, apiKey?: string);
/**
* Derives a UTXO address from a compressed public key.
*
* @param publicKey - Compressed (33-byte) secp256k1 public key.
* @param addressType - `'segwit'`, `'legacy'`, or `'taproot'`. Defaults to
* the network's {@link defaultAddressType}.
*/
publicKeyToAddress(publicKey: Uint8Array, addressType?: UtxoAddressType): string;
/**
* Signs a message using the Bitcoin message signing standard.
*
* @param message - The message to sign (string or raw bytes).
* @param privateKey - The 32-byte secp256k1 private key.
* @returns The signature as a base64 string (65 bytes).
*
* @example
* ```ts
* const key = await wallet.derive("m/84'/0'/0'/0/0");
* const sig = cg.networks.bitcoin.signMessage('Hello', key.privateKey.raw);
* ```
*/
signMessage(message: string | Uint8Array, privateKey: Uint8Array): string;
/**
* Verifies a Bitcoin-style signed message by recovering the public key and
* comparing the derived address against the expected address.
*
* @param message - The original message.
* @param signature - The base64-encoded signature (65 bytes).
* @param address - The expected signer address.
* @returns `true` if the signature is valid.
*
* @example
* ```ts
* const valid = cg.networks.bitcoin.verifyMessage('Hello', sig, 'bc1q...');
* ```
*/
verifyMessage(message: string, signature: string, address: string): boolean;
/**
* Checks whether a string is a valid address for this UTXO network.
*
* @param address - The address string to validate.
* @returns `true` if the address is valid for this network.
*/
isValidAddress(address: string): boolean;
/**
* Identifies the address type of a UTXO address by decoding it.
*
* @param address - The address to identify.
* @returns The detailed address type, or `'unknown'` if the format is not recognized.
*
* @example
* ```ts
* cg.networks.bitcoin.identifyAddressType('bc1q...');
* // → 'segwit-p2wpkh'
*
* cg.networks.bitcoin.identifyAddressType('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa');
* // → 'legacy-p2pkh'
* ```
*/
identifyAddressType(address: string): DetailedUtxoAddressType;
}