How to Sweep Your Bitcoin Private Keys Into Electrum

In this tutorial, I will show you how to sweep your Bitcoin private keys into Electrum. This tutorial might be especially useful to you if you tried to sweep your private keys in the past, but couldn’t get Electrum to detect your Bitcoins.

How does sweeping private keys differ from importing them?

While this tutorial explains how to sweep private keys into Electrum, it’s also possible to import them. But what’s the difference?

When you create a new wallet in Electrum, you are given a set of words – called seed words – that look something like the example below. Typically, they are composed of 12, 18 or 24 words. They serve as the basis to generate all the private keys that make up your wallet.

casual fabric female banana stuff sudden salute crowd analyst ten today document

When you access your wallet in Electrum, you don’t have to enter your seed words each time. Instead, Electrum stores an encrypted wallet file on your computer and you enter a password to decrypt it. Should something bad happen (for instance, your hard drive fails or you lose your password), you can recreate the wallet file with your seed words.

However, the seed words cannot recreate private keys that were imported into your wallet. To benefit from this feature, the private keys must be swept into your wallet. When you sweep a private key, Electrum doesn’t simply add it to your wallet; rather, it takes the funds from it and move them to a private key that was generated through your wallet’s seed words. This means you have to pay a transaction fee to move the Bitcoins from one private key to another.

How to sweep private keys into Electurm

Open your wallet in Electrum.

Screenshot

In the menu, click on Wallet, Private keys and Sweep.

Screenshot

Electrum will ask you to enter your private keys.

Screenshot

Now, you need to input your private keys into the text box that has appeared. The private keys need to be in a format called WIF. When a private key is in such a format, it will usually (but not always) start with 5, K or L and be comprised of 51 or 52 alphanumeric characters. For instance, KzQhifVHanPvBmnqTjNnRSqKU64LLJfJXbEmdmxeTdX8jLKkhFMr is a private key in WIF.

What you may not know is that you can generate different addresses from the same private key. By default, Electrum will generate only one of the possible addresses for a given private key, and your Bitcoins might not be available on that one. Thus, you might need to tell Electrum what kind of address to generate, which is done by prepending p2pkh:, p2wpkh-p2sh: or p2wpkh: to the private key.

  • p2pkh: will generate an address that starts with 1 (like 1KKJ88u3BeCXVv3Eg5FhGVQfe81raodoo4)
  • p2wpkh-p2sh: will generate an address that starts with 3 (like 3Ct4iSaBC8GVs3P2CzcJbpsmswrzzAhM9C)
  • p2wpkh: will generate an address that starts with bc1q (like bc1qer5qhp09j4u26zhav0sfzk75x0sp5mkmtmjjs7)

For instance, if you know that your Bitcoin address is bc1qer5qhp09j4u26zhav0sfzk75x0sp5mkmtmjjs7 (i.e., it starts with bc1q), you would input the following private key into the text box: p2wpkh:KzQhifVHanPvBmnqTjNnRSqKU64LLJfJXbEmdmxeTdX8jLKkhFMr. If you were to prepend something else than p2wpkh:, Electrum might not be able to detect your Bitcoins.

Note that you can import the same private key once for each address type. Therefore, if your private key is KzQhifVHanPvBmnqTjNnRSqKU64LLJfJXbEmdmxeTdX8jLKkhFMr, you can input the lines below in the text box. This will tell Electrum to generate three addresses from the same private key: one that starts with 1, one that starts with 3 and one that starts with bc1q.

1p2pkh:KzQhifVHanPvBmnqTjNnRSqKU64LLJfJXbEmdmxeTdX8jLKkhFMr
2p2wpkh-p2sh:KzQhifVHanPvBmnqTjNnRSqKU64LLJfJXbEmdmxeTdX8jLKkhFMr
3p2wpkh:KzQhifVHanPvBmnqTjNnRSqKU64LLJfJXbEmdmxeTdX8jLKkhFMr

Once you have input your private keys into the text box, click on Sweep. If no Bitcoins are found, Electrum will throw the error No inputs found. Otherwise, it will prompt you to enter your password and to set a transaction fee so that the Bitcoins can be moved from the input private keys to private keys that were generated through your wallet’s seed words.