0

Using this post to define the format of a transaction: Create Output with a bunch of input

Why is the previous utxo index (also called the previous output index) 4 bytes?

The maximum output index should be equivalent to the maximum number of outputs that could fit into a transaction which would be constrained by block size. So is 2 bytes not enough? (2 bytes --> max index of 65,535)

Which mined transaction on mainnet has created the highest number of outputs so far?

What is the largest previous output index that has been mined into a block so far?

Related code: https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L30

Related question: Maximum number of inputs per transaction

andozw
  • 25
  • 4
  • I think one question was not answered. Few transactions with 20000 inputs were mined in 2015. Example: `5f4d2593c859833db2e2d25c672a46e98f7f8564b991af9642a8b37e88af62bc` –  Dec 02 '21 at 08:13

2 Answers2

1

Realistically you're probably never going to need more than 2 bytes to represent an output index, but many of the constraints in Bitcoin aren't necessarily that closely defined to their theoretical limits. It could have been represented as a variable length integer as with other values to save a few bytes per output, but it just isn't.

Which mined transaction on mainnet has created the highest number of outputs so far?

The record for most outputs in a transaction is 13107 in 445KiB mined in 2016.

Claris
  • 15,323
  • 2
  • 26
  • 43
1

In theory, a block can contain about 111000 outputs, as outputs can be as small as 9 bytes.

Still, the current 4000000 block weight limit, as well as the 1000000 block size limit that predated it, were both introduced after the transaction serialization format.

Presumably 4 bytes was just some sort of standard choice for serializing integers. Something similar in the other direction happened would timestamps I think; they are also 4 bytes, but probably should have been larger (or less accurate).

Pieter Wuille
  • 98,249
  • 9
  • 183
  • 287