2

What are the limits of different transactions and scripts (by consensus and standardness)?

Some stack exchange questions discuss some of them (but not all) and all these are scattered around.

What is a summary with basic information about such limits? Or is there a resource I could consult that has such a summary?

2
  • 2
    Are you interested only in standardness, or also "policy" limits? As in standardness being static and policy depending on context. If the latter there is a (non-exhaustive) list of them here github.com/bitcoin/bitcoin/tree/master/doc/policy. Commented Mar 16, 2023 at 8:53
  • Not that much interested in policy limits but definitely worth mentioning it for the benefit of others! Thanks for the comment.
    – karask
    Commented Mar 16, 2023 at 9:58

1 Answer 1

2

Transaction validity vs standardness*

A transaction that follows the consensus rules is a valid transaction. However, some extra rules were introduced that are called standardness rules.

Bitcoin nodes only relay (propagate) standard transactions. Thus the only way to mine a valid but non-standard transaction is by arranging it with a miner.

Bitcoin Transaction Limits

Transaction size limit

The maximum size for legacy (or non-Segwit) transactions is 1 MB, effectively the whole block. The standardness limit, however, is 100 kBs. For Segwit transactions the maximum size limit is 4 MBs (the weight limit). Again, standardness rules reduce that to 400 kBs.

The minimum size for legacy transactions is 65 bytes.

Inputs/Outputs limit

Effectively, as many inputs and outputs as the user wants, provided that it fits in the transaction size limit.

Bitcoin Script Limits

Bare scripts limit

Bare scripts have a size limit of 10k bytes by consensus. However, standardness rules explicitly specify the kind of locking scripts allowed and the scripts are much smaller (e.g. P2PKH is 25 bytes, P2SH is 23 bytes, etc).

P2SH scripts limits

P2SH scripts have a size limit of 10k bytes by consensus. Standardness rules only allow for 520 bytes for the redeem script though, which is enough for a 15-of-15 multisig. The maximum unlocking script (scriptSig) size is 1650 bytes.

P2WSH (Segwit v0) and P2SH-P2WSH limits

P2WSH scripts have a size limit of 10k bytes by consensus. Standardness rules only allow for 3600 bytes for the script witness. In addition, only 201 non-push opcodes are allowed per script and only 520 bytes can be pushed per stack element.

P2TR (Segwit v1) limits

As P2WSH but the script witness is now limited only by the transaction size (4MBs by consensus and 400kBs by standardness).

OP_RETURN DATA limit

The consensus rules have no limit to an OP_RETURN size, i.e. the size of the transaction is the limit. One can also have more than one OP_RETURN in a transaction. However, standardness rules specify that only one OP_RETURN output is allowed per transaction with a maximum data size of 80 bytes.

*EDIT: Specific miners can also apply local policy rules in addition to the consensus rules. Since these are custom configurable rules they are not list here but a list of potential policy rules can be found at https://github.com/bitcoin/bitcoin/tree/master/doc/policy

2
  • 1
    By default all Bitcoin Core nodes enforce the policy limits, it's not specific to miners. Some standardness limits can also be configured, it's not specific to policy limits. Also i think there are a couple mistakes / misses in your standardness limits list. I'll try to compile a list later today if nobody else beat me to it. Commented Mar 16, 2023 at 10:10
  • But if miners don't have them then the limits are moot.. they won't be included in the block so it's still up to them, no? I am aware of some of the misses which I didn't include as it would require further explanation of some concepts. But please, I'd appreciate any fixes and/or a more complete list!
    – karask
    Commented Mar 16, 2023 at 11:05

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.