def unlock_user(self, user, password, create_new, sync_approval, api_key, api_secret): # unlock or create the DB self.password = password user_dir = self.data.unlock(user, password, create_new) self.try_premium_at_start(api_key, api_secret, create_new, sync_approval, user_dir) secret_data = self.data.db.get_exchange_secrets() self.cache_data_filename = os.path.join(self.data_dir, 'cache_data.json') historical_data_start = self.data.historical_start_date() self.trades_historian = TradesHistorian( self.data_dir, self.data.db, self.data.get_eth_accounts(), historical_data_start, ) self.price_historian = PriceHistorian( self.data_dir, historical_data_start, ) self.accountant = Accountant(price_historian=self.price_historian, profit_currency=self.data.main_currency(), create_csv=True) self.inquirer = Inquirer(kraken=self.kraken) self.initialize_exchanges(secret_data) self.blockchain = Blockchain(self.data.db.get_blockchain_accounts(), self.data.eth_tokens, self.data.db.get_owned_tokens(), self.inquirer, self.args.ethrpc_port)
def test_remove_eth_token_before_any_queries(rotkehlchen_server, ethchain_client): """Regrestion test for 467""" tokens_to_add = ['PRL'] response = rotkehlchen_server.add_owned_eth_tokens(tokens_to_add) assert response['result'] is True # At least for now the PRL token is not in cryptocompare. A token without a # price is not counted in the total assert 'PRL' not in response['totals'] response = rotkehlchen_server.get_eth_tokens() assert set(tokens_to_add) == set(response['owned_eth_tokens']) assert 'all_eth_tokens' in response # Now use a clean blockchain instance to emulate restart where blockchain.totals # has not been populated. rotki = rotkehlchen_server.rotkehlchen rotki.blockchain = Blockchain( blockchain_accounts=rotki.data.db.get_blockchain_accounts(), owned_eth_tokens=rotki.data.db.get_owned_tokens(), ethchain=ethchain_client, msg_aggregator=MessagesAggregator(), ) response = rotkehlchen_server.remove_owned_eth_tokens(['PRL']) assert response['result'] is True response = rotkehlchen_server.get_eth_tokens() assert 'all_eth_tokens' in response assert len(response['owned_eth_tokens']) == 0
def unlock_user(self, user, password, create_new, sync_approval, api_key, api_secret): log.info( 'Unlocking user', user=user, create_new=create_new, sync_approval=sync_approval, ) # unlock or create the DB self.password = password self.user_directory = self.data.unlock(user, password, create_new) self.try_premium_at_start( api_key=api_key, api_secret=api_secret, create_new=create_new, sync_approval=sync_approval, ) secret_data = self.data.db.get_exchange_secrets() settings = self.data.db.get_settings() historical_data_start = settings['historical_data_start'] eth_rpc_port = settings['eth_rpc_port'] self.trades_historian = TradesHistorian( user_directory=self.user_directory, db=self.data.db, eth_accounts=self.data.get_eth_accounts(), historical_data_start=historical_data_start, ) self.inquirer = Inquirer(data_dir=self.data_dir, kraken=self.kraken) price_historian = PriceHistorian( data_directory=self.data_dir, history_date_start=historical_data_start, inquirer=self.inquirer, ) db_settings = self.data.db.get_settings() self.accountant = Accountant( price_historian=price_historian, profit_currency=self.data.main_currency(), user_directory=self.user_directory, create_csv=True, ignored_assets=self.data.db.get_ignored_assets(), include_crypto2crypto=db_settings['include_crypto2crypto'], taxfree_after_period=db_settings['taxfree_after_period'], include_gas_costs=db_settings['include_gas_costs'], ) # Initialize the rotkehlchen logger LoggingSettings(anonymized_logs=db_settings['anonymized_logs']) self.initialize_exchanges(secret_data) ethchain = Ethchain(eth_rpc_port) self.blockchain = Blockchain( blockchain_accounts=self.data.db.get_blockchain_accounts(), all_eth_tokens=self.data.eth_tokens, owned_eth_tokens=self.data.db.get_owned_tokens(), inquirer=self.inquirer, ethchain=ethchain, )
def blockchain( blockchain_backend, # pylint: disable=unused-argument ethchain_client, blockchain_accounts, inquirer, # pylint: disable=unused-argument ): return Blockchain( blockchain_accounts=blockchain_accounts, owned_eth_tokens=[], ethchain=ethchain_client, msg_aggregator=MessagesAggregator(), )
def blockchain( blockchain_backend, ethchain_client, blockchain_accounts, all_eth_tokens, inquirer ): return Blockchain( blockchain_accounts, all_eth_tokens, [], inquirer, ethchain_client )
def blockchain( blockchain_backend, ethchain_client, blockchain_accounts, all_eth_tokens, inquirer, ): return Blockchain( blockchain_accounts=blockchain_accounts, all_eth_tokens=all_eth_tokens, owned_eth_tokens=[], inquirer=inquirer, ethchain=ethchain_client, )
def unlock_user(self, user, password, create_new, sync_approval, api_key, api_secret): # unlock or create the DB self.password = password user_dir = self.data.unlock(user, password, create_new) self.try_premium_at_start(api_key, api_secret, create_new, sync_approval, user_dir) secret_data = self.data.db.get_exchange_secrets() settings = self.data.db.get_settings() historical_data_start = settings['historical_data_start'] eth_rpc_port = settings['eth_rpc_port'] self.trades_historian = TradesHistorian( self.data_dir, self.data.db, self.data.get_eth_accounts(), historical_data_start, ) self.price_historian = PriceHistorian( self.data_dir, historical_data_start, ) db_settings = self.data.db.get_settings() self.accountant = Accountant( price_historian=self.price_historian, profit_currency=self.data.main_currency(), user_directory=user_dir, create_csv=True, ignored_assets=self.data.db.get_ignored_assets(), include_crypto2crypto=db_settings['include_crypto2crypto'], taxfree_after_period=db_settings['taxfree_after_period'], ) self.inquirer = Inquirer(kraken=self.kraken) self.initialize_exchanges(secret_data) ethchain = Ethchain(eth_rpc_port) self.blockchain = Blockchain( blockchain_accounts=self.data.db.get_blockchain_accounts(), all_eth_tokens=self.data.eth_tokens, owned_eth_tokens=self.data.db.get_owned_tokens(), inquirer=self.inquirer, ethchain=ethchain, )
def unlock_user( self, user: str, password: str, create_new: bool, sync_approval: bool, api_key: ApiKey, api_secret: ApiSecret, ) -> None: """Unlocks an existing user or creates a new one if `create_new` is True""" log.info( 'Unlocking user', user=user, create_new=create_new, sync_approval=sync_approval, ) # unlock or create the DB self.password = password self.user_directory = self.data.unlock(user, password, create_new) self.last_data_upload_ts = self.data.db.get_last_data_upload_ts() self.premium_sync_manager = PremiumSyncManager(data=self.data, password=password) try: self.premium = self.premium_sync_manager.try_premium_at_start( api_key=api_key, api_secret=api_secret, username=user, create_new=create_new, sync_approval=sync_approval, ) except AuthenticationError: # It means that our credentials were not accepted by the server # or some other error happened pass exchange_credentials = self.data.db.get_exchange_credentials() settings = self.data.db.get_settings() historical_data_start = settings['historical_data_start'] eth_rpc_endpoint = settings['eth_rpc_endpoint'] self.trades_historian = TradesHistorian( user_directory=self.user_directory, db=self.data.db, eth_accounts=self.data.get_eth_accounts(), msg_aggregator=self.msg_aggregator, ) # Initialize the price historian singleton PriceHistorian( data_directory=self.data_dir, history_date_start=historical_data_start, cryptocompare=Cryptocompare(data_directory=self.data_dir), ) db_settings = self.data.db.get_settings() self.accountant = Accountant( profit_currency=self.data.main_currency(), user_directory=self.user_directory, msg_aggregator=self.msg_aggregator, create_csv=True, ignored_assets=self.data.db.get_ignored_assets(), include_crypto2crypto=db_settings['include_crypto2crypto'], taxfree_after_period=db_settings['taxfree_after_period'], include_gas_costs=db_settings['include_gas_costs'], ) # Initialize the rotkehlchen logger LoggingSettings(anonymized_logs=db_settings['anonymized_logs']) self.initialize_exchanges(exchange_credentials) ethchain = Ethchain(eth_rpc_endpoint) self.blockchain = Blockchain( blockchain_accounts=self.data.db.get_blockchain_accounts(), owned_eth_tokens=self.data.db.get_owned_tokens(), ethchain=ethchain, msg_aggregator=self.msg_aggregator, ) self.user_is_logged_in = True