Subject: [bitcoin-dev] Clarification on the use of getblocktemplate RPC method.

From: Mike Rosset <[email-masked]>
Date: Thu, 09 Sep 2021 05:54:18 -0700

Hello all,

I recently went down the bitcoin protocol rabbit hole. I wanted to use
GNU guile scheme to experiment with bitcoin. I initially started by
creating a toy bitcoin miner but I've run into some inconsistencies with
the documentation found on
https://en.bitcoin.it/wiki/Getblocktemplate. Namely with creating the
templates merkle root.

>From my understanding a coinbase transaction should have the
transactions data concatenated before creating the merkle root. But
getblocktemplate does not have a json cointbasetxn field. So I'm not
sure how to create a coinbase transaction without that.

I have a test template response data found here.
https://raw.githubusercontent.com/mrosset/prospect/master/test-suite/data.json
and using a modified version of the merkle python reference script found
on the wiki page. see
https://github.com/mrosset/prospect/blob/master/scripts/merkle.py . I'm
able to create a merkle root with the hash
c5fff939f628a04428c080ed5bd7cd9bc0b4722b2522743049adb18213adf28a but
that's minus the coinbase transaction.

So far I'm able to replicate this hash using the test data in guile. But
I'd like to sanitize this so that I'm using a coinbase transaction and
making sure the python and guile merkle roots match.

In short how do I get the coinbase transaction without the coinbasetxn
field existing?

Mike