Skip to content

About

No description, website, or topics provided.

Resources

Stars

8 stars

Watchers

2 watching

Forks

 
 

Repository files navigation

Electrs Logo

Electrs on StartOS

Everything not listed in this document should behave the same as upstream electrs. If a feature, setting, or behavior is not mentioned here, the upstream documentation is accurate and fully applicable — see the Documentation section of instructions.md for links.

electrs is an Electrum server: it builds an address index over your own Bitcoin node so wallets can query their history without asking anyone else. This package wires it to that node's REST API over the internal bridge, serves it over TLS, and reports the one thing upstream cannot — how far through its index it has got.


Table of Contents


Image and Container Runtime

One image, built here from upstream source.

Property Value
Image Built from this repo's Dockerfile
Architectures x86_64, aarch64; never emulated on other architectures
Command electrs
Subcontainer Purpose
electrs The only daemon — the one to attach to

Volume and Data Layout

One volume, plus a read-only view of Bitcoin's public volume.

Volume Mount Point Purpose
main /data The address index, the config, the store
Bitcoin's public (ro) /mnt/bitcoind The RPC cookie

The index is the bulk of the volume and is excluded from backups — see Backups and Restore. Everything else on main is small.

An update from the previous index format keeps the old index as db-0.11, and main deletes it only after a supported Bitcoin serves rpc-local and its public volume mounts (see Dependencies). Until then a downgrade to the previous compatible Electrs release moves it back and that release resumes where it was; otherwise it rebuilds its index from scratch. db-0.11 is excluded from backups too.

A pending Reindex is an empty reindex.request file at the volume root. main removes it once the index is gone — see Actions.

File Models

Two models, and most of the config file is pinned rather than configurable.

File Format Modelled Written by
electrs.toml TOML Yes — FileHelper.toml Init, main, and the Configure action
store.json JSON Yes — FileHelper.json main

Its fields fall into three groups:

  • Pinned. The cookie path, the network, and the Electrum bind address are z.literal(...).catch(...), so a changed value is repaired on read rather than merely overwritten. The auth field is pinned to undefined for a specific reason: electrs exits outright if both an auth value and a cookie file are set.
  • Resolved at start. The Bitcoin RPC address is written by main from the live bridge address. When it cannot be resolved nothing is written and electrs is not started — main returns the bitcoind-rest check instead (see Health Checks), and the reactive read restarts it when Bitcoin's binding appears.
  • User-owned via the Configure action. The log level.

Every other upstream option — the database directory, the block-download wait, the RPC timeout, the server banner — is fixed or not exposed.

store.json holds two flags the package uses to avoid lying to the user: whether the index has ever finished, and whether the completion notification has been sent. Both matter to how sync is reported — see Health Checks.

Dependencies

One, and it is required.

Dependency Required Health checks required Mounted Why
Bitcoin Yes bitcoind, sync-progress, background-validation public, read-only at /mnt/bitcoind The RPC cookie

Requiring Bitcoin's own sync check is deliberate. While Bitcoin is still doing its initial download, StartOS reports the dependency as unsatisfied. Dependency declarations do not block startup: electrs's own initial-download wait handles normal sync, and the bitcoin-history health check explicitly gates the daemon on Bitcoin's background-validation check.

background-validation covers a Bitcoin bootstrapped from a UTXO snapshot. Such a node reports sync-progress complete at the tip while it is still downloading the blocks beneath the snapshot, and electrs indexes from genesis: started early, it hits a block Bitcoin cannot serve yet, gets a 404 over REST, and crash-loops. The dependency lists the check so StartOS shows Bitcoin as unsatisfied meanwhile; the bitcoin-history health check is what holds the electrs daemon until those blocks are on disk.

Bitcoin must not be pruned, and a recurring task enforces it: electrs needs an archival node. It does not need Bitcoin's transaction index, unlike some other Electrum servers.

Electrs uses Bitcoin's direct RPC/REST listener over the bridge-only rpc-local binding. The exported rpc binding lands on a JSON-RPC-only proxy, so it cannot serve the REST endpoints Electrs requires.

