diff --git a/Block.py b/Block.py index 66e7c909..9c79c6c7 100644 --- a/Block.py +++ b/Block.py @@ -66,6 +66,7 @@ def get_mined_tx_data(cls, tx_files): fee_collected = 0 tx_included= [] + # we should also account for weight of coinbase tx for tx in tx_files: if (BLOCK_SIZE_FOR_TX -weight_stored)> tx["weights"]: tx_count+= 1 @@ -112,8 +113,6 @@ def create_block(cls, tx_files): # get the data related to tx mined in our block (tx_count,tx_included,fees_collected,weight_stored)=Block.get_mined_tx_data(tx_files) - - #------------------------------------------------------------------------------------------- # create coinbase tx and get serliased form @@ -207,5 +206,3 @@ def get_valid_nonce(self,target): print("shit-man") break return self - - diff --git a/Helper.py b/Helper.py index c6d76a50..a9a72f06 100755 --- a/Helper.py +++ b/Helper.py @@ -3,7 +3,7 @@ import json,hashlib,os -from RIPEMD160 import ripemd160 +from Crypto.Hash import RIPEMD160 ## This function will return all the the transactions @@ -168,11 +168,6 @@ def merkle_root(hashes): def HASH160(s): - return ripemd160(s) + hash_object = RIPEMD160.new(data=s) + return hash_object.digest() - - - - - - diff --git a/__pycache__/Block.cpython-311.pyc b/__pycache__/Block.cpython-311.pyc index bf4190ba..6fb11dc0 100644 Binary files a/__pycache__/Block.cpython-311.pyc and b/__pycache__/Block.cpython-311.pyc differ diff --git a/__pycache__/Helper.cpython-311.pyc b/__pycache__/Helper.cpython-311.pyc index 6b720549..be826db9 100644 Binary files a/__pycache__/Helper.cpython-311.pyc and b/__pycache__/Helper.cpython-311.pyc differ diff --git a/output.txt b/output.txt index 96cb11db..ce83740a 100644 --- a/output.txt +++ b/output.txt @@ -1,4 +1,4 @@ -0060e92f3f18ee206e1350f1cabe4ff319851d4c3c64b8d2d90e03000000000000000000664d84331a42280c640a257b7e2223c2774445a448668a242a075add51187f57cf282d66ffff001f9c2d0100 +0060e92f3f18ee206e1350f1cabe4ff319851d4c3c64b8d2d90e03000000000000000000664d84331a42280c640a257b7e2223c2774445a448668a242a075add51187f57252f2f66ffff001fc8060000 010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff11030cd3bf0c004f4345414e2e58595a002effffffff02e412bf13000000001976a9142c30a6aaac6d96687291475d7d52f4b469f665a688ac0000000000000000266a24aa21a9ed68d3d720d695be2c9d1e2f33c3d9d1042bdec1ce26b563afdc471db6a02a12520120000000000000000000000000000000000000000000000000000000000000000000000000 96cb0dce25d42069df3ad24623a1d0c303e32b30412821f25cb7f6619d2e66c5 dcd522b3588c7adb0418454539e1a929fff936f211e5a20383fdcbc3ad8751b9 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..08e3598e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pycryptodome==3.20.0 diff --git a/run.sh b/run.sh index 4aeb060e..d3f899f4 100755 --- a/run.sh +++ b/run.sh @@ -1,6 +1,8 @@ # Update this file to run your own code #!/bin/bash -# Run main.py and redirect output to Output.txt +# install required dependencies from requirements.txt +pip install -r requirements.txt +# Run main.py and redirect output to Output.txt python main.py > output.txt