Scruple · XSL · ℈

Protocol
specification.

The frozen consensus rules of Scruple, from wire formats and sighash construction to RandomX epoch rotation and per-block LWMA difficulty. Complete enough to implement a second node.

Version 1.0 Mainnet candidate Frozen consensus Download Markdown ↓

Version: 1.0 (Mainnet Candidate)
Status: Frozen Consensus Rules — Production Launch Specification
Units: 1 ℈ (1 XSL) = 100,000,000 grains (10^8)


1. Design Goals & Frozen Consensus Constants

Scruple is a minimalist, post-quantum, CPU-mineable UTXO cryptocurrency designed for long-term ossification, bounded hardware requirements, and fair public launch.

Parameter Value Notes
Name / Ticker / Symbol Scruple / XSL / ℈ (U+2108) Base unit: grains
Subdivisions 100,000,000 (10^8) grains / XSL u64 amounts
Block Subsidy (BLOCK_REWARD) 100,000,000 grains (1 XSL) Fixed tail emission forever; no halvings, no premine (~105,120 XSL/year)
Target Block Time (T) 300 seconds (5 minutes) Mainnet, Testnet, and Devnet
Maximum Block Size (MAX_BLOCK_SIZE) 1,000,000 bytes (1 MB decimal) Hard cap on full serialized block bytes; 1:1 weight (no witness discount)
Maximum Transaction Size (MAX_TX_SIZE) 100,000 bytes Full serialized transaction bytes
Maximum Inputs / Outputs / Auth (MAX_TX_IO) 1,024 Per transaction
Maximum Transactions per Block 10,000 Wire decode upper bound
Consensus Minimum Output (CONSENSUS_MIN_OUTPUT) 1 grain (0.00000001 XSL) Strict consensus floor on all normal and coinbase outputs (non-consensus mempool/wallet dust policy DUST_FLOOR = 5,000 grains)
Block Version (BLOCK_VERSION) 1 Strict equality required
Address Versions (ADDR_VERSION_SQISIGN_L1 / ADDR_VERSION_MULTISIG_SQISIGN_L1) 1 / 2 Checksummed Bech32m (xsl1p.../xsl1z... Mainnet, txsl1... Testnet, dxsl1... Devnet) & legacy xsl1:<64-hex> / xsl2:<64-hex>
Max Multisig Keys (MAX_MULTISIG_KEYS) 15 Upper bound N per v2 multisig output / TxAuth::Multisig
Coinbase Maturity Mainnet: 24 (2 hr) · Testnet: 6 (30m) · Devnet: 2 Spendable when spend_height >= outpoint.height + coinbase_maturity
LWMA Window (LWMA_WINDOW) 60 blocks Per-block difficulty adjustment
RandomX Epoch Length (RANDOMX_EPOCH_LENGTH) 2,048 blocks Automatic PoW seed rotation (~7.1 days)
RandomX Epoch Lag (RANDOMX_EPOCH_LAG) 64 blocks Stabilization window before new seed activates
Max Future Block Time (MAX_FUTURE_BLOCK_TIME) 1,200 seconds (20 minutes) Relative to local node wall clock
Mainnet Initial / Max Target Bits 0x1e0fffff / 0x1f7fffff Compact Bitcoin-style nBits
Testnet Initial / Max Target Bits 0x1f0fffff / 0x207fffff Fast public testnet start (~4k RandomX hashes), then LWMA adapts
Devnet Initial / Max Target Bits 0x200fffff / 0x207fffff Fast local testing target
P2P Protocol Magic (p2p_magic) Mainnet: "XSL1" (58534C31) · Testnet: "XSLT" (58534C54) · Devnet: "XSLD" (58534C44) Per-network 4-byte transport frame prefix; cross-network peers reject immediately
Default P2P / RPC Ports Mainnet & Devnet: 18333 / 18332 · Testnet: 28333 / 28332 Used automatically when --p2p / --rpc are omitted

No general-purpose scripting VM, no OP_RETURN, and no witness discount exist in consensus.


2. Cryptographic Primitives & Domain Separation

2.1 Domain-Separated BLAKE3

All consensus hashing uses BLAKE3-256 with explicit ASCII domain prefix concatenation:

