Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: smokeydog on September 24, 2017, 02:59:40 PM



Title: location of my bitcoin
Post by: smokeydog on September 24, 2017, 02:59:40 PM
I want to send to another party.  How does the software find my balance out of the 20 gig worth of block chain data.  Does the system use indexes or something in the same way an Oracle or other relational database does?  Is the block chain data sorted so that a binary search can find it quickly?


Title: Re: location of my bitcoin
Post by: achow101 on September 24, 2017, 04:01:57 PM
First of all, the blockchain is more than 20 GB, it is around 150 GB now.

Secondly, how software finds data in the blockchain is all up to their implementation. There is no singular standard way to look up blockchain data. Most software use a similar approach though, and what I will be describing is how Bitcoin Core does it.

Bitcoin Core maintains a database separate from the blockchain which contains all of the unspent transaction outputs. This database is updated when blocks are found; outputs that are spent are removed from the database and new outputs that are created are added to it. When a transaction is received, the outputs that it spends from are looked up in that database so that the transaction can be verified. There are no balances, just unspent transaction outputs and a node will look up the outputs that a transaction spends from.

For sending Bitcoin, your wallet maintains its own database of your transactions. It maintains a database separate from the blockchain which contains the transactions and outputs that pertain to you. When you want to spend, that database is read and the outputs that you are spending are chosen from that database.


Title: Re: location of my bitcoin
Post by: smokeydog on September 24, 2017, 04:11:27 PM
Thanks, that was a big help.  There is so much here it's difficult to see the picture.  I would like to just use it and ignore the details but, it's not in my nature to just accept what I don't understand but, I have a feeling I my want to know too much.