If you are new to the Blockchain world then reading my articles posted earlier would be a valuable deal for you. Here, you get some basic knowledge and also all sort of information you must know about the Blockchain world.
https://bit.ly/2SeNJat <- Blockchain Basics and important terminologies.
https://bit.ly/2FzolZT <- How Blockchain works.
In this article, we’ll be breaking down the Bitcoin raw transaction for our better understanding of how a transaction works and what are all its contents in the Bitcoin Blockchain. Firstly, you need to know that transactions are stored on the blockchain by their Transaction Hash. Transactions stored in the bitcoin blockchain are stored in a double-hashed form. This means the raw transaction was put through SHA256 twice to get the Transaction hash we see on the blockchain.
For example, a transaction with this hash: 2621c2609d114f652dadf6fd95820c021da1cf2d0ac15e0361fd5d136e30a3c4
Transaction in the bitcoin blockchain are stored in a double-hashed form:
SHA256(SHA256(01000…) = 2621c2609d114f652dadf6fd95820c021da1cf2d0ac15e0361fd5d136e30a3c4
To get the raw transaction, you can use this Web API: https://bit.ly/2VV6y56 .You just need to enter the transaction id in order to get the raw transaction details.
You can use getrawtransaction “txid” command in the Bitcoin Core Console.
Given the raw transaction= 0100000001f3f6a909f8521adb57d898d2985834e632374e770fd9e2b98656f1bf1fdfd427010000006b48304502203a776322ebf8eb8b58cc6ced4f2574f4c73aa664edce0b0022690f2f6f47c521022100b82353305988cb0ebd443089a173ceec93fe4dbfe98d74419ecc84a6a698e31d012103c5c1bc61f60ce3d6223a63cedbece03b12ef9f0068f2f3c4a7e7f06c523c3664ffffffff0260e31600000000001976a914977ae6e32349b99b72196cb62b5ef37329ed81b488ac063d1000000000001976a914f76bc4190f3d8e2315e5c11c59cfc8be9df747e388ac00000000,
We were able to see more details about the Transaction Data model.
Version — All transactions include information about the Bitcoin Version number so we know which rules this transaction follows.
Input Count — Which is how many inputs were used for this transaction.
Data stored in Input information:
- Previous output hash — All the inputs reference back to an output (UTXO). This points back to the transaction containing the UTXO (Unspent Transaction Output) that will be spent in this input. The hash value of this UTXO is saved in reverse order.
- Previous output index — The transaction may have more than one UTXO which are referenced by their index number. The first index is 0.
- Unlocking Script Size — This is the size of the unlocking script in bytes.
- Unlocking Script — This is the hash of the unlocking script that fulfils the conditions of the UTXO locking script.
- Sequence Number — This is a deprecated feature of bitcoin, currently set to ffffffff by default.
Output Count — which tells us how many outputs were produced from this transaction.
Data stored in Output Information:
- Amount — The amount of Bitcoin outputted in Satoshis (the smallest bitcoin unit). ¹⁰⁸ Satoshis = 1 Bitcoin.
- Locking Script Size — This is the size of the locking script in bytes.
- Locking Script — This is the hash of the locking script that specifies the conditions that must be met in order to spend this output.
Locktime — The locktime field indicates the earliest time or the earliest block that a transaction can be added to the blockchain.
If the locktime is non-zero & less than 500 million, it is interpreted that block height and miners have to wait until that block height is reached before attempting to add it to a block. If the locktime is above 500 million, it is read as a UNIX timestamp which means the number of seconds since the date January 1st 1970. It is usually 0 which means confirm as soon as possible.
Thanks for your read!
Show some love, if you find it helpful 🙂
Related Stories from DDI:
- Why Data will Transform Investment Management
- A Quick Guide to Investment Algorithms
Bitcoin Raw Transaction Breakdown was originally published in Data Driven Investor on Medium, where people are continuing the conversation by highlighting and responding to this story.