def show_wallet(self, arguments): if not self.Wallet: print("Please open a wallet") return item = get_arg(arguments) if not item: print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4)) return if item in ['v', '--v', 'verbose']: print("Wallet %s " % json.dumps(self.Wallet.ToJson(verbose=True), indent=4)) return elif item == 'migrate' and self.Wallet is not None: self.Wallet.Migrate() print("Migrated wallet") elif item == 'delete_addr': addr_to_delete = get_arg(arguments, 1) DeleteAddress(self, self.Wallet, addr_to_delete) elif item == 'delete_token': token_to_delete = get_arg(arguments, 1) DeleteToken(self.Wallet, token_to_delete) elif item == 'close': self.do_close_wallet() elif item == 'claim': ClaimGas(self.Wallet, True, arguments[1:]) elif item == 'rebuild': self.Wallet.Rebuild() try: item2 = int(get_arg(arguments, 1)) if item2 and item2 > 0: print("Restarting at %s" % item2) self.Wallet._current_height = item2 except Exception as e: pass elif item == 'tkn_send': token_send(self.Wallet, arguments[1:]) elif item == 'tkn_send_from': token_send_from(self.Wallet, arguments[1:]) elif item == 'tkn_send_blog': token_send_blog(self.Wallet, arguments[1:]) elif item == 'tkn_approve': token_approve_allowance(self.Wallet, arguments[1:]) elif item == 'tkn_allowance': token_get_allowance(self.Wallet, arguments[1:], verbose=True) elif item == 'tkn_mint': token_mint(self.Wallet, arguments[1:]) elif item == 'tkn_register': token_crowdsale_register(self.Wallet, arguments[1:]) elif item == 'unspent': ShowUnspentCoins(self.Wallet, arguments[1:]) elif item == 'alias': if len(arguments) == 3: AddAlias(self.Wallet, arguments[1], arguments[2]) else: print("Please supply an address and title") else: print("Wallet: '{}' is an invalid parameter".format(item))
def show_wallet(self, arguments): if not self.Wallet: print("please open a wallet") return item = get_arg(arguments) if not item: print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4)) return if item in ['v', '--v', 'verbose']: print("Wallet %s " % json.dumps(self.Wallet.ToJson(verbose=True), indent=4)) return elif item == 'migrate' and self.Wallet is not None: self.Wallet.Migrate() print("migrated wallet") elif item == 'delete_addr': addr_to_delete = get_arg(arguments, 1) DeleteAddress(self, self.Wallet, addr_to_delete) elif item == 'delete_token': token_to_delete = get_arg(arguments, 1) DeleteToken(self.Wallet, token_to_delete) elif item == 'close': self.do_close_wallet() elif item == 'claim': ClaimGas(self.Wallet) elif item == 'rebuild': self.Wallet.Rebuild() # self._walletdb_loop = task.LoopingCall(self.Wallet.ProcessBlocks) # self._walletdb_loop.start(1) try: item2 = int(get_arg(arguments, 1)) if item2 and item2 > 0: print('restarting at %s ' % item2) self.Wallet._current_height = item2 except Exception as e: pass elif item == 'tkn_send': token_send(self.Wallet, arguments[1:]) elif item == 'tkn_send_from': token_send_from(self.Wallet, arguments[1:]) elif item == 'tkn_approve': token_approve_allowance(self.Wallet, arguments[1:]) elif item == 'tkn_allowance': token_get_allowance(self.Wallet, arguments[1:], verbose=True) elif item == 'tkn_mint': token_mint(self.Wallet, arguments[1:]) elif item == 'tkn_register': token_crowdsale_register(self.Wallet, arguments[1:]) elif item == 'alias': if len(arguments) == 3: AddAlias(self.Wallet, arguments[1], arguments[2]) else: print("Please supply an address and title")
def test_2_import_addr(self): wallet = self.GetWallet1() self.assertEqual(len(wallet.LoadWatchOnly()), 1) success = DeleteAddress(wallet, self.watch_addr_str) self.assertTrue(success) self.assertEqual(len(wallet.LoadWatchOnly()), 0)
def show_wallet(self, arguments): if not self.Wallet: print("please open a wallet") return item = get_arg(arguments) if not item: print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4)) return if item in ['v', '--v', 'verbose']: print("Wallet %s " % json.dumps(self.Wallet.ToJson(verbose=True), indent=4)) return elif item == 'migrate' and self.Wallet is not None: self.Wallet.Migrate() print("migrated wallet") elif item == 'delete_addr': addr_to_delete = get_arg(arguments, 1) DeleteAddress(self, self.Wallet, addr_to_delete) elif item == 'delete_token': token_to_delete = get_arg(arguments, 1) DeleteToken(self.Wallet, token_to_delete) elif item == 'close': self.do_close_wallet() elif item == 'claim': ClaimGas(self.Wallet) elif item == 'rebuild': self.Wallet.Rebuild() try: item2 = int(get_arg(arguments, 1)) if item2 and item2 > 0: print('restarting at %s ' % item2) self.Wallet._current_height = item2 except Exception as e: pass elif item == 'tkn_send': token_send(self.Wallet, arguments[1:]) elif item == 'tkn_send_from': token_send_from(self.Wallet, arguments[1:]) elif item == 'tkn_approve': token_approve_allowance(self.Wallet, arguments[1:]) elif item == 'tkn_allowance': token_get_allowance(self.Wallet, arguments[1:], verbose=True)
def show_wallet(self, arguments): if not self.Wallet: print("please open a wallet") return item = get_arg(arguments) if not item: print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4)) return if item in ['v', '--v', 'verbose']: print("Wallet %s " % json.dumps(self.Wallet.ToJson(verbose=True), indent=4)) return if item == 'migrate' and self.Wallet is not None: print("migrating wallet...") self.Wallet.Migrate() print("migrated wallet") if item == 'delete_addr': addr_to_delete = get_arg(arguments, 1) print("address to delete %s" % addr_to_delete) DeleteAddress(self, self.Wallet, addr_to_delete) if item == 'close': print('closed wallet') self.Wallet = None if item == 'rebuild': self.Wallet.Rebuild() try: item2 = int(get_arg(arguments, 1)) if item2 and item2 > 0: print('restarting at %s ' % item2) self.Wallet._current_height = item2 except Exception as e: pass if item == 'unspent': self.Wallet.FindUnspentCoins()
def runPrompt(self): dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) Blockchain.Default().PersistBlocks() self.createWallet() self.autoDeploy() print("\n") # self.withdrawFunds(self.Wallet) # self.exit() while self.go_on: try: result = prompt( "neoFund> ", completer=self.get_completer(), history=self.history, get_bottom_toolbar_tokens=self.get_bottom_toolbar, style=self.token_style, refresh_interval=.5) except EOFError: # Control-D pressed: quit return self.quit() except KeyboardInterrupt: # Control-C pressed: do nothing continue try: command, arguments = self.parse_result(result) if command is not None and len(command) > 0: # command = command.lower() print(command) if command == 'quit' or command == 'exit': self.quit() elif command == 'help': self.help() elif command == 'tx': self.show_tx(arguments) elif command == 'wallet': self.show_wallet(arguments) elif command == 'invokeDeploy': self.invokeDeploy() elif command == 'createFund': self.createFund(self.Wallet, test_fund, 'neo', 'withdrawal_SH', 100, 9999) elif command == 'getFundParameter': self.getFundParameter(self.Wallet, test_fund, 'fundBalance') elif command == 'depositFunds': self.depositFunds(self.Wallet, test_fund, 'neo', 5, args=arguments) elif command == 'withdrawFunds': self.withdrawFunds(self.Wallet, 1, args=arguments) elif command == 'withdrawRequestFunds': self.withdrawRequestFunds(self.Wallet, test_fund, 1, args=arguments) elif command == 'withdrawRequestReset': self.withdrawRequestReset(self.Wallet) elif command == 'importContract': self.importContract() elif command == 'send_test_funds': self.send_test_funds() elif command == 'deleteAddr': DeleteAddress(self, self.Wallet, arguments[0]) elif command == 'isRefundActive': self.isRefundActive(test_fund) elif command is None: print('please specify a command') else: print("command %s not found" % command) except Exception as e: print("could not execute command: %s " % e) traceback.print_stack() traceback.print_exc()
def show_wallet(self, arguments): if not self.Wallet: print("Please open a wallet") return item = get_arg(arguments) if not item: print("Wallet %s " % json.dumps(self.Wallet.ToJson(), indent=4)) return if item in ['v', '--v', 'verbose']: print("Wallet %s " % json.dumps(self.Wallet.ToJson(verbose=True), indent=4)) return elif item == 'migrate' and self.Wallet is not None: self.Wallet.Migrate() print("Migrated wallet") elif item == 'delete_addr': addr_to_delete = get_arg(arguments, 1) DeleteAddress(self, self.Wallet, addr_to_delete) elif item == 'delete_token': token_to_delete = get_arg(arguments, 1) DeleteToken(self.Wallet, token_to_delete) elif item == 'close': self.do_close_wallet() elif item == 'claim': ClaimGas(self.Wallet, True, arguments[1:]) elif item == 'rebuild': self.Wallet.Rebuild() try: item2 = int(get_arg(arguments, 1)) item2 = Blockchain.Default().Height if item2 and item2 > 0: print("Restarting at %s" % item2) self.Wallet._current_height = item2 #TODO - NeoCompiler.io syncing process - BEGINS print( "Waiting, at least, 30 seconds, for wallet to sync and rebuild..." ) #time.sleep(30) timenow = time.time() timebase = time.time() while (timenow - timebase < 30): timenow = time.time() walletheight = self.Wallet._current_height blockchainheight = max(Blockchain.Default().HeaderHeight, Blockchain.Default().Height) while (walletheight < blockchainheight): walletheight = self.Wallet._current_height blockchainheight = max(Blockchain.Default().HeaderHeight, Blockchain.Default().Height) #TODO - NeoCompiler.io syncing process - ENDS except Exception as e: print("Problems happened when rebuilding %s" % e) pass elif item == 'tkn_send': token_send(self.Wallet, arguments[1:]) elif item == 'tkn_send_from': token_send_from(self.Wallet, arguments[1:]) elif item == 'tkn_approve': token_approve_allowance(self.Wallet, arguments[1:]) elif item == 'tkn_allowance': token_get_allowance(self.Wallet, arguments[1:], verbose=True) elif item == 'tkn_mint': token_mint(self.Wallet, arguments[1:]) elif item == 'tkn_register': token_crowdsale_register(self.Wallet, arguments[1:]) elif item == 'unspent': ShowUnspentCoins(self.Wallet, arguments[1:]) elif item == 'alias': if len(arguments) == 3: AddAlias(self.Wallet, arguments[1], arguments[2]) else: print("Please supply an address and title") else: print("Wallet: '{}' is an invalid parameter".format(item))