℈Scruple Docs v0.1.0-alpha.1

Mining

Mining

Mine XSL blocks with RandomX on CPU, using a local node template and per-block payout rotation.

CPU-first proof-of-work

Scruple uses RandomX with automatic epoch rotation. Validating nodes can run Light mode (~256 MB RAM); solo miners can enable Full-Memory mode (~2 GB shared dataset) for higher CPU hashrate on identical consensus rules. There are no ASIC-specific extensions.

How solo mining works

The miner requests a block template from a running node through get_block_template, initializes the RandomX dataset for the template's seed_hash, searches the 85-byte block header for a nonce meeting the target, and submits the solved block through submit_block. A background watcher polls info every 2 seconds to cancel stale templates when the tip changes, and refreshes the template every 45 seconds to pick up new mempool fees and keep timestamps fresh.

Template

The node builds a coinbase paying the requested address, includes eligible mempool transactions, and returns the serialized block plus RandomX seed.

Search

The miner hashes the header across worker threads until the RandomX hash is at or below the target.

Submit

The solved block is submitted to the local node, validated, and accepted if it extends the active chain.

Payout

With --wallet, each accepted block auto-labels its coin and rotates to the next unused even receive address.

Quick start

Start a node first, then run the miner against its RPC endpoint. The CLI reads <data-dir>/.cookie automatically.

# Terminal 1: node
./target/release/scruple node \
  --network devnet \
  --data-dir ./data \
  --p2p 127.0.0.1:18333 \
  --rpc 127.0.0.1:18332

# Terminal 2: mine one block to a wallet
./target/release/scruple mine \
  --data-dir ./data \
  --rpc 127.0.0.1:18332 \
  --wallet ./wallet.json \
  --threads 2 \
  --blocks 1

When a block is accepted, inspect it in the block explorer if you are mining on testnet.

Auto-created wallets are unencrypted

If --wallet points to a file that does not exist, the miner creates a new HD wallet and prints its 24-word phrase. Without a passphrase or SCRUPLE_PASSPHRASE, the file is unencrypted (mode 0600) and a warning is printed. Create an encrypted wallet first with wallet new --encrypt if you plan to keep funds.

Continuous mining

For mainnet or testnet, use --continuous to run a long-lived miner with live hashrate reporting, stale-tip cancellation, and clean Ctrl-C shutdown.

./target/release/scruple mine \
  --continuous \
  --data-dir ./data \
  --rpc 127.0.0.1:18332 \
  --wallet ./wallet.json \
  --threads 8 \
  --full-mem

Continuous mode prints periodic statistics to stderr, including height, hashrate, total hashes, and blocks found. On Ctrl-C it stops worker threads, joins the watcher, and prints a JSON summary:

{
  "blocks_found": 0,
  "total_hashes": 123456789,
  "stale_restarts": 0
}

--blocks N in continuous mode is an optional cap on accepted blocks; omit it to mine until stopped. In non-continuous mode, --blocks defaults to 1.

Mining flags

FlagDescription
--network <mainnet|testnet|devnet>Used to resolve the default RPC port when --rpc is omitted.
--rpc <ADDR>Node JSON-RPC address. Defaults to 127.0.0.1:<network RPC port>.
--data-dir <PATH>Reads <data-dir>/.cookie for authentication.
--cookie <HEX|PATH>Explicit cookie token or path to a cookie file, overriding --data-dir.
--wallet <PATH>Use the wallet's next unused receive address and rotate payout addresses after each accepted block.
--passphrase <STR>Wallet passphrase. Prefer SCRUPLE_PASSPHRASE or the interactive prompt.
--to <ADDRESS>Mine directly to an explicit xsl1/xsl2 address. Overrides --wallet; no rotation.
--blocks <N>Number of blocks to mine. Defaults to 1; in continuous mode it is a cap.
--continuousRun the long-lived miner with a 2-second tip watcher and Ctrl-C shutdown.
--threads <N>RandomX worker threads. Defaults to 1; practical values depend on CPU cores and cache.
--full-memUse the ~2 GB RandomX Full-Memory dataset shared across threads. Requires roughly 2.5 GB free RAM.

Payout address rotation

When mining with --wallet, the miner selects the next unused even receive address, mines to it, and after each accepted block labels the coinbase and rotates to the next unused receive address. Rotation happens only after a block is accepted; stale-tip refreshes, rejected blocks, RPC errors, and clean shutdown without a found block do not burn a fresh address.

This is implemented in both the CLI (scruple mine --wallet) and the GUI miner. Mining to --to <ADDRESS> disables rotation and pays the same address every block.

Mining to a vault

