Skip to content

Instantly share code, notes, and snippets.

@simform-solutions
Last active September 20, 2017 06:56
Show Gist options
  • Save simform-solutions/29c35d507f2591623201942770e0026b to your computer and use it in GitHub Desktop.
Save simform-solutions/29c35d507f2591623201942770e0026b to your computer and use it in GitHub Desktop.
# Sends a request to the IOTA node and gets the current confirmed balance
def address_balance(address):
api = Iota(iota_node)
gna_result = api.get_balances([address])
balance = gna_result['balances']
return balance[0]
# Checks all addresses that are saved in the account file and updates there balance
# start_index can be set in order to ignore all addresses befor the start index
def update_addresses_balance(start_index=0):
max_index = 0
for data in address_data:
index = data["index"]
if start_index <= index:
address = str(data["address"])
balance = address_balance(address)
write_address_data(index, address, balance)
if max_index < index:
max_index = index
if max_index < start_index:
print("Start index was not found. You should generate more addresses or use a lower start index")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment