Skip to content

Instantly share code, notes, and snippets.

@ShaunApps
Last active March 13, 2019 12:30
Show Gist options
  • Save ShaunApps/861ecd81614f0483283f194fb9020eef to your computer and use it in GitHub Desktop.
Save ShaunApps/861ecd81614f0483283f194fb9020eef to your computer and use it in GitHub Desktop.

Stuff I learned about Coinbase transactions

  • The coinbase transaction can assign the entire reward to a single Bitcoin address, or split it in portions among multiple addresses, just like any other transaction. Coinbase transactions always contain outputs totalling the sum of the block reward plus all transaction fees collected from the other transactions in the same block.

  • What is the format of a coinbase transaction?

    • It has exactly one txin
    • This txin's prevout hash is 0000...0000.
    • This txin's prevout index is 0xFFFFFFFF
    • The txin's prevout script is an arbitrary byte array (it doesn't have to be a valid script, though this is commonly done anyway) of 2 to 100 bytes. It has to start with a correct push of the block height (see BIP34).
    • The sum of the txout's values cannot exceed the subsidy (25 BTC for now, halves every 210000 blocks) plus the fees of the non-coinbase transactions in the same block.
    • There is no standard for putting extranonces in the coinbase transaction. It is really just arbitrary data. You cannot determine what is actually the extra nonce and what is just arbitrary data unless you know what the software that generated the coinbase transaction actually does.
  • Segwit relies on an OP_RETURN output in coinbase transaction for Segwit blocks

  • Looks like whoever mined this block fucked up, or wanted to show off

  • Some blocks include coinbase transactions with an OP_RETURN output related to RSK merged mining, like this one.

  • Bonus: BIP30 another explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment