示例#1
0
def is_compatible_account(exchange_name: str, api_key, api_sec, api_pass) -> dict:
    to_check_config = copy.deepcopy(interfaces_util.get_edited_config()[commons_constants.CONFIG_EXCHANGES].get(exchange_name, {}))
    if _is_real_exchange_value(api_key):
        to_check_config[commons_constants.CONFIG_EXCHANGE_KEY] = configuration.encrypt(api_key).decode()
    if _is_real_exchange_value(api_sec):
        to_check_config[commons_constants.CONFIG_EXCHANGE_SECRET] = configuration.encrypt(api_sec).decode()
    if _is_real_exchange_value(api_pass):
        to_check_config[commons_constants.CONFIG_EXCHANGE_PASSWORD] = configuration.encrypt(api_pass).decode()
    is_compatible = False
    is_sponsoring = trading_api.is_sponsoring(exchange_name)
    is_configured = False
    authenticator = interfaces_util.get_bot_api().get_community_auth()
    is_supporter = authenticator.supports.is_supporting()
    error = None
    if _is_possible_exchange_config(to_check_config):
        is_configured = True
        is_compatible, error = interfaces_util.run_in_bot_async_executor(
            trading_api.is_compatible_account(
                exchange_name,
                to_check_config,
                interfaces_util.get_edited_tentacles_config()
            )
        )
    return {
        "exchange": exchange_name,
        "compatible": is_compatible,
        "supporter_account": is_supporter,
        "configured": is_configured,
        "supporting": is_sponsoring,
        "error_message": error
    }
def exchange_config():
    return {
        commons_constants.CONFIG_EXCHANGE_KEY:
        commons_configuration.encrypt("01234").decode(),
        commons_constants.CONFIG_EXCHANGE_SECRET:
        commons_configuration.encrypt("012345").decode()
    }
示例#3
0
def exchange_keys_encrypter(catch=False):
    try:
        api_key_crypted = configuration.encrypt(input("ENTER YOUR API-KEY : ")).decode()
        api_secret_crypted = configuration.encrypt(input("ENTER YOUR API-SECRET : ")).decode()
        print(f"Here are your encrypted exchanges keys : \n "
              f"\t- API-KEY : {api_key_crypted}\n"
              f"\t- API-SECRET : {api_secret_crypted}\n\n"
              f"Your new exchange key configuration is : \n"
              f'\t"api-key": "{api_key_crypted}",\n'
              f'\t"api-secret": "{api_secret_crypted}"\n')
    except Exception as e:
        if not catch:
            logging.get_logger(COMMANDS_LOGGER_NAME).error(
                f"Fail to encrypt your exchange keys, please try again ({e}).")
            raise e