def main(): while True: operating_system = platform.system() if operating_system != 'Win64' and operating_system != 'Windows': os.system('clear') else: os.system('cls') print(tuilib.colorize(header, 'pink')) print(tuilib.colorize('TUI v0.0.3\n', 'green')) menu_items_counter = 0 for item in menuItems: print( tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) choice = input(">> ") try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Exit": list(menuItems[int(choice)].values())[0]() elif list( menuItems[int(choice)].keys() )[0] == "Start singleplayer tetris game (creating, registering and starting game)": list(menuItems[int(choice)].values())[0](rpc_connection, False) else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass
def main(): while True: operating_system = platform.system() if operating_system != 'Win64' and operating_system != 'Windows': os.system('clear') else: os.system('cls') print(tuilib.colorize(header, 'pink')) print(tuilib.colorize('TUI v0.0.3\n', 'green')) menu_items_counter = 0 for item in menuItems: if menu_items_counter == 0: print("\nUtility:\n") menu_items_counter = menu_items_counter + 1 print( tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) if menu_items_counter == 6: print("\nNew singleplayer game:\n") if menu_items_counter == 7: print("\nMultiplayer games:\n") if menu_items_counter == 10: print("\nDEX features:\n") choice = input(">> ") try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Exit": list(menuItems[int(choice)].values())[0]() else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass
def main(): while True: os.system('clear') print(tuilib.colorize(header, 'pink')) print(tuilib.colorize('CLI version 0.2\n', 'green')) for item in menuItems: print( tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) choice = input(">> ") try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Exit": list(menuItems[int(choice)].values())[0]() # We have to call SAFE specific functions with connection to SAFE daemon elif list(menuItems[int( choice)].keys())[0] == "Connect to SAFE daemon": rpc_connection_safe = list( menuItems[int(choice)].values())[0]() elif list(menuItems[int( choice)].keys())[0] == "Check connection to SAFE": while True: try: list(menuItems[int(choice)].values())[0]( rpc_connection_safe) break except Exception as e: print("Please connect to SAFE daemon first!") input("Press [Enter] to continue...") break elif list(menuItems[int(choice)].keys() )[0] == "Send SAFE gateway deposit transaction": while True: try: list(menuItems[int(choice)].values())[0]( rpc_connection_safe) break except Exception as e: print(e) print("Please connect to SAFE daemon first!") input("Press [Enter] to continue...") break elif list(menuItems[int( choice)].keys())[0] == "Execute gateways deposit": while True: try: list(menuItems[int(choice)].values())[0]( rpc_connection, rpc_connection_safe) break except Exception as e: print(e) print("Please connect to SAFE daemon first!") input("Press [Enter] to continue...") break else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass
def submenu(menu): menuItems = menu['menu'] while True: os.system('clear') print(tuilib.colorize(menu['header'], 'blue')) print(tuilib.colorize(menu['author'], 'green')) for item in menuItems: print( tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) choice = input(">> ") try: if int(choice) < 0: raise ValueError if list(menuItems[int( choice)].keys())[0] == "Return to Antara modules menu": submenu(antara) elif list(menuItems[int(choice)].keys())[0] in main_menu_options: submenu(list(menuItems[int(choice)].values())[0]) elif list(menuItems[int(choice)].keys())[0] in no_param_options: list(menuItems[int(choice)].values())[0]() elif list(menuItems[int(choice)].keys())[0] in docs_options: index = docs_options.index( list(menuItems[int(choice)].keys())[0]) list(menuItems[int(choice)].values())[0](readme_files[index]) elif list(menuItems[int(choice)].keys())[0] in kmd_connect_options: rpc_connection_kmd = list(menuItems[int(choice)].values())[0]() elif list(menuItems[int(choice)].keys())[0] in kmd_rpc_options: while True: try: list(menuItems[int(choice)].values())[0]( rpc_connection_kmd) break except Exception as e: print("Please connect to KMD daemon first!") input("Press [Enter] to continue...") break elif list(menuItems[int(choice)].keys())[0] in kmd_ac_rpc_options: while True: try: list(menuItems[int(choice)].values())[0]( rpc_connection, rpc_connection_kmd) break except Exception as e: print(e) print("Please connect to KMD daemon first!") input("Press [Enter] to continue...") break else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass
def main(): while True: os.system('clear') print(tuilib.colorize(header, 'pink')) print(tuilib.colorize('CLI version 0.1 by Thor Mennet\n', 'green')) for item in menuItems: print( tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) choice = input(">> ") try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Exit": list(menuItems[int(choice)].values())[0]() elif list( menuItems[int(choice)].keys())[0] == "Pegs Module Readme": list(menuItems[int(choice)].values())[0]('docs/pegs_module.md') # We have to call KMD specific functions with connection to KMD daemon elif list(menuItems[int( choice)].keys())[0] == "Connect to KMD daemon": rpc_connection_kmd = list(menuItems[int(choice)].values())[0]() elif list(menuItems[int( choice)].keys())[0] == "Check connection to KMD": while True: try: list(menuItems[int(choice)].values())[0]( rpc_connection_kmd) break except Exception as e: print("Please connect to KMD daemon first!") input("Press [Enter] to continue...") break elif list(menuItems[int(choice)].keys() )[0] == "Deposit KMD in Gateway and claim Tokens": while True: try: list(menuItems[int(choice)].values())[0]( rpc_connection, rpc_connection_kmd) break except Exception as e: print(e) print("Please connect to KMD daemon first!") input("Press [Enter] to continue...") break else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass
def main(): while True: os.system('clear') print(tuilib.colorize(header, 'pink')) print(tuilib.colorize('CLI version 0.2 by Anton Lysakov\n', 'green')) for item in menuItems: print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) choice = input(">> ") try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Exit": list(menuItems[int(choice)].values())[0]() else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass
def main(): while True: os.system('clear') print(tuilib.colorize(header, 'pink')) print(tuilib.colorize('CLI version 0.1 by Thor Mennet\n', 'green')) for item in menuItems: print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) choice = input(">> ") try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Pegs Module Readme": list(menuItems[int(choice)].values())[0]('docs/pegs_module.md') else: list(menuItems[int(choice)].values())[0]() except (ValueError, IndexError): pass
def main(): menuItems = antara['menu'] while True: os.system('clear') print(tuilib.colorize(antara['header'], 'blue')) print(tuilib.colorize(antara['author'], 'green')) for item in menuItems: print(tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + list(item.keys())[0]) choice = input(">> ") try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Exit TUI": list(menuItems[int(choice)].values())[0]() else: submenu(list(menuItems[int(choice)].values())[0]) except (ValueError, IndexError): pass
#!/usr/bin/env python3 from lib import tuilib rpc_connection_ac = tuilib.def_credentials("ROGUE") games_list = rpc_connection_ac.cclib("games", "17") pastgames_list = games_list["pastgames"] activegames_list = games_list["games"] print(tuilib.colorize("\n*** Pastgames *** \n", "blue")) print("TXID SEED") for game in pastgames_list: pastgame_info = tuilib.rogue_game_info(rpc_connection_ac, game) print(game + " " + str(pastgame_info["seed"])) print(tuilib.colorize("\n*** Active games *** \n", "blue")) print("TXID SEED") for game in activegames_list: activegame_info = tuilib.rogue_game_info(rpc_connection_ac, game) print(game + " " + str(activegame_info["seed"]))
print(e) print("Please connect to KMD daemon first!") input("Press [Enter] to continue...") break else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass if __name__ == "__main__": while True: try: print( tuilib.colorize( "Welcome to the GatewaysCC TUI!\nPlease provide RPC connection details for initialization", "blue")) rpc_connection = tuilib.rpc_connection_tui() rpclib.getinfo(rpc_connection) except Exception: print( tuilib.colorize( "Cant connect to RPC! Please re-check credentials.", "pink")) else: print(tuilib.colorize("Succesfully connected!\n", "green")) with (open("lib/logo.txt", "r")) as logo: for line in logo: print(line, end='') time.sleep(0.04) print("\n")
# Call the matching function if list(menuItems[int(choice)].keys())[0] == "Exit": list(menuItems[int(choice)].values())[0]() else: list(menuItems[int(choice)].values())[0](rpc_connection) except (ValueError, IndexError): pass if __name__ == "__main__": while True: chain = "ROGUE" try: print( tuilib.colorize( "Welcome to the RogueCC TUI!\n" "Please provide asset chain RPC connection details for initialization", "blue")) rpc_connection = rpclib.def_credentials(chain) rpclib.getinfo(rpc_connection) # waiting until chain is in sync while True: have_blocks = rpclib.getinfo(rpc_connection)["blocks"] longest_chain = rpclib.getinfo(rpc_connection)["longestchain"] if have_blocks != longest_chain: print(tuilib.colorize("ROGUE not synced yet.", "red")) print("Have " + str(have_blocks) + " from " + str(longest_chain) + " blocks") time.sleep(5) else: print(tuilib.colorize("Chain is synced!", "green")) break
#!/usr/bin/env python3 from lib import tuilib AC_NAME = "BETSTEST" rpc_connection = tuilib.def_credentials(AC_NAME) while True: # scanning list prices_list = rpc_connection.priceslist("open") print( tuilib.colorize( "Looking for rekts... Current height is: " + str(rpc_connection.getinfo()["blocks"]), "blue")) for position in prices_list: position_info = rpc_connection.pricesinfo(position) if position_info["rekt"] == 1: try: rekt_raw = rpc_connection.pricesrekt( position, position_info["LastHeight"])["hex"] rekt_txid = rpc_connection.sendrawtransaction(rekt_raw) print( tuilib.colorize("MUAHAHA REEEEKTED! TXID: " + rekt_txid, "green")) print( tuilib.colorize( "Position size: " + str(position_info["TotalPositionSize"]), "magenta")) except Exception as e: print(e)
def main(): try: with open(cwd + "/MM2.json") as j: mm2json = json.load(j) gui = mm2json['gui'] netid = mm2json['netid'] passphrase = mm2json['passphrase'] userpass = mm2json['rpc_password'] rpc_password = mm2json['rpc_password'] local_ip = "http://127.0.0.1:7783" MM2_json_exists = True except: MM2_json_exists = False pass while True: os.system('clear') print(tuilib.colorize(header, 'lightgreen')) print(tuilib.colorize(author, 'cyan')) menuItems = [] if not MM2_json_exists: print(tuilib.colorize("No MM2.json file!", 'red')) menuItems.append({"Setup MM2.json file": tuilib.create_MM2_json}) else: status = rpclib.get_status(local_ip, userpass) print('{:^84}'.format(status[0])) num_orders = status[4] if status[1]: swaps_info = tuilib.swaps_info(local_ip, userpass) num_swaps = swaps_info[1] num_finished = swaps_info[2] num_failed = swaps_info[3] num_in_progress = swaps_info[4] print( tuilib.colorize( '{:^68}'.format("[Total swaps: " + str(num_swaps) + "] [Failed swaps: " + str(num_failed) + "] [In Progress: " + str(num_in_progress) + "] "), 'orange')) print( tuilib.colorize( '{:^68}'.format("[You have " + str(num_orders) + " orders active in the orderbook]"), 'orange')) # Build Menu if status[1] is False: menuItems.append({"Start MarketMaker 2": tuilib.start_mm2}) else: menuItems.append({"Stop MarketMaker 2": tuilib.stop_mm2}) if status[2] is False: menuItems.append({"Activate coins": tuilib.activate_all}) if len(status[3]) > 0: menuItems.append( {"View/withdraw balances": tuilib.show_balances_table}) menuItems.append({ "View/buy from orderbook": tuilib.show_orderbook_pair }) menuItems.append( {"View/cancel my orders": tuilib.show_orders_table}) menuItems.append( {"View swaps in progress": tuilib.show_pending_swaps}) menuItems.append( {"Review recent swaps": tuilib.show_recent_swaps}) menuItems.append( {"Review failed swaps": tuilib.show_failed_swaps}) menuItems.append( {"Recover stuck swap": tuilib.recover_swap}) menuItems.append({"Run Tradebot": tuilib.run_tradebot}) menuItems.append({"Exit TUI": tuilib.exit}) print("\n") for item in menuItems: print( tuilib.colorize("[" + str(menuItems.index(item)) + "] ", 'blue') + tuilib.colorize(list(item.keys())[0], 'blue')) choice = input(tuilib.colorize("Select menu option: ", 'orange')) try: if int(choice) < 0: raise ValueError # Call the matching function if list(menuItems[int(choice)].keys())[0] == "Setup MM2.json file": list(menuItems[int(choice)].values())[0]() try: with open(cwd + "/MM2.json") as j: mm2json = json.load(j) gui = mm2json['gui'] netid = mm2json['netid'] passphrase = mm2json['passphrase'] userpass = mm2json['rpc_password'] rpc_password = mm2json['rpc_password'] local_ip = "http://127.0.0.1:7783" MM2_json_exists = True except: input( colorize( "Error in MM2.json file! See MM2_example.json for a valid example..." )) MM2_json_exists = False pass elif list(menuItems[int(choice)].keys())[0] in no_params_list: list(menuItems[int(choice)].values())[0]() elif list(menuItems[int(choice)].keys())[0].find('Menu') != -1: submenu(list(menuItems[int(choice)].values())[0]) else: list(menuItems[int(choice)].values())[0](local_ip, userpass) except (ValueError, IndexError): pass
elif list(menuItems[int(choice)].keys())[0] in no_params_list: list(menuItems[int(choice)].values())[0]() elif list(menuItems[int(choice)].keys())[0].find('Menu') != -1: submenu(list(menuItems[int(choice)].values())[0]) else: list(menuItems[int(choice)].values())[0](local_ip, userpass) except (ValueError, IndexError): pass if __name__ == "__main__": while True: os.system('clear') print("\n\n") with (open("lib/logo.txt", "r")) as logo: for line in logo: parts = line.split(' ') row = '' for part in parts: if part.find('.') == -1: row += tuilib.colorize(part, 'blue') else: row += tuilib.colorize(part, 'black') print(row, end='') #print(line, end='') time.sleep(0.04) time.sleep(0.4) print("\n") break main()
#!/usr/bin/env python3 from lib import tuilib import time import subprocess ac_name = "GWTEST5" start_time = time.time() # proxies for ac_name assetchain and KMD daemon (both should be up)\ rpc_connection_ac = tuilib.def_credentials(ac_name) rpc_connection_kmd = tuilib.def_credentials("KMD") print( tuilib.colorize( "\nSetting up 1of1 test GW for KMD. Please be patient - it can take some time.\n", "green")) # creating token token_hex = rpc_connection_ac.tokencreate("KMD", "1", "Test")["hex"] token_txid = rpc_connection_ac.sendrawtransaction(token_hex) # create oracle oracle_hex = rpc_connection_ac.oraclescreate("KMD", "Test", "Ihh")["hex"] oracle_txid = rpc_connection_ac.sendrawtransaction(oracle_hex) # register as publisher with 10000 sat datafee register_hex = rpc_connection_ac.oraclesregister(oracle_txid, "10000")["hex"] register_txid = rpc_connection_ac.sendrawtransaction(register_hex) # waiting until registration transaction is mined
if __name__ == "__main__": while True: try: info = rpclib.getinfo(rpc_connection) chain = info['name'] if "pubkey" in info.keys(): print("Pubkey is already set") else: valid_address = rpc_connection.getaccountaddress("") print(valid_address) valid_pubkey = rpc_connection.validateaddress(valid_address)["pubkey"] print(valid_pubkey) rpc_connection.setpubkey(valid_pubkey) print(tuilib.colorize("Pubkey is succesfully set!", "green")) except Exception as e: try: print(antara['author']) rpc_connection = tuilib.rpc_connection_tui() except Exception as e: print(e) print(tuilib.colorize("Cant connect to RPC! Please re-check credentials and make sure smartchain is running.", "red")) pass pass else: print(tuilib.colorize("Succesfully connected to "+chain+" smartchain!\n", "green")) time.sleep(1.6) with (open("lib/logo.txt", "r")) as logo: for line in logo: parts = line.split(' ')