Bitcoin Transaction Structure

1

Is there a "standard" Bitcoin transaction format?

The context is that I am putting together a tech talk to explain the blockchain concept to complete newbies, and I wanted to show the general structure of a transaction. However, I see different JSON document structures (different field names and content structure) returned by different sources, for the same transaction. For example, compare the output of the following 3 sources for Tx ID 90b18aa54288ec610d83ff1abe90f10d8ca87fb6411a72b2e56a169fdc9b0219

  1. https://blockexplorer.com/api/tx/90b18aa54288ec610d83ff1abe90f10d8ca87fb6411a72b2e56a169fdc9b0219
  2. https://blockchain.info/tx/90b18aa54288ec610d83ff1abe90f10d8ca87fb6411a72b2e56a169fdc9b0219?format=json
  3. https://cdn4.cryptocoinsnews.com/wp-content/uploads/2014/07/Bitcoin_tx_example.png

I know the image (#3) is showing only a subset but it has in and out arrays, and an input has a prev_out object with a hash string field. However, #1 (BlockExplorer) has vin and vout arrays, and the input does not have a prev_out object. It directly contains a string txid field with the hash of previous output transaction. There is yet another JSON structure in #2 (blockchain.info).

Is there an "official" or "standard" JSON structure of a transaction? If so, I would like to show that in my talk. Or what would be the recommended way to show a newbie what a Bitcoin transaction looks like?

Ajoy Bhatia

Posted 2017-04-04T00:10:10.667

Reputation: 167

Answers

1

The official or standard names would be the ones built into the bitcoin JSON-RPC API. The developer reference section is a good place to start you can see example outputs from different calls.

For example the result to the gettransaction call:

{
    "amount" : 0.00000000,
    "fee" : 0.00000000,
    "confirmations" : 106670,
    "blockhash" : "000000008b630b3aae99b6fe215548168bed92167c47a2f7ad4df41e571bcb51",
    "blockindex" : 1,
    "blocktime" : 1396321351,
    "txid" : "5a7d24cd665108c66b2d56146f244932edae4e2376b561b3d396d5ae017b9589",
    "walletconflicts" : [
    ],
    "time" : 1396321351,
    "timereceived" : 1418924711,
    "bip125-replaceable" : "no",
    "details" : [
        {
            "account" : "",
            "address" : "mjSk1Ny9spzU2fouzYgLqGUD8U41iR35QN",
            "category" : "send",
            "amount" : -0.10000000,
            "vout" : 0,
            "fee" : 0.00000000
        },
        {
            "account" : "doc test",
            "address" : "mjSk1Ny9spzU2fouzYgLqGUD8U41iR35QN",
            "category" : "receive",
            "amount" : 0.10000000,
            "vout" : 0
        }
    ],
    "hex" : "0100000001cde58f2e37d000eabbb60d9cf0b79ddf67cede6dba58732539983fa341dd5e6c010000006a47304402201feaf12908260f666ab369bb8753cdc12f78d0c8bdfdef997da17acff502d321022049ba0b80945a7192e631c03bafd5c6dc3c7cb35ac5c1c0ffb9e22fec86dd311c01210321eeeb46fd878ce8e62d5e0f408a0eab41d7c3a7872dc836ce360439536e423dffffffff0180969800000000001976a9142b14950b8d31620c6cc923c5408a701b1ec0a02088ac00000000"
}

Source: https://bitcoin.org/en/developer-reference#gettransaction

m1xolyd1an

Posted 2017-04-04T00:10:10.667

Reputation: 3 356

1Note that gettransaction is a wallet RPC, which shows the effects of a transaction on your own balance/wallet. This depends on which addresses are considered yours, labels/accounts, and other transactions. If you want a pure "decode" of the actual transaction data, use decoderawtransaction on the hex field.Pieter Wuille 2017-04-08T04:53:27.713