我正在尝试确认nonce是正确的,我在python 3.5.2中使用以下代码
import hashlib
# trying to confirm Bloc #480969 from https://blockchain.info/sl/block/000000000000000000a77b8f299f11d6d0919f9b83612a1afdbf28f862066241
version = '0x20000002'
previous_block = '000000000000000000a12aae865630fb42fc43829f823202459f55a614ec49ff'
merkel_root = '66ea9763df0924bb40ed8e3b53c21b7882867356ed6919d37668a28a0551b010'
time = '2017-08-17 18:02:00'
bits = '402731232'
nonce = '3856196048'
target_value = '000000000000000000a77b8f299f11d6d0919f9b83612a1afdbf28f862066241'
input_values = version+previous_block+merkel_root+time+bits+nonce
my_try = hashlib.sha256(input_values.encode()).hexdigest()
if 13*'0'+my_try == target_value:
print('it works')
else:
print('no work')
输出是:
no work
请你好好向我解释一下,我失败了,所以我可以改进我的代码。我试图了解块是如何被推入块链的。
我也不明白merkel root取自何处。