How to Parse Blockchain Transactions to a Google Drive Folder

In this article, we will analyze bitcoin transactions and learn how to parse RawTX very quickly from the blockchain network to the Google Drive folder, all this will help us better understand how bitcoin transactions work and what all its contents are on the blockchain network.
First, we need to know that all bitcoin transactions are stored in [txid].

txid  is the transaction ID stored on the bitcoin blockchain, RawTX is stored in the form of a double hash.

This means that RawTX went through the SHA256 algorithm twice to get the transaction hash that we see on the blockchain.

For example, a transaction with this hash:  d76641afb4d0cc648a2f74db09f86ea264498341c49434a933ba8eef9352ab6f

Transactions on the bitcoin blockchain are stored in the form of a double hash:

SHA256(SHA256(0100000001f2068914e2fea859cacd8df990daf4008f11296b3cb953794051147a265d850a000000008b483045022043784344e1e0cb498c1d73b4cee970fb0f9adf38b7891d0b1310fdb9cbc23929022100a734f4e97a05bd169a9f0eb296fc841fa57f8753db09869f8f6f8cc1232616d4014104d6597d465408e6e11264c116dd98b539740e802dc756d7eb88741696e20dfe7d3588695d2e7ad23cbf0aa056d42afada63036d66a1d9b97070dd6bc0c87ceb0dffffffff0100b864d9450000001976a9142df31a60b02cce392822c9a87198753578ef7de888ac00000000) = d76641afb4d0cc648a2f74db09f86ea264498341c49434a933ba8eef9352ab6f

To get RawTX we just need to enter the transaction id [txid],

https://blockchain.info/rawtx/[txid]?format=hex

further we will receive information in HEX format, this is our cherished RawTX.

https://blockchain.info/rawtx/d76641afb4d0cc648a2f74db09f86ea264498341c49434a933ba8eef9352ab6f?format=hex

but as we know, there can be a lot of transactions [txid] in one Bitcoin Address and this is the main problem, which takes a lot of time to find, loads our PC and takes up a lot of disk space.

To solve this problem, just use  API the site  https://chain.so/api/

And so, we specify one Bitcoin Address in the bash script:  getrawtx.sh «address» and then we extract the entire previous output hash – all inputs refer to the output (UTXO)

The UTXO  is the  (unspent transaction output)  that will be spent on the new input. The hash value of this is  UTXO stored in reverse order.

As a result, all unspent transaction output will be stored in a file: «RawTX.json»

To get  RawTX Bitcoin Addresses, use  the Bash script: getrawtx.sh

Parsing Blockchain in Google Drive
Parsing Blockchain in Google Drive

How to parse to the Google Drive folder?

To do this, you can use the Terminal for Google Colab  [TerminalGoogleColab]

Earlier I recorded a video tutorial:  “TERMINAL in Google Colab creating all the conveniences for working in GITHUB”

Let’s take a closer look at how the Bash script works: getrawtx.sh

Bash script: getrawtx.sh
Bash script: getrawtx.sh

./getrawtx.sh 12ib7dApVFvg82TXKycWBNpN8kFyiAN1dr

Bitcoin The address that we specify for the  utility command wget

How to Parse Blockchain Transactions to a Google Drive Folder
all content is saved to file: index.json
all content is saved to file: index.json

https://chain.so/api/v2/get_tx_spent/BTC/12ib7dApVFvg82TXKycWBNpN8kFyiAN1dr

The grep utility saves all "txid" transaction IDs into one common index2.json file
The grep utility saves all transaction IDs “txid” into one common file index2.json
all content is saved to file: index2.json
all content is saved to file: index2.json
Delete index.json
Delete index.json
Using the sed utility, remove the "txid" prefix and quotes commas
Using the sed utility, remove the “txid” prefix and quotes commas
Final result in file: index2.json
Final result in file: index2.json
Creating a Python Script Using the Echo Utilities
Creating a Python Script Using the Echo Utilities
Run Python script fileopen.py
Run Python script fileopen.py
After running the Python script fileopen.py, the Bash script rawscript.sh is created
After running the Python script fileopen.py, the Bash script rawscript.sh is created
Delete index2.json
Delete index2.json
We get permissions for the Bash script rawscript.sh and successfully run it!
We get permissions for the Bash script rawscript.sh and successfully run it!
Delete scripts fileopen.py // rawscript.sh
Delete scripts fileopen.py // rawscript.sh
All transactions are saved in the file: "RawTX.json"
All transactions are saved in the file: “RawTX.json”

What advantage do we get as a result:

  • RawTX parsing is fast and everything is saved in one file in the Google Drive folder
  • unlike the getrawtransaction command  «txid», in the console  Bitcoin Сore we do not need to enter  «txid» , just enter Bitcoin Address  getrawtx.sh “address”
  • bash script:  getrawtx.sh  through  site  API https://chain.so/api/  finds unspent transaction output  (UTXO)

Source code:  https://github.com/demining/CryptoDeepTools/tree/main/01BlockchainGoogleDrive

Telegram:  https://t.me/cryptodeeptech

Video:  https://youtu.be/ECAPypsmMQs

Source: https://cryptodeeptech.ru/blockchain-google-drive

Crypto Deep Tech