Calculate BitcoinGold Block Header Hash I am trying to calculate block hash # 632295

{ 
'version': 536870912,  
'prev_block_hash': '000000017590609fd72cadc5fd05732cfa1760bd882213afbb7b788c42e115c8', 
'merkle_root': '20e8e04b62d9cd21dbcee23e445fda60a07bc5785a0a2b0b419227c6a2ec936a',  
'reserved': '00000000000000000000000000000000000000000000000000000000',  
'timestamp': 1588602316,  
'bits': 486818083,  
'nonce': '0085c0dd0000000000000000000000000000000000000000000000000106002e',  
'solution': '441cf79198cc4b0fb4dd5f9fa7be645adc4197ff655b555d4139051c9d7b82419f4824f055a5c993390569681ac67061ce041776751d6d72129c18e446dd31d4cc1e78e5d7b4ba440b1d188caffe6da433f73d9d53cfefc36505da3b9270521650a6930064', 
'height': 632295 
}


This is what my code for calculating the hash for Bitcoin looks like, but it does not work for BitcoinGold.

block_array: List = list()
block_array.append(struct.pack('&lt;L', block['version']))
block_array.append(bytes.fromhex(block['prev_block_hash'])[::-1])
block_array.append(bytes.fromhex(block['merkle_root'])[::-1])
block_array.append(struct.pack("&lt;L", block['timestamp']))
block_array.append(struct.pack("&lt;L", block['bits']))
block_array.append(struct.pack("&lt;L", block['nonce']))

header_hex: bytes = bytes.join(b'', block_array)
hash = double_sha256(header_hex)


Next, I turned to the documentation:
https://github.com/BTCGPU/BTCGPU/wiki/Technical-Spec

This suggests that I need to add 3 more fields:


  nHeight, nReserved,nSolution


I believe that the code should look like this for bitcoingold:

block_array: List = list()
block_array.append(struct.pack('&lt;L', block['version']))
block_array.append(bytes.fromhex(block['prev_block_hash'])[::-1])
block_array.append(bytes.fromhex(block['merkle_root'])[::-1])
block_array.append(struct.pack("&lt;L", block['height']))  # 632295
block_array.append(struct.pack("&lt;L", block['reversed']))  # 0
block_array.append(struct.pack("&lt;L", block['timestamp']))
block_array.append(struct.pack("&lt;L", block['bits']))
block_array.append(struct.pack("&lt;L", block['nonce'])))
block_array.append(struct.pack("B", block['solution']))

header_hex: bytes = bytes.join(b'', block_array)
hash = double_sha256(header_hex)


But this does not work, because nonce is not int.

As a result of executing the code, should get this hash:
00000003dd91f04483e990a1ecc5176abdfb18f40ae2ca6b0d203127bc150998

How to convert "nonce" and "solution"?
It is resolved.

block_array: List = list()
block_array.append(struct.pack('&lt;L', block['version']))
block_array.append(bytes.fromhex(block['prev_block_hash'])[::-1])
block_array.append(bytes.fromhex(block['merkle_root'])[::-1])
block_array.append(struct.pack("&lt;L", block['height']))  # 632295
block_array.append(bytes.fromhex(block['reserved']))  # 0
block_array.append(struct.pack("&lt;L", block['timestamp']))
block_array.append(struct.pack("&lt;L", block['bits']))
block_array.append(bytes.fromhex(block['nonce'])[::-1])
block_array.append(bytes.fromhex(block['solution'])[::-1])

header_hex: bytes = bytes.join(b'', block_array)
hash = double_sha256(header_hex)


Fun

def double_sha256(bytes_str: bytes):
    result = sha256(sha256(bytes_str).digest()).digest()
    return result[::-1]  # little endian