Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: eclipseoto on March 20, 2014, 09:10:23 PM



Title: Question about the index field of a transaction in
Post by: eclipseoto on March 20, 2014, 09:10:23 PM
I've recently been investigating the transaction protocol and have come into a question;

The index on a txin refers to the output of the previous, but can't there be up to 8bytes worth of outputs, while this input field is limited to 4 bytes?  What am I missing here?


Title: Re: Question about the index field of a transaction in
Post by: DannyHamilton on March 20, 2014, 10:21:50 PM
I've recently been investigating the transaction protocol and have come into a question;

The index on a txin refers to the output of the previous, but can't there be up to 8bytes worth of outputs, while this input field is limited to 4 bytes?  What am I missing here?

While I see your point:
Previous Txout-index (Also known as "vout") in the input is an unsigned 4 byte INT while the transaction Out-counter is an unsigned VarInt between 1 and 9 bytes long

It isn't really a problem at the moment because blocks can't exceed a megabyte, and each transaction output is approximately 34 bytes in size.  This means that even if there was a block that was completely filled to max size with nothing but outputs, you couldn't have more than 30,800 ouputs in a transaction.  You don't need a 9 byte VarInt to represent 30,800.  You don't even need a 4 byte unsigned INT.

Therefore, unless the protocol is changed to allow blocks larger than 1 megabyte, Out-Counter shouldn't ever exceed 3 bytes in length.