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() exit()
case "Explore the Blockchain": case "Explore the Blockchain":
print("TODO") taskHelper.exploreBlocks(self)
case "Login": case "Login":
self.user = User(self.db) self.user = User(self.db)
@ -84,9 +84,16 @@ class MenuHelper:
case "Sign up": case "Sign up":
self.user = User(self.db) self.user = User(self.db)
registered = self.user.register() registered = self.user.register()
utilityHelper.clearScreen()
if registered: if registered:
print("Registration successful") 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 return
print("Transaction is invalid")
print("Registration failed") print("Registration failed")
self.user = None self.user = None
@ -132,26 +139,16 @@ class MenuHelper:
return return
case "Explore the Blockchain": case "Explore the Blockchain":
print("TODO") taskHelper.exploreBlocks(self)
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
case "Transfer coins": case "Transfer coins":
new_tx = taskHelper.transaction(self) new_tx = taskHelper.transaction(self)
if new_tx != False and new_tx.is_valid(): if new_tx != False and new_tx.is_valid():
# TODO: add to pool
print("Transaction is valid") print("Transaction is valid")
utilityHelper.saveFile("../data/transaction_pool.dat", new_tx) utilityHelper.saveFile("../data/transaction_pool.dat", new_tx)
continue continue
print("Transaction is invalid") print("Transaction is invalid")
case "Cancel transaction": case "Cancel transaction":
print("TODO") print("TODO")
@ -168,7 +165,6 @@ class MenuHelper:
case "Mine a block": case "Mine a block":
taskHelper.createBlock(self) taskHelper.createBlock(self)
print("TODO")
case _: case _:
print("Wrong input, try again") print("Wrong input, try again")