How do you build a merkle root without a coinbase transaction? I compute the merkle root without the coinbase portion and I get a different root then the submitter.

  • 1
    Could you clarify the intent behind your question? Calculating the merkle root in the Bitcoin protocol includes the coinbase. – Nick ODell Jan 6 '16 at 2:20
  • Same as question bitcoin.stackexchange.com/q/28133/31696 actually. I ask for coinbasetxn and do not get it from the pool. Is the pool set up wrong? (i.e I specify the mutable key to return it but it does not) – n8CodeGuru Jan 6 '16 at 2:23
  • basically I am trying to verify I have everything right to compute merkle root if I where to submit a block. So I examine another submission. For an example I use block 391971 and I find that the coinbase transaction is actually at the top. So I change my code to generate the merkle root without a coinbase txn to verify I check the result I get for getrawtransaction of the coinbase transaction and double has that using dblsha(coinbase).encode('hex') now what I get is the little endian form of the hash. I am using the same python code in the exampe – n8CodeGuru Jan 6 '16 at 16:53

What pool are you using? As an example, if you hit (POST a request to) eligius pool (http://gbt.mining.eligius.st:9337) with the body as

{"id": 0, "method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}]}

as taken from https://en.bitcoin.it/wiki/Getblocktemplate you will get a coinbasetxn field returned in the json.

  • You got me :) I'm calling my own bitcoind service. I do not get it back. Perhaps there is a configuration setting. This is what I submit. .\bitcoin-cli.exe getblocktemplate '{\"id\": 0, \"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": [\"coinbasetxn\", \"workid\", \"coinbase/append\"],\"mutable\": [\"coinbase/append\"] }]}' – n8CodeGuru Jan 6 '16 at 5:53

The coinbase transaction is on the top of the list. I was not able to verify the merkle chain because I think I have not reversed the endianess of the hash. I am using the same python code I got from the provided examples. I have not verified that this is the issue yet as I am not sure if I need to put the coinbase txn at the front or the end before the.

I am using dblsha(coinbase).encode('hex') perhaps there is another python method that does not reverse endianess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.