<blockquote>
<p><strong>is this balance calculated by addresses, that is, by accounts?</strong></p>
</blockquote>
<p>You are wrong to conflate addresses and accounts. There are no accounts in the Bitcoin network, nor in the current version of the Bitcoin core wallet, nor in the blockchain data.</p>
<p>There are no balances anywhere in the Bitcoin network data. None in the blockchain.</p>
<p>Most wallets choose to show you a total amount of money in UTXOs for which the wallet holds a private key. Most call this a balance because people are familiar with balances of bank accounts but Bitcoin doesn't work like a bank accounts - it is cash. Balances don't really apply to cash.</p>
<p>Bitcoin core used to have an &quot;account&quot; feature but that was an arbitrary label you could apply to addresses to help you organise your money. That feature was removed and replaced by &quot;labels&quot;</p>
<p>Any &quot;balance&quot; shown by a wallet is likely to be a total across all <strike>addresses</strike> <em>UTXOs spendable by use of the private keys generated by the wallet - and therefore a total across at least all &quot;addresses&quot; that might be specifiable for locking scripts relating to many or all of those UTXOs</em>.</p>
<p>Custodial accounts exist, they are provided by businesses who want to earn an income from cash that people would otherwise keep in their own personal wallets. The balance shown in these accounts is rather like an IOU. There's no guarantee of any sort that the business actually holds any cash or that it can pay you what it owes you.</p>
<p>Bitcoin's inventor primarily wanted to create a system by which one party could pay a second party without any need for a trusted third party to act as intermediary. The idea of custodial accounts is clearly in direct conflict with that goal.</p>
<p>Accounts almost invariably mean custodial accounts. An exploitation by businesses of what was intended to be purely a peer to peer cash payment system. The sort of business exploitation that leads to MtGox, Quadriga-CX, FTX and huge loss of money for thousands of people.</p>
<hr />
<p>In short, The data circulated in the Bitcoin network and the data in the blockchain</p>
<ul>
<li>have no accounts</li>
<li>have no addresses</li>
<li>have no balances</li>
</ul>
<hr />
<p>Ye Olde Blockchain:</p>
<p><a href="https://i.sstatic.net/o3Lgr.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/o3Lgr.jpg" alt="enter image description here" /></a></p>
<p>In this cash daybook (cash journal), each page is a block, each line <em>is</em> a UTXO, a primitive proto-Bitcoin. It's just that the network protocol involved moving lumps of metal and paper between people's pockets rather than electrical impulses between people's computers.</p>

