Files
dragonx/doc/zsweep-consolidation.md
T
DanSandClaude Opus 5.5 5d5b47d05a wallet/rpc: z_consolidate is not safe-mode; say which units it uses
z_consolidate creates and broadcasts transactions, so like z_sendmany
and z_shieldcoinbase it must not run in safe mode. Its fee argument is
in DRGX, like z_sendmany's, while -consolidationtxfee and every amount
in z_consolidationstatus are in puposhis; the help and the doc now say
so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 12:59:46 -05:00

9.6 KiB

zsweep and consolidation

This is to document zsweep and consolidation for advanced DragonX users.

Warning: If you don't know what Zsweep or Consolidation are, there is a good chance that you will not be using these advanced options. User beware!

Table of Contents

  1. Using Zsweep
  2. Using Consolidation
  3. Using Zsweep & Consolidation Together

Pre-Step & Further Details

A user can use these options at the command line, but it is recommended to configure these options within the DRAGONX.conf file.

Consolidation merges many unspent shielded notes (zutxos) of one z-address into a few notes of that same address, which makes spending them later faster and cheaper, keeps the wallet smaller and shortens witness rebuilds and rescans. It never moves funds between addresses. Both zsweep and consolidation are off by default in dragonxd, for CLI nodes and for GUI wallets that run an embedded dragonxd alike (the ObsidianDragon GUI does its own, separate auto-consolidation through z_mergetoaddress).

Zsweep is when you sweep numerous zutxos into one z-address that you configure. This z-address can be local to that system or it can be configured to sweep to a remote wallet on a different system with the zsweepexternal=1 option, which is explained below in the Zsweep section.

Zsweep

  1. We add the following to our conf file as per the Pre-Step.

    zsweep=1
    zsweepaddress=zs1...
    
  2. The above zsweepaddress will be the z-address you want to sweep into (zs1... is a placeholder for this documentation) and it must exist within the same local wallet you are configuring this for. If you want to zsweep to an address on another computer, then set zsweepexternal=1 as explained in the options below.

  3. The following are optional zsweep settings with their details:

    Zsweep Option Name Details of what it does
    zsweepexternal=1 Will enable the option to zsweep to an "external" z-address which exists in a wallet on a different system.
    zsweepinterval=10 By default zsweep runs every 10 blocks (values below 5 fall back to 10), so set and modify this value to change that.
    zsweepmaxinputs=8 By default zsweep makes sure to not reduce the anonset in any tx by having a maximum number of inputs of 8. This should be fine for new wallets, but if you have an existing wallet with many zutxos it can be changed with this option. Keep in mind that large values will make sweeping faster at the expense of reducing the AnonSet.
    zsweepfee=0 The default zsweep fee is 10000 puposhis or 0.0001 DRAGONX, the default for all transactions. To use fee=0 for zsweep transactions, set this option.
    zsweepexclude=zs1... Exclude a certain address from being swept. Can be used multiple times to exclude multiple addressses
  4. The following DragonX RPC will let you view your zsweep configuration options and run-time stats at the command line: dragonx-cli z_sweepstatus

Consolidation

Mining with auto-shielding on (the default for wallets created or restored by dragonxd) adds one shielded note to the wallet per auto-shield round. Over weeks that is thousands of small notes, which slow down sends, balance calls and witness rebuilds. Consolidation keeps that in check.

