Skip to main content
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

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

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

sparkcli unilateralexit --testmode=true

sparkcli unilateralexit

sparkcli getleaves
sparkcli checktimelock <leaf-id>

sparkcli testonly_expiretimelock <leaf-id>
sparkcli signfeebump <psbt> <private_key>