regarding transaction size in a block

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

Posted 2019-03-26T09:35:07.100

Reputation: 11

By "does each transaction carry a counter", do you mean a counter as to how many transactions are included in the block?Ugam Kamat 2019-03-26T11:34:54.373

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 2019-03-26T11:59:08.927

There’s a counter after the block header, but not part of it. Transactions have no other index.Anonymous 2019-03-26T12:51:10.027

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 2019-03-26T13:13:44.220

Answers

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

Posted 2019-03-26T09:35:07.100

Reputation: 40 910

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 2019-03-26T14:54:12.930

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 2019-03-26T14:58:35.017

@andrewchow when does the transaction counter get the max of 9 bytes ?user92452 2019-03-26T15:15:30.390

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 2019-03-26T16:26:55.793

@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 2019-03-27T01:08:56.077

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 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 2019-03-27T02:03:30.313

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 2019-03-27T03:38:24.937

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 2019-03-27T04:15:03.227

@andrewchow thank you. that does answer a lot of questions.user92452 2019-03-27T10:02:49.167