℈Scruple Docs v0.1.0-alpha.1

Wallet

Wallet

Create a deterministic post-quantum HD wallet, protect it at rest, and spend safely with explicit coin control.

The phrase is the wallet

A single 24-word BIP-39 mnemonic deterministically recovers every receive and change address. Write it down offline before receiving funds. If you lose both the phrase and every copy of the wallet file, the funds are unrecoverable.

HD wallet model

Scruple wallets are deterministic HD wallets built on SQIsign Round-3 Level 1:

  1. A 24-word BIP-39 mnemonic yields a 64-byte master seed.
  2. For each index, child_seed = BLAKE3("scruple-hd-v1" || master_seed_64 || index_u32_le).
  3. The child seed initializes ChaCha20Rng, which deterministically derives an SQIsign keypair.
  4. Even indices 0, 2, 4, ... are external receive addresses. Odd indices 1, 3, 5, ... are internal change addresses.
  5. New receive addresses skip indices already used on-chain, and rescan uses a gap limit (DEFAULT_GAP_LIMIT = 20) plus the node's ever-seen address index to discover spent addresses.
PropertyValue
Mnemonic length24 words (256-bit entropy)
Master seed64 bytes from BIP-39
HD domainscruple-hd-v1
Receive indicesEven: 0, 2, 4, ...
Change indicesOdd: 1, 3, 5, ...
Default gap limit20 consecutive unused addresses
Signature schemeSQIsign Round-3 Level 1, 83-byte public key, 176-byte compressed signature

Create a wallet

./target/release/scruple wallet new \
  --wallet ./wallet.json \
  --encrypt

The command prints the 24-word phrase once and derives receive address index 0. With --encrypt, it prompts for a passphrase without echo and stores the wallet encrypted with Argon2id (m=19456 KiB, t=2, p=1) and ChaCha20-Poly1305, using atomic 0600 writes.

If the wallet file already exists, wallet new derives and prints the next receive address instead of overwriting the file. --encrypt and BYOE entropy flags only apply when creating a new file.

Passphrase handling

MethodBehaviour
--encryptPrompts for a passphrase without echo. Recommended for interactive use.
SCRUPLE_PASSPHRASEEnvironment variable for non-interactive scripts and services. Recommended over --passphrase.
--passphrase <STR>Explicit passphrase. Convenient but visible in shell history and ps; use with care.

Bring-your-own-entropy (BYOE)

You can generate the wallet from user-supplied entropy instead of relying solely on the OS RNG. By default, 32 bytes of OS RNG are mixed with the BYOE input. Pass --no-mix-os-rng for pure deterministic user entropy, subject to minimum input requirements.

FlagInputMinimum for pure BYOE
--entropy-dice <ROLLS>6-sided dice rolls, characters 1–6, whitespace ignoredAt least 99 rolls
--entropy-coins <FLIPS>Coin flips, characters 0/1/H/T, whitespace ignoredAt least 256 flips
--entropy-hex <HEX>Exactly 64 hex characters (32 bytes)Exact 32 bytes
--entropy-text <TEXT>Arbitrary text hashed into 32 bytesAt least 32 bytes of text

Specify at most one BYOE source. --no-mix-os-rng requires one of the BYOE flags.

# Mix 120 dice rolls with OS RNG
./target/release/scruple wallet new \
  --wallet ./byoe.json \
  --entropy-dice "415263..." \
  --encrypt

# Pure 256-bit hex entropy (no OS RNG mixing)
./target/release/scruple wallet new \
  --wallet ./byoe-hex.json \
  --entropy-hex <64-hex> \
  --no-mix-os-rng \
  --encrypt

Recover a wallet

./target/release/scruple wallet recover \
  --wallet ./recovered.json \
  --encrypt

If --mnemonic is omitted, the command prompts on stdin so the phrase does not appear in shell history. The destination wallet file must not already exist. --gap-limit controls how many initial receive addresses are derived; the default is 20.

After recovery, run a rescan against a synced node to discover every used receive and change address and the associated UTXOs:

