How create coinbase transaction with createrawtransaction?

Bitcoin Asked by tseries on October 24, 2021

I would like to generate a transaction with createrawtransaction such that it can be passed to submitblock along with the block header.

I tried to use:


but it’s not outputting a coinbase transaction:


2 Answers

It is not possible to create a coinbase transaction using createrawtransaction. There are numerous rules that coinbase transactions must follow that the createrawtransaction RPC does not have the ability to set the fields to meet those rules. For example, BIP 34 requires the coinbase contain the block's height in the scriptSig. However createrawtransaction does not allow you to set the anything in the scriptSig.

Miners must use software that can independently create the coinbase transaction. Miners actually prefer doing this because they want to be able to modify the coinbase to use as an extra nonce so that when they run out of nonces, they don't necessarily have to re-select the transactions to include in the block. Instead they can change the coinbase to cause the merkle root to change.

Answered by Andrew Chow on October 24, 2021

According to BIP 34, you must include the block Height to your Coinbase transaction, otherwise, it will be invalid,

The scryptSig of your coinbase transaction, must begin with number of pushed bytes (Actually is 0x03) and then the hex representation of your candidate block, dont forget the little endian conversion

Answered by Hamita on October 24, 2021

Add your own answers!

Related Questions

Name of attack where you pay a high fee to block others

2  Asked on October 24, 2021 by m-johnson


Configure Bitcoin full node in my local LAN

1  Asked on October 24, 2021 by miltonc


missing transaction not received

2  Asked on October 24, 2021 by n-w


I received an email that says someone sent me bitcoin

2  Asked on October 24, 2021 by user107566


OP_LSHIFT & OP_RSHIFT purpose & functionality

1  Asked on October 24, 2021 by bhala-t-r


What is proof-of-work?

3  Asked on October 24, 2021 by dr-haribo


How do I get hash to verify transaction?

1  Asked on October 24, 2021 by kriley


Blockchain API whitelist all IP addresses

1  Asked on October 24, 2021 by samuel-ralak


Error on Centos Minergate Installation

0  Asked on October 24, 2021 by centosminer


bitcoin-cli “Could not connect to the server”

1  Asked on October 24, 2021 by user97315


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir