Self-hosted explorer for the BLAKE2b chain of Bitcoin Knots.
This is a self-hosted explorer driven by RPC calls to your own Bitcoin Knots node. It is a fork of BTC RPC Explorer by Dan Janosik (MIT license), adapted to the chain that Knots follows since its BLAKE2b hard fork. It is easy to run and lacks some features compared to database-backed explorers.
Whatever reasons you may have for running a full node (trustlessness, technical curiosity, supporting the network, etc) it's valuable to appreciate the fullness of your own node. With this explorer you can explore the blockchain, and also the functional capabilities of your own node.
- Reads
difficulty_blake2bas well asdifficulty(Knots reports the former for BLAKE2b blocks). - Sends the
blake2brule withgetblocktemplate, which Knots requires on this chain. - The block page shows the extended BLAKE2b header fields (
nonce2,nonce3, extranonce, time offset, flags). - The difficulty history shows the work per block (the expected number of hashes) so that the SHA-256d and BLAKE2b epochs are on one scale: the BLAKE2b difficulty of Knots already is that number, and the SHA-256d difficulty is multiplied by 2^48 / 0xffff. The fall at the fork is visible, and marked.
- No hashrate is reported for a window that reaches back before the fork, for the same reason.
- The node details page shows the BLAKE2b fork height and whether it has taken effect.
- The charts of the transaction stats and the difficulty history mark the fork (a dashed line; grey before it, red after it).
- A hand-maintained list identifies the miners seen on this chain (
public/txt/mining-pools-configs-custom/). - Red theme and the Blake2b name.
- Safer defaults: production mode, verified Electrum certificates, CSRF protection, rate-limited logins, security headers, and the RPC tools and admin pages only behind the password. See "Security" below.
- TypeScript, a build step, tests that run the whole explorer, and a Docker image.
Blocks up to the fork are shared with Bitcoin. From the fork on, blocks use BLAKE2b proof of work and difficulty is the expected number of hashes per block.
- Network summary dashboard
- View details of blocks, transactions, and addresses
- Analysis tools for viewing stats on blocks, transactions, and miner activity
- JSON REST API
- See raw JSON content from bitcoind used to generate most pages
- Search by transaction ID, block hash/height, and address
- Optional transaction history for addresses by querying one or more Electrum-protocol servers (e.g. Fulcrum, Electrs, ElectrumX); with several, the answers are compared and a disagreement is shown
- Mempool summary, with fee, size, and age breakdowns
- RPC command browser and terminal
See CHANGELOG.md: the release notes of this fork start at 4.0.0 (read "Upgrading" there when you come from upstream), and upstream's history follows. Changes to the public API are in CHANGELOG-API.md.
- A Bitcoin Knots node on the BLAKE2b chain (v29.4.2 or later), with its RPC server enabled (
server=1). - Let the node synchronize (you can use this tool while synchronizing, but some pages may fail).
- Node.js 20+ (22+ recommended).
- Optional, for address history: an Electrum-protocol server for the same chain, such as a Fulcrum build that follows it.
This tool works best with full transaction indexing enabled (txindex=1) and pruning disabled. You can run without txindex and/or with pruning, and the tool will continue to function, but some data will be incomplete or missing.
With pruning enabled and/or txindex disabled:
- You will only be able to search for mempool, recently confirmed, and wallet transactions by their txid.
- Pruned blocks will display basic header information, without the list of transactions.
- The address and amount of previous transaction outputs will not be shown, only the txid:vout.
- The mining fee will only be available for unconfirmed transactions.
For the UTXO set page, the node can also keep the coin statistics index (coinstatsindex=1 in bitcoin.conf; restart the node, wait until bitcoin-cli getindexinfo shows it as synced, then restart the explorer). It is optional: without it the page works but builds its snapshot more slowly and says so; with it the explorer uses it automatically.
git clone https://github.com/2rdzy/btc-rpc-explorer
cd btc-rpc-explorer
npm ci
npm run build
npm startThe app is then at http://127.0.0.1:3002/. Views are cached, so restart after editing a template.
The code runs from dist/, which npm run build compiles with TypeScript. Run npm run build again after every update (and after npm run css), then restart. npm ci installs the dev dependencies the build needs; to keep a smaller install, build first and then run npm prune --omit=dev. Errors show the original source file and line, because npm start runs Node with --enable-source-maps.
Set options with environment variables or CLI arguments.
Create one of these files and enter values in it:
~/.config/btc-rpc-explorer.env.envin the working directory
See .env-sample for all options. A typical .env for a local node with cookie authentication and a Fulcrum server:
BTCEXP_HOST=127.0.0.1
BTCEXP_PORT=3002
BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=8332
BTCEXP_BITCOIND_COOKIE=/path/to/.cookie
BTCEXP_ADDRESS_API=electrum
BTCEXP_ELECTRUM_SERVERS=tls://your-fulcrum-host:50002
BTCEXP_ELECTRUM_TXINDEX=true
Notes:
- The cookie file is regenerated every time bitcoind restarts. Copy it again after a restart.
- Electrum servers over
tls://are verified. A server with a self-signed certificate (Fulcrum's default) needs its fingerprint inBTCEXP_ELECTRUM_TLS_FINGERPRINT(get it withopenssl x509 -in cert.pem -noout -fingerprint -sha256), or its certificate inBTCEXP_ELECTRUM_TLS_CA. See .env-sample. With several servers, the address page shows what most of them say and warns when they differ. - To use a node on another machine without opening its RPC port, forward it over SSH:
ssh -N -L 8332:127.0.0.1:8332 user@node-host, then pointBTCEXP_BITCOIND_HOSTat127.0.0.1.
Run node dist/bin/cli.js --help for the full list, for example:
node dist/bin/cli.js --port 8080 --bitcoind-port 8332 --bitcoind-cookie ~/.bitcoin/.cookieYou can configure SSO authentication similar to what ThunderHub and RTL provide. To enable it, make sure BTCEXP_BASIC_AUTH_PASSWORD is not set and set BTCEXP_SSO_TOKEN_FILE to point to a file write-accessible by btc-rpc-explorer. Your SSO provider then needs to read the token from this file and set it in the URL parameter token. The token changes with each login, so the provider needs to read it each time.
After successful access with the token, a cookie is set for authentication. To redirect users to your login page when needed, set BTCEXP_SSO_LOGIN_REDIRECT_URL.
docker build -t btc-rpc-explorer .docker run -d --name btc-rpc-explorer --network host --env-file .env -v /path/to/.cookie:/path/to/.cookie:ro btc-rpc-explorer(with--network hostthe explorer reaches a node on the same machine as127.0.0.1; otherwise publish the port with-p 127.0.0.1:3002:3002and pointBTCEXP_BITCOIND_HOSTat an address the container can reach)
The image holds no settings: they come from --env-file (.env and the caches are left out of the build by .dockerignore). It runs as the unprivileged user node, so the cookie file has to be readable by user id 1000. See also docker-compose.yml and docs/Server-Setup-Docker.md.
- The explorer is meant for your own node. It binds to
127.0.0.1by default; to reach it from elsewhere put it behind a reverse proxy with HTTPS (below) and setBTCEXP_BASIC_AUTH_PASSWORD. - The RPC browser, the RPC terminal and the admin pages are only served when the password is set and given. Without it they show a message instead. What the RPC tools can run is limited by
BTCEXP_RPC_BLACKLIST(see .env-sample). - The pages need the node's RPC login: prefer the cookie file (
BTCEXP_BITCOIND_COOKIE) to a password in the environment, and never expose the RPC port of the node itself. - Set
BTCEXP_PRIVACY_MODE=true(the default isfalse) when you do not want the explorer to ask external services for exchange rates, IP locations and the like. - Found a vulnerability? Please report it privately, through the "Report a vulnerability" option under the Security tab of the repository, not in a public issue.
See docs/nginx-reverse-proxy.md for nginx and certbot (Let's Encrypt), and docs/Server-Setup.md for a full server walkthrough.
npm testruns the tests (TypeScript is loaded withtsx),npm run lintruns ESLint (with typescript-eslint), andnpm run typechecktype-checks everything with TypeScript. CI runs all three, and builds.- TypeScript. All of the code is TypeScript, and is checked with
strictand with no tolerance (tsconfig.json):app.ts,routes/,bin/,app/(including the coin data inapp/coins/),docs/api.tsand the tests intest/. What the node returns is JSON that varies by RPC method and node version, so it is typed loosely asRpcData(app/api/rpcApi.ts), and the types get tighter where a use needs it. Shared helpers are inapp/helpers/, andapp/utils.tsre-exports them for the code that has always imported from there. Two things to know about the order of imports:app.tsandbin/cli.tsrun code between their imports on purpose (the.envfiles and command line settings must be in the environment beforeconfigloads), andtsckeeps the imports where they are written, so do not sort them. In the tests,test/helpers/setup.tsmust be the first import of a file for the same reason. - The only JavaScript left is
eslint.config.jsand what is served to the browser frompublic/. test/pages.test.tsstarts the whole explorer (built withtsc, as a separate process) against a fake node, and requests about 150 pages and endpoints over HTTP (test/fixtures/pages.ts). The fake node answers questions about the chain (blocks, transactions, ...) from a recording of a real node (test/fixtures/rpc.json: public chain data), and what belongs to a node (peers, addresses, mempool, block template, uptime, ...) from made-up answers (test/fixtures/nodeSpecific.ts). When a change makes a page ask for something that is in neither, the test names the call: record again withBTCEXP_RECORD_COOKIE_FILE=/path/to/.cookie npm run record-fixtures(it needs a node; only chain data is kept, and long lists are cut) or add a made-up answer.- Tests and the type check run on the source. The app itself runs from
dist/:npm run build && npm start. Files that are not code (views/,public/, the changelogs) are read from the project root, found byapp/paths.js, so do not use__dirnameto reach them. npm run cssrebuilds the three theme stylesheets frompublic/scss/and rewrites the integrity hashes inapp/resourceIntegrityHashes.ts. Commit the compiled*.min.cssfiles and the hashes together, or browsers will reject the stylesheets.npm run minersdownloads the upstream mining pool lists (it runs the builtdist/bin/refresh-mining-pool-configs.js, so build first). It does not touchpublic/txt/mining-pools-configs-custom/.
The explorer is the work of Dan Janosik and the contributors to BTC RPC Explorer, whose design, pages and most of the features are what you see here. This fork adds, among other things:
- support for the BLAKE2b chain of Bitcoin Knots (see "What is different from upstream" above);
- the red theme and the rebrand;
- security work: CSRF protection with
csrf-sync, a limit on failed logins, TLS verification and pinning for Electrum servers, no credentials in cache keys, dependency upgrades; - the whole code base in strict TypeScript, with a build step, around 460 tests, lint, CI and a Docker image that holds no settings.
Fixes that apply to the upstream project too are welcome there as well.
MIT. See LICENSE. Original work by Dan Janosik; changes in this fork by its contributors.
