CoinJoin with Sparrow: How to anonymize your Bitcoins

Anyone who is deeply involved with Bitcoin and privacy will sooner or later come across something called a CoinJoin

In short, a CoinJoin is a protocol for improving on-chain privacy in which several participants create a joint transaction that contains Bitcoin from all participants and pays it out to new addresses of these participants. This makes it impossible to tell exactly which address belongs to which participant at the end.

A CoinJoin turns a few different-sized transactions into many of the same size – via wasabiwallet.io

Fortunately, these transactions don’t have to be built by hand. Some development teams have taken on this challenge, including Samourai, which provides one of the most popular CoinJoin implementations with its Whirlpool. Whirlpool can be used with both Samourai Wallet (Android) and Sparrow Wallet (Linux, Mac, Windows). Below you will find instructions on how to use Whirlpool with Sparrow Wallet.

Preparation

Download and verify Sparrow Wallet

Before we can use Whirlpool on our Mac, Linux or Windows, we need to download and install Sparrow Wallet. You can find the latest release of the software on the Sparrow Wallet repository.

After downloading, you can check the integrity of the software to make sure that you are actually installing the wallet application provided by the developer. For this purpose, Sparrow provides a manifest file with SHA256 checksums, as well as an associated PGP signature file.

Set up Sparrow Wallet

After you have installed the wallet software, you can start the setup process. When you start Sparrow Wallet for the first time, a setup wizard opens automatically, which explains the basics of the software. Furthermore, you have to decide where the wallet should get its blockchain data from. For maximum privacy, you should connect your own Fullnode/Electrum Rust server at this point.

Create a new wallet

Now you need to create or import a wallet. Below you can see how to create a BIP39 software wallet in Sparrow. You will find the option to create a new wallet via the setting tab.

Choose a name for your wallet and create a new software wallet.

Loading the Wallet

After you have created your new wallet, you will land on the transaction overview, which is of course currently still empty. In order to be able to load your Bitcoin CoinJoin in the next step, you must first send Satoshis to your new wallet. Just go to the Receive tab and send a few sats to the address of your wallet.

IMPORTANT: The smallest CoinJoin pool at Whirlpool is 100,000 sats, so send at least 110,000 sats to the wallet (The 10% extra is for the pool and mining fees, more on this later).

Perform a CoinJoin

Once you have sent coins to your new wallet and this transaction has received at least one confirmation, you can finally start CoinJoin.

To start you need to go to the UTXO tab of your wallet, select the Unspent Transaction Outputs (UTXOs) you want to mix and click on “Mix Selected”.

Coinjoin

Now a short explanation dialog will appear explaining the Samourai Whirlpool principle. Once you have started the first mix, Sparrow Wallet will create three new sub-accounts on your wallet. The Premix, the Postmix and the Badbank.

Premix, Postmix and Badbank

Since Whirlpool only works with inputs and outputs of the same size, it may well be that your coins first have to be chunked accordingly. For this purpose Sparrow creates a transaction that sends your coins from the Deposit account to the Premix account . Here the correct UTXOs are waiting for a place in the whirlpool

Once a place is found your UTXOs will be mixed together with 4 other inputs and then end up in the postmix account. This step is the actual CoinJoin. UTXOs that are in the postmix account can be remixed as often as you like without incurring a pool or mining fee.

The badbank is a kind of change cashbox for the parts of the initial transaction that are left after the denomination. To better illustrate the concept here is a small example:

We want to mix 1,000,000 sats in the 100,000 pool. In order for the mining fees to be settled, each premix UTXO must be 100,310 sats in size. To this is added the pool fee of 5,000 sats.

5000 + (9 * 100300) = 907790

So out of the 1,000,000, 92,210 sats remain. This remainder is too small to form another premix UTXO. If this remainder were now simply put together with the already mixed coins, third parties could link premix and postmix coins again through this change. To ensure that this does not happen, Samourai deposits these coins in the bad bank. These coins are by no means lost. We can leave them here for now and put them in the mixer at the next CoinJoin.

SCODE

