From 25e16b99e3260dab796743d5174752fd2d24f865 Mon Sep 17 00:00:00 2001 From: Pavitra Agarwal Date: Tue, 30 Apr 2024 08:40:58 +0530 Subject: [PATCH] merkle --- __pycache__/tx.cpython-312.pyc | Bin 14288 -> 14471 bytes main.py | 4 ++-- output.txt | 2 +- tx.py | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/__pycache__/tx.cpython-312.pyc b/__pycache__/tx.cpython-312.pyc index 02280630b4d10cff225848185e7366b06e6db90c..96b3bc0d2e1d24bd09a70c378f5bda5e43f81868 100644 GIT binary patch delta 787 zcmYL{Ur1AN6vyw`t!=v9?dqLQ=06;{T+KgRcefHMQPXW?78>O=$MDWHtm$t{%|IfI z9tw&MB$RJG^%V6Bf*uN@w}K`HffPYcy(-ajzjHIZ4w0WsPyys+4w{n(1DJv|=hE@|Ye$ujv(3 zO`oZXn+mf+M3rWxpmrU?Rs4CGCPNfUF2gx2F-6!vL$}h>wN*ZyEllf1Y%0%|m64^k zy|7Ot6{-bpO5eQI4~k#?kqv)j)8Dq~Z7(_7alXD5-@B9eTdDSRiL_9L8k;nU; z)H@993L1LEHA{t7-vrL;ZIH(&dZ;c-PR`sycJ^Afm=kN;Ym&t8dZ5;717+Rr!n!M2M?a>*myA-PsTrodNrPmCzB?P2hYyi>K=ai-psu3doz3I^4gsGSyi`7 z;`{S9eWALd?ssWSRF9=;sR5SMkgWiIRYKTwMGgim_cAm*mS_nvz!flbzUm4pcuO4u108D8#|{hYC1-6hJv-5zJ&qgdODN)VZyYN8lQ$}h zVqFV4$Hb}b3kf&$ULNz;6)53#J?kioWmdu0dIswJm)>!xLt@47umWwAa3-A4Mo3l( zdBP|@4X2>Zzl6)m|Nc-U0{3_!QX$`)(K1x=L-df_c8^k11>G?d9`b?Mnha&s;u%=s zgYn$}lXyOng*W_BVh=zCUnLK~d;T+dTZs=-V-Ml9fDvT3gM{sO8Zp;iC@ diff --git a/main.py b/main.py index db5c750..6fafe44 100644 --- a/main.py +++ b/main.py @@ -185,8 +185,8 @@ def initializeTxn(txex , segwitness) : # print(txids) - -txinlittle = [little_endian_to_big_endian_txid(tx) for tx in txids] +txides = [h[::-1] for h in txids] +txinlittle = [little_endian_to_big_endian_txid(tx) for tx in txides] merklebigedian = big_endian_to_little_endian_txid(merkle_root(txinlittle).hex()) # print(little_endian_to_big_endian_txid(txids[0]).hex()) diff --git a/output.txt b/output.txt index bf00635..b97f788 100644 --- a/output.txt +++ b/output.txt @@ -1,4 +1,4 @@ -020000200000000000000000000000000000000000000000000000000000000000000000e016e1851957a9a69e138c34bf5c67fdf83581514903d012886f1c3d9d0c54aa6b5a3066ffff001f9861bea1 +020000200000000000000000000000000000000000000000000000000000000000000000d2bc7e0fa5eb79224ebfaf16f5b618bfa03fde212347e42efd3a45d4ee0cac7111613066ffff001f2ea3fbc7 010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff6a47304402201f6e9296e322013f90f89433926509a9ff686ce91452679c82c921cf18257c95022027497b1354b4dce14b3e15d2372c69d6323ecfad9cbc0c8bb20d8d8d088fc22001210224c6633127ca04e9b678ae7d106a9828ba2aed9a402eefae69f52fbe7a065699ffffffff02f595814a000000001976a914edf10a7fac6b32e24daa5305c723f3de58db1bc888ac0000000000000000266a24aa21a9ed0743cafb2ad89219798f1b2651467d2f6256998e493800f2560784f5f1bcd4670120000000000000000000000000000000000000000000000000000000000000000000000000 FD0600 49a6af777488f947e2b6e2e0ab87f56f44cbfe8280c4dfd9c7c5d9c1b1291f10 diff --git a/tx.py b/tx.py index 1fd9a66..871b1f4 100644 --- a/tx.py +++ b/tx.py @@ -65,6 +65,9 @@ def wtxid(self) : # used to find the wxtid return (hash256(self.serialize_segwit())[::-1]).hex() # used in the formation of the witness commitment # tag::source5[] + def hash256for(self) : + return hash256(self.serialize_legacy()) + def hash(self): return hash256(self.serialize_legacy())[::-1] # currently only serialixe the transaction using the