H(domain, data) = BLAKE3(domain || data)
Domain Tag (ASCII bytes) Input (data) Purpose
scruple-addr-v1 pubkey (83 B) 32-byte v1 single-key address hash
scruple-addr-v2 threshold (1 B) || n (1 B) || pubkey_0 (83 B) || ... || pubkey_{n-1} (83 B) 32-byte v2 M-of-N multisig address hash (1 <= threshold <= n <= 15, strictly ascending pubkeys)
scruple-txid-v1 encode_body(tx) Non-malleable transaction ID (excludes auth)
scruple-wtxid-v1 encode(tx) Full witness transaction ID (includes auth)
scruple-sighash-v1 txid || Σ(utxo.txid || encode(utxo.output)) Reorg-safe signature digest
scruple-merkle-leaf leaf_hash (32 B) Binary Merkle tree leaf node
scruple-merkle-node left_32 || right_32 (64 B) Binary Merkle tree internal node
scruple-block-root-v1 tx_root_32 || wt_root_32 (64 B) Dual Merkle root committed in block header
scruple-header-v1 header_bytes (85 B) Canonical 32-byte block hash / identifier
scruple-genesis-v1 genesis_seed || genesis_timestamp (u64_le) Genesis block prev_hash commitment & burn output
scruple-rx-genesis genesis_seed || genesis_timestamp (u64_le) RandomX Epoch-0 seed hash
scruple-hd-v1 master_seed (64 B) || index (u32_le) Deterministic HD child seed derivation (wallet standard)
scruple-rbf-shrink-v1 old_txid (32 B) || new_txid (32 B) Non-consensus Ownership-Proven FSS-RBF change-shrink proof (MSG_TX_BUMP)

2.2 SQIsign Round-3 Level 1 (Compressed Format)

Scruple uses pure-Rust NIST Round-3 SQIsign Security Level 1:

  • Public Key (PK_LEN): exactly 83 bytes (PublicKey::<Level1>::to_bytes()).
  • Compressed Signature (SIG_LEN): exactly 176 bytes (Signature::compress().to_bytes()).
  • Tagged Auth Footprint: 260 bytes (1 B tag + 83 B pk + 176 B sig) per unique v1 signing address; 4 + 83*N + 177*M bytes per unique v2 M-of-N multisig address (e.g. 607 bytes for 2-of-3).
  • Address Derivation (v1 Single-Key):
    addr_hash = BLAKE3("scruple-addr-v1" || pubkey_83)
    bech32m   = bech32m_encode(hrp, witness_ver=1, addr_hash)   // xsl1p... / txsl1p... / dxsl1p...
    legacy    = "xsl1:" || lowercase_hex(addr_hash)
    
  • Address Derivation (v2 Native M-of-N Multisig): Requires 1 <= threshold <= N <= 15 (MAX_MULTISIG_KEYS) and strictly ascending pubkeys[0] < pubkeys[1] < ... < pubkeys[N-1] (lexicographical byte order):
    addr_hash = BLAKE3("scruple-addr-v2" || u8(threshold) || u8(N) || pubkeys[0] || ... || pubkeys[N-1])
    bech32m   = bech32m_encode(hrp, witness_ver=2, addr_hash)   // xsl1z... / txsl1z... / dxsl1z...
    legacy    = "xsl2:" || lowercase_hex(addr_hash)
    
    Bech32m (BIP-350) carries a 6-character BCH checksum and network HRP (xsl Mainnet, txsl Testnet, dxsl Devnet) so typos and cross-network sends are rejected client-side; legacy xsl1:/xsl2: hex remains accepted for backward compatibility.
  • Non-SUF-CMA Immunity: Because SQIsign signatures are not strongly unforgeable under chosen message attacks (an observer could potentially transform one valid signature into another valid signature for the same message), Scruple completely excludes the auth section from txid, while still committing to full signatures via wtxid inside the block header's merkle_root.

3. Canonical Binary Wire Format

Every consensus object has a single canonical byte representation. Non-canonical encodings and trailing bytes are consensus-invalid and MUST be rejected during decoding.

