Author

Topic: How does the bitcoin client verify that an address has enough coins... (Read 484 times)

donator
Activity: 1218
Merit: 1079
Gerald Davis
That I get but I'm wondering about the UXTO list.  Is that created by the client after analyzing the block chain it downloads?  Does it keep the entire UXTO list (for the whole world) in a separate database or does it just keep transactions that relate to addresses in your wallet? 

There is no separate database but there is a UXTO index which allows quick lookup of transactions.  In theory one could prune the database such that only tx in the UXTO remain.  Your client updates the UXTO in realtime.  As it learns of new confirmed txs (via block notification) the inputs are removed from the UXTO and the new outputs are added.  The client attempts to cache the UXTO to memory (for faster verification) and flush spent outputs only to disk.  If you have sufficient memory available the overhead should be negligible and it allows near instantaneous lookup and valdation.
newbie
Activity: 27
Merit: 0
That I get but I'm wondering about the UXTO list.  Is that created by the client after analyzing the block chain it downloads?  Does it keep the entire UXTO list (for the whole world) in a separate database or does it just keep transactions that relate to addresses in your wallet? 
newbie
Activity: 33
Merit: 0
Thank you for the reply.  Just fascinating.

So when I'm running bitcoin-qt, not only do I have the blockchain downloaded to my harddrive,  I also have the entire UXTO list (not just the UXTO that relate to me).  I guess it builds that list itself as it downloads the blockchain initially?



yeah, the first time you synchronize it download the whole block. it resynchronizes every 10 mins and only download the latest block.
newbie
Activity: 27
Merit: 0
Thank you for the reply.  Just fascinating.

So when I'm running bitcoin-qt, not only do I have the blockchain downloaded to my harddrive,  I also have the entire UXTO list (not just the UXTO that relate to me).  I guess it builds that list itself as it downloads the blockchain initially?
donator
Activity: 1218
Merit: 1079
Gerald Davis
...for the transaction it is a part of (assuming it is the input)?

Does it have to look through the entire block chain to find every instance of that address and see what has been sent to it and what has been taken out of it?  If so, man is that going to get processor intensive in the future?  It can't be the case but I can't find out how this is accomplished anywhere.

Addresses don't have coins.  Bitcoin works on the concept of outputs.  The input of all transactions is the output of a prior one.  The transaction ID of the output being spent is part of the transaction.  The bitcoin network simply looks up the transaction and verifies that it hasn't been spent before.

Your wallet doesn't need to do any checking to see "how much is taken out" because an output can only have two states.  Spent or unspent.  The client keeps a set of all unspent outputs (which is generally significantly smaller than the entire blockchain) called the UXTO.  It can quickly look for outputs to your addresses there and take the sum of those outputs.

When your wallet says "you have 13 BTC" what it means it "I have searched the UXTO and found a number of unspent outputs to addresses for which I have the private key, the sum of those unspent outputs is 13 BTC".

The efficiency of the verification of transactions and the computation of wallet value depends not on the blockchain but on the size of the UXTO.  This generally increases linearly with the number of users.   This is one reason why things like preventing uneconomical dust are important.   If the value of an output is less than the cost to spend it, it won't be spent and thus it will remain in the UXTO.  This reduces the efficiency of all nodes.
newbie
Activity: 27
Merit: 0
...for the transaction it is a part of (assuming it is the input)?

Does it have to look through the entire block chain to find every instance of that address and see what has been sent to it and what has been taken out of it?  If so, man is that going to get processor intensive in the future?  It can't be the case but I can't find out how this is accomplished anywhere.
Jump to: