0

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.

user92452
  • 11
  • 1
  • 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 '19 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 '19 at 11:59
  • There’s a counter after the block header, but not part of it. Transactions have no other index. – Claris Mar 26 '19 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 '19 at 13:13

1 Answers1

2

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

Yes.

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).

Andrew Chow
  • 67,209
  • 5
  • 76
  • 149
  • The "global counter" (between header and transactions) is not a part of consensus block :) You can serialize your data on disk as
    ||<16bit-counter> or |
    | 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 '19 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 '19 at 14:58
  • @andrewchow when does the transaction counter get the max of 9 bytes ? – user92452 Mar 26 '19 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 '19 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 '19 at 01:08
  • That way of asking differently does not make any sense. What is it that you really want to know? The way you are asking questions sounds like an [XY problem](http://xyproblem.info/) as it seems like you are fixated on this counter and think that answering a question about the counter will get you an answer for some other related question. – Andrew Chow Mar 27 '19 at 02:03
  • What is the maximum number of transactions that be showcased by the maximum value which is 9 bytes, could you illustrate this ? Then I might be able to answer my own misunderstandings myself. – user92452 Mar 27 '19 at 03:38
  • Just ask what it is that you are misunderstanding instead of asking for something that you think will help you understand it. A block can contain 16392 minimally sized transactions, including the coinbase transaction. This does not require 9 bytes to represent, it requires 3. The maximum number of transactions that 9 bytes can count is 18446744073709551615 (0xffffffffffffffff), but that far exceeds the maximum number of transactions in a block (and basically the capacity of storage you would find in any computer ). – Andrew Chow Mar 27 '19 at 04:15
  • @andrewchow thank you. that does answer a lot of questions. – user92452 Mar 27 '19 at 10:02