1

I'm attempting to estimate how much "spare capacity" there is for merged mining protocols.

As I understand it the scriptSig in the coinbase transaction must be less than 100B. However, the miner can include multiple OP_RETURN statements. For instance this recent block has a coinbase tx with 3 OP_RETURN statements and is 353 bytes.

A. Is there a limit in the overall size of the coinbase tx?

B. Is there a limit to the number of OP_RETURN statements in the coinbase transaction?

C. What is the mean, median, range and general trend in the size of coinbase transactions?

2 Answers 2

2

A. Is there a limit in the overall size of the coinbase tx?

I thought the limit for coinbase was the same as the general limit for transactions.

What is the maximum size of a transaction?

But as Murch noted:

coinbase transactions are not subject to mempool policies and standardness rules, because they are not relayed on the network outside of the context of being included in blocks. Therefore, they are only limited by the blockweight limit instead of the weight limit of 400,000 wu for standard transactions.

n.b. How many weight units does an input use?


B. Is there a limit to the number of OP_RETURN statements in the coinbase transaction?

So far as I know, you can only have one OP_RETURN in any one Bitcoin script, any following data is not parsed.

Like any transaction, a Coinbase transaction can have many outputs, although only one input. So it can have numerous OP_RETURNs.

As Pieter Wuille noted:

There can be multiple OP_RETURN opcodes within a transaction output too. The typical standardness rules about OP_RETURN outputs require the opcode to be the first script byte, but again because standardness rules don't apply to coinbase transactions, that doesn't matter.

It is probably worth saying that scripts in coinbase inputs should never get executed, although the first opcode should push the block height. Other than that, their contents can be considered as arbitrary byte data which might contain the value 0x6A (OP_RETURN) multiple times.


C. What is the mean, median, range and general trend in the size of coinbase transactions

You can work this out if you collect data using a full node such as Bitcoin core. See

You can write your own analytic tool using a blockchain parser. I wrote my own parser library (unpublished) which could be used as follows

package main

import (
    bc "blockchain/blockchain"
    "fmt"
    "os"
    "time"
)

func main() {
    b, err := os.ReadFile(`blk02000.dat`)
    check("Reading data", err)

    parser := bc.New(BlockHandler)
    err = parser.ParseBlocks(&b)
    check("Parsing data", err)
}

// Extract length of coinbase transactions 
var i int = 1
func BlockHandler(b *bc.Block) {
    blockDate := time.Unix(int64(b.Header.TimeStamp), 0).Format("2006-01-02 15:04")
    coinbase :=  b.TransactionList[0]
    txBytes := coinbase.Size()
    fmt.Printf("Block %5d dated %s has coinbase of %5d Bytes\n",
        i, blockDate, txBytes) 
    i++
}

// Rudimentary convenience function for error handling
func check(where string, err error) {
    if err != nil {
        fmt.Println(where, err)
        os.Exit(1)
    }
}

results

