Skip to content

Commit

Permalink
merkle root
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavitra Agarwal authored and Pavitra Agarwal committed Apr 29, 2024
1 parent 21c29a3 commit 2ace35a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Binary file modified __pycache__/block.cpython-312.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion block.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ def validate_merkle_root(self):

hashes = [h[::-1] for h in self.tx_hashes]
# compute the Merkle Root and reverse
root = merkle_root(hashes)[::-1]
root = merkle_root(hashes)
# return whether self.merkle_root is the same
return root == self.merkle_root
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ def hash2561(data):
block = Block (
version = 0x20000002 ,
prev_block= bytes.fromhex(base_block),
merkle_root= merkle_root(txides)[::-1],
merkle_root= merkle_root(txides),
timestamp= int(ts),
bits=bytes.fromhex('1f00ffff') ,
nonce= bytes.fromhex(nonce()) , #nonce()) , #nonce should be of the bytes
tx_hashes = [bytes.fromhex(h) for h in txids]
)


for h in txids :
print(h)
print(merkle_root(txides).hex())
print(block.validate_merkle_root())


Expand Down
2 changes: 1 addition & 1 deletion output.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
020000200000000000000000000000000000000000000000000000000000000000000000e016e1851957a9a69e138c34bf5c67fdf83581514903d012886f1c3d9d0c54aa60a22f66ffff001f06f16696
020000200000000000000000000000000000000000000000000000000000000000000000aa540c9d3d1c6f8812d00349518135f8fd675cbf348c139ea6a9571985e116e094a32f66ffff001f5dbdb1c1
010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff6a47304402201f6e9296e322013f90f89433926509a9ff686ce91452679c82c921cf18257c95022027497b1354b4dce14b3e15d2372c69d6323ecfad9cbc0c8bb20d8d8d088fc22001210224c6633127ca04e9b678ae7d106a9828ba2aed9a402eefae69f52fbe7a065699ffffffff02f595814a000000001976a914edf10a7fac6b32e24daa5305c723f3de58db1bc888ac0000000000000000266a24aa21a9ed0743cafb2ad89219798f1b2651467d2f6256998e493800f2560784f5f1bcd4670120000000000000000000000000000000000000000000000000000000000000000000000000
FD0600
49a6af777488f947e2b6e2e0ab87f56f44cbfe8280c4dfd9c7c5d9c1b1291f10
Expand Down

0 comments on commit 2ace35a

Please sign in to comment.