Skip to content

Instantly share code, notes, and snippets.

@simform-solutions
Last active September 20, 2017 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simform-solutions/30e5c077bccebabc2f7a60ae80bdb51d to your computer and use it in GitHub Desktop.
Save simform-solutions/30e5c077bccebabc2f7a60ae80bdb51d to your computer and use it in GitHub Desktop.
# Generates one or more addresses and saves them in the account file
def generate_addresses(count):
index_list = [-1]
for data in address_data:
index = data["index"]
index_list.append(index)
if max(index_list) == -1:
start_index = 0
else:
start_index = max(index_list) + 1
generator = AddressGenerator(seed)
addresses = generator.get_addresses(start_index, count) # This is the actual function to generate the address.
i = 0
while i < count:
index = start_index + i
address = addresses[i]
balance = address_balance(address)
write_address_data(index, str(address), balance)
i += 1
update_fal_balance()
# Will generate and scan X addresses of an seed for balance. If there are already saved addresses in the ac-
# count data, it will start with the next higher address index
def find_balance(count):
max_gap = 3
margin = 4
i = 0
balance_found = False
print("Generating addresses and checking for balance, please wait...\n")
while i < count and margin > 0:
print("Checking address " + str(i+1) + " in range of " + str(count))
generate_addresses(1)
index_list = []
for data in address_data:
index = data['index']
index_list.append(index)
max_index = max(index_list)
for data in address_data:
index = data['index']
balance = data['balance']
if index == max_index and balance > 0:
balance_found = True
address = data['address']
print("Balance found! \n" +
" Index: " + str(index) + "\n" +
" Address: " + str(address) + "\n" +
" Balanc: " + convert_units(balance) + "\n")
margin = max_gap
if count - i <= max_gap:
count += max_gap
elif index == max_index and margin <= max_gap:
margin -= 1
i += 1
if not balance_found:
print("No address with balance found!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment