Docs
v1

Guide

Stratum bridge

Serve your node's work to many mining rigs with tenrai-stratum-bridge, step by step. Listeners, TLS, access control, vardiff, every option and the statistics.

On this page

tenrai-stratum-bridge takes work from your node and hands it to miners on other machines. Each miner logs in with its own address, and every block it finds pays that address directly. The bridge keeps no balances and pays nothing itself; for shared payouts, run a pool.

1. Run a synced node

The bridge runs on the node's machine and talks to its mining listener at 127.0.0.1:28702. Set up the node as in Run a node.

2. Start the bridge

Shell
tenrai-stratum-bridge

Without options the bridge serves miners on this machine: it takes work from the node at 127.0.0.1:28702, listens on 127.0.0.1:28720 and shows its dashboard on http://127.0.0.1:28771/. It waits for the node when that is not running yet. The first start writes tenrai-stratum-bridge.json with the default settings next to the program.

For rigs in your local network:

Shell
tenrai-stratum-bridge --listen-tls 0.0.0.0 --tls-name 192.168.1.10 --allow 192.168.1.0/24
Option
--listen-tls 0.0.0.0Accepts miners over TLS on port 28721 on every interface
--tls-name 192.168.1.10The address the rigs connect to, written into the certificate the bridge creates
--allow 192.168.1.0/24Accepts only these addresses

The first start creates tenrai-stratum-bridge.crt and its key next to the program. The miner sends unencrypted Stratum only to its own machine, so the rigs need TLS and this certificate.

Every listener outside 127.0.0.1 needs one of --allow, --password-file or --public.

3. Point the miners at it

On each rig:

Shell
tenrai-miner -a <address> --stratum 192.168.1.10 --tls-ca tenrai-stratum-bridge.crt -w rig1

No --pool here: the bridge builds work that pays each miner's own address.

4. Check it

The dashboard at http://127.0.0.1:28771/ shows workers, hashrate, shares and found blocks. The log prints a worker report every 30 seconds.

Over the internet

Use TLS and protect the port:

Shell
tenrai-stratum-bridge --listen-tls 0.0.0.0:28721 --tls-cert bridge.crt --tls-key bridge.key \
  --password-file bridge.pass --autoban
Shell
tenrai-miner -a <address> --stratum stratum+tls://bridge.example.org:28721 -w rig1 -p "<password>"

The certificate and key are PEM files, for example from Let's Encrypt. Miners trust a self-signed certificate with --tls-ca bridge.crt. TLS listeners speak TLS 1.3 with the X25519MLKEM768 key exchange only.

Open to everyone, without a password:

Shell
tenrai-stratum-bridge --listen-tls 0.0.0.0:28721 --tls-cert bridge.crt --tls-key bridge.key --public --autoban

Stratum version 2; miners then use stratum2+tls://:

Shell
tenrai-stratum-bridge --listen-v2-tls 0.0.0.0:28722 --tls-cert bridge.crt --tls-key bridge.key --public

Browser miners, behind a TLS proxy:

Shell
tenrai-stratum-bridge --listen-ws 127.0.0.1:28723 --ws-origin https://miner.example --public

The proxy passes each visitor's address as X-Real-IP; the bridge reads it only from connections that come from 127.0.0.1. Without it, limits and bans would apply to all browser miners together. --ws-origin keeps other web pages from mining through the bridge.

Unencrypted listeners, --listen and --listen-ws, only accept 127.0.0.1; the bridge refuses them on any other address. Miners on other machines connect over TLS, or through a TLS proxy in front of a loopback listener.

Options

The bridge reads tenrai-stratum-bridge.json next to the program and creates it with the default settings on the first start; --config names another file. The file takes the long option names. A value on the command line replaces the file's; lists from both are added together.

Node and listeners

OptionDefaultWhat it does
--network <NAME>mainnetmainnet, testnet or development. Sets the default ports, see Default ports
-s, --node <HOST[:PORT]>127.0.0.1:28702Mining listener of the node; a URL works too
--chain-id <HEX>Refuses a node on another chain
-l, --listen <IP[:PORT]>127.0.0.1:28720Unencrypted version 1 listener. Repeatable
--listen-tls <IP[:PORT]>Version 1 over TLS, port 28721 unless given. Repeatable
--listen-v2-tls <IP[:PORT]>Version 2, always TLS, port 28722 unless given. Repeatable
--no-v1offNo version 1 listener at all, not even the default; needs --listen-v2-tls
--listen-ws <IP[:PORT]>Version 1 over WebSocket for web pages, port 28723 unless given; a proxy adds TLS. Repeatable
--ws-origin <ORIGIN>any pageWeb pages that may mine over WebSocket
--tls-cert <FILE>, --tls-key <FILE>tenrai-stratum-bridge.crt and .key next to the programCertificate and key of the TLS and version 2 listeners. Without them the bridge creates a self-signed pair at its first start; miners pass the .crt as --tls-ca
--tls-name <NAME>Host name or IP miners connect to, for the created certificate. Repeatable; localhost and the listeners' own addresses are always in it

Access

OptionDefaultWhat it does
--password-file <FILE>Miners must send this password
--allow <RANGE>everyoneAccepts miners only from these addresses or ranges
--publicoffAccepts miners from anywhere without a password
--max-clients <N>512Connections in total, at most 65536
--max-clients-per-ip <N>64Connections from one IPv4 address or IPv6 /64
--autobanoffBans addresses that send invalid shares or bad requests
--ban-time <S>600Length of a ban
--ban-invalid-percent <P>50Share of invalid shares in a batch that leads to a ban
--ban-check-shares <N>20Shares per batch

Loopback is never banned.

Shares and blocks

OptionDefaultWhat it does
--start-difficulty <D>65536First share difficulty of a connection
--min-difficulty <D>50Lowest share difficulty
--max-difficulty <D>network difficultyHighest share difficulty
--share-interval <S>20Seconds between two shares of one worker that vardiff aims for
--tag <TEXT>the miner'sWrites this tag into every block instead of each miner's own
--tenq-mode full|lightfulllight saves the 2 GiB dataset but checks shares much slower
--no-tenq-prefetchoffBuilds the next epoch's dataset only when the epoch starts; share checks wait for it
--verify-concurrency <N>CPU countShare checks at the same time; 0 automatic
--candidate-concurrency <N>CPU countFound blocks sent to the node at the same time; 0 automatic
--candidate-queue <N>512Found blocks waiting for the node

A miner can ask for a fixed share difficulty with the password d=131072, or <password>,d=131072.

Statistics and logs

OptionDefaultWhat it does
--api-bind <IP[:PORT]>127.0.0.1:28771Dashboard and JSON statistics
--no-apioffServes neither
--no-dashboardoffServes the JSON statistics only
--explorer-url <URL>Tenrai ExplorerExplorer the dashboard links to; empty for no links
--metrics-bind <IP[:PORT]>offPrometheus metrics at /metrics, port 28792 unless given
--stats-interval <S>30Seconds between worker reports in the log
-d, --debug, --log-file <FILE>, --no-colorLogging

Statistics

PathContent
/v1/statsHashrate, workers, shares, blocks
/v1/workersEvery worker of the last hour
/v1/miners/<address>One address with its workers and recent blocks
/v1/miners/<address>/historyHashrate of one address per minute for a day
/v1/blocks?limit=NRecent blocks, at most 100
/v1/historyBridge and network hashrate per minute for a day

The protocol is described in the stratum reference.

Type to search guides, concepts and reference pages.