I want to compute the merkle root for transactions in a given template block - bitcoind:getblocktemplate().
I understand the merkle root is a hash of all the transactions in a block from the last up to the coinbase transaction, but this is currently way above my pay grade and the documentation I can find for this process is abstract and sketchy at best.
Has anyone done this in JavaScript or know of a resource that could be helpful?
Thanks in advance.
client.getBlockTemplate( function(error, template) {
if (error) return console.log(error);
// SETUP MINING
nonce=0;
const block = {
version: template.version
,previousblockhash: template.previousblockhash
,merkleroot: calculateMerkleRoot(template)
,time: template.mintime
,bits: template.bits
}
// START MINER
miner(block,nonce);
});