What a round does

  • An address is consolidated only when it holds more than consolidationthreshold (default 25) eligible notes: unspent (also not spent by a transaction still in the mempool), not locked by another operation, spendable by this wallet, and at least 11 confirmations deep. Addresses at or below the threshold are left alone.
  • For each such address a round sends up to consolidationmaxtxs (default 3) transactions. Each spends up to consolidationbatchsize (default 15) of the address's smallest notes and pays their value, minus the fee, back to the same address. The big note an earlier round produced is therefore not merged again every round.
  • The number of inputs per transaction is drawn at random between two thirds of the batch size and the batch size (10 to 15 by default), so rounds don't all look alike. A transaction never takes an address's last remaining note, so every address keeps at least one spendable note while the round confirms.
  • Each transaction has exactly 8 shielded outputs: the real one plus 7 zero-value dummy ("Sietch") outputs to random addresses, so it does not shrink the anonymity set. It pays consolidationtxfee, or no fee when its notes are worth no more than the fee, and expires 15 blocks after it is made.
  • Only the notes a round actually spends are locked while it proves, so sends made meanwhile still see the rest of the wallet.
  • All spends of one transaction must use one anchor (Sapling tree root). An address's spends use the tip's root, where the wallet keeps its witnesses, or else the chain anchor most of its planned notes are at. A note without a witness, or whose witness root the chain never had (a desynced witness), is skipped and the round goes on without it; so is, until a later round, a note whose witness is at another real anchor. Each round logs how many it skipped (last_round.skipped_notes).
  • If one transaction fails to build or is not accepted, the rest of that address's transactions are skipped for the round, but the other addresses still get theirs; last_round.error gives the first failure.
  • With the defaults, an address over the threshold loses 27 to 42 notes per round, and a round runs every 25 blocks.
  • dragonxd runs one async operation at a time. So that a z_sendmany (or any other async RPC) made during a round does not wait for all of it, the round ends after its current transaction when another operation is queued (last_round.yielded); the notes it did not get to are unlocked and taken up by the next round. A node that is asked to stop also ends the round after the current transaction.

Turning it on

  1. Add the following to the conf file as per the Pre-Step.

    consolidation=1
    
  2. The following are optional consolidation settings with their details:

    Consolidation Option Name Details of what it does
    consolidationinterval=25 Blocks between rounds (default 25, minimum 5; smaller values are raised to 5).
    consolidationthreshold=25 Only addresses with more than this many eligible notes are consolidated (default 25, minimum 1).
    consolidationbatchsize=15 Most notes one consolidation transaction spends (default 15, clamped to 2..50).
    consolidationmaxtxs=3 Most consolidation transactions per address per round (default 3, clamped to 1..100).
    consolidationtxfee=10000 Fee in puposhis per consolidation transaction (default 10000 = 0.0001 DRAGONX; allowed range 1000..10000000, anything else falls back to the default).
    consolidatesaplingaddress=zs1... Only consolidate this address (may be given several times). The default is every address the wallet can spend. With consolidation=1 the wallet must hold the address's spending key, or dragonxd refuses to start; with it off, such an address is ignored with a warning (and z_consolidate works on all addresses unless given its own).
  3. dragonx-cli z_consolidationstatus shows the settings, whether a round is running, when the next one is due, cumulative totals (notes_consolidated, amount_consolidated in puposhis), the last round (last_round: height, time, txids, notes merged, amount merged, notes skipped, error) and, when rounds can't run, why (disabled_reason). dragonx-cli z_consolidationstatus true also counts the eligible notes of every address and lists which are over the threshold (this walks the whole wallet, so it is only done on request).

Consolidating on demand

dragonx-cli z_consolidate runs one round now with the current settings, also when consolidation is off, so a CLI miner can clean up whenever it suits them. It takes optional overrides, in order: fee (in DRAGONX), batch size, maximum transactions per address, and a JSON array of addresses; pass null to keep a setting, e.g. dragonx-cli z_consolidate null 50 20 '["zs1..."]'. Its fee is in DRAGONX like z_sendmany's, while consolidationtxfee and the amounts in z_consolidationstatus are in puposhis. It returns an operation id; z_getoperationstatus / z_getoperationresult give the result. It refuses while the node is syncing, while the wallet is locked, and while a consolidation, zsweep or auto-shield round is in flight.

Off, but suggested

When consolidation is off and some address has more notes than the threshold, dragonxd logs once after loading the wallet: N addresses have more than 25 spendable notes; consider -consolidation=1 or z_consolidate. z_autoshieldstatus then reports consolidation_suggested: true, and z_consolidationstatus true reports consolidation_suggested and consolidation_suggested_count.

Zsweep & Consolidation Together

  1. We add the following to our conf file as per the Pre-Step.

    zsweep=1
    zsweepaddress=zs1...
    consolidation=1
    
  2. Then follow along with the zsweep section above if you want to set specific options for the zsweep behavior.

  3. With zsweep on, consolidation only works on the sweep address: a consolidatesaplingaddress other than the sweep address is refused at startup (with consolidation=0 it is replaced by the sweep address, with a warning), and z_consolidate refuses any other address too. Sweep and consolidation never run at the same time, and a sweep is not started when a consolidation round is due within 5 blocks.

The DragonX Developers, jahway603, and The Hush Developers

License

GPLv3