import * as ws from 'ws'; import { FailoverProxy } from './failoverProxy'; type MessageEvent = ws.MessageEvent | { data: Blob; }; export declare enum ConnectionStrategy { ClosestFirst = "CLOSEST_FIRST", AsOrdered = "AS_ORDERED" } /** * Measures connection latency to a given WebSocket URL * @param {string} wsUrl WebSocket URL to test connection * @returns {Promise} Returns latency in milliseconds, or Infinity if connection times out or fails */ export declare function measureWebsocketLatency(wsUrl: string): Promise; /** * Sort nodes by latency * @param {string[]} urls Array of URLs to sort * @returns {Promise} Array of URLs sorted by latency */ export declare function sortNodesByLatency(urls: string[]): Promise; /** * Client to access an in-node Chronik instance. * Plain object, without any connections. */ export declare class ChronikClient { private _proxyInterface; /** * Create Chronik client instance with specified strategy * * @param {ConnectionStrategy} strategy Connection strategy * @param {string[]} urls Array of Chronik URLs * @returns {Promise} Client instance created with sorted URLs */ static useStrategy(strategy: ConnectionStrategy, urls: string[]): Promise; /** * Create a new client. This just creates an object, without any connections. * * @param {string[]} urls Array of valid urls. A valid url comes with schema and without a trailing slash. * e.g. `['https://chronik.e.cash', 'https://someotherchronikinstance.e.cash']` * The approach of accepting an array of urls as input is to ensure redundancy if the * first url encounters downtime. * @throws {error} throws error on invalid constructor inputs */ constructor(urls: string[]); proxyInterface(): FailoverProxy; /** * Broadcasts the `rawTx` on the network. * * If `skipTokenChecks` is false, it will be checked that the tx doesn't burn * any tokens before broadcasting. * * NB this method DOES NOT wait for finalization */ broadcastTx(rawTx: Uint8Array | string, skipTokenChecks?: boolean): Promise; /** * Broadcasts the `rawTxs` on the network, only if all of them are valid. * * If `skipTokenChecks` is false, it will be checked that the txs don't burn * any tokens before broadcasting. * * NB this method DOES NOT wait for finalization */ broadcastTxs(rawTxs: (Uint8Array | string)[], skipTokenChecks?: boolean): Promise; /** * Broadcasts the `rawTx` on the network. * * Wait for the tx to finalize by default. Allow user customization of finalizationTimeoutSecs. * * If `skipTokenChecks` is false, it will be checked that the tx doesn't burn * any tokens before broadcasting. */ broadcastAndFinalizeTx(rawTx: Uint8Array | string, finalizationTimeoutSecs?: number, skipTokenChecks?: boolean): Promise<{ txid: string; }>; /** * Broadcasts the `rawTxs` on the network, only if all of them are valid. * * Wait for the txs to finalize by default. Allow user customization of finalizationTimeoutSecs. * * If `skipTokenChecks` is false, it will be checked that the txs don't burn * any tokens before broadcasting. */ broadcastAndFinalizeTxs(rawTxs: (Uint8Array | string)[], finalizationTimeoutSecs?: number, skipTokenChecks?: boolean): Promise; /** * Private method to standardize method API calls for broadcasting txs for * both broadcastTx and broadcastAndFinalizeTx. */ private _broadcastTxRequest; /** * Private method to standardize method API calls for broadcasting txs for * both broadcastTxs and broadcastAndFinalizeTxs. */ private _broadcastTxsRequest; /** * Validate a tx by rawtx * This is a sort of preflight check before broadcasting a tx * Allows us to * - check before broadcast if a tx unintentionally burns tokens */ validateRawTx(rawTx: Uint8Array | string): Promise; /** * Fetch UTXOs for a batch of scripts. * Similar to utxos() but for multiple scripts in a single request. */ batchUtxos(scripts: ScriptRef[]): Promise; /** Fetch current info of the blockchain, such as tip hash and height. */ blockchainInfo(): Promise; /** Fetch info about the current running chronik server */ chronikInfo(): Promise; /** Fetch the block given hash or height. */ block(hashOrHeight: string | number): Promise; /** Fetch the tx history of a block given hash or height. */ blockTxs(hashOrHeight: string | number, page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetch unconfirmed transactions from the mempool. * * NB this endpoint is NOT paginated, even though it does return the TxHistoryPage shape */ unconfirmedTxs(): Promise; /** * Fetch block info of a range of blocks. * `startHeight` and `endHeight` are inclusive ranges. */ blocks(startHeight: number, endHeight: number): Promise; /** Fetch token info and stats given the tokenId. */ token(tokenId: string): Promise; /** Fetch tx details given the txid. */ tx(txid: string): Promise; /** Fetch tx details given the txid. */ rawTx(txid: string): Promise; /** Create object that allows fetching info about a given token */ tokenId(tokenId: string): TokenIdEndpoint; /** Create object that allows fetching info about a given lokadId */ lokadId(lokadId: string): LokadIdEndpoint; /** Create object that allows fetching info about a given plugin */ plugin(pluginName: string): PluginEndpoint; /** Create object that allows fetching script history or UTXOs. */ script(scriptType: ScriptType, scriptPayload: string): ScriptEndpoint; /** Create object that allows fetching script history or UTXOs by p2pkh or p2sh address */ address(address: string): ScriptEndpoint; /** Open a WebSocket connection to listen for updates. */ ws(config: WsConfig): WsEndpoint; } /** Allows fetching script history and UTXOs. */ export declare class ScriptEndpoint { private _proxyInterface; private _scriptType; private _scriptPayload; constructor(proxyInterface: FailoverProxy, scriptType: string, scriptPayload: string); /** * Fetches the tx history of this script, in anti-chronological order. * This means it's ordered by first-seen first, i.e. TxHistoryPage.txs[0] * will be the most recent tx. If the tx hasn't been seen * by the indexer before, it's ordered by the block timestamp. * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ history(page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the confirmed tx history of this script, in the order they appear on the blockchain. * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ confirmedTxs(page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the unconfirmed tx history of this script, in chronological order. * * NB this endpoint is NOT paginated, even though it does return the TxHistoryPage shape */ unconfirmedTxs(): Promise; /** * Fetches the current UTXO set for this script. * It is grouped by output script, in case a script type can match multiple * different output scripts (e.g. Taproot on Lotus). */ utxos(): Promise; } /** Allows fetching tokenId confirmedTxs, unconfirmedTxs, history, and UTXOs. */ export declare class TokenIdEndpoint { private _proxyInterface; private _tokenId; constructor(proxyInterface: FailoverProxy, tokenId: string); /** * Fetches the tx history of this tokenId, in anti-chronological order. * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ history(page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the confirmed tx history of this tokenId, in the order they appear on the blockchain. * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ confirmedTxs(page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the unconfirmed tx history of this tokenId, in chronological order. * * NB this endpoint is NOT paginated, even though it does return the TxHistoryPage shape */ unconfirmedTxs(): Promise; /** * Fetches the current UTXO set for this tokenId. */ utxos(): Promise; } /** Allows fetching lokadId confirmedTxs, unconfirmedTxs, and history. */ export declare class LokadIdEndpoint { private _proxyInterface; private _lokadId; constructor(proxyInterface: FailoverProxy, lokadId: string); /** * Fetches the tx history of this tokenId, in anti-chronological order. * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ history(page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the confirmed tx history of this tokenId, in the order they appear on the blockchain. * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ confirmedTxs(page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the unconfirmed tx history of this tokenId, in chronological order. * * NB this endpoint is NOT paginated, even though it does return the TxHistoryPage shape */ unconfirmedTxs(): Promise; } /** Allows fetching plugin UTXOs. */ export declare class PluginEndpoint { private _proxyInterface; private _pluginName; constructor(proxyInterface: FailoverProxy, pluginName: string); /** * Fetches the current UTXO set for this plugin group. */ utxos(groupHex: string): Promise; /** * Fetches groups of this plugin. */ groups(prefixHex?: string, startHex?: string, pageSize?: number): Promise; /** * Fetches the tx history of this groupHex for this plugin, in anti-chronological order. * @param groupHex group as a lowercase hex string * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ history(groupHex: string, page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the confirmed tx history of this groupHex for this plugin, in the order they appear on the blockchain. * @param groupHex group as a lowercase hex string * @param page Page index of the tx history. * @param pageSize Number of txs per page. */ confirmedTxs(groupHex: string, page?: number, // Get the first page if unspecified pageSize?: number): Promise; /** * Fetches the unconfirmed tx history of this groupHex for this plugin, in chronological order. * @param groupHex group as a lowercase hex string * * NB this endpoint is NOT paginated, even though it does return the TxHistoryPage shape */ unconfirmedTxs(groupHex: string): Promise; } /** Config for a WebSocket connection to Chronik. */ export interface WsConfig { /** Fired when a message is sent from the WebSocket. */ onMessage?: (msg: WsMsgClient) => void; /** Fired when a connection has been (re)established. */ onConnect?: (e: ws.Event) => void; /** * Fired after a connection has been unexpectedly closed, and before a * reconnection attempt is made. Only fired if `autoReconnect` is true. */ onReconnect?: (e: ws.Event) => void; /** Fired when an error with the WebSocket occurs. */ onError?: (e: ws.ErrorEvent) => void; /** * Fired after a connection has been manually closed, or if `autoReconnect` * is false, if the WebSocket disconnects for any reason. */ onEnd?: (e: ws.Event) => void; /** Whether to automatically reconnect on disconnect, default true. */ autoReconnect?: boolean; } /** WebSocket connection to Chronik. */ export declare class WsEndpoint { private _proxyInterface; /** Fired when a message is sent from the WebSocket. */ onMessage?: (msg: WsMsgClient) => void; /** Fired when a connection has been (re)established. */ onConnect?: (e: ws.Event) => void; /** * Fired after a connection has been unexpectedly closed, and before a * reconnection attempt is made. Only fired if `autoReconnect` is true. */ onReconnect?: (e: ws.Event) => void; /** Fired when an error with the WebSocket occurs. */ onError?: (e: ws.ErrorEvent) => void; /** * Fired after a connection has been manually closed, or if `autoReconnect` * is false, if the WebSocket disconnects for any reason. */ onEnd?: (e: ws.Event) => void; /** Whether to automatically reconnect on disconnect, default true. */ autoReconnect: boolean; ws: ws.WebSocket | undefined; connected: Promise | undefined; manuallyClosed: boolean; subs: WsSubscriptions; constructor(proxyInterface: FailoverProxy, config: WsConfig); /** Wait for the WebSocket to be connected. */ waitForOpen(): Promise; /** * Subscribe to block messages */ subscribeToBlocks(): void; /** * Unsubscribe from block messages */ unsubscribeFromBlocks(): void; /** * Subscribe to all tx messages */ subscribeToTxs(): void; /** * Unsubscribe from all tx messages */ unsubscribeFromTxs(): void; /** * Subscribe to the given script type and payload. * For "p2pkh", `scriptPayload` is the 20 byte public key hash. */ subscribeToScript(type: ScriptType, payload: string): void; /** Unsubscribe from the given script type and payload. */ unsubscribeFromScript(type: ScriptType, payload: string): void; /** * Subscribe to an address * Method can be used for p2pkh or p2sh addresses */ subscribeToAddress(address: string): void; /** Unsubscribe from the given address */ unsubscribeFromAddress(address: string): void; /** Subscribe to a lokadId */ subscribeToLokadId(lokadId: string): void; /** Unsubscribe from the given lokadId */ unsubscribeFromLokadId(lokadId: string): void; /** Subscribe to a tokenId */ subscribeToTokenId(tokenId: string): void; /** Unsubscribe from the given tokenId */ unsubscribeFromTokenId(tokenId: string): void; /** Subscribe to a plugin */ subscribeToPlugin(pluginName: string, group: string): void; /** Unsubscribe from the given plugin */ unsubscribeFromPlugin(pluginName: string, group: string): void; /** Subscribe to a txid */ subscribeToTxid(txid: string): void; /** Unsubscribe from the given txid */ unsubscribeFromTxid(txid: string): void; /** * Close the WebSocket connection and prevent any future reconnection * attempts. */ close(): void; /** * Pause the WebSocket connection by disabling auto-reconnect and closing * the connection. Useful when the app is backgrounded to save resources. * * Because we cannot predict the behavior of mobile operating systems handling * websocket connections, it is better for the app developer to manually handle. * * We provide standard methods to accomplish this. */ pause(): void; /** * Resume the WebSocket connection by re-enabling auto-reconnect and * reconnecting if the connection is closed. Useful when the app comes * to foreground. */ resume(): Promise; private _subUnsubBlocks; private _subUnsubTxs; private _subUnsubScript; private _subUnsubLokadId; private _subUnsubToken; private _subUnsubTxid; private _subUnsubPlugin; handleMsg(wsMsg: MessageEvent): Promise; } /** Info about connected chronik server */ export interface ChronikInfo { version: string; } /** BlockInfo interface for in-node chronik */ export interface BlockInfo { /** Block hash of the block, in 'human-readable' (big-endian) hex encoding. */ hash: string; /** Block hash of the prev block, in 'human-readable' (big-endian) hex encoding. */ prevHash: string; /** Height of the block; Genesis block has height 0. */ height: number; /** nBits field of the block, encodes the target compactly. */ nBits: number; /** * Timestamp of the block. Filled in by the miner, * so might not be 100 % precise. */ timestamp: number; /** Is this block avalanche finalized? */ isFinal: boolean; /** Block size of this block in bytes (including headers etc.). */ blockSize: number; /** Number of txs in this block. */ numTxs: number; /** Total number of tx inputs in block (including coinbase). */ numInputs: number; /** Total number of tx output in block (including coinbase). */ numOutputs: number; /** Total number of satoshis spent by tx inputs. */ sumInputSats: bigint; /** Total block reward for this block. */ sumCoinbaseOutputSats: bigint; /** Total number of satoshis in non-coinbase tx outputs. */ sumNormalOutputSats: bigint; /** Total number of satoshis burned using OP_RETURN. */ sumBurnedSats: bigint; } /** Block interface for in-node chronik */ export interface Block { /** Contains the blockInfo object defined above */ blockInfo: BlockInfo; } /** A page of in-node chronik tx history */ export interface TxHistoryPage { /** Txs of the page */ txs: Tx[]; /** How many pages there are total */ numPages: number; /** How many txs there are total */ numTxs: number; } /** The hex bytes of a raw tx */ export interface RawTx { rawTx: string; } /** Current state of the blockchain. */ export interface BlockchainInfo { /** Block hash of the current blockchain tip */ tipHash: string; /** Current height of the blockchain */ tipHeight: number; } /** * Outpoint referencing an output on the blockchain (or input for field * `spentBy`). */ export interface OutPoint { /** Transaction referenced by this outpoint. */ txid: string; /** * Index of the output in the tx referenced by this outpoint * (or input index if used in field `spentBy`). */ outIdx: number; } /** A transaction on the blockchain or in the mempool. */ export interface Tx { /** Transaction ID. */ txid: string; /** `version` field of the transaction. */ version: number; /** Inputs of this transaction. */ inputs: TxInput[]; /** Outputs of this transaction. */ outputs: TxOutput[]; /** `locktime` field of the transaction, tx is not valid before this time. */ lockTime: number; /** Block data for this tx, if it is in a block. */ block?: BlockMetadata; /** * UNIX timestamp when this tx has first been seen in the mempool. * 0 if unknown -> make sure to check. */ timeFirstSeen: number; /** Serialized size of the tx. */ size: number; /** Whether this tx is a coinbase tx. */ isCoinbase: boolean; /** Tokens involved in this txs */ tokenEntries: TokenEntry[]; /** Failed parsing attempts of this tx */ tokenFailedParsings: TokenFailedParsing[]; /** * Token status, i.e. whether this tx has any tokens or unintentional token burns * or something unexpected, like failed parsings etc. */ tokenStatus: TokenStatus; /** Whether or not the tx is finalized */ isFinal: boolean; } /** Input of a tx, spends an output of a previous tx. */ export interface TxInput { /** Points to an output spent by this input. */ prevOut: OutPoint; /** * Script unlocking the output, in hex encoding. * Aka. `scriptSig` in bitcoind parlance. */ inputScript: string; /** * Script of the output, in hex encoding. * Aka. `scriptPubKey` in bitcoind parlance. * Not present for coinbase txs */ outputScript?: string; /** Value of the output spent by this input, in satoshis. */ sats: bigint; /** `sequence` field of the input; can be used for relative time locking. */ sequenceNo: number; /** Token value attached to this input */ token?: Token; /** Plugin data attached to this input */ plugins?: PluginEntries; } /** Output of a tx, creates new UTXOs. */ export interface TxOutput { /** Value of the output, in satoshis. */ sats: bigint; /** * Script of this output, locking the coins. * Aka. `scriptPubKey` in bitcoind parlance. */ outputScript: string; /** * Transaction & input index spending this output, if * spent. */ spentBy?: OutPoint; /** Token value attached to this output */ token?: Token; /** Plugin data attached to this output */ plugins?: PluginEntries; } /** Metadata of a block, used in transaction data. */ export interface BlockMetadata { /** Height of the block. */ height: number; /** Hash of the block. */ hash: string; /** * Timestamp of the block; useful if `timeFirstSeen` of a transaction is * unknown. */ timestamp: number; } /** Token involved in a transaction */ export interface TokenEntry { /** * Hex token_id (in big-endian, like usually displayed to users) of the token. * This is not `bytes` because SLP and ALP use different endiannes, so to avoid * this we use hex, which conventionally implies big-endian in a bitcoin context. */ tokenId: string; /** Token type of the token */ tokenType: TokenType; /** Tx type of the token; NONE if there's no section that introduced it (e.g. in an accidental burn) */ txType: TokenTxType; /** * For NFT1 Child tokens: group ID * Unset if the token is not an NFT1 Child token */ groupTokenId?: string; /** Whether the validation rules have been violated for this section */ isInvalid: boolean; /** Human-readable error message of why this entry burned tokens */ burnSummary: string; /** Human-readable error messages of why colorings failed */ failedColorings: TokenFailedColoring[]; /** Number of actually burned tokens (in atoms, aka base tokens). */ actualBurnAtoms: bigint; /** Burn amount the user explicitly opted into (in atoms, aka base tokens) */ intentionalBurnAtoms: bigint; /** Whether any mint batons have been burned of this token */ burnsMintBatons: boolean; } /** * SLP/ALP token type */ export type TokenType = SlpTokenType | AlpTokenType | UnknownTokenType; export interface SlpTokenType { protocol: 'SLP'; type: SlpTokenType_Type; number: number; } export interface AlpTokenType { protocol: 'ALP'; type: AlpTokenType_Type; number: number; } export interface UnknownTokenType { protocol: 'UNKNOWN'; type: 'UNKNOWN'; number: 0; } /** Possible ALP token types returned by chronik */ export type AlpTokenType_Type = 'ALP_TOKEN_TYPE_STANDARD' | 'ALP_TOKEN_TYPE_UNKNOWN'; export declare const ALP_TOKEN_TYPES: AlpTokenType_Type[]; /** Possible SLP token types returned by chronik */ export type SlpTokenType_Type = 'SLP_TOKEN_TYPE_FUNGIBLE' | 'SLP_TOKEN_TYPE_MINT_VAULT' | 'SLP_TOKEN_TYPE_NFT1_GROUP' | 'SLP_TOKEN_TYPE_NFT1_CHILD' | 'SLP_TOKEN_TYPE_UNKNOWN'; /** * TokenStatus * TOKEN_STATUS_NON_TOKEN - Tx involves no tokens whatsover, i.e. neither any burns nor any failed * parsing/coloring or any tokens being created / moved. * TOKEN_STATUS_NORMAL - Tx involves tokens but no unintentional burns or failed parsings/colorings * TOKEN_STATUS_NOT_NORMAL - Tx involves tokens but contains unintentional burns or failed parsings/colorings * TOKEN_STATUS_UNKNOWN - Token tx of unknown status */ export type TokenStatus = 'TOKEN_STATUS_NON_TOKEN' | 'TOKEN_STATUS_NORMAL' | 'TOKEN_STATUS_NOT_NORMAL' | 'TOKEN_STATUS_UNKNOWN'; /** SLP/ALP tx type */ export type TokenTxType = /** NONE - No tx type, e.g. when input tokens are burned */ 'NONE' /** UNKNOWN - Unknown tx type, i.e. for unknown token types */ | 'UNKNOWN' /** GENESIS - GENESIS tx */ | 'GENESIS' /** SEND - SEND tx */ | 'SEND' /** MINT - MINT tx */ | 'MINT' /** BURN - BURN tx */ | 'BURN'; /** * A report of a failed coloring attempt of SLP/ALP. * This should always indicate something went wrong when building the tx. */ export interface TokenFailedColoring { /** For ALP, the index of the pushdata in the OP_RETURN that failed parsing. */ pushdataIdx: number; /** Human-readable message of what went wrong */ error: string; } /** * TokenFailedParsing * A report of a failed parsing attempt of SLP/ALP. * This should always indicate something went wrong when building the tx. */ export interface TokenFailedParsing { /** * For ALP, the index of the pushdata in the OP_RETURN that failed parsing. * -1 if the whole OP_RETURN failed, e.g. for SLP or eMPP */ pushdataIdx: number; /** The bytes that failed parsing, useful for debugging */ bytes: string; /** Human-readable message of what went wrong */ error: string; } /** Data attached by a plugin to an output */ export interface PluginEntry { /** Groups assigned to this output */ groups: string[]; /** Data assigned to the output */ data: string[]; } export type PluginEntries = { [key: string]: PluginEntry; }; /** Group of UTXOs by output script. */ export interface ScriptUtxos { /** Output script in hex. */ outputScript: string; /** UTXOs of the output script. */ utxos: ScriptUtxo[]; } /** * Script identity for HTTP script endpoints: `scriptType` plus hex `payload`. */ export interface ScriptRef { /** Script type to query ("p2pkh", "p2sh", "p2pk", "other"). */ scriptType: ScriptType; /** * Payload for the given script type: * - 20-byte hash for "p2pkh" and "p2sh" * - 33-byte or 65-byte pubkey for "p2pk" * - Serialized script for "other" */ payload: string; } /** * One successful row from {@link ChronikClient.batchUtxos}, aligned with the * request. */ export interface BatchUtxosRow { /** Echoed script from the batch request. */ script: ScriptRef; utxos: ScriptUtxos; } /** An unspent transaction output (aka. UTXO, aka. "Coin") of a script. */ export interface ScriptUtxo { /** Outpoint of the UTXO. */ outpoint: OutPoint; /** Which block this UTXO is in, or -1 if in the mempool. */ blockHeight: number; /** Whether this UTXO is a coinbase UTXO * (make sure it's buried 100 blocks before spending!) */ isCoinbase: boolean; /** Value of the UTXO in satoshis. */ sats: bigint; /** Is this utxo avalanche finalized */ isFinal: boolean; /** Token value attached to this utxo */ token?: Token; /** Plugin data attached to this output */ plugins?: PluginEntries; } /** * An unspent transaction output (aka. UTXO, aka. "Coin") with script attached * Useful when getting utxos by something other than script, e.g. tokenId */ export interface Utxo { /** Outpoint of the UTXO. */ outpoint: OutPoint; /** Which block this UTXO is in, or -1 if in the mempool. */ blockHeight: number; /** Whether this UTXO is a coinbase UTXO * (make sure it's buried 100 blocks before spending!) */ isCoinbase: boolean; /** Value of the UTXO in satoshis. */ sats: bigint; /** Bytecode of the script of the output */ script: string; /** Is this utxo avalanche finalized */ isFinal: boolean; /** Token value attached to this utxo */ token?: Token; /** Plugin data attached to this output */ plugins?: PluginEntries; } /** Token coloring an input or output */ export interface Token { /** Hex token_id of the token, see `TokenInfo` for details */ tokenId: string; /** Token type of the token */ tokenType: TokenType; /** * Index into `token_entries` for `Tx` * chronik returns -1 for UTXOs, chronik-client * passes no entryIdx key for UTXOS */ entryIdx?: number; /** Amount in atoms (aka base tokens) of the input/output */ atoms: bigint; /** Whether the token is a mint baton */ isMintBaton: boolean; } /** * Script type queried in the `script` method. * - `other`: Script type not covered by the standard script types; payload is * the raw hex. * - `p2pk`: Pay-to-Public-Key (` OP_CHECKSIG`), payload is the hex of the * pubkey (compressed (33 bytes) or uncompressed (65 bytes)). * - `p2pkh`: Pay-to-Public-Key-Hash * (`OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG`). * Payload is the 20 byte public key hash. * - `p2sh`: Pay-to-Script-Hash (`OP_HASH160 OP_EQUAL`). * Payload is the 20 byte script hash. */ export type ScriptType = 'other' | 'p2pk' | 'p2pkh' | 'p2sh'; /** Message returned from the WebSocket, translated to be more human-readable for client */ export type WsMsgClient = Error | MsgBlockClient | MsgTxClient; /** Block got connected, disconnected, finalized, etc.*/ export interface MsgBlockClient { type: 'Block'; /** What happened to the block */ msgType: BlockMsgType; /** Hash of the block (human-readable big-endian) */ blockHash: string; /** Height of the block */ blockHeight: number; /** Timestamp of the block */ blockTimestamp: number; /** Coinbase data of the block */ coinbaseData?: CoinbaseData; } /** Block message types that can come from chronik */ export type BlockMsgType = 'BLK_CONNECTED' | 'BLK_DISCONNECTED' | 'BLK_FINALIZED' | 'BLK_INVALIDATED' | 'UNRECOGNIZED'; export interface CoinbaseData { /** The scriptsig of the coinbase */ scriptsig: string; /** The outputs of the coinbase */ outputs: TxOutput[]; } /** Tx got added to/removed from mempool, or confirmed in a block, etc.*/ export interface MsgTxClient { type: 'Tx'; /** What happened to the tx */ msgType: TxMsgType; /** Txid of the tx (human-readable big-endian) */ txid: string; /** If the tx is finalized, why it was finalized */ finalizationReasonType?: TxFinalizationReasonType; } /** Tx message types that can come from chronik */ export type TxMsgType = 'TX_ADDED_TO_MEMPOOL' | 'TX_REMOVED_FROM_MEMPOOL' | 'TX_CONFIRMED' | 'TX_FINALIZED' | 'TX_INVALIDATED' | 'UNRECOGNIZED'; /** Reasons a tx can be finalized by Avalanche */ export type TxFinalizationReasonType = 'TX_FINALIZATION_REASON_POST_CONSENSUS' | 'TX_FINALIZATION_REASON_PRE_CONSENSUS' | 'UNRECOGNIZED'; export interface WsSubScriptClient { /** Script type to subscribe to ("p2pkh", "p2sh", "p2pk", "other"). */ scriptType: ScriptType; /** * Payload for the given script type: * - 20-byte hash for "p2pkh" and "p2sh" * - 33-byte or 65-byte pubkey for "p2pk" * - Serialized script for "other" */ payload: string; } export interface WsSubPluginClient { /** pluginName as lower-case hex string */ pluginName: string; /** group as lower-case hex string */ group: string; } export interface Error { type: 'Error'; msg: string; } /** List of UTXOs */ export interface TokenIdUtxos { /** TokenId used to fetch these utxos */ tokenId: string; /** UTXOs */ utxos: Utxo[]; } /** List of UTXOs */ export interface PluginUtxos { /** Plugin used to fetch these utxos */ pluginName: string; /** Group hex */ groupHex: string; /** UTXOs */ utxos: Utxo[]; } /** * Information about a given plugin group * For now, we just include the group */ export interface PluginGroup { group: string; } /** List of plugin groups */ export interface PluginGroups { groups: PluginGroup[]; nextStart: string; } /** Info about a token */ export interface TokenInfo { /** * Hex token_id (in big-endian, like usually displayed to users) of the token. * This is not `bytes` because SLP and ALP use different endiannnes, * so to avoid this we use hex, which conventionally implies big-endian in a bitcoin context. */ tokenId: string; /** Token type of the token */ tokenType: TokenType; /** Info found in the token's GENESIS tx */ genesisInfo: GenesisInfo; /** Block of the GENESIS tx, if it's mined already */ block?: BlockMetadata; /** Time the GENESIS tx has first been seen by the indexer */ timeFirstSeen: number; } /** Genesis info found in GENESIS txs of tokens */ export interface GenesisInfo { /** token_ticker of the token */ tokenTicker: string; /** token_name of the token */ tokenName: string; /** URL of the token */ url: string; /** token_document_hash of the token (only on SLP) */ hash?: string; /** mint_vault_scripthash (only on SLP V2 Mint Vault) */ mintVaultScripthash?: string; /** Arbitray payload data of the token (only on ALP) */ data?: string; /** auth_pubkey of the token (only on ALP) */ authPubkey?: string; /** decimals of the token, i.e. how many decimal places the token should be displayed with. */ decimals: number; } interface WsSubscriptions { /** Subscriptions to scripts */ scripts: WsSubScriptClient[]; /** Subscriptions to tokens by tokenId */ tokens: string[]; /** Subscriptions to lokadIds */ lokadIds: string[]; /** Subscriptions to txids */ txids: string[]; /** Subscriptions to plugins */ plugins: WsSubPluginClient[]; /** Subscription to blocks */ blocks: boolean; /** Subscription to all txs */ txs: boolean; } interface BroadcastTxResponse { txid: string; } interface BroadcastTxsResponse { txids: string[]; } export {}; //# sourceMappingURL=ChronikClient.d.ts.map