Still trying to write a function to properly create a coinbase transaction and the only thing I can't seem to get a hold on is..... How to get the block height provided by getblocktemplate
into the coinbase transaction? - which I create using the createrawtransaction
rpc command. But the thing is, by calling the createrawtransaction
and doing
[{"txid":"0000000000000000000000000000000000000000000000000000000000000000","vout":2147483647}]{" insert address ":6.25000000}
, I'd get a processed hash which is to be added as transaction 0 within the list of transactions before building the merklehash.
This is great but this wouldn't be a valid coinbase transaction as the block height is missing!! - Which is needed as the first 8 bytes of the scriptsig within the coinbase transaction.
So it got me thinking, What if the data field after the address field is where I insert the blocks height?
While reading the Official Bitcoin Developer RPC API Reference, I came across a parameter within the createrawtransaction
rpc command -- The key must be "data", the value is hex-encoded data and I thought maybe this is where I ought to fill in the height data .... which I would grab from here and maybe somehow parse it with this ; after which I then take the hexadecimal hash and insert it within the data field.