Given the following block, how do I verify the proof of work? I got this data from bitcoin-cli getblock and parsed in to a Ruby hash called data:
{"hash"=>"00000000000000001354e21fea9c1ec9ac337c8a6c0bda736ec1096663383429",
"confirmations"=>2, "size"=>529935, "height"=>347928, "version"=>2,
"merkleroot"=>"14b2c974a4f9ab92a68f03a491965063d1f8a2e8b2268fdb4cbce92262bb09c0",
"tx"=>"..removed for space convenience...", "time"=>1426554998,
"nonce"=>3284264479, "bits"=>"18172ec0", "difficulty"=>47427554950.6483,
"chainwork"=>"000000000000000000000000000000000000000000056f68a6406c831f16c1bd",
"previousblockhash"=>"000000000000000007c464352935f12c3695f7de4eee8390f444233682abf8aa",
"nextblockhash"=>"000000000000000016e3530b3a7cdaaa495e6eb70aa8f3f15d02fd078235e931"}
I have tried the following:
version = "02000000"
prev = data["previousblockhash"]
merkle = data["merkleroot"]
time = data["time"].to_s(16) #convert to hex
bits = data["bits"]
nonce = data["nonce"]
hashable = version + prev + merkle + time + bits + nonce
answer = Digest::SHA256.hexdigest hashable
The problem is my answer is this:
b7dc9db86cdf47bf1b13274f88b14211a1ce58c52ac1e41c987b4ad65cf50f4f
but the given answer (in data["hash"]) is
00000000000000001354e21fea9c1ec9ac337c8a6c0bda736ec1096663383429
What am I doing wrong?
Thanks for any help, Kevin