get balance
This commit is contained in:
parent
f35f9d1a44
commit
34a78d3e64
@ -153,7 +153,7 @@ class MenuHelper:
|
|||||||
print("TODO")
|
print("TODO")
|
||||||
|
|
||||||
case "Check balance":
|
case "Check balance":
|
||||||
print("TODO")
|
taskHelper.getBalance(self)
|
||||||
|
|
||||||
case "Check the pool":
|
case "Check the pool":
|
||||||
transactions = utilityHelper.loadFile("../data/transaction_pool.dat")
|
transactions = utilityHelper.loadFile("../data/transaction_pool.dat")
|
||||||
|
@ -185,3 +185,14 @@ def exploreBlocks(self):
|
|||||||
print("Wrong input, try again")
|
print("Wrong input, try again")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def getBalance(self):
|
||||||
|
balance = 0
|
||||||
|
blocks = utilityHelper.loadFile("../data/ledger.dat")
|
||||||
|
for block in blocks:
|
||||||
|
for transaction in block.data:
|
||||||
|
if transaction.outputs[0][0] == self.user.public_ser:
|
||||||
|
balance += transaction.outputs[0][1]
|
||||||
|
elif transaction.inputs[0][0] == self.user.public_ser:
|
||||||
|
balance -= transaction.inputs[0][1]
|
||||||
|
print(f"Your balance is: {balance}")
|
||||||
|
return balance
|
Loading…
x
Reference in New Issue
Block a user