<p>I don't fully understand your question, first a reaction on your assumption.</p>

<p>It is indeed so that your wallet does not hold actual coins. However, consider the distinction between the terms wallet and client. This is not an official distinction, but it is useful to understand the two different principles.</p>

<p>A Bitcoin client, stores the complete block chain. When you request information about an address or a transaction, it can inspect the block chain and retrieve the requested information. So indeed balances are retrieves by a query to the block chain. Most clients keep an index of all transaction of your addresses so that these queries can be achieved very efficiently.</p>

<p>A wallet often refers to the set of private keys of your own addresses. For the default Bitcoin client, this is the wallet.dat file. It contains a list of the addresses you own and the corresponding private keys you need to make transactions with your addresses.</p>

<p>However the term wallet is also often used for a Bitcoin client, f.e. <a href="http://bitcoin.org/en/choose-your-wallet" rel="noreferrer">on the Bitcoin homepage</a>. A caveat here is that some of those wallet indeed do not store the complete block chain but have other techniques to implicitly query the block chain in another way. This sort of clients are called lightweight clients.</p>

<hr>

<p>Now, what a transaction is, in principle, is just a handing over the control over a certain value in the block chain to another address.</p>

<p>For each address there are zero or more transactions that have the address as output. When you did not send them over to someone else, the are called unspent bitcoins or unspent transaction outputs. The sum of those make up the balance of the address.</p>

<p>When you want to send these coins, or a part of them (note that there is no notion of a coin, but just some value of currency that you send which can be any decimal number up to <a href="https://en.bitcoin.it/wiki/Units" rel="noreferrer">satoshi precision</a>), you make a transaction in which you claim some of the unspent outputs for your address (as inputs for your transaction) and distribute the value they have over other addresses (which are the outputs for your transaction). So the unspent outputs for an address can be used as inputs for a transaction.</p>

<p>When you sign the transaction and it gets verified in a block, the unspent outputs are now spent and new unspent outputs have been assigned to the addresses you specified in the transaction outputs for the transaction.</p>

CC BY-SA 3.0
2013-04-27T12:14:42.527Z
Steven- Thank you. You're observation about the distinction between a wallet and client is interesting. When I spoke of a wallet, I was indeed referring to the client. By your definition, the client HAS A wallet; the collection of keys. In my mind, the term wallet is a more user friendly name for the client, as it relates it to the real world equivalent. My question that you didn't understand, as to do with the 'previous transaction' thats hashed -is it the previous transaction in the chain or the previous transaction of that coin? Understanding he inputs/outputs will help I suspect.
Gene M.
CC BY-SA 3.0
2013-04-27T12:23:08.843Z
Most peope call clients wallets, that's why the distinction is not really officially true, but it's useful to understand the different principles. I'll try to explain your question in the answer
Steven Roose
CC BY-SA 3.0
2013-05-01T08:35:36.627Z
As I have read the source on a few client now (bitcoin, bitcoinj, and libbitcoin) I'm come to learn that the wallet (wallet.dat, xxx.wallet or whatever the client names it) is more than a collection of keys and addresses. 

Each client implements the wallet differently, but this comment from bitcoinj sums up its purpose:
"A Wallet stores keys and a record of transactions that send and receive value from those keys. Using these,
it is able to create new transactions that spend the recorded transactions, and this is the fundamental operation of the Bitcoin protocol."
Gene M.
CC BY-SA 3.0
2013-04-27T11:03:35.037Z
2013-04-27T12:33:59.967Z
2013-04-27T12:33:59.967Z
Steven Roose
<p>I'm reading through Satoshi's paper, and in <em>Section 2. Transactions</em>, he starts by saying:</p>
<p>We define an electronic coin as a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.</p>
<p>Then there is a good diagram that shows this in the paper
<img src="https://i.sstatic.net/HUZQ2.jpg" alt="Satoshi bitcoin paper Oct 2008, Section 2" /></p>
<p>So, effectively if BTC0 is the previous transaction, the new transaction is:</p>
<blockquote>
<p>Kp(Owner1)</p>
<p><em>hash</em> := H(BTC0,Kp(Owner1))</p>
<p>S(<em>hash</em>,Ks(Owner0))</p>
</blockquote>
<p>where</p>
<ul>
<li><p>Kp(Owner1) is the public key fo the recipient (Owner1)</p>
</li>
<li><p><em>hash</em> := H(BTC0,Kp(Owner1)) is the Hash of the prev transaction together with the pub key of the recipient</p>
</li>
</ul>
<p>and</p>
<ul>
<li>S(<em>hash</em>,Ks(Owner0)) is the previously computed hash, signed with the private key sender (Owner0)</li>
</ul>
<p>I have a  couple of questions:</p>
<p>Here I've indicated the 'previous transaction' is BTC0- is this the previous transaction for that Coin, or the previous transaction on the chain? Danielle Drainville suggests it is &quot;the previous transaction in which this coin was used is hashed together with the recipient's public key&quot; in her paper (<a href="https://math.uwaterloo.ca/combinatorics-and-optimization/sites/ca.combinatorics-and-optimization/files/uploads/files/Drainville,%20Danielle.pdf" rel="noreferrer">An Analysis of the Bitcoin Electronic Cash System</a>)</p>
<p>If so, there must be some kind of search for the previous transaction first?</p>
<p>And, if I understand correctly, there are no 'Coins' in your wallet...the wallet stores the Block Chain, that is, the Transactions log, and your pub/pri key(s). When you're wallet displays to you, the number of bitcoins 'in' it, its actually the result of a search of the Block Chain?</p>

