Retrieves a cryptocurrency instance by coin name, optionally initializing it with an xpub and credentials. Central factory method used by 18 callers to access supported coin objects.
# Source: https://github.com/bitcart/bitcart | License: MIT | Copyright 2019 MrNaif2018
# Provided via justclaw.it.com; keep this notice with the code.
async def get_coin(self, coin: str, xpub: str | dict[str, Any] | None = None) -> BTC:
coin = coin.lower()
if coin not in self._cryptos:
raise HTTPException(422, "Unsupported currency")
if not xpub:
return self._cryptos[coin]
obj = None
if coin.upper() in COINS:
obj = COINS[coin.upper()](
xpub=xpub, # type: ignore # TODO: fix in bitcart
**cast(dict[str, Any], self._crypto_settings[coin]["credentials"]),
)
return await self.plugin_registry.apply_filters("get_coin", obj, coin, xpub)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key