<blockquote>
<p>Does <code>wallet.dat</code> contain every address that I created?  Even if I didn't get any coins from it?</p>
</blockquote>
<p>Yes</p>
<blockquote>
<p>To be clear, suppose I run <code>bitcoin-qt</code> in Linux, and, in the GUI, I click on <code>Receive</code> then click on <code>Create new receiving address</code>:</p>
<ol>
<li>At this point, no coins are received.  Will this immediately generate a new public-private key pair?</li>
</ol>
</blockquote>
<p>Yes. Well, not quite, but in essence, yes. Bitcoin Core pre-generates 1000 keys in a structure known as the keypool. When you request a new address, one of those pre-generated keys is returned to you and another one is generated to replace it in the keypool. This replacement generation can be deferred to a later time, if, for example, your wallet is locked.</p>
<blockquote>
<p>How was this public-private key generated?</p>
</blockquote>
<p>Depending on when you created your wallet, either randomly, or with BIP 32. Newly created wallets with modern versions of Bitcoin Core will use BIP 32. BIP 32 is a deterministic way to generate keys from a randomly generated seed. Bitcoin Core randomly generates the seed and derives the actual private keys from it using BIP 32.</p>
<blockquote>
<ol start="2">
<li>Is this new key pair stored in <code>wallet.dat</code> even before me receiving any payments?</li>
</ol>
</blockquote>
<p>Yes</p>
<blockquote>
<ol start="3">
<li>I receive coins on that address.  Will this affect the size of <code>wallet.dat</code>?</li>
</ol>
</blockquote>
<p>Yes. When you receive a transaction, that transaction is added to the wallet and this will increase the size of the <code>wallet.dat</code>.</p>
<blockquote>
<p>Basically I'm concerned on the size of <code>wallet.dat</code> as I keep creating new receiving addresses.</p>
<p>What determines the size of <code>wallet.dat</code>?  It's about 1.4 MB now.  What made it so?  What will make it change?</p>
</blockquote>
<p>The size is largely determined by the number of addresses you have requested already, the size of the keypool, and the number of transactions that you have, both incoming and outgoing.</p>
<blockquote>
<p>Looks pretty linear to me with a slope of <code>1135.0361445783133</code> bytes per address.  I wonder why is this?  Is it because <code>wallet.dat</code> is storing a whole new public-private key pair per address?  Or what is happening?</p>
</blockquote>
<p>Yes.</p>
<p>If your wallet is unencrypted, each new keypair that is generated will add at least 388 bytes.</p>
<p>If your wallet is encrypted, each new keypair will add at least 120 bytes. This size difference is because encrypted private keys are encoded more efficiently than unencrypted private keys.</p>
<blockquote>
<p>I then delted all those addresses, but  <code>wallet.dat</code>'s size didn't reduce.  In fact it even increased!</p>
</blockquote>
<p>Bitcoin Core does not allow you to delete addresses. However you &quot;deleted&quot; them, it was likely just hiding them.</p>
<hr />
<p>If you want a smaller wallet, then you should create a new encrypted wallet. Note that this means creating a new wallet and choosing the option to make it encrypted. Creating a new wallet and then encrypting it after the fact will create extra keys that are never used and just take up space.</p>

CC BY-SA 4.0
2020-08-12T03:59:15.940Z
Thanks.  Extra questions:  (1) will that newly encrypted wallet contain coins in the big wallet that I used in the past?  (2) Mathematically, why should each wallet have a public-private key pair for each receiving address?  Can't we have a single public-private key pair proves its ownership of all receiving addresses?  This way, a wallet will have a single public-private key pair, and it can scan the entire block chain and discover all coins that belongs to it.  This way the wallet will not grow bigger over use.  Any reason this is not done?
caveman
CC BY-SA 4.0
2020-08-12T04:02:51.583Z
1) New wallets are independent of other wallets. They will not contain anything from any othre wallet. 2) A single keypair does not have multiple addresses. In order to have multiple addresses, you must have multiple keypairs. Reusing addresses is not advised due to the privacy risks of doing so. The wallet size is really not a factor until you get into the tens of thousands of transactions.
Ava Chow
CC BY-SA 4.0
2020-08-12T04:14:20.267Z
Is the wallet size a problem for stores that sell in BTC? I guess they have millions of transactions every year?
caveman
CC BY-SA 4.0
2020-08-12T05:23:37.313Z
Businesses generally don't use Bitcoin Core for their wallet because it is harder to integrate it for processing payments. It also does not work well with extremely large wallets. Such businesses generally either use a service provider (who has custom software) or a software geared towards business use such as BTCPayServer.
Ava Chow
CC BY-SA 4.0
2020-08-12T03:31:06.730Z
2020-08-12T03:31:06.730Z
Ava Chow
<p>Does <code>wallet.dat</code> contain every address that I created?  Even if I didn't get any coins from it?</p>
<p>To be clear, suppose I run <code>bitcoin-qt</code> in Linux, and, in the GUI, I click on <code>Receive</code> then click on <code>Create new receiving address</code>:</p>
<ol>
<li>At this point, no coins are received.  Will this immediately generate a new public-private key pair?   How was this public-private key generated?</li>
<li>Is this new key pair stored in <code>wallet.dat</code> even before me receiving any payments?</li>
<li>I receive coins on that address.  Will this affect the size of <code>wallet.dat</code>?</li>
</ol>
<p>Basically I'm concerned on the size of <code>wallet.dat</code> as I keep creating new receiving addresses.</p>
<p>What determines the size of <code>wallet.dat</code>?  It's about 1.4 MB now.  What made it so?  What will make it change?</p>
<p>This is a graph showing how <code>wallet.dat</code>'s size increases as I keep adding new addresses:</p>
<p><a href="https://i.sstatic.net/kdSm7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kdSm7.png" alt="enter image description here" /></a></p>
<p>Looks pretty linear to me with a slope of <code>1135.0361445783133</code> bytes per address.  I wonder why is this?  Is it because <code>wallet.dat</code> is storing a whole new public-private key pair per address?  Or what is happening?</p>
<p>I then delted all those addresses, but  <code>wallet.dat</code>'s size didn't reduce.  In fact it even increased!</p>