CC BY-SA 4.0
2023-03-12T14:51:36.587Z
First of all, thank you very much for your reply. Second, I also realized that the concept of account, wallet and its balance does not exist in the context of blockchain, so I labeled them as something abstract, something that exists in user applications only to facilitate interaction for users. At the end, you wrote that the network has no accounts, balances and addresses? I understand the first two, but how do you think there is no address? I mean, even in text you wrote the following: `Any "balance" shown by a wallet is likely to be a total across all addresses.`
dassd
CC BY-SA 4.0
2023-03-12T18:29:21.967Z
A Bitcoin "address" is a string of printable characters that a Bitcoin recipient (e.g. a seller of goods or services) shows to a Bitcoin sender (purchaser of goods or services), often in the form of a 2-D barcode, so that the sender can create a specific locking script in one output of a transaction. It is only the locking script that exists in the Bitcoin data in the network or in the blockchain. Wallets may show you addresses corresponding to a standard type of locking scripts for which the wallet contains private keys that can be used to create a corresponding unlocking script.  ....
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T18:29:27.633Z
... Some types of locking scripts don't have have any standard address. Despite this, I sometimes write about Bitcoin addresses because this is a lot to describe every time we want to discuss Bitcoin payments. Sometimes you can lose sight of the forest because the trees get in the way.
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T18:32:31.067Z
P.S. Your (implicit?) criticism is valid, It is just that sometimes I don't have the time to work out a completely unambiguous yet concise answer.
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T19:01:37.567Z
So there are no addresses in the bitcoin blockchain? I mean even @Murch (comment below) talks about addresses. Also, I am reading `Mastering Bitcoin by Andreas M. Antonopoulos` and addresses are also discussed. Or maybe you want to say that there are addresses that are used to create a lock script that is then used in transactions, and bitcoin only recognize that (bitcoin does not recognize the addresses)? Now you have me completely confused. Do you have a suggestion for a good book or material that goes into ultra detail about the structure and workings of the Bitcoin blockchain?
dassd
CC BY-SA 4.0
2023-03-12T19:12:57.400Z
There are no addresses in the Bitcoin blockchain. If you want, you can derive addresses from information in the blockchain, specifically from locking scripts. There are standard ways of deriving an address from (or for) certain standard types of locking script. But the payment system which the Bitcoin network provides does not use addresses inside the network.  The Antonopoulos book is the best one I know of.
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T19:19:26.650Z
And yes, everybody often use words imprecisely in order to avoid overloading readers with obscure or esoteric details when trying to convey more basic principles. After all: wallets don't contain money, unlike real wallets; addresses don't identify locations, unlike real addresses; Bitcoins are never transmitted anywhere. Bitcoins don't exist as data entities; If UTXO's are coins, they are coins that never change owners, unlike real coins. They are coins that are melted down and recast when you spend them, unlike real coins. etc etc.
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T19:26:54.297Z
I just started the Antonopoulos book. Is everything (everything you're telling me right now) explained within the book? I mean, is the explanation that there are no addresses but a lock script derived from them? Also, if you've read it, I'm interested in whether everything written there is correct, that is, whether the algorithms that were explained are still valid? In other words, has bitcoin moved to something else or are those algorithms still being used. I ask because the book is from 2017/18. All the best!
dassd
CC BY-SA 4.0
2023-03-12T19:59:30.653Z
Thanks for the image you added later and for the more detailed explanation of the block transaction concept and UTXO. It would help me a lot if you know the answer to the question I asked in the previous comment.
dassd
CC BY-SA 4.0
2023-03-12T22:20:53.410Z
I expect the second edition is almost entirely still correct, relevant and worth reading. The algorithms are likely all still valid. It won't cover some recent developments, perhaps not taproot and one or two other things.
RedGrittyBrick
CC BY-SA 4.0
2023-03-13T17:44:12.620Z
Thanks for the help, I appreciate it.
dassd
CC BY-SA 4.0
2023-03-12T11:02:14.543Z
2023-03-12T19:46:01.640Z
2023-03-12T19:46:01.640Z
RedGrittyBrick
<p>All spendable bitcoins are locked in UTXOs (Unspent Transaction Outputs)</p>
<p>When you want to spend bitcoin, you use one or more of your UTXOs as inputs to a transaction, and create one or more outputs. Since these inputs are now spent, they are no longer UTXOs, and while the new outputs are not spent, they are UTXOs.</p>
<p>So when you spend bitcoin you spend UTXOs and generate new UTXOs.</p>
<p>UTXOs are locked by locking scripts, and there are different locking scripts:</p>
<ul>
<li><p>P2PK (Pay to Public Key) where the UTXO is locked to a particular public key, and you need to present a signature (by the corresponding private key) to unlock it;</p>
</li>
<li><p>P2PKH (Pay to Public Key Hash) where the UTXO is locked to a public key hash, and you need to present the public key and a signature to unlock it;</p>
</li>
<li><p>P2SH (Pay to Script Hash) where the UTXO is locked to a particular script hash, and you need to present the original script and a way to unlock this script to unlock the output;</p>
</li>
<li><p>Others, but I will stop right here for simplicity.</p>
</li>
</ul>
<p>When you want to send me some bitcoins, what will happen is you are going to spend one or more of your UTXOs and lock those bitcoins in one UTXO I control. So, I need to tell you how I want my UTXO locked.</p>
<p>And here is where addresses come through: it’s a way for my wallet to inform your wallet how I want my UTXO locked.</p>
<p>So, if I show you an address starting with ‘1’, I’m saying that I want my UTXO locked in a P2PKH script with the following public key hash (that your wallet finds in the rest of the address).</p>
<p>If I show you an address starting with ‘3’, I’m saying that I want my UTXO locked in a P2SH script with the following script hash (that your wallet finds in the rest of the address).</p>
<p>Addresses also have a checksum suffix to prevent errors.</p>
<p>There is no address format for P2PK.</p>
<p>A wallet is a tool where you store secrets (private keys, master seeds, …) and sign transactions. Remember, you need to present signatures to unlock your UTXOs, and this is where those signatures come from.</p>
<p>For privacy reasons you should never reuse a public key.</p>
<p>A modern wallet is Hierarchical Deterministic, which means it doesn’t need to store all private keys it has ever used/generated. It just needs to store a master seed, since all keys can be derived in a deterministic way from that master seed.</p>
<p>To calculate the balance for a specific master seed, the wallet goes like this:</p>
<ol>
<li>Derive the first private key (and corresponding public key)</li>
<li>Calculate possible locking scripts for that public key (P2PK, P2PKH, …)</li>
<li>Search the UTXOs set for UTXOs locked with any of the above scripts</li>
<li>When finds one UTXO locked that way, add the value of that UTXO to the balance</li>
<li>Repeat process until it finds 1000 straight public keys with no UTXOs</li>
</ol>

CC BY-SA 4.0
2023-03-15T13:12:00.790Z
Good answer! Perhaps “tool” would be better than “place” as a label for what the wallet is. The gap limit used by Bitcoin Core is 1000, not 20.
Murch
CC BY-SA 4.0
2023-03-15T16:59:26.687Z
@murch thanks for the suggestion and correction. Changed.
bordalix
CC BY-SA 4.0
2023-03-15T11:25:39.960Z
2023-03-15T16:58:12.140Z
2023-03-15T16:58:12.140Z
bordalix
<blockquote>
<p>Is each wallet connected to only one address or account?</p>
</blockquote>
<p>Addresses have the character of invoice identifiers. You should only use each address once in the context of a specific payment interaction. Addresses are used by recipients to inform senders what output script they expect the payment to be locked to. I am not sure how the concept of accounts as you describe it is useful in this context.</p>
<p>You mention Metamask—Ethereum works very differently in regard to tracking funds: it’s an account-based system. Funds are associated with one <em>reused</em> address and you can freely spend any portion of your balance. Bitcoin uses the UTXO-model: your funds are structured in discrete chunks that have to be spent in full like coins and bills in the physical world. Sure, you can sum up all the coins and bills in your wallet and refer to that sum as a balance. You can’t spend your whole Bitcoin wallet balance though, because you’ll also need to pay transaction fees, you can only spend discrete chunks of it and will need to consider change outputs, etc. so that may be confusing.</p>
<p>In Bitcoin, the most recent use of “account” that I’ve seen was people using the term as an opposite to “wallet”: if you manage your own key material and self-custody your funds, you have a <em>wallet</em>, when you use a custodial service that only shows you your balance they owe you, you have an <em>account</em>.</p>

CC BY-SA 4.0
2023-03-12T15:03:38.470Z
So, if I understood correctly. A wallet contains private-public key pairs and thus addresses derived from a given public key. A new address (that is, a new private-public key pair) should be used for each transaction, but it doesn't have to be. UTXO is tied to addresses, where will a wallet containing given addresses, then add up all UTXO across all addresses and display that to the user as a balance?
dassd
CC BY-SA 4.0
2023-03-12T20:54:34.660Z
Wallets only “contain” private keys. They may track transactions and UTXOs that are relevant to the wallet owner, but those are not “in the wallet” but part of the global state of the network. Addresses don’t exist in transactions, they exist only out of band. Addresses are just a transfer format for the recipient to inform the sender what output script to use to pay them: they’re a user-friendly shorthand for some output scripts.—If you wanted to get an idea of your spendable funds, yes, you should sum up all of your UTXO’s value. You might call that the balance of a wallet.
Murch
CC BY-SA 4.0
2023-03-13T17:45:11.350Z
Thanks for the help, I appreciate it.
dassd
CC BY-SA 4.0
2023-03-12T12:48:49.273Z
2023-03-13T19:43:53.237Z
2023-03-13T19:43:53.237Z
Murch
<p>Regards to all,</p>
<p>I am completely new to blockchain and bitcoin as its most popular implementation.</p>
<p>I have some probably basic questions for someone, but it's really important for me to get it right. It is about accounts, addresses and wallets. I will number them and give some comment as I understood it. If I have not understood something well, I would ask you to indicate it.</p>
<ol>
<li>What is an address?</li>
</ol>
<blockquote>
<p>The address is created from the public key via hash functions. It is used to indicate to whom bitcoin is sent and from whom it is received.</p>
</blockquote>
<ol start="2">
<li>What is an account?</li>
</ol>
<blockquote>
<p>An account represents some kind of abstract concept that is associated with an address. Blockchain does not know the concept of an account. Actually the account can be represented as the knowledge of the private-public key pair on which the address was created.</p>
</blockquote>
<ol start="3">
<li>What is a wallet?</li>
</ol>
<blockquote>
<p>Blockchain, similar to an address, is wallet-aware. It's just some kind of client application that will store the private-public key pairs (thus it will have the addresses associated with that account), calculate the balance, facilitate user interaction with the blockchain, etc.</p>
</blockquote>
<ol start="4">
<li>Is each wallet connected to only one address or account?</li>
</ol>
<blockquote>
<p>No, the wallet has as many addresses and accounts as you want. In other words, you can hold as many public-private key pairs as you like, and therefore addresses and accounts.</p>
</blockquote>
<p>The last question is about the balance of the wallet. I know balance is calculated based on UTXO. So, my question is, is this balance calculated by addresses, that is, by accounts? In other words, if you have 5 private-public key pairs, there will be 5 addresses (accounts) where for each they will look which UTXOs belong to it and then calculate 5 balances (one for each address/account). So, one wallet with 5 accounts and a separate balance for each of them. Is the above written correct, or is the balance calculated by finding the UTXO associated with the wallet addresses and then the balance is calculated as the total value. In other words, no matter how many addresses there are, there will always be only one balance, that is, there will always be only one account per wallet. If the second is true, it actually means that the concept of an account does not even exist within Bitcoin, that is, that a wallet is actually an account. I ask because in Metamask wallets, as I have seen, you have multiple accounts (one account corresponds to one address) in one wallet and a balance in each account. It's separate.</p>
<p>Thank you very much for your help.</p>

CC BY-SA 4.0
2023-03-12T04:12:03.133Z
Hi Filip, our website works best if a topic is started by asking an open question, and answers are posted in response. It tends to not work well, if you post many questions or incorporate your own answer into your question post. Perhaps you could please rephrase your question post into a question and respond to it with the answer you're giving.
Murch
CC BY-SA 4.0
2023-03-12T10:48:44.000Z
1. [What is an address](https://bitcoin.stackexchange.com/a/116371/13866)
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T10:50:36.877Z
2. What is an account? -- [In Bitcoin Core](https://bitcoin.stackexchange.com/a/79835/13866)
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T10:52:11.963Z
3. [What is a wallet](https://bitcoin.stackexchange.com/a/106324/13866)
RedGrittyBrick
CC BY-SA 4.0
2023-03-12T12:51:04.893Z
Please check out our [tour] for an overview of how our site works.
Murch
<wallet><balance><bitcoin-core-accounts>
Have I understood the concept of address, account and wallet correctly and how the wallet balance is calculated?
dassd
# Have I understood the concept of address, account and wallet correctly and how the wallet balance is calculated?

(Asked by: username_0 on 2023-03-12)

Regards to all,

I am completely new to blockchain and bitcoin as its most popular implementation.

I have some probably basic questions for someone, but it's really important for me to get it right. It is about accounts, addresses and wallets. I will number them and give some comment as I understood it. If I have not understood something well, I would ask you to indicate it.

1. What is an address?

> The address is created from the public key via hash functions. It is used to indicate to whom bitcoin is sent and from whom it is received.

2. What is an account?

> An account represents some kind of abstract concept that is associated with an address. Blockchain does not know the concept of an account. Actually the account can be represented as the knowledge of the private-public key pair on which the address was created.

3. What is a wallet?

> Blockchain, similar to an address, is wallet-aware. It's just some kind of client application that will store the private-public key pairs (thus it will have the addresses associated with that account), calculate the balance, facilitate user interaction with the blockchain, etc.

4. Is each wallet connected to only one address or account?

> No, the wallet has as many addresses and accounts as you want. In other words, you can hold as many public-private key pairs as you like, and therefore addresses and accounts.

The last question is about the balance of the wallet. I know balance is calculated based on UTXO. So, my question is, is this balance calculated by addresses, that is, by accounts? In other words, if you have 5 private-public key pairs, there will be 5 addresses (accounts) where for each they will look which UTXOs belong to it and then calculate 5 balances (one for each address/account). So, one wallet with 5 accounts and a separate balance for each of them. Is the above written correct, or is the balance calculated by finding the UTXO associated with the wallet addresses and then the balance is calculated as the total value. In other words, no matter how many addresses there are, there will always be only one balance, that is, there will always be only one account per wallet. If the second is true, it actually means that the concept of an account does not even exist within Bitcoin, that is, that a wallet is actually an account. I ask because in Metamask wallets, as I have seen, you have multiple accounts (one account corresponds to one address) in one wallet and a balance in each account. It's separate.

Thank you very much for your help.

**Tags:** wallet, balance, bitcoin-core-accounts

> **Comments:**
> **username_1**: Hi Filip, our website works best if a topic is started by asking an open question, and answers are posted in response. It tends to not work well, if you post many questions or incorporate your own answer into your question post. Perhaps you could please rephrase your question post into a question and respond to it with the answer you're giving.  
> **username_2**: 1. [What is an address](https://bitcoin.stackexchange.com/a/116371/13866)  
> **username_2**: 2. What is an account? -- [In Bitcoin Core](https://bitcoin.stackexchange.com/a/79835/13866)  
> **username_2**: 3. [What is a wallet](https://bitcoin.stackexchange.com/a/106324/13866)  
> **username_1**: Please check out our [tour] for an overview of how our site works.  

---

## 3 answers

### Answer by username_2 on 2023-03-12. Score: 2 | Accepted answer

> **is this balance calculated by addresses, that is, by accounts?**

You are wrong to conflate addresses and accounts. There are no accounts in the Bitcoin network, nor in the current version of the Bitcoin core wallet, nor in the blockchain data.

There are no balances anywhere in the Bitcoin network data. None in the blockchain.

Most wallets choose to show you a total amount of money in UTXOs for which the wallet holds a private key. Most call this a balance because people are familiar with balances of bank accounts but Bitcoin doesn't work like a bank accounts - it is cash. Balances don't really apply to cash.

Bitcoin core used to have an "account" feature but that was an arbitrary label you could apply to addresses to help you organise your money. That feature was removed and replaced by "labels"

Any "balance" shown by a wallet is likely to be a total across all addresses *UTXOs spendable by use of the private keys generated by the wallet - and therefore a total across at least all "addresses" that might be specifiable for locking scripts relating to many or all of those UTXOs*.

Custodial accounts exist, they are provided by businesses who want to earn an income from cash that people would otherwise keep in their own personal wallets. The balance shown in these accounts is rather like an IOU. There's no guarantee of any sort that the business actually holds any cash or that it can pay you what it owes you.

Bitcoin's inventor primarily wanted to create a system by which one party could pay a second party without any need for a trusted third party to act as intermediary. The idea of custodial accounts is clearly in direct conflict with that goal.

Accounts almost invariably mean custodial accounts. An exploitation by businesses of what was intended to be purely a peer to peer cash payment system. The sort of business exploitation that leads to MtGox, Quadriga-CX, FTX and huge loss of money for thousands of people.

---

In short, The data circulated in the Bitcoin network and the data in the blockchain

* have no accounts
* have no addresses
* have no balances

---

Ye Olde Blockchain:

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

In this cash daybook (cash journal), each page is a block, each line *is* a UTXO, a primitive proto-Bitcoin. It's just that the network protocol involved moving lumps of metal and paper between people's pockets rather than electrical impulses between people's computers.

> **Comments:**
> **username_0**: First of all, thank you very much for your reply. Second, I also realized that the concept of account, wallet and its balance does not exist in the context of blockchain, so I labeled them as something abstract, something that exists in user applications only to facilitate interaction for users. At the end, you wrote that the network has no accounts, balances and addresses? I understand the first two, but how do you think there is no address? I mean, even in text you wrote the following: `Any "balance" shown by a wallet is likely to be a total across all addresses.`  
> **username_2**: A Bitcoin "address" is a string of printable characters that a Bitcoin recipient (e.g. a seller of goods or services) shows to a Bitcoin sender (purchaser of goods or services), often in the form of a 2-D barcode, so that the sender can create a specific locking script in one output of a transaction. It is only the locking script that exists in the Bitcoin data in the network or in the blockchain. Wallets may show you addresses corresponding to a standard type of locking scripts for which the wallet contains private keys that can be used to create a corresponding unlocking script.  ....  
> **username_2**: ... Some types of locking scripts don't have have any standard address. Despite this, I sometimes write about Bitcoin addresses because this is a lot to describe every time we want to discuss Bitcoin payments. Sometimes you can lose sight of the forest because the trees get in the way.  
> **username_2**: P.S. Your (implicit?) criticism is valid, It is just that sometimes I don't have the time to work out a completely unambiguous yet concise answer.  
> **username_0**: So there are no addresses in the bitcoin blockchain? I mean even @username_1 (comment below) talks about addresses. Also, I am reading `Mastering Bitcoin by Andreas M. Antonopoulos` and addresses are also discussed. Or maybe you want to say that there are addresses that are used to create a lock script that is then used in transactions, and bitcoin only recognize that (bitcoin does not recognize the addresses)? Now you have me completely confused. Do you have a suggestion for a good book or material that goes into ultra detail about the structure and workings of the Bitcoin blockchain?  
> **username_2**: There are no addresses in the Bitcoin blockchain. If you want, you can derive addresses from information in the blockchain, specifically from locking scripts. There are standard ways of deriving an address from (or for) certain standard types of locking script. But the payment system which the Bitcoin network provides does not use addresses inside the network.  The Antonopoulos book is the best one I know of.  
> **username_2**: And yes, everybody often use words imprecisely in order to avoid overloading readers with obscure or esoteric details when trying to convey more basic principles. After all: wallets don't contain money, unlike real wallets; addresses don't identify locations, unlike real addresses; Bitcoins are never transmitted anywhere. Bitcoins don't exist as data entities; If UTXO's are coins, they are coins that never change owners, unlike real coins. They are coins that are melted down and recast when you spend them, unlike real coins. etc etc.  
> **username_0**: I just started the Antonopoulos book. Is everything (everything you're telling me right now) explained within the book? I mean, is the explanation that there are no addresses but a lock script derived from them? Also, if you've read it, I'm interested in whether everything written there is correct, that is, whether the algorithms that were explained are still valid? In other words, has bitcoin moved to something else or are those algorithms still being used. I ask because the book is from 2017/18. All the best!  
> **username_0**: Thanks for the image you added later and for the more detailed explanation of the block transaction concept and UTXO. It would help me a lot if you know the answer to the question I asked in the previous comment.  
> **username_2**: I expect the second edition is almost entirely still correct, relevant and worth reading. The algorithms are likely all still valid. It won't cover some recent developments, perhaps not taproot and one or two other things.  
> **username_0**: Thanks for the help, I appreciate it.  

---

### Answer by username_3 on 2023-03-15. Score: 2

All spendable bitcoins are locked in UTXOs (Unspent Transaction Outputs)

When you want to spend bitcoin, you use one or more of your UTXOs as inputs to a transaction, and create one or more outputs. Since these inputs are now spent, they are no longer UTXOs, and while the new outputs are not spent, they are UTXOs.

So when you spend bitcoin you spend UTXOs and generate new UTXOs.

UTXOs are locked by locking scripts, and there are different locking scripts:

* P2PK (Pay to Public Key) where the UTXO is locked to a particular public key, and you need to present a signature (by the corresponding private key) to unlock it;
* P2PKH (Pay to Public Key Hash) where the UTXO is locked to a public key hash, and you need to present the public key and a signature to unlock it;
* P2SH (Pay to Script Hash) where the UTXO is locked to a particular script hash, and you need to present the original script and a way to unlock this script to unlock the output;
* Others, but I will stop right here for simplicity.

When you want to send me some bitcoins, what will happen is you are going to spend one or more of your UTXOs and lock those bitcoins in one UTXO I control. So, I need to tell you how I want my UTXO locked.

And here is where addresses come through: it’s a way for my wallet to inform your wallet how I want my UTXO locked.

So, if I show you an address starting with ‘1’, I’m saying that I want my UTXO locked in a P2PKH script with the following public key hash (that your wallet finds in the rest of the address).

If I show you an address starting with ‘3’, I’m saying that I want my UTXO locked in a P2SH script with the following script hash (that your wallet finds in the rest of the address).

Addresses also have a checksum suffix to prevent errors.

There is no address format for P2PK.

A wallet is a tool where you store secrets (private keys, master seeds, …) and sign transactions. Remember, you need to present signatures to unlock your UTXOs, and this is where those signatures come from.

For privacy reasons you should never reuse a public key.

A modern wallet is Hierarchical Deterministic, which means it doesn’t need to store all private keys it has ever used/generated. It just needs to store a master seed, since all keys can be derived in a deterministic way from that master seed.

To calculate the balance for a specific master seed, the wallet goes like this:

1. Derive the first private key (and corresponding public key)
2. Calculate possible locking scripts for that public key (P2PK, P2PKH, …)
3. Search the UTXOs set for UTXOs locked with any of the above scripts
4. When finds one UTXO locked that way, add the value of that UTXO to the balance
5. Repeat process until it finds 1000 straight public keys with no UTXOs

> **Comments:**
> **username_1**: Good answer! Perhaps “tool” would be better than “place” as a label for what the wallet is. The gap limit used by Bitcoin Core is 1000, not 20.  
> **username_3**: @username_1 thanks for the suggestion and correction. Changed.  

---

### Answer by username_1 on 2023-03-12. Score: 1

> Is each wallet connected to only one address or account?

Addresses have the character of invoice identifiers. You should only use each address once in the context of a specific payment interaction. Addresses are used by recipients to inform senders what output script they expect the payment to be locked to. I am not sure how the concept of accounts as you describe it is useful in this context.

You mention Metamask—Ethereum works very differently in regard to tracking funds: it’s an account-based system. Funds are associated with one *reused* address and you can freely spend any portion of your balance. Bitcoin uses the UTXO-model: your funds are structured in discrete chunks that have to be spent in full like coins and bills in the physical world. Sure, you can sum up all the coins and bills in your wallet and refer to that sum as a balance. You can’t spend your whole Bitcoin wallet balance though, because you’ll also need to pay transaction fees, you can only spend discrete chunks of it and will need to consider change outputs, etc. so that may be confusing.

In Bitcoin, the most recent use of “account” that I’ve seen was people using the term as an opposite to “wallet”: if you manage your own key material and self-custody your funds, you have a *wallet*, when you use a custodial service that only shows you your balance they owe you, you have an *account*.

> **Comments:**
> **username_0**: So, if I understood correctly. A wallet contains private-public key pairs and thus addresses derived from a given public key. A new address (that is, a new private-public key pair) should be used for each transaction, but it doesn't have to be. UTXO is tied to addresses, where will a wallet containing given addresses, then add up all UTXO across all addresses and display that to the user as a balance?  
> **username_1**: Wallets only “contain” private keys. They may track transactions and UTXOs that are relevant to the wallet owner, but those are not “in the wallet” but part of the global state of the network. Addresses don’t exist in transactions, they exist only out of band. Addresses are just a transfer format for the recipient to inform the sender what output script to use to pay them: they’re a user-friendly shorthand for some output scripts.—If you wanted to get an idea of your spendable funds, yes, you should sum up all of your UTXO’s value. You might call that the balance of a wallet.  
> **username_0**: Thanks for the help, I appreciate it.  

---