You can mine directly to a native multisig vault with --to xsl2:... or a Bech32m v2 address. The coinbase output uses address version 2, so the vault can spend it later with the threshold cosigners.

RPC mining

The mine RPC method performs a synchronous mining operation inside the node. It is convenient for scripts and small batches, but a single call holds a node-wide mining lock and can run for a long time on high-difficulty networks.

COOKIE=$(cat ./data/.cookie)
curl -sS --max-time 0 http://127.0.0.1:18332 \
  -H "X-Scruple-Cookie: $COOKIE" \
  -H 'Content-Type: application/json' \
  -d '{
    "method": "mine",
    "params": {
      "address": "xsl1:<64-hex>",
      "blocks": 1,
      "threads": 4,
      "full_mem": false
    }
  }'
ParameterTypeRequiredDescription
addressstringrequiredReward address. Must match the node's active network.
blocksintegeroptional1–100. Defaults to 1.
threadsintegeroptional1–64. Defaults to 1.
full_membooleanoptionalEnable Full-Memory RandomX. Defaults to false.

The result contains a mined array with height, hash, transaction count, byte size, hash count, threads, and mode for each accepted block. If another RPC mining call is already running, the node returns another RPC mine operation is already in progress.

Long-running calls

The standard RPC client uses a 300-second read timeout. For high-difficulty mining, use a client that disables the timeout or use scruple mine --continuous, which manages templates and cancellation itself.

External miner integration

Any external miner can participate by implementing the template/submit flow. The node does not require a proprietary protocol; it exposes the serialized block and RandomX seed over JSON-RPC.

  1. Call get_block_template with a reward address that matches the node's network.
  2. Decode block_hex into a block, or use header_hex plus seed_hash.
  3. Initialize RandomX with seed_hash and search the 85-byte header nonce until the hash meets target_bits.
  4. Replace the header with the solved header, serialize the block, and call submit_block with block_hex.
  5. If became_tip is false, the block was accepted but did not become the active tip; refresh the template and continue.

See get_block_template and submit_block for exact fields, limits, and examples.

GUI mining

The desktop GUI includes a RandomX solo miner in the Overview tab. It uses the same template/submit RPC flow and supports per-block rotating payout addresses when a wallet is open. See Desktop GUI for the walkthrough.

Hardware and expectations

SetupMemoryNotes
Validating node only~256 MBRandomX Light mode is sufficient to validate blocks.
Solo mining, Light mode~256 MB plus worker overheadLower hashrate; useful for devnet/testnet or low-power machines.
Solo mining, Full-Memory mode~2.5 GB free RAMShared ~2 GB dataset across threads; significantly higher CPU hashrate.
Mainnet expectationsVariesInitial mainnet target is ~1,048,577 expected RandomX hashes. At 300-second blocks, hashrate and luck determine time-to-first-block. Solo mining is probabilistic.
Do not oversubscribe memory

Full-Memory mode allocates a large dataset. Running it on a machine with less than ~2.5 GB free RAM can cause swapping and dramatically reduce hashrate. Start with Light mode if unsure.

Mining economics

  • Each block pays a fixed 1 XSL subsidy forever, plus transaction fees included in the block.
  • There are no halvings and no premine. Annual issuance at 300-second blocks is roughly 105,120 XSL if every block is found.
  • Coinbase outputs mature after 24 blocks on mainnet, 6 on testnet, and 2 on devnet.
  • Solo mining is a Poisson process. A high hashrate improves expected time-to-block but does not guarantee a block within a fixed window.
  • Mempool fees are selected by the node template; mining with a synced node and a healthy mempool can add fee revenue.

Troubleshooting mining

SymptomFix
get_block_template failed: ... unauthorizedStale or missing cookie. Re-read <data-dir>/.cookie or pass --cookie.
submit_block rejected (stale/orphan)The tip changed while hashing. The continuous miner refreshes automatically; for custom miners, fetch a new template and retry.
RandomX initialization is slowFull-Memory dataset initialization can take noticeable time. The miner prints an initialization message and continues.
Hashrate is lowEnable --full-mem if RAM allows, increase --threads up to physical cores, and avoid oversubscribing memory.
Wallet lock errors during miningThe continuous miner releases the wallet lock while hashing and briefly re-acquires it after a block to rotate the payout address. Concurrent sends may briefly contend; retry.
Mined balance is immatureWait for coinbase maturity (24 mainnet blocks, 6 testnet, 2 devnet). balance reports mature and immature amounts separately.

Scruple Docs · v0.1.0-alpha.1 · Mainnet candidate

Scruple is alpha software. Verify commands against --help and the protocol specification before relying on them.