3.1 Primitive Types

  • u8: 1 byte unsigned integer.
  • u32_le: 4-byte little-endian unsigned integer.
  • u64_le: 8-byte little-endian unsigned integer.
  • varint: Canonical unsigned LEB128 (u64):
    • Emits 7 bits per byte (LSB first); bit 7 (0x80) is 1 on all bytes except the final byte.
    • Strict minimality rule: A multi-byte varint MUST NOT end in a 0x00 byte (e.g. [0x80, 0x00] is rejected as NonCanonicalVarint).
    • Overflow rule: At most 10 bytes; in the 10th byte (shift == 63), payload bits MUST be <= 1 (otherwise VarintOverflow).
  • EOF rule: Decoding a standalone Transaction or Block MUST consume every byte in the buffer; any trailing bytes are rejected (TrailingBytes).

3.2 Block Header (85 Bytes Fixed)

Offset Length Field Type Description
0 1 version u8 Must be 1 (BLOCK_VERSION)
1 32 prev_hash [u8; 32] Parent block's block_hash (genesis_commitment(params) for genesis)
33 32 merkle_root [u8; 32] Dual txid/wtxid Merkle commitment
65 8 timestamp u64_le Unix timestamp (seconds)
73 4 target_bits u32_le Compact PoW target (nBits)
77 8 nonce u64_le PoW nonce
  • Block Identifier: block_hash = BLAKE3("scruple-header-v1" || header[0..85]).
  • PoW Input: RandomX hashes the exact same 85-byte serialized header (header[0..85]).

3.3 Compact OutPoint

Instead of 36-byte (txid, vout) pointers, Scruple references UTXOs by their immutable chain position (~3–5 bytes on-chain):

OutPoint :=
    height    : varint(u64)   // block height creating the UTXO
    tx_index  : varint(u32)   // transaction index within that block (0 = coinbase)
    out_index : varint(u32)   // output index within that transaction

Ordering of OutPoint is lexicographical on (height, tx_index, out_index).

3.4 Output

Output :=
    addr_version : u8          // must be 1 (xsl1 single-key) or 2 (xsl2 M-of-N multisig)
    addr_hash    : [u8; 32]    // scruple-addr-v1 or scruple-addr-v2 commitment
    amount       : varint(u64) // grains; consensus >= 1 (mempool/wallet policy >= 5,000)

Ordering of Output is lexicographical on (addr_version, addr_hash, amount).

3.5 TxAuth (Tagged Canonical Encoding)

Each TxAuth entry begins with a 1-byte version tag matching the spent output's addr_version:

TxAuth :=
    tag : u8
    if tag == 1:                                     // SingleSig (260 bytes fixed)
        pubkey     : [u8; 83]                        // SQIsign Round-3 Level 1 public key
        sig        : [u8; 176]                       // SQIsign Round-3 Level 1 compressed signature
    else if tag == 2:                                // Multisig (4 + 83*n + 177*m bytes)
        threshold  : u8                              // 1 <= threshold <= n
        n          : u8                              // 1 <= n <= 15 (MAX_MULTISIG_KEYS)
        pubkeys    : [u8; 83][n]                     // strictly ascending lexicographical order
        m          : u8                              // must equal threshold (m == threshold)
        sigs       : (signer_idx: u8, sig: [u8; 176])[m] // strictly ascending signer_idx < n
    else:
        INVALID

Strict canonical decode rules (enforced during wire decoding AND consensus validation):

  1. Unknown tag values (anything other than 1 or 2) are rejected.
  2. For tag == 2, threshold == 0, n == 0, n > 15, threshold > n, and m != threshold are rejected.
  3. Remaining input bytes MUST cover n * 83 + 1 + threshold * 177 before allocating vectors.
  4. pubkeys MUST be strictly ascending (pubkeys[i-1] < pubkeys[i], forbidding duplicates and permutations).
  5. signer_idx values MUST satisfy signer_idx < n and be strictly ascending (signer_idx[i-1] < signer_idx[i], forbidding duplicate signer reuse and permutation malleability).

3.6 Transaction

TransactionBody :=
    flag : u8                                   // 1 = coinbase, 0 = normal spend
    if flag == 1:
        coinbase_height : varint(u64)
    else if flag == 0:
        input_count     : varint(usize <= 1024)
        inputs          : OutPoint[input_count]
    else:
        INVALID
    output_count        : varint(usize <= 1024)
    outputs             : Output[output_count]