./target/release/scruple wallet rescan \
  --data-dir ./mainnet-data \
  --rpc 127.0.0.1:18332 \
  --wallet ./recovered.json
Rescan mechanics

Rescan queries the node's utxos and seen_addresses methods in chunks of up to 1,000 address hashes. It expands past the gap limit when it finds used addresses, including spent addresses that no longer have UTXOs, so recovery does not stop early across long gaps.

Wallet lock

Mutating or signing commands acquire an exclusive OS-level lock on <wallet>.lock (mode 0600). The OS releases the lock automatically on exit or crash. This prevents concurrent CLI and GUI processes from clobbering the wallet or reusing HD indices.

CommandHolds the lock?
wallet new, wallet recover, wallet rescan, wallet clear-pendingYes
send, bump-fee, mine --walletYes, with a brief re-acquire while mining rotates payout addresses
multisig signYes
wallet list, wallet pubkey, balanceNo exclusive lock for the read-only path
scruple-guiHolds the lock for the open wallet while the GUI runs

If a lock is held, the command returns a wallet-locked error instead of corrupting state. Wait for the other process to exit or close the wallet in the GUI.

List addresses and export public keys

# List derived receive/change addresses; optionally show checksummed Bech32m forms
./target/release/scruple wallet list --wallet ./wallet.json
./target/release/scruple wallet list --network mainnet --wallet ./wallet.json

# Print the 83-byte SQIsign public key hex for cosigner coordination
./target/release/scruple wallet pubkey --wallet ./wallet.json --index 0

wallet list also shows wallet type, encryption status, key count, pending outgoing UTXOs, and recent local transactions. The pubkey command prints 166 hex characters (83 bytes) for the requested HD index.

Check balance

./target/release/scruple balance \
  --data-dir ./mainnet-data \
  --rpc 127.0.0.1:18332 \
  --wallet ./wallet.json

The balance command reports mature, immature, and pending outgoing amounts. Immature coinbase outputs cannot be spent until the network's coinbase maturity is reached. Pending outgoing UTXOs are locked locally to prevent accidental double-spends while a broadcast transaction is unconfirmed.

Send XSL

Single recipient

./target/release/scruple send \
  --data-dir ./mainnet-data \
  --rpc 127.0.0.1:18332 \
  --wallet ./wallet.json \
  --to xsl1:<64-hex> \
  --amount 0.4 \
  --fee-rate 1
FlagDescription
--to <ADDR>Recipient address. Bech32m or legacy xsl1:/xsl2: forms are accepted. Required.
--amount <XSL>Exact decimal XSL amount, up to 8 decimals. Must be greater than zero.
--send-maxSweep all selected (or all economical mature spendable) UTXOs minus fee into one output with zero change.
--fit-maxWith --send-max, sweep the maximum batch of UTXOs that fits in one transaction when the wallet holds more than the transaction size limit allows.
--fee-rate <GR/B>Fee rate in grains per serialized byte. Minimum 1. Defaults to 1.
--fee <XSL>Explicit fee override in XSL. The wallet floors it at exact bytes × fee rate.
--coin <HEIGHT:TX:OUT>Repeatable explicit UTXO selection for coin control.
--fast-fluffBypass Dandelion++ stem delay and immediately fluff-broadcast. Useful for 0-conf point-of-sale.

Multi-recipient batch

./target/release/scruple send \
  --data-dir ./mainnet-data \
  --rpc 127.0.0.1:18332 \
  --wallet ./wallet.json \
  --to xsl1:<hex-a>=0.25 \
  --to xsl2:<hex-b>=1.5 \
  --fee-rate 1

Batch mode uses repeatable --to <address>=<XSL> entries. It cannot be combined with --amount, --send-max, or --fit-max.

Coin control

./target/release/scruple send \
  --data-dir ./mainnet-data \
  --rpc 127.0.0.1:18332 \
  --wallet ./wallet.json \
  --to xsl1:<64-hex> \
  --amount 0.4 \
  --coin 12345:2:0 \
  --coin 12350:1:1 \
  --fee-rate 2

