Advertisement
Guest User

merkle-root-bitcoin-step-by-step

a guest
Jul 9th, 2018
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. import hashlib
  2.  
  3. def hash256(s):
  4.   return hashlib.new('sha256', s).digest()
  5.  
  6. def dhash256(s):
  7.   return hash256(hash256(s))
  8.  
  9. tx1="5b75086dafeede555fc8f9a810d8b10df57c46f9f176ccc3dd8d2fa20edd685b".decode('hex')[::-1]
  10. tx2="e3d0425ab346dd5b76f44c222a4bb5d16640a4247050ef82462ab17e229c83b4".decode('hex')[::-1]
  11. tx3="137d247eca8b99dee58e1e9232014183a5c5a9e338001a0109df32794cdcc92e".decode('hex')[::-1]
  12. tx4="5fd167f7b8c417e59106ef5acfe181b09d71b8353a61a55a2f01aa266af5412d".decode('hex')[::-1]
  13. tx5="60925f1948b71f429d514ead7ae7391e0edf965bf5a60331398dae24c6964774".decode('hex')[::-1]
  14. tx6="d4d5fc1529487527e9873256934dfb1e4cdcb39f4c0509577ca19bfad6c5d28f".decode('hex')[::-1]
  15. tx7="7b29d65e5018c56a33652085dbb13f2df39a1a9942bfe1f7e78e97919a6bdea2".decode('hex')[::-1]
  16. tx8="0b89e120efd0a4674c127a76ff5f7590ca304e6a064fbc51adffbd7ce3a3deef".decode('hex')[::-1]
  17. tx9="603f2044da9656084174cfb5812feaf510f862d3addcf70cacce3dc55dab446e".decode('hex')[::-1]
  18. tx10="9a4ed892b43a4df916a7a1213b78e83cd83f5695f635d535c94b2b65ffb144d3".decode('hex')[::-1]
  19. tx11="dda726e3dad9504dce5098dfab5064ecd4a7650bfe854bb2606da3152b60e427".decode('hex')[::-1]
  20. tx12="e46ea8b4d68719b65ead930f07f1f3804cb3701014f8e6d76c4bdbc390893b94".decode('hex')[::-1]
  21. tx13="864a102aeedf53dd9b2baab4eeb898c5083fde6141113e0606b664c41fe15e1f".decode('hex')[::-1]
  22.  
  23. mrkl_tree1 = dhash256(tx1+tx2)
  24. mrkl_tree2 = dhash256(tx3+tx4)
  25. mrkl_tree3 = dhash256(tx5+tx6)
  26. mrkl_tree4 = dhash256(tx7+tx8)
  27. mrkl_tree5 = dhash256(tx9+tx10)
  28. mrkl_tree6 = dhash256(tx11+tx12)
  29. mrkl_tree7 = dhash256(tx13+ tx13)
  30.  
  31. mrkl_tree1_1 = dhash256(mrkl_tree1 + mrkl_tree2)
  32. mrkl_tree2_2 = dhash256(mrkl_tree3 + mrkl_tree4)
  33. mrkl_tree3_3 = dhash256(mrkl_tree5 + mrkl_tree6)
  34. mrkl_tree4_4 = dhash256(mrkl_tree7 + mrkl_tree7)
  35.  
  36.  
  37. mrkl_tree1_1_1 = dhash256(mrkl_tree1_1 + mrkl_tree2_2 )
  38. mrkl_tree2_2_2 = dhash256(mrkl_tree3_3 + mrkl_tree4_4 )
  39.  
  40. result = dhash256(mrkl_tree1_1_1 + mrkl_tree2_2_2 )
  41.  
  42. print("0e60651a9934e8f0decd1c5fde39309e48fca0cd1c84a21ddfde95033762d86c", "ok")
  43. print result[::-1].encode('hex')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement