|
|
@ -268,6 +268,7 @@ class HttpHandler(BaseHTTPRequestHandler): |
|
|
|
|
|
|
|
|
|
|
|
result = None |
|
|
|
result = None |
|
|
|
cmd = '' |
|
|
|
cmd = '' |
|
|
|
|
|
|
|
coin_type_selected = -1 |
|
|
|
coin_type = -1 |
|
|
|
coin_type = -1 |
|
|
|
coin_id = -1 |
|
|
|
coin_id = -1 |
|
|
|
call_type = 'cli' |
|
|
|
call_type = 'cli' |
|
|
@ -280,15 +281,10 @@ class HttpHandler(BaseHTTPRequestHandler): |
|
|
|
call_type = get_data_entry_or(form_data, 'call_type', 'cli') |
|
|
|
call_type = get_data_entry_or(form_data, 'call_type', 'cli') |
|
|
|
type_map = get_data_entry_or(form_data, 'type_map', '') |
|
|
|
type_map = get_data_entry_or(form_data, 'type_map', '') |
|
|
|
try: |
|
|
|
try: |
|
|
|
coin_id = int(get_data_entry(form_data, 'coin_type')) |
|
|
|
coin_type_selected = get_data_entry(form_data, 'coin_type') |
|
|
|
if coin_id in (-2, -3, -4): |
|
|
|
coin_type_split = coin_type_selected.split(',') |
|
|
|
coin_type = Coins(Coins.XMR) |
|
|
|
coin_type = Coins(int(coin_type_split[0])) |
|
|
|
elif coin_id in (-5,): |
|
|
|
coin_variant = int(coin_type_split[1]) |
|
|
|
coin_type = Coins(Coins.LTC) |
|
|
|
|
|
|
|
elif coin_id in (-6,): |
|
|
|
|
|
|
|
coin_type = Coins(Coins.DCR) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
coin_type = Coins(coin_id) |
|
|
|
|
|
|
|
except Exception: |
|
|
|
except Exception: |
|
|
|
raise ValueError('Unknown Coin Type') |
|
|
|
raise ValueError('Unknown Coin Type') |
|
|
|
|
|
|
|
|
|
|
@ -299,29 +295,29 @@ class HttpHandler(BaseHTTPRequestHandler): |
|
|
|
cmd = get_data_entry(form_data, 'cmd') |
|
|
|
cmd = get_data_entry(form_data, 'cmd') |
|
|
|
except Exception: |
|
|
|
except Exception: |
|
|
|
raise ValueError('Invalid command') |
|
|
|
raise ValueError('Invalid command') |
|
|
|
if coin_type == Coins.XMR: |
|
|
|
if coin_type in (Coins.XMR, ): |
|
|
|
ci = swap_client.ci(coin_type) |
|
|
|
ci = swap_client.ci(coin_type) |
|
|
|
arr = cmd.split(None, 1) |
|
|
|
arr = cmd.split(None, 1) |
|
|
|
method = arr[0] |
|
|
|
method = arr[0] |
|
|
|
params = json.loads(arr[1]) if len(arr) > 1 else [] |
|
|
|
params = json.loads(arr[1]) if len(arr) > 1 else [] |
|
|
|
if coin_id == -4: |
|
|
|
if coin_variant == 2: |
|
|
|
rv = ci.rpc_wallet(method, params) |
|
|
|
rv = ci.rpc_wallet(method, params) |
|
|
|
elif coin_id == -3: |
|
|
|
elif coin_variant == 0: |
|
|
|
rv = ci.rpc(method, params) |
|
|
|
rv = ci.rpc(method, params) |
|
|
|
elif coin_id == -2: |
|
|
|
elif coin_variant == 1: |
|
|
|
if params == []: |
|
|
|
if params == []: |
|
|
|
params = None |
|
|
|
params = None |
|
|
|
rv = ci.rpc2(method, params) |
|
|
|
rv = ci.rpc2(method, params) |
|
|
|
else: |
|
|
|
else: |
|
|
|
raise ValueError('Unknown XMR RPC variant') |
|
|
|
raise ValueError('Unknown RPC variant') |
|
|
|
result = json.dumps(rv, indent=4) |
|
|
|
result = json.dumps(rv, indent=4) |
|
|
|
else: |
|
|
|
else: |
|
|
|
if call_type == 'http': |
|
|
|
if call_type == 'http': |
|
|
|
ci = swap_client.ci(coin_type) |
|
|
|
ci = swap_client.ci(coin_type) |
|
|
|
method, params = parse_cmd(cmd, type_map) |
|
|
|
method, params = parse_cmd(cmd, type_map) |
|
|
|
if coin_id == -6: |
|
|
|
if coin_variant == 1: |
|
|
|
rv = ci.rpc_wallet(method, params) |
|
|
|
rv = ci.rpc_wallet(method, params) |
|
|
|
elif coin_id == -5: |
|
|
|
elif coin_variant == 2: |
|
|
|
rv = ci.rpc_wallet_mweb(method, params) |
|
|
|
rv = ci.rpc_wallet_mweb(method, params) |
|
|
|
else: |
|
|
|
else: |
|
|
|
if coin_type in (Coins.DCR, ): |
|
|
|
if coin_type in (Coins.DCR, ): |
|
|
@ -340,24 +336,24 @@ class HttpHandler(BaseHTTPRequestHandler): |
|
|
|
|
|
|
|
|
|
|
|
template = env.get_template('rpc.html') |
|
|
|
template = env.get_template('rpc.html') |
|
|
|
|
|
|
|
|
|
|
|
coins = listAvailableCoins(swap_client, with_variants=False) |
|
|
|
coin_available = listAvailableCoins(swap_client, with_variants=False) |
|
|
|
with_xmr: bool = any(c[0] == Coins.XMR for c in coins) |
|
|
|
with_xmr: bool = any(c[0] == Coins.XMR for c in coin_available) |
|
|
|
coins = [c for c in coins if c[0] != Coins.XMR] |
|
|
|
coins = [(str(c[0]) + ',0', c[1]) for c in coin_available if c[0] not in (Coins.XMR, )] |
|
|
|
|
|
|
|
|
|
|
|
if any(c[0] == Coins.DCR for c in coins): |
|
|
|
if any(c[0] == Coins.DCR for c in coin_available): |
|
|
|
coins.append((-6, 'Decred Wallet')) |
|
|
|
coins.append((str(int(Coins.DCR)) + ',1', 'Decred Wallet')) |
|
|
|
if any(c[0] == Coins.LTC for c in coins): |
|
|
|
if any(c[0] == Coins.LTC for c in coin_available): |
|
|
|
coins.append((-5, 'Litecoin MWEB Wallet')) |
|
|
|
coins.append((str(int(Coins.LTC)) + ',2', 'Litecoin MWEB Wallet')) |
|
|
|
if with_xmr: |
|
|
|
if with_xmr: |
|
|
|
coins.append((-2, 'Monero')) |
|
|
|
coins.append((str(int(Coins.XMR)) + ',0', 'Monero')) |
|
|
|
coins.append((-3, 'Monero JSON')) |
|
|
|
coins.append((str(int(Coins.XMR)) + ',1', 'Monero JSON')) |
|
|
|
coins.append((-4, 'Monero Wallet')) |
|
|
|
coins.append((str(int(Coins.XMR)) + ',2', 'Monero Wallet')) |
|
|
|
|
|
|
|
|
|
|
|
return self.render_template(template, { |
|
|
|
return self.render_template(template, { |
|
|
|
'messages': messages, |
|
|
|
'messages': messages, |
|
|
|
'err_messages': err_messages, |
|
|
|
'err_messages': err_messages, |
|
|
|
'coins': coins, |
|
|
|
'coins': coins, |
|
|
|
'coin_type': coin_id, |
|
|
|
'coin_type': coin_type_selected, |
|
|
|
'call_type': call_type, |
|
|
|
'call_type': call_type, |
|
|
|
'result': result, |
|
|
|
'result': result, |
|
|
|
'messages': messages, |
|
|
|
'messages': messages, |
|
|
|