Explicit coins must exist among the wallet's UTXOs and must be mature. Frozen UTXOs are excluded from automatic selection and rejected by explicit coin control until unfrozen in the GUI.

Fee behaviour

  • Transactions are sized from the exact serialized bytes, including SQIsign authorization entries.
  • Sub-dust change is absorbed into the miner fee, and the CLI prints a warning with the absorbed amount.
  • The wallet enforces a non-consensus dust floor of 5,000 grains (0.00005 XSL) for standard outputs. The consensus minimum is 1 grain.
  • Change returns to a fresh internal change address (odd HD index) when a change output is needed.
  • Before broadcast, the wallet persists the pending spend and derived change key so a crash cannot lose the double-spend lock. If the RPC call fails, the pending state is rolled back.

Bump a stuck transaction

./target/release/scruple bump-fee \
  --data-dir ./mainnet-data \
  --rpc 127.0.0.1:18332 \
  --wallet ./wallet.json \
  --txid <64-hex> \
  --fee-rate 3

Fee bumps use Ownership-Proven First-Seen-Safe RBF. The new transaction must strictly raise both the fee rate (at least the old rate plus 1 grain/byte) and the total fee, while preserving every recipient output at or above its original amount. The sender can shrink their own change output by attaching a valid TxAuth signature over the shrink proof. Merchant outputs can never be reduced, redirected, or removed on honest nodes.

--txid identifies the stuck unconfirmed transaction. --fee-rate is the target new rate in grains per serialized byte.

Clear pending spends

./target/release/scruple wallet clear-pending --wallet ./wallet.json

If a broadcast transaction expired, was dropped, or was replaced and the local pending state is stale, this escape hatch clears the local pending outgoing UTXO locks and pending raw transactions. Use it only when you are sure the transaction is no longer expected to confirm.

Address formats

Scruple supports two address encodings for two output versions:

VersionBech32m examplesLegacy examplesMeaning
1xsl1p... (mainnet), txsl1p... (testnet), dxsl1p... (devnet)xsl1:<64-hex>Single-key SQIsign address.
2xsl1z... (mainnet), txsl1z... (testnet), dxsl1z... (devnet)xsl2:<64-hex>Native M-of-N SQIsign multisig vault.

Bech32m addresses carry a network-scoped human-readable prefix and a 6-character BCH checksum, so typos and cross-network sends are rejected client-side. Legacy hex addresses remain accepted for backward compatibility. The addr_hash inside an address is a 32-byte BLAKE3 commitment, not the public key itself.

Network mismatch

A mainnet Bech32m address starts with xsl1; testnet starts with txsl1; devnet starts with dxsl1. Sending a testnet address on mainnet fails validation. Legacy xsl1: hex addresses do not encode a network, so double-check the destination when using them.

Wallet file and encryption details

PropertyValue
At-rest encryptionArgon2id KDF (m=19456 KiB, t=2, p=1) + ChaCha20-Poly1305 AEAD
File permissions0600 on Unix, atomic writes
Secret handlingSecret material is zeroized on drop
Lock file<wallet>.lock, mode 0600, automatically released on exit or crash
Pending statePending outgoing UTXOs, raw pending transactions, frozen outpoints, labels, and lifecycle statuses

The wallet file contains the encrypted master seed and derived key records. Back it up, but remember that the 24-word phrase is the ultimate recovery mechanism. Test a recovery on a separate machine before relying on a backup.

Safety checklist

  • Write the 24-word phrase on paper or metal and store it offline.
  • Use --encrypt or SCRUPLE_PASSPHRASE; avoid --passphrase in shared shells.
  • Verify the recipient address character-by-character, especially the Bech32m checksum and network prefix.
  • Start with a small test transaction before sending a large amount.
  • Keep the node and wallet on machines you control; RPC is plaintext HTTP.
  • Do not run two mutating processes against the same wallet file; the lockfile is there to stop you.
  • After restoring from a phrase, run wallet rescan against a synced node before assuming a zero balance.

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.