In What are the minimum sizes for transactions and blocks in Bitcoin?

The first transaction is set to be 65 bytes long, due to coinbase requirements. What about the second one ? That can be 61 bytes long ? Also, does each transaction carry a counter ? How is that added to the byte count.

  • By "does each transaction carry a counter", do you mean a counter as to how many transactions are included in the block? – Ugam Kamat Mar 26 at 11:34
  • The transaction counter is part of the blockheader or not ? Does the counter refer to the number of all transactions inside the block or does each transaction have a counter ID ? – user92452 Mar 26 at 11:59
  • There’s a counter after the block header, but not part of it. Transactions have no other index. – Anonymous Mar 26 at 12:51
  • There’s a counter after the block header if you mean block serialization to disk by BitcoinCore. In fact, serialization to your disk is not a consensus rule. You have a right to write data on your disk in your own format. – amaclin Mar 26 at 13:13

What about the second one ? That can be 61 bytes long ?


Also, does each transaction carry a counter ?

No. There is a global counter in the block that is right after the block header. That counter is the number of transactions included in the block. It is not part of any transaction and its size does not affect the size of any transaction in the block (compared to when that transaction was unconfirmed and in the mempool).

The transactions come after that counter just listed one after another with no additional information separating them (transactions follow a specific format so it is trivial to know when one ends and the next starts).

  • The "global counter" (between header and transactions) is not a part of consensus block :) You can serialize your data on disk as <header>|<transactions>|<16bit-counter> or <counter>|<header>|<transactions> and so on. And you definetely can add any counters for transactions while saving block to your local database. (There is no reason for it) – amaclin Mar 26 at 14:54
  • The counter is part of the block weight so it is consensus critical. However, yes you can put the counter wherever you want, although blocks received over the network will have them after the header because that's what the block message specifies. – Andrew Chow Mar 26 at 14:58
  • @andrewchow when does the transaction counter get the max of 9 bytes ? – user92452 Mar 26 at 15:15
  • Whenever the counter requires 8 bytes to represent it. Currently this is not possible because that's way too many transactions than can fit within the block weight limit. However the number of bytes required for the counter is variable. – Andrew Chow Mar 26 at 16:26
  • @AndrewChow sorry let me ask differently, how is the value represented in hex ? so with let's say 5 bytes what would be the max value we could obtain ? – user92452 Mar 27 at 1:08

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.