<wallet.dat>
What determines BTC's wallet size in bytes?
caveman
# What determines BTC's wallet size in bytes?

(Asked by: username_0 on 2020-08-12)

Does `wallet.dat` contain every address that I created? Even if I didn't get any coins from it?

To be clear, suppose I run `bitcoin-qt` in Linux, and, in the GUI, I click on `Receive` then click on `Create new receiving address`:

1. At this point, no coins are received. Will this immediately generate a new public-private key pair? How was this public-private key generated?
2. Is this new key pair stored in `wallet.dat` even before me receiving any payments?
3. I receive coins on that address. Will this affect the size of `wallet.dat`?

Basically I'm concerned on the size of `wallet.dat` as I keep creating new receiving addresses.

What determines the size of `wallet.dat`? It's about 1.4 MB now. What made it so? What will make it change?

This is a graph showing how `wallet.dat`'s size increases as I keep adding new addresses:

[![enter image description here](https://i.sstatic.net/kdSm7.png)](https://i.sstatic.net/kdSm7.png)

Looks pretty linear to me with a slope of `1135.0361445783133` bytes per address. I wonder why is this? Is it because `wallet.dat` is storing a whole new public-private key pair per address? Or what is happening?

I then delted all those addresses, but `wallet.dat`'s size didn't reduce. In fact it even increased!

**Tags:** wallet.dat


---

## 1 answers

### Answer by username_1 on 2020-08-12. Score: 3 | Accepted answer

> Does `wallet.dat` contain every address that I created? Even if I didn't get any coins from it?

Yes

> To be clear, suppose I run `bitcoin-qt` in Linux, and, in the GUI, I click on `Receive` then click on `Create new receiving address`:
>
> 1. At this point, no coins are received. Will this immediately generate a new public-private key pair?

Yes. Well, not quite, but in essence, yes. Bitcoin Core pre-generates 1000 keys in a structure known as the keypool. When you request a new address, one of those pre-generated keys is returned to you and another one is generated to replace it in the keypool. This replacement generation can be deferred to a later time, if, for example, your wallet is locked.

> How was this public-private key generated?

Depending on when you created your wallet, either randomly, or with BIP 32. Newly created wallets with modern versions of Bitcoin Core will use BIP 32. BIP 32 is a deterministic way to generate keys from a randomly generated seed. Bitcoin Core randomly generates the seed and derives the actual private keys from it using BIP 32.

> 2. Is this new key pair stored in `wallet.dat` even before me receiving any payments?

Yes

> 3. I receive coins on that address. Will this affect the size of `wallet.dat`?

Yes. When you receive a transaction, that transaction is added to the wallet and this will increase the size of the `wallet.dat`.

> Basically I'm concerned on the size of `wallet.dat` as I keep creating new receiving addresses.
>
> What determines the size of `wallet.dat`? It's about 1.4 MB now. What made it so? What will make it change?

The size is largely determined by the number of addresses you have requested already, the size of the keypool, and the number of transactions that you have, both incoming and outgoing.

> Looks pretty linear to me with a slope of `1135.0361445783133` bytes per address. I wonder why is this? Is it because `wallet.dat` is storing a whole new public-private key pair per address? Or what is happening?

Yes.

If your wallet is unencrypted, each new keypair that is generated will add at least 388 bytes.

If your wallet is encrypted, each new keypair will add at least 120 bytes. This size difference is because encrypted private keys are encoded more efficiently than unencrypted private keys.

> I then delted all those addresses, but `wallet.dat`'s size didn't reduce. In fact it even increased!

Bitcoin Core does not allow you to delete addresses. However you "deleted" them, it was likely just hiding them.

---

If you want a smaller wallet, then you should create a new encrypted wallet. Note that this means creating a new wallet and choosing the option to make it encrypted. Creating a new wallet and then encrypting it after the fact will create extra keys that are never used and just take up space.

> **Comments:**
> **username_0**: Thanks.  Extra questions:  (1) will that newly encrypted wallet contain coins in the big wallet that I used in the past?  (2) Mathematically, why should each wallet have a public-private key pair for each receiving address?  Can't we have a single public-private key pair proves its ownership of all receiving addresses?  This way, a wallet will have a single public-private key pair, and it can scan the entire block chain and discover all coins that belongs to it.  This way the wallet will not grow bigger over use.  Any reason this is not done?  
> **username_1**: 1) New wallets are independent of other wallets. They will not contain anything from any othre wallet. 2) A single keypair does not have multiple addresses. In order to have multiple addresses, you must have multiple keypairs. Reusing addresses is not advised due to the privacy risks of doing so. The wallet size is really not a factor until you get into the tens of thousands of transactions.  
> **username_0**: Is the wallet size a problem for stores that sell in BTC? I guess they have millions of transactions every year?  
> **username_1**: Businesses generally don't use Bitcoin Core for their wallet because it is harder to integrate it for processing payments. It also does not work well with extremely large wallets. Such businesses generally either use a service provider (who has custom software) or a software geared towards business use such as BTCPayServer.  

---

