∟Decode Bitcoin Raw Transaction Format

This section describes how to decode a Bitcoin raw transaction format.

Using the data structure given in the previous section, let's decode a raw transaction e22d5998a43e3e1d81784e6e92988d1c4eae77cd0e439542337e48a786 on the Bitcoin test network:

C:\>\local\bitcoin-0.15.1\bin\bitcoin-cli.exe -testnet getrawtransaction 
   e22d5998a43e3e1d81784e6e92988d1c4eae77cd0e439542337e48a786c75e69 false
   
0200000001aa4bc55d88477cc8921c4769e84882e99fc2961219a796b4c4007a2bc5356e6f0
00000006a47304402202ab88452cd720f3e42731a5fd1345e5f2c6888a3d0a0568abf315c46
e6b038cf0220394e02c12aecd9bb2356b4b09980476a4cb347b9e96088f39c995d6d0302fd7
601210387ab1fa2aedc1dfe5fd8fba9275455b392db1e3b7bad3a8d611fb3cdb789f84dfeff
ffff0220ebc4bb130000001976a914c14be92816c5ccfa8c742acba43ee5382ce22eac88ac4
11af129000000001976a9145e25fd265324c70a1a8bbbeb969614d39f6f664788ac0e8d1300

Here are the decoded fields and values:

Hex value  Name and Description

02000000   version - Transaction version 2

01         tx_in_count - 1 transaction input

aa4bc55d88477cc8921c4769e84882e99fc2961219a796b4c4007a2bc5356e6f
           outpoint txid - Identifies an old transaction where this input 
                           came from

00000000   outpoint index - This input was the first 1 output of the old
                            transaction

6a         script bytes - The signature script has 106 bytes.

47304402202ab88452cd720f3e42731a5fd1345e5f2c6888a3d0a0568abf315c46e6b038cf
0220394e02c12aecd9bb2356b4b09980476a4cb347b9e96088f39c995d6d0302fd76012103
87ab1fa2aedc1dfe5fd8fba9275455b392db1e3b7bad3a8d611fb3cdb789f84d
           signature script of this input

feffffff   sequence - End of this input

02         tx_out_count - 2 transaction outputs

20ebc4bb13000000
           value - Amount of the first output in little-endian integer
                   format: 84754623264 Satoshis = 847.54623264 BTC

19         script bytes - The pubkey script has 25 bytes
76a914c14be92816c5ccfa8c742acba43ee5382ce22eac88ac
           pubkey script - Represents the account address of the sender 
                           to keep unused fund of the input.

411af12900000000
           value - Amount of the second output in little-endian integer
                   format: 703666753 Satoshis = 7.03666753 BTC

19         script bytes - The pubkey script has 25 bytes

76a9145e25fd265324c70a1a8bbbeb969614d39f6f664788ac
           pubkey script - Represents my account address

0e8d1300   lock_time - Reference to a block height: 1281294, 
                       meaning this transaction was posted after that block

Table of Contents

 About This Book

 Introduction of Bitcoin

 Bitcoin Blockchain

 Bitcoin Wallet

 Bitcoin Core

 Bitcoin Transaction

 Bitcoin-Qt - Bitcoin Core GUI

 Bitcoin Mining

 Bitcoin Consensus Rules

 Bitcoin Block Data Structure

►Bitcoin Transaction Data Structure

 Data Properties of Bitcoin Transaction

 Data Structure of Bitcoin Raw Transaction Format

►Decode Bitcoin Raw Transaction Format

 Data Structure of Coinbase Transaction

 Calculate Transaction ID

 Bitcoin Blockchain APIs

 Copay - Bitcoin Wallet

 Archived Tutorials

 References

 Full Version in PDF/EPUB