Skip to content

Instantly share code, notes, and snippets.

View simform-solutions's full-sized avatar

Simform simform-solutions

View GitHub Profile
# 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:
# Gets the first address after the last address with balance. If there is no saved address it will generate a new one
def get_deposit_address():
try:
l_index = fal_balance[0]["l_index"]
if l_index == 0:
deposit_address = address_data[0]["address"]
return deposit_address
for p in address_data:
address = p["address"]
# Displays all saved addresses and there balance
def full_account_info():
update_addresses_balance(fal_balance[0]["f_index"])
update_fal_balance()
if len(address_data) > 0:
all_address_data = ""
for p in address_data:
address = p["address"]
checksum = p["checksum"]
balance = int(p["balance"])
# Displays all addresses with balance, the total account balance and a deposit address.
# In case that there are no saved addresses it will ask if the account should be scanned for balance
# If the User answers with no, then it will just generate a deposit address (at index 0)
def standard_account_info():
address_count = len(address_data)
update_addresses_balance(fal_balance[0]["f_index"])
update_fal_balance()
if address_count < 1:
find_balance(10)
# Will ask the user to enter the amount and Units (Iota, MegaIota, GigaIota,etc.)
def transfer_value_user_input():
print("\n\nEnter a number and the the unit size.\n"
"Avaliable units are \"i\"(Iota), \"ki\"(KiloIota), \"mi\"(MegaIota), "
"\"gi\"(GigaIota) and \"ti\"(TerraIota)\n"
"Example: If you enter \"12.3 gi\", I will send 12.3 GigaIota\n")
ask_user = True
while ask_user:
user_input = raw_input("Please enter the amount to send: ")
user_input = user_input.upper()
# Gets all necessary data from the user to make one or more transfers
def prepare_transferes():
new_transfer = True
prepared_transferes = []
while new_transfer:
get_recipient_address = True
while get_recipient_address:
recipient_address = raw_input("\nPlease enter the receiving address: ")
if len(recipient_address) == 81:
# Takes the prepared transaction data and sends it to the IOTA node for attaching itto the tangle
def send_transfer(prepared_transferes):
print("Sending transfer, this can take a while...")
change_addy = bytes(get_deposit_address())
api = Iota(iota_node, seed)
api.send_transfer(
depth=7,
transfers=prepared_transferes,
change_address=change_addy,
min_weight_magnitude=18
#execute command according to transaction tag
#To turn on led use this command TURNONLED999999999999999999
#To turn off led use this command TURNOFFLED99999999999999999
#To rotate servo motor use this command TURNONSERVO9999999999999999
def execute_command(command):
print("Transaction tag: " + command)
if command == 'TURNONLED':
blink_led(True)
elif command == 'TURNOFFLED':
blink_led(False)
#rotate servo motor according to transaction
def rotate_motor():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(25, GPIO.OUT)
pwm=GPIO.PWM(25,50)
pwm.start(7.5)
try: