def test_saving_settings(self): backup_settings = the_settings() temp_settings = the_settings() temp_settings["test_mode"] = True temp_settings["debug_mode"] = True save_settings(temp_settings) temp_test_settings = the_settings() self.assertEqual(temp_test_settings["test_mode"], True, "A problem on the saving the settings.") self.assertEqual(temp_test_settings["debug_mode"], True, "A problem on the saving the settings.") temp_test_settings["test_mode"] = False temp_test_settings["debug_mode"] = False save_settings(temp_test_settings) temp_test_settings2 = the_settings() self.assertEqual(temp_test_settings2["test_mode"], False, "A problem on the saving the settings.") self.assertEqual(temp_test_settings2["debug_mode"], False, "A problem on the saving the settings.") temp_test_settings2["test_mode"] = backup_settings["test_mode"] temp_test_settings2["debug_mode"] = backup_settings["debug_mode"] save_settings(temp_test_settings2)
def test_saving_settings(self): temp_settings = the_settings() temp_test_mode = temp_settings.test_mode() temp_debug_mode = temp_settings.debug_mode() temp_settings.test_mode(True) temp_settings.debug_mode(True) temp_settings.save_settings() temp_test_settings = the_settings() self.assertEqual(temp_test_settings.test_mode(), True, "A problem on the saving the settings.") self.assertEqual(temp_test_settings.debug_mode(), True, "A problem on the saving the settings.") temp_settings.test_mode(False) temp_settings.debug_mode(False) temp_settings.save_settings() temp_test_settings = the_settings() self.assertEqual(temp_test_settings.test_mode(), False, "A problem on the saving the settings.") self.assertEqual(temp_test_settings.debug_mode(), False, "A problem on the saving the settings.") temp_settings.test_mode(temp_test_mode) temp_settings.debug_mode(temp_debug_mode)
class SettingsBox(MDGridLayout): cols = 2 d_first_status = the_settings()["debug_mode"] t_first_status = the_settings()["test_mode"] def D_Status_Changing(self, instance, value): debug_mode(value) def T_Status_Changing(self, instance, value): test_mode(value)
def delete_current_wallet(): """ Deletes the current wallet. """ if not the_settings()["wallet"] == 0: saved_wallets = get_saved_wallet() selected_wallet_pubkey = Wallet_Import(int(the_settings()["wallet"]), 0) for each_wallet in saved_wallets: if selected_wallet_pubkey == saved_wallets[each_wallet]["publickey"]: change_wallet(0) Wallet_Delete(each_wallet) else: print("First wallet cannot be deleted.")
def Wallet_Import(account, mode): temp_saved_wallet = get_saved_wallet() if isinstance(account, int): if not -1 == account: account = list(temp_saved_wallet)[account] else: account = list(temp_saved_wallet)[int(the_settings()["wallet"])] if mode == 0: my_public_key = temp_saved_wallet[account]["publickey"] return my_public_key elif mode == 1: my_private_key = temp_saved_wallet[account]["privatekey"] return my_private_key elif mode == 3: my_address = temp_saved_wallet[account]["publickey"] my_address = "".join([ l.strip() for l in my_address.splitlines() if l and not l.startswith("-----") ]) my_address = Address(my_address) return my_address else: raise ValueError("the mode variable contains an unplanned value")
def callback_for_menu_items(self, *args): if not args[0] == the_settings()["wallet"]: change_wallet(args[0]) self.reflesh_balance() else: change_wallet(args[0]) Clipboard.copy(Wallet_Import(int(args[0]),3)) toast("The address has been copied to your clipboard.")
def Wallet_Delete(self): if not the_settings()["wallet"] == 0: self.show_delete_wallet_alert_dialog() else: SweetAlert().fire( "First wallet cannot be deleted.", type='failure', )
def callback_for_menu_items(self, *args): if not args[0] == the_settings()["wallet"]: change_wallet(int(args[0])) self.reflesh_balance() Clipboard.copy(Wallet_Import(int(args[0]), 3)) SweetAlert().fire( "The address has been copied to your clipboard.", type='success', )
def create_ledger(): if the_settings().test_mode(): dprint("Creating new ledger") system = ledger(Wallet_Import(0, 0)) from node.myownp2pn import MyOwnPeer2PeerNode MyOwnPeer2PeerNode.main_node.send_full_chain() else: dprint("Getting ledger from nodes") get_ledger()
def delete_the_wallet(self, widget): saved_wallets = get_saved_wallet() selected_wallet_pubkey = Wallet_Import(int(the_settings()["wallet"]), 0) for each_wallet in saved_wallets: if selected_wallet_pubkey == saved_wallets[each_wallet][ "publickey"]: change_wallet(0) Wallet_Delete(each_wallet) self.reflesh_balance() self.dismiss_delete_wallet_alert_dialog(widget)
def show_menu(): print( banner_maker( sc_name="Decentra Network", description= "This is an open source decentralized application network. In this network, you can develop and publish decentralized applications.", author="Onur Atakan ULUSOY", email="*****@*****.**")) from lib.settings_system import the_settings if the_settings().test_mode(): print(menu_maker(menu_number="cbl", menu_text="Create ledger")) else: print( menu_maker(menu_number="connectmainnetwork", menu_text="Connect to Main Network")) print(menu_space() + \ menu_maker(menu_number="cw", menu_text="Create wallet")+ \ menu_space() + \ menu_maker(menu_number="sc", menu_text="Send Coin")+ \ menu_space() + \ menu_maker(menu_number="gb", menu_text="Get Balance")+ \ menu_space() + \ menu_maker(menu_number="ndstart", menu_text="Node Start")+ \ menu_maker(menu_number="ndstop", menu_text="Node Stop")+ \ menu_maker(menu_number="ndconnect", menu_text="Node Connect")+ \ menu_maker(menu_number="connectmainnetwork", menu_text="Connect to Main Network")+ \ menu_maker(menu_number="ndconnectmixdb", menu_text="Node Connect from mixdb")+ \ menu_maker(menu_number="ndnewunl", menu_text="Add new UNL node")+ \ menu_space() + \ menu_maker(menu_number="testmodeon", menu_text="Test mode ON")+ \ menu_maker(menu_number="testmodeoff", menu_text="Test mode OF")+ \ menu_maker(menu_number="debugmodeon", menu_text="Debug mode ON")+ \ menu_maker(menu_number="debugmodeoff", menu_text="Debug mode OF")+ \ menu_space() + \ menu_maker(menu_number="getfullnodelist", menu_text="Get Full Node List")+ \ menu_maker(menu_number="getledger", menu_text="Get Ledger From Other Nodes")+ \ menu_space()) for folder_entry in os.scandir('apps'): if ".md" not in folder_entry.name: for entry in os.scandir("apps/" + folder_entry.name): if entry.is_file(): if entry.name[ 0] != '_' and ".py" in entry.name and "_main" in entry.name: print(entry.name) import_command = f"from apps.{folder_entry.name}.{entry.name.replace('.py','')} import {entry.name.replace('.py','')}_cli" tx_command = f"{entry.name.replace('.py','')}_cli()" exec(import_command) exec(tx_command) print(quit_menu_maker(mode="main"))
def send_the_coin(receiver, temp_coin_amount, password): try: temp_coin_amount = float(temp_coin_amount) except ValueError: print("This is not float coin amount.") return False if not temp_coin_amount < GetBlock().minumum_transfer_amount: if Wallet_Import(int(the_settings()["wallet"]), 2) == sha256(password.encode("utf-8")).hexdigest(): send_coin(float(temp_coin_amount), receiver, password) else: print("Password is not correct")
def dprint(text): """ Prints the given data according to the debug mode Inputs: * text: A data (It is returned to str in function.) """ try: from lib.settings_system import the_settings if the_settings()["debug_mode"]: print("DEBUG: " + str(text)) except Exception as e: print(e)
def create_ledger(): if the_settings()["test_mode"]: dprint("Creating new ledger") pubkey = "".join([ l.strip() for l in Wallet_Import(0, 0).splitlines() if l and not l.startswith("-----") ]) system = ledger(pubkey) from node.myownp2pn import MyOwnPeer2PeerNode MyOwnPeer2PeerNode.main_node.send_full_chain() else: dprint("Getting ledger from nodes") get_ledger()
def CreateBlock(): """ If test mode is on, creates genesis block and send the connected nodes, if it is off, it calls get_block() function. """ if the_settings()["test_mode"]: dprint("Creating the genesis block") Block(0, Wallet_Import(0, 3)) mynode.main_node.send_full_accounts() mynode.main_node.send_full_chain() else: dprint("Getting block from nodes") GetBlock()
def sent_the_coins(self, widget): text_list = self.get_send_coin_dialog_text() receiver_adress = text_list[2] amount = text_list[1] if not float(amount) < GetBlock().minumum_transfer_amount: if Wallet_Import(int(the_settings()["wallet"]), 2) == sha256( text_list[0].encode("utf-8")).hexdigest(): send_coin(float(amount), receiver_adress, text_list[0]) else: SweetAlert().fire( "Password is not correct", type='failure', ) del text_list self.send_coin_dialog.dismiss()
def Wallet_Import(account,mode,password = None): """ A function for get info about a wallet. Inputs: * account: Account index of saved accounts (if you give -1 the default wallet will use) * mode: Information mode [0 = Public key | 1 = Private key (needs password) | 2 = Returns sha256 of password | 3 = Returns the address of account] * password: Some function needed password for operation you can give with this input """ temp_saved_wallet = get_saved_wallet() if isinstance(account,int): if not -1 == account: account = list(temp_saved_wallet)[account] else: account = list(temp_saved_wallet)[the_settings()["wallet"]] if mode == 0: my_public_key = temp_saved_wallet[account]["publickey"] return my_public_key elif mode == 1: if not password is None and not list(temp_saved_wallet).index(account) == 0: return decrypt(temp_saved_wallet[account]["privatekey"], password) else: my_private_key = temp_saved_wallet[account]["privatekey"] return my_private_key elif mode == 2: return temp_saved_wallet[account]["password_sha256"] elif mode == 3: my_address = temp_saved_wallet[account]["publickey"] my_address = "".join([ l.strip() for l in my_address.splitlines() if l and not l.startswith("-----") ]) my_address = Address(my_address) return my_address else: raise ValueError("the mode variable contains an unplanned value")
def show_example_list_bottom_sheet(self): bottom_sheet_menu = MDListBottomSheet(radius=25, radius_from="top") data = {} all_wallets = list(get_saved_wallet()) current_wallet = the_settings()["wallet"] for wallet in all_wallets: number = all_wallets.index(wallet) address = Wallet_Import(all_wallets.index(wallet), 3) if not current_wallet == number: data[number] = address else: data[number] = address + " - CURRENTLY USED" for item in data.items(): bottom_sheet_menu.add_item( str(item[0]) + " : " + item[1], lambda x, y=item[0]: self.callback_for_menu_items(y), ) bottom_sheet_menu.open()
def print_wallets(): """ Prints the wallets. """ all_wallets = list(get_saved_wallet()) current_wallet = the_settings()["wallet"] print("\nWallets:") result = [] for wallet in all_wallets: number = all_wallets.index(wallet) address = Wallet_Import(all_wallets.index(wallet), 3) if not current_wallet == number: text = menu_maker(menu_number=number, menu_text=address) print(text) result.append(text) else: text = menu_maker(menu_number=number, menu_text=address + " - CURRENTLY USED") print(text) result.append(text) return result
def menu(): """ The main structure of the cli mode, this function prints the menu, listens to the entries, makes the directions. """ animation = [ "[■□□□□□□□□□]", "[■■□□□□□□□□]", "[■■■□□□□□□□]", "[■■■■□□□□□□]", "[■■■■■□□□□□]", "[■■■■■■□□□□]", "[■■■■■■■□□□]", "[■■■■■■■■□□]", "[■■■■■■■■■□]", "[■■■■■■■■■■]" ] for i in range(len(animation)): time.sleep(0.1) sys.stdout.write("\r" + animation[i]) sys.stdout.flush() while True: show_menu() choices_input = question_maker(mode="main") if choices_input == "pw": print_wallets() if choices_input == "w": wallet_selector() if choices_input == "cw": create_a_wallet() if choices_input == "dw": if "y" == input("Are you sure ? (y or n): "): delete_current_wallet() if choices_input == "sc": send_the_coin(input("Please write receiver adress: "), input("Coin Amount (ex. 1.0): "), getpass("Password: "******"gb": print_balance() if choices_input == "help": show_menu() if choices_input == "ndstart": ndstart(str(input("ip: ")), int(input("port: "))) if choices_input == "ndstop": ndstop() if choices_input == "ndconnect": ndconnect(str(input("node ip: ")), int(input("node port: "))) if choices_input == "ndconnectmixdb": ndconnectmixdb() if choices_input == "ndnewunl": save_new_unl_node(input("Please write ID of the node: ")) if choices_input == "ndid": print(ndid()) if choices_input == "testmodeon": test_mode(True) if choices_input == "testmodeoff": test_mode(False) if choices_input == "debugmodeon": debug_mode(True) if choices_input == "debugmodeoff": debug_mode(False) if choices_input == "exptrcsv": if export_the_transactions(): print( f"CSV file created in {MY_TRANSACTION_EXPORT_PATH} directory" ) else: print("You have not a transaction") if choices_input == "returntrs": PrintTransactions() if choices_input == "getblock": if the_settings()["test_mode"]: CreateBlock() else: GetBlockFromOtherNode() if choices_input == "status": print(Status()) if choices_input == "0": exit()
def debug_mode_off(self): the_settings().debug_mode(False) messagebox.showinfo('System', 'Debug mode is OFF')
def menu(): """ The main structure of the cli mode, this function prints the menu, listens to the entries, makes the directions. """ while True: show_menu() choices_input = question_maker(mode="main") if choices_input == "connectmainnetwork": connect_to_main_network() if choices_input == "cw": Wallet_Create() if choices_input == "sc": temp_coin_amount = input("Coin Amount (ex. 1.0): ") type_control = False try: float(temp_coin_amount) type_control = True except: print("This is not float coin amount.") if type_control and not float(temp_coin_amount) < GetBlock().minumum_transfer_amount: send_coin(float(temp_coin_amount), input("Please write receiver adress: ")) if choices_input == "gb": print(GetBalance(Wallet_Import(0,0), GetBlock())) print(Wallet_Import(0,3)) if choices_input == "help": show_menu() if choices_input == "ndstart": ndstart(str(input("ip: ")), int(input("port: "))) if choices_input == "ndstop": ndstop() if choices_input == "ndconnect": ndconnect(str(input("node ip: ")), int(input("node port: "))) if choices_input == "ndconnectmixdb": ndconnectmixdb() if choices_input == "ndnewunl": save_new_unl_node(input("Please write ID of the node: ")) if choices_input == "testmodeon": test_mode(True) if choices_input == "testmodeoff": test_mode(False) if choices_input == "debugmodeon": debug_mode(True) # from node.myownp2pn import mynode # mynode.main_node.debug = True if choices_input == "debugmodeoff": debug_mode(False) # from node.myownp2pn import mynode # mynode.main_node.debug = False if choices_input == "getfullnodelist": GetNodeList() if choices_input == "getblock": if the_settings()["test_mode"]: CreateBlock() else: GetBlockFromOtherNode() if choices_input == "0": exit()
def __init__(self, master=None): self.toplevel = tk.Tk() if master is None else tk.Toplevel(master) self.toplevel.columnconfigure(0, weight=1) self.toplevel.rowconfigure(0, weight=1) self.frame = ttk.Frame(self.toplevel) self.ledger_44x50_png = tk.PhotoImage( file='gui/icons/ledger_38x50.png') self.cellmolecule_50x50_png = tk.PhotoImage( file='gui/icons/cell-molecule_50x50.png') self.computerinternetnetwork_68x50_png = tk.PhotoImage( file='gui/icons/computer-internet-network_68x50.png') self.money_67x50_png = tk.PhotoImage(file='gui/icons/money_67x50.png') self.get_ledger_button = ttk.Button(self.frame) self.get_ledger_button.configure(compound='top', image=self.ledger_44x50_png, text='Get Ledger From Other Nodes') self.get_ledger_button.grid(column='0', padx='25', pady='20', row='1', sticky='n') self.get_ledger_button.configure(command=self.get_ledger_command) self.button2 = ttk.Button(self.frame) self.button2.configure(compound='top', image=self.computerinternetnetwork_68x50_png, text='Start Node Server') self.button2.grid(column='0', padx='25', pady='20', row='2', sticky='n') self.button2.configure(command=self.start_node_server) self.button3 = ttk.Button(self.frame) self.button3.configure(compound='top', image=self.cellmolecule_50x50_png, text='Connect Node \nfrom MIX Database') self.button3.grid(column='0', padx='25', pady='20', row='3', sticky='n') self.button3.configure( command=self.connect_node_fba_algorithm_infrustructure) self.send_coin_button = ttk.Button(self.frame) self.send_coin_button.configure(compound='top', image=self.money_67x50_png, text='Send Coin') self.send_coin_button.grid(column='1', padx='25', pady='20', row='3', sticky='n') self.send_coin_button.configure(command=self.send_coin) self.create_wallet_button = ttk.Button(self.frame) self.wallet_60x50_png = tk.PhotoImage( file='gui/icons/wallet_60x50.png') self.create_wallet_button.configure(compound='top', image=self.wallet_60x50_png, text='Create Wallet') self.create_wallet_button.grid(column='1', padx='25', pady='20', row='1', sticky='n') self.create_wallet_button.configure(command=self.Wallet_Create) self.balance_label = ttk.Label(self.frame) self.balance_label.configure(text='Balance: ') self.balance_label.grid(column='0', ipadx='25', padx='25', pady='20', row='4', sticky='n') self.reflesh_balance_button = ttk.Button(self.frame) self.reflesh_balance_button.configure(compound='top', text='Reflesh Balance') self.reflesh_balance_button.grid(column='0', padx='25', pady='20', row='5', sticky='n') self.reflesh_balance_button.configure(command=self.reflesh_balance) self.button1 = ttk.Button(self.frame) self.button1.configure(compound='top', image=self.cellmolecule_50x50_png, text='Connect Node') self.button1.grid(column='2', padx='25', pady='20', row='1', sticky='n') self.button1.configure(command=self.connect_node) self.buttonunl = ttk.Button(self.frame) self.buttonunl.configure(compound='top', image=self.cellmolecule_50x50_png, text='Add New UNL') self.buttonunl.grid(column='2', padx='25', pady='20', row='2', sticky='n') self.buttonunl.configure(command=self.add_new_unl) self.button_get_node_list = ttk.Button(self.frame) self.button_get_node_list.configure(compound='top', image=self.cellmolecule_50x50_png, text='Get Full Node List') self.button_get_node_list.grid(column='2', padx='25', pady='20', row='3', sticky='n') self.button_get_node_list.configure(command=self.get_node_list_command) self.button4 = ttk.Button(self.frame) self.button4.configure(compound='top', text='Test Mode ON') self.button4.grid(column='2', padx='25', pady='20', row='4', sticky='n') self.button4.configure(command=self.test_mode_on) self.button6 = ttk.Button(self.frame) self.button6.configure(compound='top', text='Test Mode OFF') self.button6.grid(column='2', padx='25', pady='20', row='5', sticky='n') self.button6.configure(command=self.test_mode_off) self.buttondebugmodeon = ttk.Button(self.frame) self.buttondebugmodeon.configure(compound='top', text='Debug Mode ON') self.buttondebugmodeon.grid(column='1', padx='25', pady='20', row='4', sticky='n') self.buttondebugmodeon.configure(command=self.debug_mode_on) self.buttondebugmodeoff = ttk.Button(self.frame) self.buttondebugmodeoff.configure(compound='top', text='Debug Mode OFF') self.buttondebugmodeoff.grid(column='1', padx='25', pady='20', row='5', sticky='n') self.buttondebugmodeoff.configure(command=self.debug_mode_off) self.button7 = ttk.Button(self.frame) self.button7.configure(compound='top', image=self.computerinternetnetwork_68x50_png, text='Stop Node Server') self.button7.grid(column='1', padx='25', pady='20', row='2', sticky='n') self.button7.configure(command=self.stop_node_server) self.frame.configure(height='200', width='200') self.frame.grid(column='0', row='0') self.toplevel.configure(height='200', takefocus=True, width='200') self.icon_50x50_png = tk.PhotoImage(file='gui/icons/icon_50x50.png') self.toplevel.iconphoto(True, self.icon_50x50_png) self.toplevel.resizable(True, True) self.toplevel.title('Decentra Network') from lib.settings_system import the_settings if the_settings()["test_mode"]: self.Test_Mode_Menu_Label = ttk.Label(self.frame, text="Test Mode Menu").grid( column='3', padx='25', pady='20', row='1', sticky='n') self.create_ledger_button = ttk.Button(self.frame) self.create_ledger_button.configure(compound='top', image=self.ledger_44x50_png, text='Create ledger') self.create_ledger_button.grid(column='3', padx='25', pady='20', row='2', sticky='n') self.create_ledger_button.configure(command=self.create_ledger) else: self.connect_to_main_network = ttk.Button(self.frame) self.connect_to_main_network.configure( compound='top', image=self.computerinternetnetwork_68x50_png, text='Connect to Main Network') self.connect_to_main_network.grid(column='3', padx='25', pady='20', row='1', sticky='n') self.connect_to_main_network.configure( command=self.connect_to_main_network_command) row = 7 for folder_entry in os.scandir('apps'): if ".md" not in folder_entry.name: for entry in os.scandir("apps/" + folder_entry.name): if entry.is_file(): if entry.name[ 0] != '_' and ".py" in entry.name and "_main" in entry.name: self.App_Menu_Label = ttk.Label( self.frame, text="APP Menu").grid(column='0', padx='25', pady='20', row='6', sticky='n') import_command = f"from apps.{folder_entry.name}.{entry.name.replace('.py','')} import {entry.name.replace('.py','')}_gui" tx_command = f"{entry.name.replace('.py','')}_gui(self,0,row)" exec(import_command) exec(tx_command) row += 1 self.mainwindow = self.toplevel
def block_get_page(): if the_settings()["test_mode"]: CreateBlock() else: GetBlockFromOtherNode() return jsonify("OK")
def test_creating_settings(self): temp_settings = the_settings() self.assertIsNotNone(temp_settings.test_mode(), "A problem on the test_mode.") self.assertIsNotNone(temp_settings.debug_mode(), "A problem on the debug_mode.")
def menu(): while True: show_menu() choices_input = question_maker(mode="main") from lib.settings_system import the_settings if the_settings().test_mode(): if choices_input == "cbl": create_ledger() else: if choices_input == "connectmainnetwork": from func.node_connection import connect_to_main_network connect_to_main_network() if choices_input == "cw": Wallet_Create() if choices_input == "sc": temp_coin_amount = input("Coin Amount (ex. 1.0): ") type_control = False try: float(temp_coin_amount) type_control = True except: print("This is not float coin amount.") if type_control: send_coin(float(temp_coin_amount), input("Please write receiver adress: ")) if choices_input == "gb": print(get_ledger().getBalance(Wallet_Import(0, 0))) if choices_input == "help": show_menu() if choices_input == "ndstart": ndstart(str(input("ip: ")), int(input("port: "))) if choices_input == "ndstop": ndstop() if choices_input == "ndconnect": ndconnect(str(input("node ip: ")), int(input("node port: "))) if choices_input == "ndconnectmixdb": ndconnectmixdb() if choices_input == "ndnewunl": from node.unl import save_new_unl_node save_new_unl_node(input("Please write ID of the node: ")) if choices_input == "testmodeon": the_settings().test_mode(True) if choices_input == "testmodeoff": the_settings().test_mode(False) if choices_input == "debugmodeon": the_settings().debug_mode(True) # from node.myownp2pn import MyOwnPeer2PeerNode # MyOwnPeer2PeerNode.main_node.debug = True if choices_input == "debugmodeoff": the_settings().debug_mode(False) # from node.myownp2pn import MyOwnPeer2PeerNode # MyOwnPeer2PeerNode.main_node.debug = False if choices_input == "getfullnodelist": sendme_full_node_list() if choices_input == "getfullledger": get_ledger_from_other_node() for folder_entry in os.scandir('apps'): if ".md" not in folder_entry.name: for entry in os.scandir("apps/" + folder_entry.name): if entry.is_file(): if entry.name[ 0] != '_' and ".py" in entry.name and "_main" in entry.name: print(entry.name) import_command = f"from apps.{folder_entry.name}.{entry.name.replace('.py','')} import {entry.name.replace('.py','')}_cli_command" tx_command = f"{entry.name.replace('.py','')}_cli_command(choices_input)" exec(import_command) exec(tx_command) if choices_input == "0": exit()
def get_block(self): if the_settings()["test_mode"]: CreateBlock() else: GetBlockFromOtherNode()
def menu(): """ The main structure of the cli mode, this function prints the menu, listens to the entries, makes the directions. """ while True: show_menu() choices_input = question_maker(mode="main") if choices_input == "w": all_wallets = list(get_saved_wallet()) if not len(all_wallets) == 0: current_wallet = the_settings()["wallet"] for wallet in all_wallets: number = str(all_wallets.index(wallet)) address = Wallet_Import(all_wallets.index(wallet),3) if not current_wallet == number: print(menu_maker(menu_number=number, menu_text=address)) else: print(menu_maker(menu_number=number, menu_text=address + " - CURRENTLY USED")) while True: try: new_wallet = input("Please select wallet: ") if int(new_wallet) in list(range(len(all_wallets))): change_wallet(new_wallet) break else: print("There is no such wallet") except: print("This is not a number") else: print("There is no wallet") if choices_input == "connectmainnetwork": connect_to_main_network() if choices_input == "cw": Wallet_Create() if choices_input == "sc": temp_coin_amount = input("Coin Amount (ex. 1.0): ") type_control = False try: float(temp_coin_amount) type_control = True except: print("This is not float coin amount.") if type_control and not float(temp_coin_amount) < GetBlock().minumum_transfer_amount: send_coin(float(temp_coin_amount), input("Please write receiver adress: ")) if choices_input == "gb": print(GetBalance(Wallet_Import(-1,0), GetBlock())) if choices_input == "help": show_menu() if choices_input == "ndstart": ndstart(str(input("ip: ")), int(input("port: "))) if choices_input == "ndstop": ndstop() if choices_input == "ndconnect": ndconnect(str(input("node ip: ")), int(input("node port: "))) if choices_input == "ndconnectmixdb": ndconnectmixdb() if choices_input == "ndnewunl": save_new_unl_node(input("Please write ID of the node: ")) if choices_input == "testmodeon": test_mode(True) if choices_input == "testmodeoff": test_mode(False) if choices_input == "debugmodeon": debug_mode(True) # from node.myownp2pn import mynode # mynode.main_node.debug = True if choices_input == "debugmodeoff": debug_mode(False) # from node.myownp2pn import mynode # mynode.main_node.debug = False if choices_input == "getfullnodelist": GetNodeList() if choices_input == "getblock": if the_settings()["test_mode"]: CreateBlock() else: GetBlockFromOtherNode() if choices_input == "0": exit()
def dprint(text): from lib.settings_system import the_settings if the_settings()["debug_mode"]: print("DEBUG: " + str(text))
def debug_mode_on(self): the_settings().debug_mode(True) messagebox.showinfo('System', 'Debug mode is ON')