transaction fix

This commit is contained in:
Ryan Bakkes 2023-11-12 21:41:02 +01:00
parent f2074251e5
commit 97f919e435

View File

@ -24,28 +24,38 @@ def transaction(self):
try: try:
amount = float(amount) amount = float(amount)
amount = round(amount, 2)
except: except:
print("Wrong input, try again") print("Wrong input, try again")
return False return False
if amount <= 0:
utilityHelper.clearScreen()
print(f"{utilityHelper.warningMessage('Transaction value needs to be above zero')}")
return False
fee = input("Enter fee:") fee = input("Enter fee:")
if fee == "": if fee == "":
return False return False
try: try:
fee = float(fee) fee = float(fee)
fee = round(fee, 2)
except: except:
print("Wrong input, try again") print("Wrong input, try again")
return False return False
if fee < 0:
utilityHelper.clearScreen() utilityHelper.clearScreen()
print(f"{utilityHelper.warningMessage('Transaction fee needs to be above zero or above')}")
return False
print(f"Processing transaction of {amount + fee} coins, {receiver} will receive {amount} coins") utilityHelper.clearScreen()
if amount + fee > taskHelper.getBalanceWithOutgoingPool(self, taskHelper.getBalance(self)): if amount + fee > taskHelper.getBalanceWithOutgoingPool(self, taskHelper.getBalance(self)):
print("You dont have enough money") print("You dont have enough money")
return False return False
print(f"Processing transaction of {amount + fee} coins, {receiver} will receive {amount} coins")
new_tx = Tx() new_tx = Tx()
new_tx.createTransaction(self.user.public_ser, self.user.private_ser, amount, fee, receiver_data[1]) new_tx.createTransaction(self.user.public_ser, self.user.private_ser, amount, fee, receiver_data[1])
return new_tx return new_tx