Transaction :=
    body : TransactionBody
    if flag == 0:
        auth_count      : varint(usize <= 1024)
        auth            : TxAuth[auth_count]

Coinbase transactions (flag == 1) serialize no inputs and no auth trailer.

3.7 Block

Block :=
    header       : BlockHeader (85 bytes)
    tx_count     : varint(usize <= 10000)
    transactions : Transaction[tx_count]

Total serialized Block length MUST satisfy block.to_bytes().len() <= 1,000,000.


4. Transaction Identifiers, Sighash, Merkle Tree & Canonical Sorting

4.1 Non-Malleable txid and Witness wtxid

txid(tx)  = BLAKE3("scruple-txid-v1"  || encode_body(tx))
wtxid(tx) = BLAKE3("scruple-wtxid-v1" || encode(tx))

4.2 Reorg-Safe Sighash (Zero Extra On-Chain Bytes)

Because compact OutPoint(height, tx_index, out_index) pointers are positional, a deep chain reorganization could otherwise map the same coordinates to a different UTXO. Scruple eliminates this completely with zero extra on-chain bytes by binding every spent UTXO's exact creating txid and full Output into the signed digest:

sighash(tx, spent_utxos) = BLAKE3(
    "scruple-sighash-v1"
    || txid(tx)
    || spent_utxos[0].txid || encode(spent_utxos[0].output)
    || spent_utxos[1].txid || encode(spent_utxos[1].output)
    || ...
    || spent_utxos[m-1].txid || encode(spent_utxos[m-1].output)
)

This simultaneously guarantees:

  1. 100% Reorg Safety: A signature cannot be replayed against a different UTXO at the same (height, tx_index, out_index).
  2. Exact Fee Commitment: Every input amount and every output amount (via txid) is cryptographically bound, protecting hardware/offline signers against fee-drain attacks.

4.3 Dual Block Merkle Root

Given a non-empty list of 32-byte leaves L[0..k]:

  1. Transform each leaf: N[i] = BLAKE3("scruple-merkle-leaf" || L[i]).
  2. While N.len() > 1, pair adjacent nodes (left, right) (duplicating the last node if N.len() is odd) and replace with BLAKE3("scruple-merkle-node" || left || right).
  3. For an empty list, return [0u8; 32].

The block header commits to both txid and wtxid trees:

tx_root     = merkle_root([tx.txid()  for tx in block.transactions])
wt_root     = merkle_root([tx.wtxid() for tx in block.transactions])
merkle_root = BLAKE3("scruple-block-root-v1" || tx_root || wt_root)

4.4 Mandatory Canonical Sorting & Signature Deduplication

Every non-coinbase transaction MUST satisfy all of the following consensus rules:

  1. Size & Bounds: encode(tx).len() <= 100,000; 1 <= inputs.len() <= 1,024; 1 <= outputs.len() <= 1,024; 1 <= auth.len() <= inputs.len().
  2. Strict Ascending Inputs: For all i, inputs[i] < inputs[i+1]. This guarantees canonical ordering and forbids duplicate inputs in a single pass.
  3. Non-Decreasing Outputs: For all i, outputs[i] <= outputs[i+1]. Eliminates change-position wallet fingerprinting.
  4. Output Validity: Every output has addr_version in {1, 2}, amount >= 1 (CONSENSUS_MIN_OUTPUT), and sum(outputs.amount) does not overflow u64. (Mempool relay and wallet builders enforce the higher non-consensus policy floor DUST_FLOOR = 5,000 grains.)
  5. UTXO Resolution & Maturity: Every OutPoint exists in the active UTXO set; if utxo.is_coinbase, then spend_height >= outpoint.height + coinbase_maturity; sum(inputs.amount) does not overflow u64 and sum(inputs.amount) >= sum(outputs.amount).
  6. Deduplicated, Strictly Sorted Auth (Mixed v1/v2 Supported): Compute the sorted unique set of (addr_version, addr_hash) pairs across all spent UTXOs. For every a in tx.auth, validate its canonical structure (for v2 multisig: 1 <= threshold <= pubkeys.len() <= 15, strictly ascending pubkeys, sigs.len() == threshold, strictly ascending signer_idx < pubkeys.len()) and derive (a.addr_version(), a.addr_hash()). The resulting list MUST be strictly ascending (auth_addr[i] < auth_addr[i+1]) and MUST equal the sorted unique spent (addr_version, addr_hash) set 1-to-1. Spending multiple UTXOs belonging to the same xsl1: or xsl2: address requires only one TxAuth entry, and a single transaction may cleanly mix xsl1: and xsl2: inputs.
  7. SQIsign Verification: For every a in tx.auth, verify over sighash:
    • SingleSig: verify_compressed(a.pubkey, sighash, a.sig) MUST succeed.
    • Multisig: for all M = a.threshold pairs (signer_idx, sig) in a.sigs, verify_compressed(a.pubkeys[signer_idx], sighash, sig) MUST succeed.
  8. Fee: fee = sum(inputs.amount) - sum(outputs.amount).

