MCPcopy Create free account
hub / github.com/Drakkar-Software/OctoBot / _invalidate

Function _invalidate

additional_tests/exchanges_tests/__init__.py:178–193  ·  view source on GitHub ↗
(exchange_config: dict)

Source from the content-addressed store, hash-verified

176
177
178def _invalidate(exchange_config: dict):
179 # try to invalidate key while returning a "plausible" value to avoid signature / parsing issues
180 decoded = configuration.decrypt_element_if_possible(
181 commons_constants.CONFIG_EXCHANGE_KEY, exchange_config, None
182 )
183 updated_decoded = decoded
184 for numb in range(9):
185 if str(numb) in decoded:
186 # replace from the end first: coinbase-like api keys have a prefix that can be changed and remain valid
187 number_rindex = decoded.rindex(str(numb))
188 if number_rindex != len(decoded) - 1:
189 updated_decoded = f"{decoded[:number_rindex]}{numb + 1}{decoded[number_rindex+1:]}"
190 break
191 if updated_decoded == decoded:
192 raise ValueError("No number to invalid api key")
193 exchange_config[commons_constants.CONFIG_EXCHANGE_KEY] = configuration.encrypt(updated_decoded).decode()
194
195
196def _get_exchange_credential_from_env(exchange_name, cred_suffix):

Callers 1

Calls 1

encryptMethod · 0.80

Tested by

no test coverage detected