mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
ui: Add json endpoint to list all coin types.
This commit is contained in:
@@ -33,6 +33,7 @@ from .basicswap_util import (
|
||||
strAddressType,
|
||||
)
|
||||
from .js_server import (
|
||||
js_coins,
|
||||
js_error,
|
||||
js_wallets,
|
||||
js_offers,
|
||||
@@ -678,7 +679,8 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||
self.putHeaders(status_code, 'text/plain')
|
||||
func = js_index
|
||||
if len(url_split) > 2:
|
||||
func = {'wallets': js_wallets,
|
||||
func = {'coins': js_coins,
|
||||
'wallets': js_wallets,
|
||||
'offers': js_offers,
|
||||
'sentoffers': js_sentoffers,
|
||||
'bids': js_bids,
|
||||
|
||||
@@ -16,6 +16,7 @@ from .basicswap_util import (
|
||||
)
|
||||
from .chainparams import (
|
||||
Coins,
|
||||
chainparams,
|
||||
)
|
||||
from .ui.util import (
|
||||
PAGE_LIMIT,
|
||||
@@ -61,6 +62,27 @@ def withdraw_coin(swap_client, coin_type, post_string, is_json):
|
||||
return {'txid': txid_hex}
|
||||
|
||||
|
||||
def js_coins(self, url_split, post_string, is_json):
|
||||
swap_client = self.server.swap_client
|
||||
|
||||
coins = []
|
||||
for coin in Coins:
|
||||
cc = swap_client.coin_clients[coin]
|
||||
entry = {
|
||||
'id': int(coin),
|
||||
'ticker': chainparams[cc['coin']]['ticker'],
|
||||
'name': cc['name'].capitalize(),
|
||||
'active': False if cc['connection_type'] == 'none' else True,
|
||||
}
|
||||
if coin == Coins.PART_ANON:
|
||||
entry['variant'] = 'Anon'
|
||||
elif coin == Coins.PART_BLIND:
|
||||
entry['variant'] = 'Blind'
|
||||
coins.append(entry)
|
||||
|
||||
return bytes(json.dumps(coins), 'UTF-8')
|
||||
|
||||
|
||||
def js_wallets(self, url_split, post_string, is_json):
|
||||
swap_client = self.server.swap_client
|
||||
if len(url_split) > 3:
|
||||
|
||||
Reference in New Issue
Block a user