Docs
v1

Reference

Stratum protocol

The tenrai-mining-v1 and tenrai-mining-v2 protocols between miners and bridges or pools. Transport, messages, work header, targets and error codes.

On this page

tenrai-mining-v1 is the stratum protocol of Tenrai. tenrai-mining-v2 carries the same session in binary frames over TLS. It borrows framing and channels from Stratum V2 but is not Stratum V2 and does not work with Stratum V2 software. The two protocols are TCC-0007 and TCC-0008 of the conventions.

V1 transport

ItemValue
FramingTCP, one JSON message per line, \n or \r\n, at most 16 KiB a line
TLSOptional. TLS 1.3 with the X25519MLKEM768 key exchange only, ALPN tenrai-mining/1
URL schemesstratum+tls://host:port; stratum+tcp://host:port only on the same machine, the Tenrai miner refuses it for any other host
Text
request        {"id": <number or string>, "method": "…", "params": […]}
response       {"id": …, "result": <value>, "error": null}
error          {"id": …, "result": null, "error": [code, "message", null]}
notification   {"id": null, "method": "…", "params": …}

A miner ignores notifications it does not know and extra fields in known ones. A server answers unknown methods with code 20 and keeps the connection.

V1 session

Text
miner → server   mining.subscribe [agent, tag]
server → miner   {"protocol": "tenrai-mining-v1", "nonce_prefix": "<hex, at most 8 bytes>", "pool_address": "<address>"}
miner → server   mining.authorize [login, password]
server → miner   true
server → miner   mining.set_target [share target]
server → miner   mining.notify {job_id, header, target, share_target, registration_height, network, clean}
miner → server   mining.submit [worker, job_id, nonce]
server → miner   true, or an error

Only pools send pool_address.

FieldMeaning
tagUp to 20 characters shown in explorers: letters, digits, spaces and . _ - / : + @ # ( ) !, no space at either end; empty for none
login<address> or <address>.<worker>. Every block pays the address, except on a pool
pool_addressA pool's blocks pay this address and the pool credits the login address
passwordThe server's password; d=<n> or <password>,d=<n> asks for a fixed share difficulty
headerThe 312-byte work header in hex, nonce all zero
target, share_target32-byte big-endian targets in hex. The share target is never harder than target
registration_heightFinalized height of the work's anchor plus one
networkmainnet, testnet, testnet100 or development

Work header

OffsetBytesField
048Chain ID
482Header version, big-endian
501Algorithm, 0x02 for TenQ
5148Work reference (anchor)
9948Parents root
14748Payload root
1954Payload length, big-endian
1998Payload mass, big-endian
20741Reward lock of the payout address
24832Nonce
28032Extranonce: tag length, tag, then bytes the server chose

Hashing

ItemValue
PreimageASCII TRAI_POW_V1 followed by the header, 323 bytes. The nonce sits at bytes 259 to 290
NonceIts last len(nonce_prefix) bytes are the prefix from mining.subscribe; every other byte is the miner's
Epoch(registration_height - 1) / 34560, rounded down
Profile0x54454E10, the 2 GiB dataset, on mainnet and the testnets; 0x54454E01 on development
HashTenQ, seeded with the header's chain ID
ShareValue ≤ share_target, compared as unsigned 256-bit big-endian numbers
BlockValue ≤ target; the server submits it to the node
DifficultyD stands for the target floor(2^256 / D) - 1. Difficulty 1 accepts every hash

Error codes

CodeMeaningMiner reaction
20Unsupported request
21Stale jobCount as stale
22Duplicate share
23Above the share target
24Unauthorized. A wrong password also closes the connectionSession ends
25Rate limited
26Malformed
27No address of the server's network in the loginSession ends
28Tag not allowedSession ends
29Banned for a whileSession ends, next server

V2 transport

ItemValue
ConnectionTCP with TLS 1.3, X25519MLKEM768 only, ALPN tenrai-mining/2. There is no unencrypted V2
URL schemestratum2+tls://host:port
FrameExtension type u16, message type u8, payload length u24, payload
Extension type0; the top bit is set on channel messages, whose payload starts with the channel ID
PayloadAt most 16 KiB
NumbersLittle-endian u16, u32, u64
boolOne byte, 0 or 1
stru8 length and UTF-8, at most 255 bytes
bytesu8 length and bytes; bytes64k has a u16 length
[n]Exactly n bytes. Targets are big-endian numbers as in V1

A server closes the connection on a malformed or unknown message, a message out of order, or a frame over the limit. A miner ignores message types it does not know.

V2 messages

TypeNameDirectionFields
0x00SetupConnectionminer → serveragent str, tag str
0x01SetupConnection.Successserver → minernonce_prefix bytes (at most 8), pool_address str (empty unless a pool)
0x02SetupConnection.Errorserver → minercode u16, message str
0x04Reconnectserver → minerhost str (empty: same host), port u16 (0: same port)
0x10OpenChannelminer → serverrequest_id u32, login str, password str
0x11OpenChannel.Successserver → minerrequest_id u32, channel_id u32
0x12OpenChannel.Errorserver → minerrequest_id u32, code u16, message str
0x15NewJobserver → miner, channelchannel_id u32, job_id [48], header bytes64k, share_target [32], target [32], registration_height u64, network str, clean bool
0x1aSubmitShareminer → server, channelchannel_id u32, sequence_number u32, job_id [48], nonce [32]
0x1cSubmitShares.Successserver → miner, channelchannel_id u32, last_sequence_number u32, accepted u32
0x1dSubmitShares.Errorserver → miner, channelchannel_id u32, sequence_number u32, code u16, message str
0x21SetTargetserver → miner, channelchannel_id u32, share_target [32]

V2 session

StepV1 equivalent
SetupConnection first, once. The answer carries the nonce prefix and a pool's addressmining.subscribe
OpenChannel; one channel per connectionmining.authorize
SetTarget and NewJobmining.set_target, mining.notify
SubmitShare with a sequence number that grows by one per sharemining.submit
SubmitShares.Success accepts every unanswered share up to last_sequence_number; SubmitShares.Error rejects onetrue or an error
Reconnect before the server stops. A miner follows it to the same host only

Fields, hashing, targets and codes are those of V1.

Type to search guides, concepts and reference pages.