There are two ways to exit Spark and withdraw funds to Bitcoin L1: cooperative and unilateral exits.

Cooperative Exit

In a cooperative exit, the user and SE work together to create a new transaction that spends directly from the deposit transaction to the user’s desired Bitcoin address. This is the most efficient and cost-effective method, as it requires only a single on-chain transaction.

  1. Transaction Creation: The user and SE collaborate to create a transaction that spends from the deposit transaction’s output directly to the user’s desired Bitcoin address.
  2. Signing: Both the user and SE sign this transaction using their respective private keys.
  3. Broadcasting: The signed transaction is broadcast to the Bitcoin network.
  4. Confirmation: Once confirmed, the funds are available in the user’s Bitcoin address.

Unilateral Exit

If the SE is unavailable or uncooperative, the user can perform a unilateral exit using the pre-signed exit transactions created during the deposit and transfer processes.

  1. Broadcasting Branch Transaction: The user broadcasts the branch transaction that was signed during the deposit process.
  2. Waiting for Confirmation: Once the branch transaction is confirmed, the user waits for the relative timelock to expire.
  3. Broadcasting Exit Transaction: After the timelock expires, the user broadcasts the exit transaction that was signed during the deposit or most recent transfer.
  4. Confirmation: Once confirmed, the funds are available in the user’s Bitcoin address.

The unilateral exit process ensures that users always have control over their funds, even if the SE becomes unavailable or malicious. This is a critical aspect of Spark’s self-custody design, providing users with the security and sovereignty that Bitcoin was designed to offer.