Bitcoin must be Bitcoin Core 31.2:4 or later. Upstream electrs 0.12 reads spent outputs and partial blocks over REST endpoints that first shipped in Bitcoin Core 30.0 and 31.0 (bitcoin#32540, bitcoin#33657), so no 28.x–30.x line can serve it however it is configured; 31.1:17 is the first Bitcoin Core package revision that enables REST and publishes rpc-local; 31.2:1 is the first that reports background-validation; and 31.2:4 is the first that publishes its cookie on the public volume electrs mounts. The >=31.2:4 floor keeps incompatible Bitcoin releases from satisfying the package, and the bitcoind-rest health check names the remedies when one is installed anyway (see Health Checks).

The service also restarts when Bitcoin's cookie changes, watched directly on the mounted file. An absent cookie means Bitcoin is down, and is deliberately not treated as a change.

Network Access and Interfaces

One interface, and the difference between its two ports is the thing to understand.

Interface Id Type Internal Port Description
Electrum (SSL) main api 50001 The Electrum protocol endpoint, over SSL

electrs listens unencrypted on 50001 inside the container, and StartOS terminates TLS in front of it. TLS is the only way in over LAN, .local and domains, which is what makes the name accurate. Tor is the one place a plaintext address is reachable: the Tor service points an onion at whichever bridge address its SSL toggle selects, so an onion added with that toggle off carries plain TCP.

A plaintext external port is allocated too, but it is reachable only at the bridge address, by the host and by other services, source-filtered to that subnet. No LAN or WAN gateway gets a forward for it. That is the address dependents such as Mempool, Specter and Canary resolve, and it is what replaced the retired .startos DNS name.

The scheme override is what renders an address as ssl://host:port; without it the bind would print a bare host:port with nothing marking it as TLS.

Clients that accept or pin an unrecognised certificate connect as-is. The Electrum desktop wallet is the exception — it rejects the device's CA chain on every address, and needs the client-side step documented at https://docs.start9.com/bitcoin-guides/connecting-wallets.

The external port is per-server, and permanent. The preferred port is only a preference, and whatever StartOS assigns to a binding never changes — only uninstall and reinstall reassigns it. Read the live value with start-cli package host binding list electrs electrum rather than assuming. Servers migrated from the previous generation are the known case where it differs: their old manifest bound a single plaintext port over Tor, and rebinding the same host and internal port left the TLS leg on 50001. Those servers serve ssl://host:50001 and will keep doing so.

Installation and First-Run Flow

Install seeds the config and nothing else. There is no credential and no task on this service.

What governs the first run is Bitcoin: electrs's own initial-download wait handles normal sync, and the bitcoin-history runtime gate holds the daemon until Bitcoin's background validation succeeds. Once Bitcoin is ready, electrs begins building its address index, which takes hours on first run and is the longest thing this package does. An update that changes the index format rebuilds it too; the update to the current format requires at least 120 GB of free space. Updating from Electrs 0.11 makes StartOS ask the user to confirm that cost and the Bitcoin Core 31.2:4 requirement before it downloads the package.

A notification is sent when the index first completes, so the wait does not have to be watched.

Actions

Two actions: one setting, and the recovery for a corrupted index.

Configure

Sets the log level in electrs.toml.

  • Cost: applies on restart.
  • Repeat safety: idempotent.

Reindex

Deletes the address index so electrs rebuilds it from Bitcoin — the in-place replacement for uninstalling and reinstalling.

  • When to run it: electrs keeps exiting and its error chain names the database — RocksDB failed: Corruption under failed to open index, or under sync failed when a compaction after catch-up reaches the bad block — or it panics with please reindex!. client failed under either wrapper means Bitcoin's REST is down or still warming up, and a reindex does not help. Not for a busy index (see Health Checks), and not for a Bitcoin that is stalled or cannot serve electrs. Input/output errors point at the drive: a rebuild on failing storage fails the same way.
  • What it changes: creates an empty reindex.request at the volume root and restarts electrs if it is running. On the next start, before anything else, main deletes db, resets both sync flags so the rebuild is reported and notified as a first run, and removes the marker last, so an interrupted delete repeats. db-0.11 is left alone, because it is the downgrade path.
  • Cost: the hours of a first-run build, during which dependents have no complete index. The rebuild needs at least 120 GB of free space.
  • Repeat safety: a second run before the next start changes nothing; a run after the rebuild has started starts it over.
  • What happens next: if electrs is stopped, nothing happens until it is started. If Bitcoin cannot serve electrs, the index is deleted and the rebuild waits for the bitcoind-rest check to clear.

Tasks

One, and it appears on Bitcoin's page rather than this one.

Task Severity Raised when Cleared when
Bitcoin's Auto-Configure critical Bitcoin is pruned Pruning is disabled on Bitcoin

It is declared recurring, so re-enabling pruning brings it back. The user sees it on Bitcoin's page with nothing there explaining that electrs asked for it.

Health Checks

Three checks. A fourth stands in for them while Bitcoin cannot serve electrs.

Check Displayed as Method
bitcoin-history "Background Validation" Bitcoin's background-validation succeeds
electrs "Electrum Server" The Electrum port is listening
sync "Sync Progress" Electrs's indexed tip versus Bitcoin's tip

bitcoin-history gates the Electrs daemon through requires. It polls the declared dependency's background-validation result and reports loading until success; a missing check also leaves the daemon waiting. When Bitcoin completes background validation, Electrs starts automatically. Once it succeeds it stays successful until main restarts, so a slow or failed Bitcoin probe later in the run never stops Electrs; one that did would kill it mid-compaction, and its first compaction after an index build would never finish.

While Bitcoin is outside the supported version range or publishes no rpc-local binding, main returns a single bitcoind-rest check ("Bitcoin REST") in place of the chain above. It fails for an incompatible Bitcoin release with the remedies in its message: a downgrade to the previous compatible Electrs release, Bitcoin Core 31.2:4 or later, or Fulcrum. It reports loading while Bitcoin is not installed. Nothing else runs, so that one line is the page's whole state instead of a daemon that cannot read a block. The binding is resolved with .const(), and the check polls Bitcoin's version; main restarts into the normal chain when a supported Bitcoin appears, even if an update preserves its bridge address.

"Electrum Server" going green does not mean electrs is usable. electrs binds its listener before it connects to Bitcoin, so the port is open throughout the wait for Bitcoin's sync and throughout the index build. A not-listening result therefore means electrs has not started yet — not that it is blocked. The check reports starting rather than failure for exactly that reason.

"Sync Progress" compares chain heights. Bitcoin's tip comes from its REST chaininfo; electrs's indexed tip comes from blockchain.headers.subscribe. The check reports success only when electrs is no more than one block behind. While electrs can answer, the loading message shows both heights.

During an index build electrs processes a whole batch before servicing requests, so a probe can time out between progress updates. The check retries a timeout only after the index has completed once, when a long non-answer is surprising enough to recheck. Before the first completion it reports that the index is building; afterwards it reports a busy indexer rather than suggesting a routine restart discarded the index.

Backups and Restore

The main volume is copied except the index, which is excluded, along with the previous-format index kept for a downgrade.

So the backup is the configuration and the two flags — kilobytes rather than the tens of gigabytes the index occupies. The trade is explicit: a restored instance rebuilds its index from scratch, taking the same hours a fresh install does, and nothing that depends on electrs works until it finishes.

Backing the index up would not be much better than rebuilding it: it is large, it is derived entirely from Bitcoin, and a torn copy of a live database is worse than no copy.

Limitations and Differences

  1. The index is not backed up, so a restore means rebuilding it — hours.
  2. Bitcoin must be unpruned, enforced by a recurring task. Its transaction index is not needed.
  3. Mainnet only. The network is pinned in the config.
  4. Most of upstream's configuration is not exposed — the database directory, the RPC timeout, the server banner, and the block-download wait are all fixed or absent.
  5. The Electrum desktop wallet needs a client-side certificate step; other wallets do not.
  6. The external port is assigned once and never changes for an existing binding, so it may not be the preferred one.

Quick Reference for AI Consumers

package_id: electrs
image: built from ./Dockerfile
architectures: # emulateMissing: false
  - x86_64
  - aarch64
subcontainers:
  - electrs
volumes:
  main: /data # bitcoin's public volume is mounted read-only at /mnt/bitcoind
file_models:
  - electrs.toml
  - store.json # everSynced / syncNotified flags
startos_managed_env_vars: [] # configuration is written into electrs.toml
dependencies:
  - bitcoind # required, kind: running, checks: bitcoind + sync-progress + background-validation
interfaces:
  main: { type: api, port: 50001 } # TLS-terminated by StartOS; plaintext is bridge-only
actions:
  - config
  - reindex # deletes db on the next start; db-0.11 is kept
tasks:
  - { action: 'bitcoind:autoconfig', severity: critical } # on Bitcoin's page, recurring
health_checks:
  - bitcoin-history # displayed "Background Validation"; gates the daemon on Bitcoin's historical blocks
  - bitcoind-rest # displayed "Bitcoin REST"; the only entry without a supported Bitcoin and its rpc-local binding
  - electrs # displayed "Electrum Server"; binds before it connects to Bitcoin
  - sync # displayed "Sync Progress"; compares indexed and Bitcoin tips

About

No description, website, or topics provided.

Resources

Stars

8 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages