How to compute merkle root without coinbasetxn?

0

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.

n8CodeGuru

Posted 2016-01-06T02:03:11.887

Reputation: 101

1Could you clarify the intent behind your question? Calculating the merkle root in the Bitcoin protocol includes the coinbase.Nick ODell 2016-01-06T02:20:38.737

Same as question http://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 2016-01-06T02:23:34.093

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 exampen8CodeGuru 2016-01-06T16:53:29.347

Answers

1

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.

cloudnthings

Posted 2016-01-06T02:03:11.887

Reputation: 357

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 2016-01-06T05:53:33.253

0

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.

n8CodeGuru

Posted 2016-01-06T02:03:11.887

Reputation: 101