SCODEs are discount codes that Samourai Wallet distributes from time to time, e.g. via Twitter. With them you save a part of the Whirlpool fee. If you don’t have one, just leave the field empty.

Whirlpool fees

Samourai does not offer the whirlpool for free. You have to pay for the mix, but it’s not the amount of coins we want to mix that determines the cost, but the pool size. Currently there are four different pools, each with their own UTXO size and fee. Choose your pool and proceed.

  • 100.000 Sats – entry fee 5.000 Sats
  • 1.000.000 Sats – entry fee 50.000 Sats
  • 5.000.000 Sats – entry fee 250.000 Sats
  • 50.000,000 sats – entry fee 2,500,000 sats

Broadcast Premix Transaction

You are almost there. In the last step you will see an overview of your Premix transaction, i.e. the transaction that sends your coins, neatly split from your Deposit Wallet to the Premix Wallet.

From Premix to Postmix

It is done! Euro Coins now reside as individual UTXOs on different addresses of your Premix account. Sparrow will now register your UTXOs as inputs to Whirlpool and put them into the mixer. Since the demand for premix inputs at Whirlpool is relatively high, you should not have to wait long until you get a place in a mix.

IMPORTANT: Since you, not Samourai, hold the keys to your wallet, Sparrow must remain open to mix and have an active connection to your fullnode, as the software cannot sign CoinJoin transactions.

Congratulations! Now it’s only a matter of time and your first CoinJoin is complete!

Extras

After the mix is before the mix

You have successfully mixed your UTXOs, but what now? The cool thing about Samourai Whirlpool is that you can simply throw UTXOs that are in your postmix account back into the mixer again and again, and that’s completely free of charge (you don’t pay a pool fee, nor a mining fee, as these are taken over by new pool participants).

To continue mixing your Postmix UTXOs, simply click on “Start Mixing” in the UXTO tab of your Postmix account

CoinControl

CoinControl is a very important concept when you are working with mixed coins. In the Bitcoin protocol, transactions can use inputs from multiple addresses. For example, I can have a wallet with 5 active addresses. There are 100,000 sats on each of these 5 addresses. Now if I want to make a payment of 450,000 sats, this is not a problem because my wallet has the private keys to all 5 addresses and can therefore create a transaction that receives inputs from all 5 addresses and issues two outputs (once 450,000 sats to the recipient and once our change – fee).

Some may now realize why this concept is so important, especially with mixed coins. If we have a wallet that manages both mixed UTXOs and non-mixed UTXOs, we have to be enormously careful not to spend them together. Because by having the addresses show up together in the blockchain, the connections we broke through the CoinJoin can be re-established.

To be on the safe side, you should simply create an extra account in your wallet and only send mixed coins there. This way you avoid spending them accidentally with unmixed Sats.

CoinJoin directly to your hardware wallet

Sparrow allows you to automatically send UTXOs to another wallet created in Sparrow Wallet after a desired number of mixes have been performed. This wallet can also be a so-called watch-only wallet, which allows us to send our mixed UTXOs directly to our hardware wallet without having to trust Sparrow Wallet with the private keys.

To do this, first create a new wallet in Sparrow Wallet. This time not a software wallet, but a “xPub / Watch Only” wallet. Now you add your extended public key under xPub and the derivation path of this wallet under Derivation Path. As mentioned above, a separate account is suitable for mixed UTXOs, so it is best to create a new one on your hardware wallet. Since the master fingerprint is not needed for a WatchOnly wallet, just enter “00000000” here.

The created wallet can’t sign transactions because it doesn’t know the private keys, but it can retrieve addresses and see their account balances. The former allows Sparrow to send the mixed UTXOs from our “mix wallet” to addresses on our WatchOnly wallet. Now we just need to instruct Sparrow Wallet to do this.

To do this, you need to navigate to the UTXO tab, of the postmix account, of your CoinJoin wallet and click “Mix to” here (active mixed must be interrupted). Now select the WatchOnly-Wallet you just created as destination and define how often the UTXOs should be mixed before Sparrow Wallet sends them to it.

Donate:

If you liked this or any of our other posts and would like to support us, please consider donating.

Leave a Reply