Matt Falkenhagen

Moving bitcoin from an exchange to a wallet

Posted on January 4, 2023

Introduction

I had a very small amount of bitcoin on an exchange. For various reasons, I wanted to move the bitcoin off the exchange and into a personal wallet. This documents how I did that.

WARNING: I do not know what I’m doing. These are my personal notes. It is not professional advice. Use of this information is at your own risk. You are responsible for anything you do with your bitcoins.

Choosing a wallet

While the community seems to largely recommend a physical product such as Tezor, I didn’t want to go this route. First, the amount of bitcoin was so small that paying for a wallet was hard to justify. Second, there were many wallet choices, and I wanted to avoid having to choose a specific commercial third-party to trust. I imagine even if the third-party were to go out of business, these wallets use some standard format that lets you access the coins again, but I didn’t see why this extra layer of indirection should be needed in my case.

Therefore, I chose to install the standard Bitcoin Core software and create the wallet there, and then move that wallet into cold storage.

Installing Bitcoin Core

The best place to download Bitcoin Core is apparently bitcoincore.org. If you click on Download, it will take you to the latest stable version. There is no reason I know of to download an earlier version.

WARNING: bitcoin.org, which also appears authoritative, and may even share the same management as bitcoincore.org, says that the latest version is 22.0 for some reason, while it is actually 24.0.1 at the time of this writing. Go straight to bitcoincore.org instead. You can also confirm by going to the GitHub repository and clicking the external download link under About.

After downloading the package, you want to verify the package has not been tampered with. In the old days, we would here simply compute the checksum with md5sum etc and then compare it to a checksum published by a trusted party. However, now there is a more complicated process documented here. I was able to follow the instructions with a couple of modifications:

Once convinced that the package is legitimate, continue on to Install the software.

Setting up Bitcoin Core

It turns out to perform a transaction on your own using Bitcoin Core, you must first download the entire blockchain which is about 500 GB at the time of this writing. I suppose this makes sense.

So when running Bitcoin Core for the first time, you will use a lot of network and storage.

The documentation says you can enable pruning which will save storage space, but the software itself recommends downloading and storing the entire blockchain initially, and then pruning it later, so you probably need to start with the space available anyway.

I made a mistake here. I elected to store the blockchain on an external hard drive with a lot of space, figuring that the network bandwidth and CPU would be the bottleneck. It turns out that disk IO matters a lot. The sync progress indicator fluctuated between a few days and a few weeks as I ran it on and off for several days. I assumed that I was being throttled by my ISP. Finally, I decided move the blockchain to the internal SSD (to do this, shut down the application, rename the blockchain directory, then copy it to the new location, restart the app, and point it to the new location when prompted). After that, syncing finished smoothly. Probably it would have taken just one day if I’d started out this way.

Now that we are synced, we can create a wallet.

Create wallet

The app lets you create a wallet with File > Create Wallet, but you are confronted with ill-explained choices: name, encryption, disable private keys, etc.

Create Wallet dialog box

Stack Overflow has at least one explanation. From what I gather:

I kept all the defaults, with the exception of additionally selecting encryption.

This will create a directory called my-wallet in your bitcoin data directory.

Send funds

Now that the wallet is made, we want to send bitcoins from the exchange to it. Click Receive in the app, and get an address to send the bitcoin to. Then on the exchange, enter this address. Start with a small test amount.

In my experience, it takes a few minutes for the funds to appear as “Pending” in the Bitcoin Core app. It takes more like an hour for the funds to be settled and available, as it becomes an irrevocably accepted part of the blockchain.

Next test that you can send bitcoins back to the exchange. On the exchange, find the Deposit feature, which gives you an address. In the Bitcoin Core app, go to Send and input the address. Again it will take some time to settle.

Backup wallet

The next step is to copy my-wallet.dat to other places, as my personal use case is just to keep it in cold storage indefinitely.

Bitcoin Core offers a command called File > Backup Wallet. What is the difference between this and just copying wallet.dat? It turns out you should use Backup Wallet and the associated Restore Wallet feature instead of just copying. Identical wallet.dat files should not be used on multiple nodes, and Backup apparently finalizes state into a single wallet.dat file.(ref, ref)

So we use Backup Wallet and write to my-wallet-backup.dat. The backup is encrypted like the primary wallet. This file is what we want to copy to cold storage, and this along with the passphrase is all that’s needed to access the bitcoins anytime in the future. Even if more bitcoins are transferred to the main wallet after the backup was made, the backup is still capable of recovering all the coins; though periodic backups are still recommended if you’re going to be transferring more coins (ref) (which I’m not planning on).

Restore wallet

Now comes a test. If I were to obliterate the main wallet, can I get it back from the backup? Close Bitcoin Core.

cd ~/bitcoin-data
mv my-wallet my-wallet-delete

Reopen Bitcoin Core. Then File > Restore Wallet.

It asks for a wallet name again. I believe this is inconsequential, but I used the original name “my-wallet”. I believe Restore Wallet is restoring the wallet from the backup and making a new wallet (with the restored data) with this name in the default directory. File > Open Wallet may also be possible here, and I suspect it would have used the backup in place.

You see the balance is available again. Here I notice that, somewhat strangely, I didn’t need to input the passphrase to open the wallet. I guess the passphrase is only needed once you try to send coins.

Send the rest of the funds

Now let’s send the rest of the funds to the wallet. We repeat the step above.

For reasons I don’t fully understand, both the exchange and Bitcoin Core allow you to reuse receiving addresses, but it appears to be universally not recommended to do so for privacy and security reasons. So just make a new receiving address for each transaction.

We wait the hour or so for the funds to arrive, and then go ahead and repeat the backup and restore drill to ensure everything is fine. This time actually try restoring from cold storage and why not also make sure we can send funds back to the exchange. Then return them, and we’re done. We’ve moved all the coins off the exchange and into our own wallet.

Thank you for reading! For feedback, you can email me at (my last name) at gmail.com.

Return to home.