mirror of
https://github.com/basicswap/basicswap.git
synced 2024-11-16 15:58:17 +00:00
coins: Rename Pivx -> PIVX
This commit is contained in:
parent
e46fd193fe
commit
59fb6c18ed
10 changed files with 75 additions and 54 deletions
|
@ -38,6 +38,7 @@ from .interface.passthrough_btc import PassthroughBTCInterface
|
|||
|
||||
from . import __version__
|
||||
from .rpc_xmr import make_xmr_rpc2_func
|
||||
from .ui.util import getCoinName
|
||||
from .util import (
|
||||
TemporaryError,
|
||||
InactiveCoin,
|
||||
|
@ -165,11 +166,11 @@ def threadPollXMRChainState(swap_client, coin_type):
|
|||
try:
|
||||
new_height = ci.getChainHeight()
|
||||
if new_height != cc['chain_height']:
|
||||
swap_client.log.debug('New {} block at height: {}'.format(str(coin_type), new_height))
|
||||
swap_client.log.debug('New {} block at height: {}'.format(ci.ticker(), new_height))
|
||||
with swap_client.mxDB:
|
||||
cc['chain_height'] = new_height
|
||||
except Exception as e:
|
||||
swap_client.log.warning('threadPollXMRChainState {}, error: {}'.format(str(coin_type), str(e)))
|
||||
swap_client.log.warning('threadPollXMRChainState {}, error: {}'.format(ci.ticker(), str(e)))
|
||||
swap_client.delay_event.wait(random.randrange(20, 30)) # random to stagger updates
|
||||
|
||||
|
||||
|
@ -180,14 +181,14 @@ def threadPollChainState(swap_client, coin_type):
|
|||
try:
|
||||
chain_state = ci.getBlockchainInfo()
|
||||
if chain_state['bestblockhash'] != cc['chain_best_block']:
|
||||
swap_client.log.debug('New {} block at height: {}'.format(str(coin_type), chain_state['blocks']))
|
||||
swap_client.log.debug('New {} block at height: {}'.format(ci.ticker(), chain_state['blocks']))
|
||||
with swap_client.mxDB:
|
||||
cc['chain_height'] = chain_state['blocks']
|
||||
cc['chain_best_block'] = chain_state['bestblockhash']
|
||||
if 'mediantime' in chain_state:
|
||||
cc['chain_median_time'] = chain_state['mediantime']
|
||||
except Exception as e:
|
||||
swap_client.log.warning('threadPollChainState {}, error: {}'.format(str(coin_type), str(e)))
|
||||
swap_client.log.warning('threadPollChainState {}, error: {}'.format(ci.ticker(), str(e)))
|
||||
swap_client.delay_event.wait(random.randrange(20, 30)) # random to stagger updates
|
||||
|
||||
|
||||
|
@ -5487,7 +5488,7 @@ class BasicSwap(BaseApp):
|
|||
rv[key] = self.getWalletInfo(c)
|
||||
rv[key].update(self.getBlockchainInfo(c))
|
||||
except Exception as ex:
|
||||
rv[key] = {'name': chainparams[c]['name'].capitalize(), 'error': str(ex)}
|
||||
rv[key] = {'name': getCoinName(c), 'error': str(ex)}
|
||||
return rv
|
||||
|
||||
def getCachedWalletsInfo(self, opts=None):
|
||||
|
@ -5537,7 +5538,7 @@ class BasicSwap(BaseApp):
|
|||
coin_id = int(c)
|
||||
if coin_id not in rv:
|
||||
rv[coin_id] = {
|
||||
'name': chainparams[c]['name'].capitalize(),
|
||||
'name': getCoinName(c),
|
||||
'no_data': True,
|
||||
'updating': self._updating_wallets_info.get(coin_id, False),
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ chainparams = {
|
|||
'decimal_places': 8,
|
||||
'has_csv': False,
|
||||
'has_segwit': False,
|
||||
'use_ticker_as_name': True,
|
||||
'mainnet': {
|
||||
'rpcport': 51473,
|
||||
'pubkey_address': 30,
|
||||
|
@ -320,7 +321,10 @@ class CoinInterface:
|
|||
return format_amount(amount_int, self.exp())
|
||||
|
||||
def coin_name(self):
|
||||
return chainparams[self.coin_type()]['name'].capitalize()
|
||||
coin_chainparams = chainparams[self.coin_type()]
|
||||
if coin_chainparams.get('use_ticker_as_name', False):
|
||||
return coin_chainparams['ticker']
|
||||
return coin_chainparams['name'].capitalize()
|
||||
|
||||
def ticker(self):
|
||||
ticker = chainparams[self.coin_type()]['ticker']
|
||||
|
|
|
@ -75,7 +75,7 @@ def listAvailableExplorers(swap_client):
|
|||
if c not in chainparams:
|
||||
continue
|
||||
for i, e in enumerate(swap_client.coin_clients[c]['explorers']):
|
||||
explorers.append(('{}_{}'.format(int(c), i), swap_client.coin_clients[c]['name'].capitalize() + ' - ' + extractDomain(e.base_url)))
|
||||
explorers.append(('{}_{}'.format(int(c), i), getCoinName(c) + ' - ' + extractDomain(e.base_url)))
|
||||
return explorers
|
||||
|
||||
|
||||
|
@ -104,7 +104,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||
self.server.last_form_id[name] = form_id
|
||||
return form_data
|
||||
|
||||
def render_template(self, template, args_dict):
|
||||
def render_template(self, template, args_dict, status_code=200):
|
||||
swap_client = self.server.swap_client
|
||||
if swap_client.ws_server:
|
||||
args_dict['ws_url'] = swap_client.ws_server.url
|
||||
|
@ -141,7 +141,7 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||
if self.server.msg_id_counter >= 0x7FFFFFFF:
|
||||
self.server.msg_id_counter = 0
|
||||
|
||||
self.putHeaders(200, 'text/html')
|
||||
self.putHeaders(status_code, 'text/html')
|
||||
return bytes(template.render(
|
||||
title=self.server.title,
|
||||
h2=self.server.title,
|
||||
|
@ -343,19 +343,26 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||
messages.append('Please restart BasicSwap.')
|
||||
elif have_data_entry(form_data, 'enable_' + name):
|
||||
swap_client.enableCoin(name)
|
||||
messages.append(name.capitalize() + ' enabled, shutting down.')
|
||||
display_name = getCoinName(swap_client.getCoinIdFromName(name))
|
||||
messages.append(display_name + ' enabled, shutting down.')
|
||||
swap_client.stopRunning()
|
||||
elif have_data_entry(form_data, 'disable_' + name):
|
||||
swap_client.disableCoin(name)
|
||||
messages.append(name.capitalize() + ' disabled, shutting down.')
|
||||
display_name = getCoinName(swap_client.getCoinIdFromName(name))
|
||||
messages.append(display_name + ' disabled, shutting down.')
|
||||
swap_client.stopRunning()
|
||||
chains_formatted = []
|
||||
|
||||
sorted_names = sorted(swap_client.settings['chainclients'].keys())
|
||||
for name in sorted_names:
|
||||
c = swap_client.settings['chainclients'][name]
|
||||
try:
|
||||
display_name = getCoinName(swap_client.getCoinIdFromName(name))
|
||||
except Exception:
|
||||
display_name = name
|
||||
chains_formatted.append({
|
||||
'name': name,
|
||||
'display_name': display_name,
|
||||
'lookups': c.get('chain_lookups', 'local'),
|
||||
'manage_daemon': c.get('manage_daemon', 'Unknown'),
|
||||
'connection_type': c.get('connection_type', 'Unknown'),
|
||||
|
@ -607,15 +614,12 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||
self.putHeaders(status_code, 'application/javascript')
|
||||
return fp.read()
|
||||
else:
|
||||
self.putHeaders(status_code, 'text/html')
|
||||
return self.page_404(url_split)
|
||||
except FileNotFoundError:
|
||||
self.putHeaders(status_code, 'text/html')
|
||||
return self.page_404(url_split)
|
||||
except Exception as ex:
|
||||
if self.server.swap_client.debug is True:
|
||||
self.server.swap_client.log.error(traceback.format_exc())
|
||||
self.putHeaders(status_code, 'text/html')
|
||||
return self.page_error(str(ex))
|
||||
|
||||
try:
|
||||
|
|
|
@ -22,6 +22,7 @@ from .chainparams import (
|
|||
)
|
||||
from .ui.util import (
|
||||
PAGE_LIMIT,
|
||||
getCoinName,
|
||||
getCoinType,
|
||||
inputAmount,
|
||||
describeBid,
|
||||
|
@ -73,7 +74,7 @@ def js_coins(self, url_split, post_string, is_json):
|
|||
entry = {
|
||||
'id': int(coin),
|
||||
'ticker': chainparams[cc['coin']]['ticker'],
|
||||
'name': cc['name'].capitalize(),
|
||||
'name': getCoinName(coin),
|
||||
'active': False if cc['connection_type'] == 'none' else True,
|
||||
}
|
||||
if coin == Coins.PART_ANON:
|
||||
|
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
@ -106,7 +106,7 @@
|
|||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
|
||||
<section class="bg-white">
|
||||
<div class="pl-6 pr-6 pt-0 pb-0 mt-5 h-full overflow-hidden bg-white ">
|
||||
<div class="pb-6 border-coolGray-100">
|
||||
|
@ -141,9 +141,9 @@
|
|||
<section class="bg-white p-3">
|
||||
<div class="flex flex-wrap items-center">
|
||||
<div class="w-full">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<span class="inline-block align-middle items-center justify-center w-9 h-10 bg-white-50 rounded">
|
||||
<img class="h-9" src="/static/images/coins/{{ c.name }}.png" alt=""> </span> {{ c.name|capitalize }}</h4>
|
||||
<img class="h-9" src="/static/images/coins/{{ c.name }}.png" alt=""> </span> {{ c.display_name }}</h4>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -214,7 +214,7 @@
|
|||
{% endif %}
|
||||
<tr class="bg-white border-t hover:bg-gray-50">
|
||||
<td class="py-4 px-6 bold w-96 bold">Chain Lookups</td>
|
||||
<td>
|
||||
<td>
|
||||
<select class="appearance-none bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg outline-none focus:ring-blue-500 focus:border-blue-500 block p-2.5" name="lookups_{{ c.name }}">
|
||||
<option value="local" {% if c.lookups=='local' %} selected{% endif %}>Local Node</option>
|
||||
<option value="explorer" {% if c.lookups=='explorer' %} selected{% endif %}>Explorer</option>
|
||||
|
@ -261,7 +261,7 @@
|
|||
{% if c.can_disable == true %}
|
||||
|
||||
<div class="w-full md:w-auto p-1.5 ml-2">
|
||||
<button name="disable_{{ c.name }}" value="Disable" onclick="return confirmPopup('Disable', '{{ c.name|capitalize }}');" type="submit" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-red-500 hover:text-red-600 border border-red-400 hover:border-red-500 bg-white rounded-md shadow-button focus:ring-0 focus:outline-none">
|
||||
<button name="disable_{{ c.name }}" value="Disable" onclick="return confirmPopup('Disable', '{{ c.display_name }}');" type="submit" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-red-500 hover:text-red-600 border border-red-400 hover:border-red-500 bg-white rounded-md shadow-button focus:ring-0 focus:outline-none">
|
||||
<span>Disable Coin</span> </button>
|
||||
</div>
|
||||
|
||||
|
@ -269,7 +269,7 @@
|
|||
{% if c.can_reenable == true %}
|
||||
|
||||
<div class="w-full md:w-auto p-1.5 ml-2">
|
||||
<button name="enable_{{ c.name }}" value="Enable" onclick="return confirmPopup('Enable', '{{ c.name|capitalize }}');" type="submit" class="flex flex-wrap justify-center w-full px-4 py-2.5 bg-white hover:bg-white font-medium text-sm text-green-500 border border-green-500 hover:text-green-600 hover:border-green-600 rounded-md shadow-button focus:ring-0 focus:outline-none">
|
||||
<button name="enable_{{ c.name }}" value="Enable" onclick="return confirmPopup('Enable', '{{ c.display_name }}');" type="submit" class="flex flex-wrap justify-center w-full px-4 py-2.5 bg-white hover:bg-white font-medium text-sm text-green-500 border border-green-500 hover:text-green-600 hover:border-green-600 rounded-md shadow-button focus:ring-0 focus:outline-none">
|
||||
<span>Enable</span> </button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -282,7 +282,7 @@
|
|||
</form>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
@ -298,9 +298,9 @@
|
|||
<section class="bg-white p-3">
|
||||
<div class="flex flex-wrap items-center">
|
||||
<div class="w-full">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<span class="inline-block align-middle items-center justify-center w-9 h-10 bg-white-50 rounded">
|
||||
<img class="h-9" src="" alt=""> </span>General</h4>
|
||||
<img class="h-9" src="" alt=""> </span>General</h4>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -315,7 +315,7 @@
|
|||
<th scope="col">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="py-4 px-6 bold w-96 bold">Debug Mode</td>
|
||||
<td>
|
||||
|
@ -325,7 +325,7 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class="bg-white border-t hover:bg-gray-50">
|
||||
<td class="py-4 px-6 bold w-96">Debug Mode UI</td>
|
||||
<td>
|
||||
|
@ -337,9 +337,9 @@
|
|||
</tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div> </div>
|
||||
|
||||
|
||||
</div> </div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -352,7 +352,7 @@
|
|||
<span>Apply</span> </button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -362,9 +362,9 @@
|
|||
<section class="bg-white p-3">
|
||||
<div class="flex flex-wrap items-center">
|
||||
<div class="w-full">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<span class="inline-block align-middle items-center justify-center w-9 h-10 bg-white-50 rounded">
|
||||
<img class="h-9" src="" alt=""> </span>Chart (todo)</h4>
|
||||
<img class="h-9" src="" alt=""> </span>Chart (todo)</h4>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -379,7 +379,7 @@
|
|||
<th scope="col">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="py-4 px-6 bold w-96 bold">Show Chart</td>
|
||||
<td>
|
||||
|
@ -389,16 +389,16 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class="bg-white border-t hover:bg-gray-50">
|
||||
<td class="py-4 px-6 bold w-96">Chart API Key (URL)</td>
|
||||
<td><input type="text" class="appearance-none bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg outline-none focus:ring-blue-500 focus:border-blue-500 block p-2.5" name="" min="3" max="32" value=""></td>
|
||||
</tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div> </div>
|
||||
|
||||
|
||||
</div> </div>
|
||||
|
||||
|
||||
|
||||
<div class="p-6 pt-10 bg-white bg-opacity-60 rounded-b-md">
|
||||
<div class="w-full md:w-0/12">
|
||||
|
@ -409,7 +409,7 @@
|
|||
<span>Apply</span> </button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -435,9 +435,9 @@
|
|||
<section class="bg-white p-3">
|
||||
<div class="flex flex-wrap items-center">
|
||||
<div class="w-full">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<h4 class="font-semibold text-black text-2xl align-middle">
|
||||
<span class="inline-block align-middle items-center justify-center w-9 h-10 bg-white-50 rounded">
|
||||
<img class="h-9" src="" alt=""> </span>Tor</h4>
|
||||
<img class="h-9" src="" alt=""> </span>Tor</h4>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -452,7 +452,7 @@
|
|||
<th scope="col">Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="py-4 px-6 bold w-96 bold">Use TOR</td>
|
||||
<td>
|
||||
|
@ -462,7 +462,7 @@
|
|||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class="bg-white border-t hover:bg-gray-50">
|
||||
<td class="py-4 px-6 bold w-96">Use Tor Proxy</td>
|
||||
<td>
|
||||
|
@ -485,15 +485,15 @@
|
|||
<td class="py-4 px-6 bold w-96">Tor Proxy Port</td>
|
||||
<td><input type="text" class="appearance-none bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg outline-none focus:ring-blue-500 focus:border-blue-500 block p-2.5" name="" min="3" max="32" value=""></td>
|
||||
</tr>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr class="bg-white border-t hover:bg-gray-50">
|
||||
<td class="py-4 px-6 bold w-96">Tor Control Port</td>
|
||||
<td><input type="text" class="appearance-none bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg outline-none focus:ring-blue-500 focus:border-blue-500 block p-2.5" name="" min="3" max="32" value=""></td>
|
||||
</tr>
|
||||
</tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div> </div>
|
||||
|
||||
</div> </div>
|
||||
|
||||
<div class="p-6 pt-10 bg-white bg-opacity-60 rounded-b-md">
|
||||
<div class="w-full md:w-0/12">
|
||||
<div class="flex flex-wrap justify-end -m-1.5">
|
||||
|
@ -541,4 +541,4 @@
|
|||
</script>
|
||||
{% include 'footer.html' %}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -388,7 +388,11 @@ def getCoinName(c):
|
|||
return chainparams[Coins.PART]['name'].capitalize() + ' Anon'
|
||||
if c == Coins.PART_BLIND:
|
||||
return chainparams[Coins.PART]['name'].capitalize() + ' Blind'
|
||||
return chainparams[c]['name'].capitalize()
|
||||
|
||||
coin_chainparams = chainparams[c]
|
||||
if coin_chainparams.get('use_ticker_as_name', False):
|
||||
return coin_chainparams['ticker']
|
||||
return coin_chainparams['name'].capitalize()
|
||||
|
||||
|
||||
def listAvailableCoins(swap_client, with_variants=True, split_from=False):
|
||||
|
|
|
@ -27,6 +27,7 @@ import basicswap.config as cfg
|
|||
from basicswap.base import getaddrinfo_tor
|
||||
from basicswap.basicswap import BasicSwap
|
||||
from basicswap.chainparams import Coins
|
||||
from basicswap.ui.util import getCoinName
|
||||
from basicswap.util import toBool
|
||||
from basicswap.util.rfc2440 import rfc2440_hash_password
|
||||
from basicswap.contrib.rpcauth import generate_salt, password_to_hmac
|
||||
|
@ -895,7 +896,7 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
|
|||
# Create wallet if it doesn't exist yet
|
||||
wallets = swap_client.callcoinrpc(c, 'listwallets')
|
||||
if len(wallets) < 1:
|
||||
logger.info('Creating wallet.dat for {}.'.format(coin_name.capitalize()))
|
||||
logger.info('Creating wallet.dat for {}.'.format(getCoinName(c)))
|
||||
swap_client.callcoinrpc(c, 'createwallet', ['wallet.dat'])
|
||||
|
||||
if 'particl' in with_coins and c == Coins.PART:
|
||||
|
|
|
@ -17,11 +17,11 @@ import subprocess
|
|||
|
||||
import basicswap.config as cfg
|
||||
from basicswap import __version__
|
||||
from basicswap.ui.util import getCoinName
|
||||
from basicswap.basicswap import BasicSwap
|
||||
from basicswap.http_server import HttpThread
|
||||
from basicswap.contrib.websocket_server import WebsocketServer
|
||||
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.level = logging.DEBUG
|
||||
if not len(logger.handlers):
|
||||
|
@ -142,15 +142,21 @@ def runClient(fp, data_dir, chain):
|
|||
try:
|
||||
# Try start daemons
|
||||
for c, v in settings['chainclients'].items():
|
||||
try:
|
||||
coin_id = swap_client.getCoinIdFromName(c)
|
||||
display_name = getCoinName(coin_id)
|
||||
except Exception as e:
|
||||
logger.warning('Error getting coin display name for {}: {}'.format(c, str(e)))
|
||||
display_name = 'Unknown'
|
||||
if c == 'monero':
|
||||
if v['manage_daemon'] is True:
|
||||
swap_client.log.info('Starting {} daemon'.format(c.capitalize()))
|
||||
swap_client.log.info(f'Starting {display_name} daemon')
|
||||
daemons.append(startXmrDaemon(v['datadir'], v['bindir'], 'monerod'))
|
||||
pid = daemons[-1].pid
|
||||
swap_client.log.info('Started {} {}'.format('monerod', pid))
|
||||
|
||||
if v['manage_wallet_daemon'] is True:
|
||||
swap_client.log.info('Starting {} wallet daemon'.format(c.capitalize()))
|
||||
swap_client.log.info(f'Starting {display_name} wallet daemon')
|
||||
daemon_addr = '{}:{}'.format(v['rpchost'], v['rpcport'])
|
||||
swap_client.log.info('daemon-address: {}'.format(daemon_addr))
|
||||
opts = ['--daemon-address', daemon_addr, ]
|
||||
|
@ -160,7 +166,7 @@ def runClient(fp, data_dir, chain):
|
|||
|
||||
continue
|
||||
if v['manage_daemon'] is True:
|
||||
swap_client.log.info('Starting {} daemon'.format(c.capitalize()))
|
||||
swap_client.log.info(f'Starting {display_name} daemon')
|
||||
|
||||
filename = c + 'd' + ('.exe' if os.name == 'nt' else '')
|
||||
daemons.append(startDaemon(v['datadir'], v['bindir'], filename))
|
||||
|
|
Loading…
Reference in a new issue