Block     1 dated 2020-03-14 06:24 has coinbase of   300 Bytes
Block     2 dated 2020-03-14 14:20 has coinbase of   300 Bytes
Block     3 dated 2020-03-14 08:42 has coinbase of   246 Bytes
Block     4 dated 2020-03-13 23:08 has coinbase of   300 Bytes
Block     5 dated 2020-03-14 04:19 has coinbase of   306 Bytes
Block     6 dated 2020-03-14 15:47 has coinbase of   295 Bytes
Block     7 dated 2020-03-13 14:39 has coinbase of   216 Bytes
Block     8 dated 2020-03-14 13:04 has coinbase of   362 Bytes
Block     9 dated 2020-03-14 09:31 has coinbase of   308 Bytes
Block    10 dated 2020-03-14 10:16 has coinbase of   306 Bytes
Block    11 dated 2020-03-14 15:39 has coinbase of   346 Bytes
Block    12 dated 2020-03-14 08:05 has coinbase of   377 Bytes
Block    13 dated 2020-03-14 13:48 has coinbase of   362 Bytes
Block    14 dated 2020-03-14 17:15 has coinbase of   299 Bytes
Block    15 dated 2020-03-14 06:18 has coinbase of   342 Bytes
Block    16 dated 2020-03-14 11:37 has coinbase of   377 Bytes
Block    17 dated 2020-03-14 12:35 has coinbase of   377 Bytes
Block    18 dated 2020-03-14 17:32 has coinbase of   377 Bytes
Block    19 dated 2020-03-14 13:22 has coinbase of   316 Bytes
Block    20 dated 2020-03-14 18:37 has coinbase of   291 Bytes
Block    21 dated 2020-03-14 15:10 has coinbase of   377 Bytes
Block    22 dated 2020-03-14 09:35 has coinbase of   362 Bytes
Block    23 dated 2020-03-14 12:58 has coinbase of   295 Bytes
Block    24 dated 2020-03-14 06:37 has coinbase of   317 Bytes
Block    25 dated 2020-03-14 18:46 has coinbase of   299 Bytes
Block    26 dated 2020-03-13 23:12 has coinbase of   298 Bytes
Block    27 dated 2020-03-14 16:27 has coinbase of   362 Bytes
Block    28 dated 2020-03-14 16:53 has coinbase of   377 Bytes
Block    29 dated 2020-03-14 19:04 has coinbase of   217 Bytes
Block    30 dated 2020-03-14 07:26 has coinbase of   342 Bytes
Block    31 dated 2020-03-14 13:42 has coinbase of   289 Bytes
Block    32 dated 2020-03-14 20:10 has coinbase of   295 Bytes
Block    33 dated 2020-03-14 12:32 has coinbase of   295 Bytes
Block    34 dated 2020-03-13 08:50 has coinbase of   342 Bytes
Block    35 dated 2020-03-14 18:07 has coinbase of   308 Bytes
Block    36 dated 2020-03-14 16:59 has coinbase of   263 Bytes
Block    37 dated 2020-03-14 21:43 has coinbase of   296 Bytes
Block    38 dated 2020-03-14 20:27 has coinbase of   377 Bytes
Block    39 dated 2020-03-14 18:33 has coinbase of   289 Bytes
Block    40 dated 2020-03-14 18:15 has coinbase of   290 Bytes
Block    41 dated 2020-03-14 23:05 has coinbase of   362 Bytes
Block    42 dated 2020-03-13 16:19 has coinbase of   377 Bytes
Block    43 dated 2020-03-14 13:48 has coinbase of   263 Bytes
Block    44 dated 2020-03-14 09:30 has coinbase of   308 Bytes
Block    45 dated 2020-03-14 20:07 has coinbase of   316 Bytes
Block    46 dated 2020-03-15 01:10 has coinbase of   289 Bytes
Block    47 dated 2020-03-14 19:19 has coinbase of   362 Bytes
Block    48 dated 2020-03-14 19:51 has coinbase of   300 Bytes
Block    49 dated 2020-03-14 22:40 has coinbase of   377 Bytes
Block    50 dated 2020-03-15 02:16 has coinbase of   296 Bytes
Block    51 dated 2020-03-14 21:43 has coinbase of   217 Bytes
Block    52 dated 2020-03-14 15:43 has coinbase of   308 Bytes
Block    53 dated 2020-03-14 22:42 has coinbase of   306 Bytes
Block    54 dated 2020-03-14 20:45 has coinbase of   306 Bytes
Block    55 dated 2020-03-14 12:13 has coinbase of   296 Bytes
Block    56 dated 2020-03-15 04:06 has coinbase of   342 Bytes
Block    57 dated 2020-03-15 01:09 has coinbase of   285 Bytes
Block    58 dated 2020-03-15 05:13 has coinbase of   299 Bytes
Block    59 dated 2020-03-15 00:31 has coinbase of   289 Bytes
Block    60 dated 2020-03-14 17:39 has coinbase of   308 Bytes
Block    61 dated 2020-03-15 01:12 has coinbase of   290 Bytes
Block    62 dated 2020-03-14 22:31 has coinbase of   299 Bytes
Block    63 dated 2020-03-15 08:39 has coinbase of   362 Bytes
Block    64 dated 2020-03-14 13:30 has coinbase of   295 Bytes
Block    65 dated 2020-03-15 01:45 has coinbase of   377 Bytes
Block    66 dated 2020-03-15 02:08 has coinbase of   311 Bytes
Block    67 dated 2020-03-15 03:10 has coinbase of   377 Bytes
Block    68 dated 2020-03-14 19:02 has coinbase of   290 Bytes
Block    69 dated 2020-03-15 01:31 has coinbase of   377 Bytes
Block    70 dated 2020-03-15 03:41 has coinbase of   377 Bytes
Block    71 dated 2020-03-15 09:34 has coinbase of   342 Bytes
Block    72 dated 2020-03-15 03:25 has coinbase of   285 Bytes
Block    73 dated 2020-03-14 16:20 has coinbase of   261 Bytes
Block    74 dated 2020-03-14 21:04 has coinbase of   298 Bytes
Block    75 dated 2020-03-15 04:01 has coinbase of   362 Bytes
Block    76 dated 2020-03-15 05:09 has coinbase of   377 Bytes
Block    77 dated 2020-03-15 04:32 has coinbase of   296 Bytes
Block    78 dated 2020-03-15 05:59 has coinbase of   289 Bytes
Block    79 dated 2020-03-15 03:24 has coinbase of   362 Bytes
Block    80 dated 2020-03-15 05:22 has coinbase of   377 Bytes
Block    81 dated 2020-03-14 18:40 has coinbase of   313 Bytes
Block    82 dated 2020-03-13 17:48 has coinbase of   298 Bytes
Block    83 dated 2020-03-15 10:38 has coinbase of   316 Bytes
Block    84 dated 2020-03-15 06:46 has coinbase of   362 Bytes
Block    85 dated 2020-03-15 06:28 has coinbase of   342 Bytes
Block    86 dated 2020-03-13 10:28 has coinbase of   306 Bytes
Block    87 dated 2020-03-15 06:41 has coinbase of   362 Bytes
Block    88 dated 2020-03-14 23:00 has coinbase of   306 Bytes
Block    89 dated 2020-03-15 04:09 has coinbase of   339 Bytes
Block    90 dated 2020-03-14 21:11 has coinbase of   295 Bytes
Block    91 dated 2020-03-15 11:18 has coinbase of   266 Bytes
Block    92 dated 2020-03-15 09:37 has coinbase of   306 Bytes
Block    93 dated 2020-03-15 09:07 has coinbase of   296 Bytes
Block    94 dated 2020-03-15 11:51 has coinbase of   299 Bytes
Block    95 dated 2020-03-15 09:26 has coinbase of   306 Bytes
Block    96 dated 2020-03-15 02:03 has coinbase of   289 Bytes
Block    97 dated 2020-03-15 12:26 has coinbase of   263 Bytes
Block    98 dated 2020-03-14 23:34 has coinbase of   377 Bytes
Block    99 dated 2020-03-15 10:32 has coinbase of   342 Bytes
Block   100 dated 2020-03-15 11:35 has coinbase of   342 Bytes
Block   101 dated 2020-03-15 10:51 has coinbase of   291 Bytes
Block   102 dated 2020-03-15 10:18 has coinbase of   377 Bytes
Block   103 dated 2020-03-15 05:58 has coinbase of   299 Bytes
Block   104 dated 2020-03-15 11:57 has coinbase of   306 Bytes
Block   105 dated 2020-03-15 13:38 has coinbase of   377 Bytes
Block   106 dated 2020-03-15 03:58 has coinbase of   298 Bytes
Block   107 dated 2020-03-15 02:17 has coinbase of   306 Bytes
Block   108 dated 2020-03-15 05:25 has coinbase of   296 Bytes
Block   109 dated 2020-03-15 06:43 has coinbase of   299 Bytes
Block   110 dated 2020-03-15 10:41 has coinbase of   342 Bytes
Block   111 dated 2020-03-15 12:15 has coinbase of   300 Bytes
Block   112 dated 2020-03-15 11:54 has coinbase of   299 Bytes

