hash – How you can generate a coinbase transaction?

0
71


I’m making a miner in C++ for solo mining, and am struggling to create the right coinbase transaction.

Say I’ve a bc1 deal with, like bc1qfc7fameteuguetm0kfzypnvf2ju6wppdvj6tkc , what can be and instance of a coinbase transaction with this, and the way would I get to it?

https://developer.bitcoin.org/reference/transactions.html

01000000 .............................. Model

01 .................................... Variety of inputs
| 00000000000000000000000000000000
| 00000000000000000000000000000000 ...  Earlier outpoint TXID
| ffffffff ............................ Earlier outpoint index
|
| 29 .................................. Bytes in coinbase // peak+message under, byte size
| |
| | 03 ................................ Bytes in peak
| | | 4e0105 .......................... Top: 328014
| |
| | 062f503253482f0472d35454085fffed
| | f2400000f90f54696d65202620486561
| | 6c74682021 ........................ Arbitrary knowledge // customized knowledge, embrace extranonce right here
| 00000000 ............................ Sequence // i assumed this was all Fs?

01 .................................... Output depend
| 2c37449500000000 .................... // coinbase worth
| ????????????????? ............. // right here, how do i correctly fill this half??
| 00000000 ............................ Locktime

These are the components wanted to create the info for the transaction.

All the pieces as much as the output, i perceive. however i dont know what to place between the coinbase worth and locktime. how does the deal with convert to hex? what OP codes do i want? and is that this transaction format appropriate?

After which I might then hash it and enter it as a brand new transaction into the block as like so,

tx = {
  "knowledge" : "<hex string talked about above>",
  "hash" : "<double sha256 of information above>",
}

is that the one knowledge i want for the json?

Thanks upfront.

LEAVE A REPLY

Please enter your comment!
Please enter your name here