4.5 Block Validation Rules

For a candidate block at height = parent.height + 1:

  1. block.to_bytes().len() <= 1,000,000.
  2. header.version == 1.
  3. header.prev_hash refers to a known valid block (parent).
  4. Timestamp: header.timestamp > MTP_11(parent) (where MTP_11 is the element at len / 2 of the sorted timestamps of up to 11 consecutive ancestors ending at parent), and header.timestamp <= local_unix_time + 1,200.
  5. Difficulty: header.target_bits == next_target_bits(params, recent_headers(parent, 61)).
  6. Proof-of-Work: RandomX(seed(height, parent), header[0..85]) <= bits_to_target(header.target_bits).
  7. Merkle Root: transactions is non-empty and header.merkle_root == Block::compute_merkle_root(&transactions).
  8. Coinbase (transactions[0]): coinbase_height == Some(height), inputs and auth are empty, 1 <= outputs.len() <= 1,024, every output has addr_version in {1, 2} (allowing mining directly to an xsl2: multisig vault) and amount >= 1 (CONSENSUS_MIN_OUTPUT), and sum(cb.outputs) <= BLOCK_REWARD + total_fees (checked u64).
  9. Non-Coinbase Transactions (transactions[1..]): Validated sequentially against the pre-block UTXO set at spend_height = height. Spent inputs are removed immediately upon validating each transaction (preventing intra-block double spends), while newly created coinbase and transaction outputs are inserted into the UTXO set only after all transactions in the block succeed (prohibiting intra-block unconfirmed chaining).
  10. Fork Choice: Cumulative work cum_work(B) = cum_work(parent) + work_from_bits(B.target_bits) (saturating U256). The active chain is the valid chain with strictly greatest cum_work.

5. RandomX Proof-of-Work & Epoch Rotation

5.1 Compact Target (target_bits) and Work

target_bits is a 32-bit unsigned compact encoding:

  • exp = bits >> 24 — MUST satisfy 1 <= exp <= 32.
  • mant = bits & 0x00ff_ffff — MUST satisfy mant != 0 and (mant & 0x0080_0000) == 0.
  • The 3 big-endian bytes of mant are placed starting at byte index 32 - exp of a 32-byte zero-initialized big-endian buffer (truncated at index 32 if exp < 3), yielding a 256-bit unsigned integer target.
  • A 32-byte RandomX hash H (interpreted as a big-endian 256-bit unsigned integer) satisfies PoW iff H <= target.
  • Block work is defined deterministically as:
    work(target) = floor(2^256 / (target + 1))
                 = floor((2^256 - 1 - target) / (target + 1)) + 1
    
    (with work(2^256 - 1) = 1).

5.2 Automatic Epoch Rotation (No PoW Hard Forks)

RandomX uses a 32-byte seed key that rotates every 2,048 blocks with a 64-block lag so nodes can pre-initialize the next epoch's cache/dataset without stalling:

if height < 2048 + 64:                      // heights 1 ..= 2111
    seed = genesis_randomx_seed(params)
else:                                       // height >= 2112
    seed_height = floor((height - 64) / 2048) * 2048
    seed        = ancestor_block_hash(parent, seed_height)

