mirror of
https://github.com/basicswap/basicswap.git
synced 2026-06-08 12:11:41 +02:00
fix: convert coin variant tickers
This commit is contained in:
@@ -552,16 +552,26 @@ chainparams = {
|
||||
|
||||
name_map = {}
|
||||
ticker_map = {}
|
||||
variant_ticker_map = {}
|
||||
|
||||
|
||||
for c, params in chainparams.items():
|
||||
name_map[params["name"].lower()] = c
|
||||
ticker_map[params["ticker"].lower()] = c
|
||||
|
||||
# Add coin variants, eg: LTC_MWEB, PART_ANON
|
||||
for c in Coins:
|
||||
if c.name.lower() in ticker_map:
|
||||
continue
|
||||
variant_ticker_map[c.name.lower()] = c
|
||||
|
||||
def getCoinIdFromTicker(ticker: str) -> str:
|
||||
|
||||
def getCoinIdFromTicker(ticker: str, inc_variant: bool = False) -> str:
|
||||
lc_ticker: str = ticker.lower()
|
||||
try:
|
||||
return ticker_map[ticker.lower()]
|
||||
if inc_variant and lc_ticker in variant_ticker_map:
|
||||
return variant_ticker_map[lc_ticker]
|
||||
return ticker_map[lc_ticker]
|
||||
except Exception:
|
||||
raise ValueError(f"Unknown coin {ticker}")
|
||||
|
||||
|
||||
@@ -449,11 +449,11 @@ class BTCInterface(Secp256k1Interface):
|
||||
# Wallet name is "" for some LTC and PART installs on older cores
|
||||
if self._rpc_wallet not in wallets and len(wallets) > 0:
|
||||
if "" in wallets:
|
||||
# Setting wallet= in the coin .conf file should also work
|
||||
self._log.warning(
|
||||
f"Nameless {self.ticker()} wallet found."
|
||||
+ '\nPlease set the "wallet_name" coin setting to "" or recreate the wallet'
|
||||
)
|
||||
# backupwallet and restorewallet with name should work.
|
||||
|
||||
if self._rpc_wallet not in wallets:
|
||||
raise RuntimeError(
|
||||
|
||||
@@ -290,7 +290,7 @@ def js_wallets(self, url_split, post_string, is_json):
|
||||
swap_client.checkSystemStatus()
|
||||
if len(url_split) > 3:
|
||||
ticker_str = url_split[3]
|
||||
coin_type = getCoinIdFromTicker(ticker_str)
|
||||
coin_type = getCoinIdFromTicker(ticker_str, inc_variant=True)
|
||||
|
||||
if len(url_split) > 4:
|
||||
cmd = url_split[4]
|
||||
|
||||
Reference in New Issue
Block a user