def load_wallet(self, name, password=None): """Load a wallet""" self._assert_daemon_running() path = self._wallet_path(name) wallet = self.daemon.get_wallet(path) if not wallet: storage = WalletStorage(path) if not storage.file_exists(): raise FileNotFoundError(path) if storage.is_encrypted(): if not password: raise util.InvalidPassword() storage.decrypt(password) wallet = Wallet(storage) wallet.start_threads(self.network) self.daemon.add_wallet(wallet) self.wallet = wallet self.network.notify("updated") return wallet
pThread.join() else: basic_logger.send("[CashShuffle Bot] Nobody in the pools") basic_logger = SimpleLogger() args = parse_args() # Get network config = SimpleConfig({}) password = args.password wallet_path = args.wallet storage = WalletStorage(wallet_path) if not storage.file_exists(): basic_logger.send("Error: Wallet file not found.") sys.exit(0) if storage.is_encrypted(): storage.decrypt(password) if args.testnet: NetworkConstants.set_testnet() config = SimpleConfig({'server': "bch0.kister.net:51002:s"}) network = Network(config) network.start() wallet = Wallet(storage) wallet.start_threads(network) coin = Coin(network) # # setup server port = args.port host = args.server stat_port = args.stat_port ssl = args.ssl fee = args.fee
set_verbosity(config_options.get('verbose')) if config_options.get('testnet'): networks.set_testnet() config = SimpleConfig(config_options) storage = WalletStorage(config.get_wallet_path()) if not storage.file_exists(): print_msg("Wallet doesn't exist, creating...") data = create_new_wallet(path=storage.path, config=config, password=config_options['wallet_password'], encrypt_file=True) storage = WalletStorage(storage.path) if storage.is_encrypted() is False: print_msg("Error: Wallet is unencrypted") sys.exit(1) fd, server = daemon.get_fd_or_server(config) if fd is not None: plugins = init_plugins(config, 'cmdline') d = daemon.Daemon(config, fd, False, plugins) wallet = d.load_wallet(path=storage.path, password=config_options['wallet_password']) if wallet is None: raise Exception("Failed to load wallet") d.cmd_runner.wallet = wallet