Because seed is looked up along the candidate header's own ancestor chain, competing forks compute their RandomX keys deterministically without consensus ambiguity.

  • Validating nodes run RandomX in Light Mode (~256 MB RAM).
  • Solo miners may enable Full-Memory Mode (~2 GB shared RandomXDataset across N worker threads) for ~10x higher CPU hashrate on identical consensus rules.

6. Per-Block LWMA Difficulty Adjustment

Difficulty is recalculated for every block using an integer Linearly Weighted Moving Average (LWMA) over up to LWMA_WINDOW = 60 preceding intervals (N + 1 headers H[0..=N] ordered oldest to newest, where H[N] is the parent tip):

  1. If headers.len() < 2 (i.e. mining Block 1 on top of Genesis): return params.initial_target_bits.
  2. Let N = min(headers.len() - 1, 60) and T = 300.
  3. Initialize prev_ts = H[0].timestamp. For k = 1 ..= N:
    • this_ts_k = max(H[k].timestamp, prev_ts.saturating_add(1))
    • dt_k = clamp(this_ts_k - prev_ts, 1, 6 * T) (clamped to [1, 1800] seconds with monotonic prev_ts to resist timestamp-alternation manipulation).
    • prev_ts = this_ts_k
    • weighted_solvetimes += k * dt_k (saturating u64).
    • sum_work += work_from_bits(H[k].target_bits) (saturating U256).
  4. Compute target work using exact 320-bit intermediate multiplication (U256::mul_div_u64) to prevent intermediate overflow:
    expected_weighted = T * N * (N + 1) / 2
    avg_work          = floor(sum_work / N)
    next_work         = floor((avg_work * expected_weighted) / max(weighted_solvetimes, 1))
    
  5. Convert back to target:
    raw_target = max_target                               if next_work == 0
               = max(floor((2^256 - 1) / next_work), 1)   otherwise
    
  6. Apply single-block smooth clamp relative to the tip (tip_target = min(bits_to_target(H[N].target_bits), max_target)):
    min_step = min(max(floor(tip_target / 2), 1), max_target)
    max_step = max(min(tip_target * 2, max_target), min_step)
    clamped  = min(clamp(raw_target, min_step, max_step), max_target)
    
  7. Return target_to_bits(clamped).

All arithmetic is exact unsigned integer math (u64 / U256) with zero floating-point operations.


7. Deterministic Genesis Block & Epoch-0 Seed

Each network (mainnet, testnet, devnet) derives a deterministic, hardcoded Genesis Block (Height 0) and RandomX Epoch-0 Seed (Heights 1..=2111) directly from its network seed and genesis timestamp with zero external dependencies.

7.1 Genesis Commitment & Epoch-0 Seed Derivation

Let genesis_seed be the ASCII network seed ("scruple-mainnet-genesis-v1" for Mainnet, "scruple-testnet-genesis-v1" for Testnet, "scruple-devnet-genesis-v1" for Devnet) and genesis_timestamp be the u64 Unix timestamp (little-endian; 1796256000):

genesis_preimage     = genesis_seed || genesis_timestamp (u64_le)

genesis_commitment   = BLAKE3("scruple-genesis-v1" || genesis_preimage)
genesis_randomx_seed = BLAKE3("scruple-rx-genesis" || genesis_preimage)

The deterministic Genesis Block (Height 0) is constructed as:

  • transactions = [Transaction::new_coinbase(height=0, reward_addr=genesis_commitment, amount=100_000_000)] (unspendable burn output; never inserted into the active UTXO set)
  • header.version = 1
  • header.prev_hash = genesis_commitment
  • header.merkle_root = Block::compute_merkle_root(&transactions)
  • header.timestamp = genesis_timestamp
  • header.target_bits = params.initial_target_bits
  • header.nonce = 0
  • genesis_hash = header.block_hash() = BLAKE3("scruple-header-v1" || header[0..85])

7.2 Inspecting the Genesis Block

Run the deterministic genesis inspector locally for any network:

scruple genesis --network mainnet

Confirm that the printed genesis_hash and randomx_epoch0_seed match the running node (scruple info) bit-for-bit.


8. Non-Consensus Node Policy & Transport Overview

