# Class BSV::Wallet::CLI::Commands::Sweep <a id="class-BSV-Wallet-CLI-Commands-Sweep"></a>

**Inherits:** `BSV::Wallet::CLI::Commands::Base`

+bin/wallet sweep --to=<root_key_hex>+ — drain every spendable output back to
the recipient's root P2PKH address.

Blank-slate operational tool. Locks a single caller output to the recipient's
**root** P2PKH (literal +hash160(recipient_pubkey)+, NOT a BRC-42-derived
address), so the receiving wallet's DB can be wiped and re-imported by
scanning the root address with +bin/wallet import+. Any rounding surplus
against the actual fee is dropped on the funding loop's change-key slot.

<code>--to</code> takes the recipient's 66-char compressed pubkey hex (02/03
prefix); the engine's <code>validate_recipient_key!</code> is a second line of
defence after CLI-side `parse_pubkey_hex`. <code>--no-send</code> keeps the
swept action unsubmitted (built and signed, but never broadcast). BEEF
emission for peer-to-peer handoff is not currently exposed — operators wanting
the BEEF bytes can pull them from the engine's return via direct API access,
or wait for a future <code>--emit-beef</code> flag.

Empty-pool case (engine returns nil) is reported as "nothing to sweep" without
an error — sweeping an empty wallet is a no-op, not a failure. Dust-only
wallet (fee exceeds total) raises `InsufficientFundsError` → exit 1 with the
engine's message.

## Public Instance Methods
### `build_parser()` <a id="method-i-build_parser"></a> <a id="build_parser-instance_method"></a>
Not documented.

### `call(args)` <a id="method-i-call"></a> <a id="call-instance_method"></a>
- **@raise** [UsageError]

### `name()` <a id="method-i-name"></a> <a id="name-instance_method"></a>
Not documented.
