A unilateral exit allows you to withdraw funds from Spark without requiring anyone else’s permission. If you choose not to trust Spark anymore or if Spark were to shut down, you can still retrieve your money.
Critical Requirements:
  • Only exit leaves > 16,348 sats (smaller amounts cost more in fees than they’re worth)
  • Must complete entire process in single session - wallet unusable until finished
  • Transactions must be broadcast from root to leaves in exact order shown
  • Bitcoin Core V29 required for ephemeral anchors
  • Beta feature: we’re fixing bugs as we find them

Cost Considerations

Unilateral exits are expensive - way more than cooperative exits:
  • Fee calculation: ~315 * sats_per_vbyte * (depth+3) per leaf
  • Each tree level adds ~1500 sats in fees
  • Fees vary with L1 network conditions (currently ~5 sats/vbyte)
The chart below shows how much you’d actually get back at different wallet sizes and how much is lost to fees: Unit Costs
  • Blue (L1): Final amount returned to you on Bitcoin L1 after completing the unilateral exit.
  • Red (Fees): Total BTC fees paid to execute the exit (varies with balance size and tree depth).
  • Green (Spark): Gross balance left on Spark after initiating the exit.
For smaller amounts, use cooperative exits or Lightning withdrawals instead.

Tree Structure Basics

Your Spark funds are organized in a tree:
  • Each “leaf” = portion of your funds with different values/timelocks
  • Deeper leaves = more transactions required to exit
  • Broadcasting order matters: root → leaves

Getting Started

1. Check Your Leaves

sparkcli getleaves
Example output:
Leaf ID: 019765d1-ad06-79ed-b30e-0afc064c5a1b
  Value: 16384 sats
  Status: AVAILABLE
  Tree ID: 019765d1-ac2e-7ec8-ac37-c77ea070237d

2. Start Interactive Exit

# Regtest only - auto-handles timelocks and fee signing
sparkcli unilateralexit --testmode=true
Important: Use --testmode=true ONLY on Regtest. Mainnet users must use the regular flow without testmode to properly handle timelocks and manual fee signing.
The CLI guides you through:
  • Leaf selection
  • Timelock handling (auto-refreshed in test mode)
  • UTXO generation for fees
  • Transaction creation and signing
  • Broadcast order instructions

Regtest Testing

Test on regtest first - don’t learn on mainnet.

Setup

  • Initialize wallet and deposit 131,072 sats for testing
  • Use regtest faucet (max 50,000 per deposit)
  • CLI auto-generates test wallet for fees

Broadcasting

Use https://regtest-mempool.us-west-2.sparkinfra.net/tx/push to submit packages in order. Wait ~1 min between packages for confirmation.

Mainnet Usage

Prerequisites

  • Sufficient L1 Bitcoin UTXOs for transaction fees
  • Only exit leaves > 16,348 sats
  • Recommended: 131,072 sats deposit for better leaf sizes

Mainnet vs Regtest

  • UTXOs: Provide your own Bitcoin UTXOs when prompted
  • Broadcasting: Use bitcoin-cli submitpackage '["node_tx", "fee_bump_tx"]'
  • Costs: Real network fees apply

Process

  1. Check leaves with sparkcli getleaves
  2. Run sparkcli unilateralexit (no testmode - you’ll handle timelocks manually)
  3. CLI will walk you through it (bring your own UTXOs)
  4. Broadcast in exact order shown by CLI

Essential Commands

# Regtest: auto-handles timelocks and signing
sparkcli unilateralexit --testmode=true

# Mainnet: manual timelock and signing process
sparkcli unilateralexit

# Check leaf status
sparkcli getleaves
sparkcli checktimelock <leaf-id>

# Legacy commands (now built into main flow)
sparkcli testonly_expiretimelock <leaf-id>
sparkcli signfeebump <psbt> <private_key>