The following rules are local node/network policy (not consensus-critical, so nodes may tune limits without forking):

  • Mempool Anti-DoS, Policy Dust, Ownership-Proven FSS-RBF & 0-Conf Protection:
    • Minimum relay fee rate: 1 grain / byte (MIN_RELAY_FEE_PER_BYTE).
    • Mempool/wallet dust floor: 5,000 grains (DUST_FLOOR, 0.00005 XSL), enforced on mempool acceptance and wallet coin selection while keeping consensus minimum output at 1 grain so fee-market changes never require a consensus fork.
    • Bounded mempool memory cap: 50,000,000 bytes (MAX_MEMPOOL_BYTES), evicting lowest fee-rate transactions when full, plus a 72-hour expiration TTL (DEFAULT_MEMPOOL_TTL_SECS = 259,200) and periodic 5-minute rebroadcast of aged unconfirmed transactions.
    • Ownership-Proven First-Seen-Safe RBF (MSG_TX_BUMP = 12): Stuck unconfirmed transactions can be fee-bumped without compromising 0-conf commerce. A TxBump { tx, shrink_proofs } replaces conflicting mempool transaction(s) iff: (a) tx strictly raises both the fee rate (>= max_old_rate + 1 gr/B) and total fee (>= sum_old_fees + new_size * 1 gr/B); (b) every output of every conflicted mempool transaction is preserved at >= its original amount (exact multiset match), EXCEPT any output reduced or removed MUST be accompanied by a valid TxAuth signature over BLAKE3("scruple-rbf-shrink-v1" || old_txid || new_txid) proving the output recipient (i.e. the sender's own change key) authorized shrinking it (capped at MAX_RBF_SHRINK_PROOFS = 4). A sender with a single UTXO can shrink their own change to bump the fee, or add extra confirmed UTXOs (0 shrink proofs) for 1-output Send Max txs, while merchants' 0-conf outputs can never be reduced, redirected, or removed on honest nodes.
    • Zero-Conf Double-Spend Proofs (MSG_DSPROOF = 13): Whenever a node receives a cryptographically valid conflicting transaction that attempts an unauthorized double-spend (without valid FSS-RBF shrink proofs), it rejects the conflict, constructs a compact DoubleSpendProof { outpoint, original_txid, conflicting_tx }, broadcasts it to all peers via MSG_DSPROOF, and exposes "double_spend_detected": true on get_tx and the dsproofs RPC endpoint.
  • Persistent Storage, Pruning, Ever-Seen Address Index & Transaction Index:
    • Disk-backed embedded database (redb) storing headers, height index, cumulative work, active UTXO set, raw block bytes, per-block undo logs (for fast, bounded-RAM restarts and reorgs), a compact seen_addrs table (32 B per ever-confirmed addr_hash, surviving spends and pruning so HD gap-limit recovery never stops early across 20+ spent addresses), and an optional tx_index table (txid [32 B] -> (height u64_le, tx_index u32_le)).
    • Optional pruning (--prune <N>, CLI/GUI minimum 288 blocks) retains all headers, the full active UTXO set, and seen_addrs while discarding raw block bodies and undo logs older than the most recent N blocks.
    • Optional --txindex maintains tx_index atomically across tip extensions and chain reorganizations (backfilling from unpruned blocks on startup if needed) and is mutually exclusive with --prune / pruned databases.
  • P2P Transport, Discovery & Privacy:
    • Framed TCP ([4B p2p_magic][1B kind][4B len_le][payload], MAX_FRAME_LEN = MAX_BLOCK_SIZE + 128) where p2p_magic is per-network ("XSL1" Mainnet, "XSLT" Testnet, "XSLD" Devnet), so peers from different networks reject each other immediately at the 4-byte framing header.
    • Persistent peer connections with Ping/Pong keepalives, bounded slots (MAX_OUTBOUND = 8, MAX_INBOUND = 32), /16 IPv4 and /32 IPv6 outbound subnet diversity for all gossiped/DNS/persisted peers (while operator-specified --peer / RPC add_peer targets bypass subnet diversity to permit home-LAN full-mesh clusters), GetPeers/Peers gossip, headers-first sync with global cross-peer in-flight block deduplication (GetHeaders → Headers → GetBlock → Block), and misbehavior ban scoring (threshold 100 → 1-hour IP ban).
    • External Address Advertisement (--external-addr): Advertises a public numeric IP:port (e.g. <PUBLIC_IP>:18333 on mainnet or <PUBLIC_IP>:28333 on testnet; numeric IP required for peer gossip) in MSG_HELLO instead of the local bind address (essential when binding 0.0.0.0:<port> on a VPS) and treats the advertised address and its resolved IPs as self in self-dial checks.
    • DNS Seed Bootstrapping & peers.json Persistence: Built-in DNS seeds (seed{1,2,3}.scruple.money:18333 on Mainnet, seed{1,2,3}.testnet.scruple.money:28333 on Testnet, disabled via --no-dns-seeds) are resolved asynchronously via ToSocketAddrs on startup and periodically when isolated (0 connected peers), expanding all returned A/AAAA records into candidate peers; DNS failures log gently and never panic or ban. Healthy non-banned peers are persisted atomically to <data-dir>/peers.json (mode 0600, capped at 256 entries) periodically and on clean shutdown, and reloaded on restart.
    • Dandelion++ & Fast-Fluff POS Mode: Originated transactions enter a stem phase routed along a per-epoch (10-minute) relay peer with an embargo timer (20 seconds) that automatically falls back to fluff broadcast if the transaction is not observed fluffed (and defers flushing while a node has 0 peers so locally submitted transactions are never silently dropped during brief disconnects). Senders may pass fast_fluff: true (CLI --fast-fluff) on submit_tx to bypass stem delay for instant 0-conf POS commerce.
  • JSON-RPC Authentication & Explorer Endpoints:
    • Local HTTP JSON-RPC server generates a fresh 32-byte random hex .cookie file (Unix mode 0600) in --data-dir on every node startup/restart (replacing any previous token) and requires valid X-Scruple-Cookie or HTTP Basic (__cookie__:<hex>) authentication using constant-time comparison on every request.
    • info reports chain/mempool/peer status including txindex: bool, clock_skew_warnings: u64, and dsproof_count: usize.
    • seen_addresses ({"addr_hashes": [...]}) returns the subset of address hashes ever confirmed on-chain (including spent/pruned outputs) or currently present in the mempool.
    • bump_tx ({"bump_hex": "<hex>"}) validates and relays an Ownership-Proven FSS-RBF TxBump.
    • dsproofs lists active 0-conf double-spend proofs; get_tx also reports "double_spend_detected": bool.
    • get_tx ({"txid": "<64-hex>"}) returns decoded transaction details, resolved input prevouts (address, amount), fee, fee_per_byte, confirmations, double_spend_detected, and raw_hex for mempool transactions (always available) and confirmed transactions (requires --txindex).
    • get_block ({"height": <u64>} or {"hash": "<64-hex>"}, optional "verbose": true) returns block metadata and raw hex; when verbose: true, also includes decoded "txs" with resolved inputs, outputs, and fees.
    • get_headers (optional "from_height", optional "count" defaulting to 100 and capped at 2000; omitting from_height returns the most recent count headers ending at tip) returns { tip_height, headers } including per-block PoW work (64-char hex), tx_count, and bytes.
  • HD Encrypted Wallet Standard:
    • 24-word BIP-39 mnemonic (from OS RNG or Bring-Your-Own-Entropy dice rolls scruple-byoe-dice-v1, coin flips scruple-byoe-coins-v1, 64-char hex scruple-byoe-hex-v1, or text scruple-byoe-text-v1) → 64-byte seed → child_seed = BLAKE3("scruple-hd-v1" || master_seed_64 || index_u32_le) → ChaCha20Rng::from_seed(child_seed) → deterministic SQIsign Round-3 Level 1 keypairs, supporting gap-limit (DEFAULT_GAP_LIMIT = 20) UTXO recovery across all receiving and change addresses.
    • Optional at-rest encryption using Argon2id KDF (m=19456 KiB, t=2, p=1) + ChaCha20-Poly1305 AEAD with atomic 0600 file writes and secret zeroization on drop, pending outgoing UTXO tracking, per-UTXO freezing (frozen_outpoints), address/UTXO labeling (labels), and exact byte-rate coin control & Send Max sweeps.

Scruple · Specification v1.0 · December 2026

Prefer the narrative version? Read the whitepaper.