config.json
Overview
The `config.json` file serves as a critical configuration descriptor for a Blockbook indexer service instance tailored to the Litecoin blockchain. It defines all the necessary parameters for the indexer to connect to the Litecoin daemon node (RPC), manage caching and concurrency, and enrich blockchain data with fiat currency exchange rates.
This JSON-formatted configuration enables the indexer to:
Connect to the Litecoin blockchain via RPC.
Configure mempool workers for concurrent transaction processing.
Specify address and extended public key formats to correctly interpret blockchain data.
Integrate with external fiat rate providers (e.g., CoinGecko) to map cryptocurrency values to various fiat currencies.
Define caching and parsing behaviors that impact performance and data accuracy.
This config file is typically located within the Litecoin coinstack indexer directory (e.g., `node/coinstacks/litecoin/indexer/config.json`) and is loaded at the startup of the Blockbook indexer service.
Detailed Explanation of Configuration Fields
Field | Type | Description | Example / Notes |
|---|---|---|---|
`fiat_rates` | string | Specifies the external provider used to fetch fiat currency exchange rates for the coin. Currently supports ["coingecko"](/projects/291/69194). | |
`fiat_rates_params` | string | A JSON string encoding parameters for the fiat rates provider API, including the base URL, coin identifier, and update interval in seconds. | "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"litecoin\", \"periodSeconds\": 900}" |
`fiat_rates_vs_currencies` | string | Comma-separated list of fiat and crypto currency codes against which the coin's price is fetched. | `"AED,ARS,AUD,...,USD,BTC,ETH"` |
`coin_name` | string | Full human-readable name of the cryptocurrency. | `"Litecoin"` |
`coin_shortcut` | string | Short ticker symbol representing the coin. | `"LTC"` |
`coin_label` | string | Label used in UI or logging to represent the coin; usually same as `coin_name`. | `"Litecoin"` |
`rpc_url` | string | The HTTP URL of the Litecoin daemon node's JSON-RPC endpoint used for blockchain queries. | `"http://localhost:8332"` |
`rpc_user` | string | Username for authenticating RPC requests to the daemon. | `"user"` |
`rpc_pass` | string | Password for authenticating RPC requests to the daemon. | `"password"` |
`rpc_timeout` | integer | Timeout in seconds for RPC requests to the daemon node, ensuring timely failure and retries. | `25` |
`parse` | boolean | Flag indicating if the indexer should parse transaction data or just index it raw (affects processing detail and performance). | `true` |
`message_queue_binding` | string | The TCP URL for binding to a message queue used for synchronizing blockchain data or distributing indexing workload. | `"tcp://localhost:28332"` |
`subversion` | string | Optional string to specify the subversion reported by the daemon node; may be left empty if not needed. | `""` |
`address_format` | string | Specifies the address format used in the blockchain (e.g., legacy, segwit). Empty if default or auto-detected. | `""` |
`xpub_magic` | integer | Magic number (prefix) used to identify extended public keys (xpub) for legacy addresses. | `27108450` |
`xpub_magic_segwit_p2sh` | integer | Magic number for extended public keys of segwit P2SH wrapped addresses. | `28471030` |
`xpub_magic_segwit_native` | integer | Magic number for extended public keys of native segwit addresses. | `78792518` |
`slip44` | integer | SLIP-0044 coin type index for Litecoin, used in hierarchical deterministic wallets. | `2` |
`mempool_workers` | integer | Number of parallel worker threads allocated to handle mempool transaction processing. | `8` |
`mempool_sub_workers` | integer | Number of sub-workers per mempool worker for further concurrency in transaction processing. | `2` |
`block_addresses_to_keep` | integer | Number of recent blocks' addresses to keep cached for efficient query and balance lookups. | `300` |
Usage Example
The `config.json` file is loaded by the Blockbook indexer service at startup. Example pseudo-code for loading and using this configuration:
const fs = require('fs');
function loadIndexerConfig(path) {
const rawConfig = fs.readFileSync(path, 'utf-8');
const config = JSON.parse(rawConfig);
config.fiat_rates_params = JSON.parse(config.fiat_rates_params); // parse nested JSON string
return config;
}
const indexerConfig = loadIndexerConfig('./config.json');
// Use indexerConfig.rpc_url, indexerConfig.rpc_user, etc. to initialize RPC client
// Use indexerConfig.fiat_rates to set up fiat rate fetcher with parameters
// Set up mempool workers and caching according to config
Important Implementation Details
Fiat Rates Integration:
Thefiat_rates_paramsfield is a JSON-encoded string containing parameters for the fiat rates provider API. This indirect encoding allows flexibility for different providers without changing the config schema. The indexer periodically polls the specified URL for the coin's fiat exchange rates, refreshing everyperiodSeconds(900 seconds = 15 minutes in this config).RPC Connection:
The indexer uses therpc_url,rpc_user, andrpc_passto establish an authenticated connection with the Litecoin daemon node. Therpc_timeoutguards against stalled requests.Extended Public Key Magic Bytes:
The threexpub_magic*fields contain network-specific prefixes used to correctly parse and derive extended public keys in different address formats (legacy, segwit P2SH, native segwit). These values are integral to wallet and address derivation logic.Mempool Worker Concurrency:
The indexer utilizesmempool_workersandmempool_sub_workersto parallelize mempool transaction processing, improving throughput and responsiveness when dealing with unconfirmed transactions.Caching Policy:
Theblock_addresses_to_keepvalue controls how many recent block addresses are cached. This impacts memory usage and performance of address balance queries.Parsing Flag:
Settingparsetotrueinstructs the indexer to parse transaction data deeply, enabling advanced features such as decoding scripts and extracting detailed metadata.
Interaction with Other System Components
Daemon Node (Litecoin Core):
The indexer connects to the Litecoin daemon node using the RPC credentials and URL defined here. It fetches blockchain data such as blocks and mempool transactions from this node.Message Queue:
Themessage_queue_bindingURL configures a ZeroMQ or similar message queue binding for asynchronous data ingestion or distribution of indexing workloads.Fiat Rate Provider:
Using the fiat rates configuration, the indexer integrates with external APIs like CoinGecko to enrich transaction data with real-time fiat currency values.API Server:
The indexer exposes indexed blockchain data to API servers that serve clients. The configuration ensures that the indexer correctly processes and formats data according to Litecoin's specifics.
Visual Diagram: Configuration Structure Overview
flowchart TD
A[config.json] --> B[RPC Connection Settings]
A --> C[Fiat Rates Settings]
A --> D[Mempool Processing Settings]
A --> E[Address & Key Formats]
A --> F[Caching & Parsing Settings]
B --> B1[rpc_url: string]
B --> B2[rpc_user: string]
B --> B3[rpc_pass: string]
B --> B4[rpc_timeout: int]
C --> C1[fiat_rates: string]
C --> C2[fiat_rates_params: JSON string]
C --> C3[fiat_rates_vs_currencies: string]
D --> D1[mempool_workers: int]
D --> D2[mempool_sub_workers: int]
D --> D3[message_queue_binding: string]
E --> E1[xpub_magic: int]
E --> E2[xpub_magic_segwit_p2sh: int]
E --> E3[xpub_magic_segwit_native: int]
E --> E4[address_format: string]
E --> E5[slip44: int]
F --> F1[parse: bool]
F --> F2[block_addresses_to_keep: int]
subgraph Coin Identification
G[coin_name: string]
H[coin_shortcut: string]
I[coin_label: string]
end
A --> G
A --> H
A --> I
Summary
The `config.json` file is a concise but comprehensive configuration descriptor for a Litecoin-specific Blockbook indexer service. It defines all parameters required for blockchain data indexing, mempool concurrency, fiat rate enrichment, and key/address parsing. By adjusting values within this file, operators can fine-tune the indexer's behavior to align with their deployment environment, Litecoin network specifics, and performance needs.
This configuration file is a vital piece bridging blockchain daemon nodes, external fiat APIs, and the higher-level API server layers, enabling a performant and adaptable blockchain indexing infrastructure within the Multi-Blockchain Coinstacks ecosystem.