implemented explore and sign up fee

This commit is contained in:
Ryan Bakkes 2023-11-08 13:42:46 +01:00
parent e41dcc3a1e
commit bdad62d2e2

View File

@ -69,7 +69,7 @@ class MenuHelper:
exit()
case "Explore the Blockchain":
print("TODO")
taskHelper.exploreBlocks(self)
case "Login":
self.user = User(self.db)
@ -84,9 +84,16 @@ class MenuHelper:
case "Sign up":
self.user = User(self.db)
registered = self.user.register()
utilityHelper.clearScreen()
if registered:
print("Registration successful")
new_tx = Tx()
new_tx.createRewardTransaction(self.user.public_ser, self.user.private_ser, "SIGNUP")
if new_tx != False and new_tx.is_valid():
print("Received sign up bonus")
utilityHelper.saveFile("../data/transaction_pool.dat", new_tx)
return
print("Transaction is invalid")
print("Registration failed")
self.user = None
@ -132,26 +139,16 @@ class MenuHelper:
return
case "Explore the Blockchain":
print("TODO")
block = blockHelper.loadBlock()
i = 0
for data in block.data:
print(f"---------------------------------- Block {str(i)} ----------------------------------")
print(f"Block hash: {data.Inputs[0][1]}")
print(f"----------------------------------------------------------------------------------")
i += 1
taskHelper.exploreBlocks(self)
case "Transfer coins":
new_tx = taskHelper.transaction(self)
if new_tx != False and new_tx.is_valid():
# TODO: add to pool
print("Transaction is valid")
utilityHelper.saveFile("../data/transaction_pool.dat", new_tx)
continue
print("Transaction is invalid")
case "Cancel transaction":
print("TODO")
@ -168,7 +165,6 @@ class MenuHelper:
case "Mine a block":
taskHelper.createBlock(self)
print("TODO")
case _:
print("Wrong input, try again")