I'm playing with getblocktemplate, provided by client.
I wrote simple proxy between breakoutd and cgminer, but all my mined block was rejected.
I searched why and I found my math is wrong.
For example, block
14814 has only 1 tx == coinbase tx:
coinbase = '0100000028c8be57010000000000000000000000000000000000000000000000000000000000000000ffffffff0602de39025901ffffffff0100f2052a01000000390000001976a9147d1f3b8b8d5be1353f08acb780780076d188ef6688ac000000000000000000'
Then:
coinbase_hash_bin = hashlib.sha256(hashlib.sha256(binascii.unhexlify(coinbase)).digest()).digest()
and
def build_merkle_root(self, merkle_branch, coinbase_hash_bin):
merkle_root = coinbase_hash_bin
for h in self.merkle_branch:
merkle_root = doublesha(merkle_root + binascii.unhexlify(h))
return binascii.hexlify(merkle_root)
binascii.hexlify(coinbase_hash_bin) results
b1a713d3a3f4cf04ddec887223bb723eb15202edd306a5f8d6ea333fd59027a0and merkle_root == coinbase_hash_bin for this block
Expected merkle root is
4d6d8cad90a9d97f2755d228e4c0764e10774b8511f99e86ef75679607341f58What is wrong?
Thank for help.