Widespread Augmented Reality

Widespread Augmented Reality
Click on the image to get the Android Augmented Reality Heads up Display

Thursday, November 18, 2021

Bitcoin Parse out the Blockchain into JSON

A bitcoin does not exist as a single persistent digital file that is passed around. Rather, bitcoins are referenced in transaction amounts between addresses a.k.a. accounts a.k.a. wallets a.k.a. nodes on an unstructured peer to peer network overlayed on top of TCP/IP a.k.a. the internet. At any rate, back to the bitcoin concept, if there are only two addresses in the system and address-1 has 50 bitcoins while address-2 has 0, then there are 50 bitcoins. One does not examine each bitcoin. If address-1 sends 25 bitcoins to address-2 then you have a transaction that tracks the movements of bitcoins. Now both address-1 and address-2 have 25 bitcoins each with a total of 50 bitcoins in existence. The 50 bitcoins have not left the Bitcoin system and are password locked into the two addresses. You know there are 50 bitcoins because the transactions state that. Again, you will not be able to examine each bitcoin individually because they don't exist except as an amount in a transaction between or among addresses.

Now let's say that another party wants to join the Bitcoin system and connects as address-3. Naturally address-3 has no bitcoins because all 50 bitcoins reside at addresses-1 and address-2. Feeling generous, address-2 sends 10 bitcoins to address-3. This transaction results in [address-1 = 25 bitcoins], [address-2 = 15 bitcoins] and [address-3 = 10 bitcoins] with the total bitcoins in existence still being 50. Finally, these addresses or accounts are secured with passwords and the transactions are cryptographically linked together so that any effort to change a transaction will have to include undoing all the preceding transactions and hiding this from all the connected addresses that are participating in this Bitcoin system. A further deterent to hacking bitcoin transactions is that an address will be rewarded with new bitcoins if that address runs the program that links these transactions into a cryptographically locked block of data. An address that joins the system and performs the computationally intensive locking task is called a miner. If an address-4 comes along with the techincal expertise to mine a new block, they will be rewarded with some agreed upon amount of bitcoin. For this example, let's say the reward is 50 bitcoins. So now the Bitcoin system has a total of 100 bitcoins, with address-4 being the wealthiest of its members unless addresses 1 through 3 come up with some bitcoin priced product to sell to address-4. Either that or addresses 1 through 3 learn to become miners and keep growing the bitcoin supply up towards its maximum of 21MM bitcoins. Anyhow, I just want to see what bitcoin block looks like.

Ran Bitcoin core on Linux laptop to get a few files like blk00828.dat
Got a Python bitcoin block parser from https://github.com/pldespaigne/blk_parser/
From the blk_parser-master\script directory I ran this:
python3 blk_parser.py -i /home/pentoo/Desktop/MyBitCoin/MyBitCoinData/blocks/ -o /home/pentoo/Desktop/MyBitCoin/MyBitCoinData/json/ -n *
This started putting out json files, which then could be viewed with this from inside the JSON folder:
jq '.' tx00828.json | more
Output:

Now I can go to an on-line blockchain explorer with transaction IDs and addresses to further explore the structure of the Bitcoin blockchain.

Fascinating stuff! Elegant solution to digital currency, but perhaps not the most optimal implementation as the peer to peer network grows. We will likely see this naturally move towards centralization and/or splinter off into digital nation states, the two things that bitcoin was seeking to overcome. But time will tell once the supply starts to cap, mining rewards cease and some folks start burning wallets because they can.

No comments:

Post a Comment