I want to understand Bitcoin data structure. So i try to understand a raw transaction in json format. When i checked the blockchain.info API documentation, i see that input structure is defined for transactions like this:


But when I query a transaction from blockchain.info, it seems differently:


Is there any document that clearly explains these data fields?

My current wonders:

  1. What is the spent field?
  2. There is no hash field at queried transaction, there must be i think?
  3. What is type field?
  4. Which fields are signed? The signature is generated by which fields hash?

3 Answers 3


You should know that different transaction parsers often include their own fields that aren't directly included in the raw transaction. For example, the "address" would not be found in the raw transaction, but it can be inferred by looking at it. I'm not sure what the 'type' and 'n' fields refer to. You may want to have a look at these links:

dissecting transactions

create raw bitcoin tx

redeeming a raw tx

I'm not sure about your questions 1, 3, it'll be specific to the api. I'm not sure what you are referring to in question 2. For question 4, it depends on the type of transaction (non-segwit or segwit) and the type of signature (sighash_all, sighash_none, sighash_single).


I have been using this for a long time, and I always skipped the fields. Now that you mention it, here is a partial answer:

1.) I do not know.

2.) The transaction hash appears at the end of the list; it also appears in the link you provided.

3.) Another good question. I do not know.

4.) The fields which are signed come from the previous transaction where, basically, the whole data structure is signed with the exception that the "scriptSig" field is filled with the "pubkey" script.

There are three great sources of documentation on transaction structures:

1.) Bitcoin.org Developer Guide

2.) "Mastering Bitcoin" by Andreas Antonopoulos

3.) Bitcoins the hard way: Using the raw Bitcoin protocol

I hope this was beneficial.

  • Thanks for the response. I will look the link that hard way uslng raw bltcoin. The hash that you mentioned in the question 2 is the hash of all transaction. But I am looking for the hash of input transaction hash. It appears in the documention but lt does not exist in the real transaction json. Dec 5, 2017 at 4:21
  • I see. The hash you are looking for does not appear in the tx. This is my answer 3, and indeed is the "tricky" part. An initial transaction is created, with inputs and outputs, and the output script is placed in the sigscript area. This whole structure is then hashed, and signed. Then the output script is removed, and the signature placed in there (and the length fields are adjusted). Quite a bit complicated, when starting, but then with "bitcoins-the-hard-way" fairly easy to understand. Also with Andreas book... Dec 5, 2017 at 19:20

I guess "spent" tells you if it is an UTXO or not.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.