Obviously its a small step from that to accumulate min, max, median values by year. Or just feed that data into some other tool.

8
  • 1
    Yes sorry, I was thinking of one OP_Return per script so one per input or output. A coinbase transaction can have many outputs. (Answer updated to clarify) Dec 2, 2022 at 19:08
  • 1
    Great answer. Small correction: coinbase transactions are not subject to mempool policies and standardness rules, because they are not relayed on the network outside of the context of being included in blocks. Therefore, they are only limited by the blockweight limit instead of the weight limit of 400,000 wu for standard transactions.
    – Murch
    Dec 2, 2022 at 19:25
  • 2
    There can be multiple OP_RETURN opcodes within a transaction output too. The typical standardness rules about OP_RETURN outputs require the opcode to be the first script byte, but again because standardness rules don't apply to coinbase transactions, that doesn't matter. Dec 2, 2022 at 20:46
  • 1
    @Pieter thanks. Answer updated. I'm a bit puzzled though. Don't coinbase outputs get validated by nodes so that valid outputs without OP-RETURN can be added to the UTXO list? I'll see what I can learn about standardness vs other validation/checking but more hints welcomed. I guess OP's question B is already answered adequately now though. Dec 2, 2022 at 21:13
  • 1
    There are almost no validity rules that apply to transaction output scripts. Most rules you'd imagine are only run when the output is attempted to be spent, but OP_RETURNs obviously can't ever be spent. There is some "shortcut" implementation rule in Bitcoin Core that detects certain subsets of outputs as unspendable, so they can avoid being inserted into the UTXO set (as they can't ever be spent anyway), but that's a local optimization and doesn't affect what transactions are valid. Dec 2, 2022 at 21:16
2

A. Is there a limit in the overall size of the coinbase tx?

Yes, but its only limited by the size of the block. A miner could choose to have the coinbase transaction fill the entire block!

B. Is there a limit to the number of OP_RETURN statements in the coinbase transaction?

It is only limited by the transaction size limit mentioned above.

C. What is the mean, median, range and general trend in the size of coinbase transactions?

Based on analysis of my local blk.*dat files (up to blk3063.dat):

Mean: 259 bytes (3 sig fig)

Range-Max: 168 bytes

Range-Min: 90 bytes

Range was the same for all parsed blk.dat file aside from blk0000.dat (129 - 3434 bytes)

Trends in mean and median:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.