0

If I understand correctly block consists of:

  • block header,
  • transactions counter,
  • list of signed transactions.

Each signed transaction consists of transaction itself and appended signature.

Each transaction consists of:

  • transaction version no,
  • number of inputs,
  • inputs themselves,
  • number of outputs,
  • outputs themselves and
  • locktime.

Each input consists of:

  • Reference to its outputing transaction
  • index of output in that transaction
  • scriptSig

Each output consists of:

  • output value
  • scriptPubKey

Is this structure correct?

  • Where did you get 81 bytes from? – Anonymous Nov 10 '17 at 21:22
  • Found that figure on several places for example here: bitexperts.com/Question/Detail/3333/…, although 80 is more commonly shown. But here en.bitcoin.it/wiki/Block I find now there is more to the structure. – croraf Nov 11 '17 at 10:17
  • It’s 80 bytes, not 81. They’re calling the number of transactions part of the header (and assuming its one byte), which it’s not. – Anonymous Nov 11 '17 at 10:19
  • So in general it is 1-9 bytes, is not part of the header and shows the actual number of transactions in this block (and not always 0)? – croraf Nov 11 '17 at 10:20
  • 1
    Right. It’s just part of the way it’s encoded though, that varint for the number of transactions isn’t included in any hash. It means you don’t know the size of the block until you’ve parsed every single transaction too. – Anonymous Nov 11 '17 at 10:22
1

I'd like to partially answer your question on the tx structure: in general you are right, here some more detail, and yes, you can have several TX_INs and TX_OUTs:

VERSION
TX_IN COUNT
  TX_IN[0] OutPoint hash
  TX_IN[0] OutPoint index
  TX_IN[0] Script Length
  TX_IN[0] Script Sig
  TX_IN[0] Sequence      

TX_OUT COUNT
  TX_OUT[0] Value/Amount in Satoshi
  TX_OUT[0] PK_Script Length
  TX_OUT[0] pk_script     
 LOCK_TIME

So in general the VERSION field at the very beginning and the LOCKTIME at the end is an additional piece. For sure you find further details in the developper section of bitcoin.org, and in Andreas' book "Mastering Bitcoin" (also online available). Avery good overview of the details was also provided here: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html I am not experienced enough to answer the part on the blocks, but it is also mentioned in the links.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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