CC BY-SA 3.0
2013-04-26T12:38:39.553Z
What isn't your rep enough for? Someone can inline pictures for you, provided you give the url somewhere.
Stéphane Gimenez
CC BY-SA 3.0
2013-04-28T09:31:59.423Z
I finally managed to merge my accounts!
Gene M.
<transactions><blockchain><hash>
Explainations about chaining of transactions
Gene M.
# Explainations about chaining of transactions

(Asked by: username_0 on 2013-04-26)

I'm reading through Satoshi's paper, and in *Section 2. Transactions*, he starts by saying:

We define an electronic coin as a chain of digital signatures. Each owner transfers the coin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.

Then there is a good diagram that shows this in the paper
![Satoshi bitcoin paper Oct 2008, Section 2](https://i.sstatic.net/HUZQ2.jpg)

So, effectively if BTC0 is the previous transaction, the new transaction is:

> Kp(Owner1)
>
> *hash* := H(BTC0,Kp(Owner1))
>
> S(*hash*,Ks(Owner0))

where

* Kp(Owner1) is the public key fo the recipient (Owner1)
* *hash* := H(BTC0,Kp(Owner1)) is the Hash of the prev transaction together with the pub key of the recipient

and

* S(*hash*,Ks(Owner0)) is the previously computed hash, signed with the private key sender (Owner0)

I have a couple of questions:

Here I've indicated the 'previous transaction' is BTC0- is this the previous transaction for that Coin, or the previous transaction on the chain? Danielle Drainville suggests it is "the previous transaction in which this coin was used is hashed together with the recipient's public key" in her paper ([An Analysis of the Bitcoin Electronic Cash System](https://math.uwaterloo.ca/combinatorics-and-optimization/sites/ca.combinatorics-and-optimization/files/uploads/files/Drainville,%20Danielle.pdf))

If so, there must be some kind of search for the previous transaction first?

And, if I understand correctly, there are no 'Coins' in your wallet...the wallet stores the Block Chain, that is, the Transactions log, and your pub/pri key(s). When you're wallet displays to you, the number of bitcoins 'in' it, its actually the result of a search of the Block Chain?

**Tags:** transactions, blockchain, hash

> **Comments:**
> **username_1**: What isn't your rep enough for? Someone can inline pictures for you, provided you give the url somewhere.  
> **username_0**: I finally managed to merge my accounts!  

---

## 1 answers

### Answer by username_2 on 2013-04-27. Score: 5 | Accepted answer

I don't fully understand your question, first a reaction on your assumption.

It is indeed so that your wallet does not hold actual coins. However, consider the distinction between the terms wallet and client. This is not an official distinction, but it is useful to understand the two different principles.

A Bitcoin client, stores the complete block chain. When you request information about an address or a transaction, it can inspect the block chain and retrieve the requested information. So indeed balances are retrieves by a query to the block chain. Most clients keep an index of all transaction of your addresses so that these queries can be achieved very efficiently.

A wallet often refers to the set of private keys of your own addresses. For the default Bitcoin client, this is the wallet.dat file. It contains a list of the addresses you own and the corresponding private keys you need to make transactions with your addresses.

However the term wallet is also often used for a Bitcoin client, f.e. [on the Bitcoin homepage](http://bitcoin.org/en/choose-your-wallet). A caveat here is that some of those wallet indeed do not store the complete block chain but have other techniques to implicitly query the block chain in another way. This sort of clients are called lightweight clients.

---

Now, what a transaction is, in principle, is just a handing over the control over a certain value in the block chain to another address.

For each address there are zero or more transactions that have the address as output. When you did not send them over to someone else, the are called unspent bitcoins or unspent transaction outputs. The sum of those make up the balance of the address.

When you want to send these coins, or a part of them (note that there is no notion of a coin, but just some value of currency that you send which can be any decimal number up to [satoshi precision](https://en.bitcoin.it/wiki/Units)), you make a transaction in which you claim some of the unspent outputs for your address (as inputs for your transaction) and distribute the value they have over other addresses (which are the outputs for your transaction). So the unspent outputs for an address can be used as inputs for a transaction.

When you sign the transaction and it gets verified in a block, the unspent outputs are now spent and new unspent outputs have been assigned to the addresses you specified in the transaction outputs for the transaction.

> **Comments:**
> **username_0**: username_2- Thank you. You're observation about the distinction between a wallet and client is interesting. When I spoke of a wallet, I was indeed referring to the client. By your definition, the client HAS A wallet; the collection of keys. In my mind, the term wallet is a more user friendly name for the client, as it relates it to the real world equivalent. My question that you didn't understand, as to do with the 'previous transaction' thats hashed -is it the previous transaction in the chain or the previous transaction of that coin? Understanding he inputs/outputs will help I suspect.  
> **username_2**: Most peope call clients wallets, that's why the distinction is not really officially true, but it's useful to understand the different principles. I'll try to explain your question in the answer  
> **username_0**: As I have read the source on a few client now (bitcoin, bitcoinj, and libbitcoin) I'm come to learn that the wallet (wallet.dat, xxx.wallet or whatever the client names it) is more than a collection of keys and addresses.   Each client implements the wallet differently, but this comment from bitcoinj sums up its purpose: "A Wallet stores keys and a record of transactions that send and receive value from those keys. Using these, it is able to create new transactions that spend the recorded transactions, and this is the fundamental operation of the Bitcoin protocol."  

---

