diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 22e36a9..19cecfa 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -98,6 +98,8 @@ def parse_cmd(cmd: str, type_map: str): type_ind = type_map[i] if type_ind == 'i': typed_params.append(int(param)) + elif type_ind == 'f': + typed_params.append(float(param)) elif type_ind == 'b': typed_params.append(toBool(param)) elif type_ind == 'j': @@ -265,6 +267,7 @@ class HttpHandler(BaseHTTPRequestHandler): summary = swap_client.getSummary() result = None + cmd = '' coin_type = -1 coin_id = -1 call_type = 'cli' @@ -282,11 +285,16 @@ class HttpHandler(BaseHTTPRequestHandler): coin_type = Coins(Coins.XMR) elif coin_id in (-5,): coin_type = Coins(Coins.LTC) + elif coin_id in (-6,): + coin_type = Coins(Coins.DCR) else: coin_type = Coins(coin_id) except Exception: raise ValueError('Unknown Coin Type') + if coin_type in (Coins.DCR,): + call_type = 'http' + try: cmd = get_data_entry(form_data, 'cmd') except Exception: @@ -309,18 +317,24 @@ class HttpHandler(BaseHTTPRequestHandler): result = json.dumps(rv, indent=4) else: if call_type == 'http': + ci = swap_client.ci(coin_type) method, params = parse_cmd(cmd, type_map) - if coin_id == -5: - rv = swap_client.ci(coin_type).rpc_wallet_mweb(method, params) + if coin_id == -6: + rv = ci.rpc_wallet(method, params) + elif coin_id == -5: + rv = ci.rpc_wallet_mweb(method, params) else: - rv = swap_client.ci(coin_type).rpc_wallet(method, params) + if coin_type in (Coins.DCR, ): + rv = ci.rpc(method, params) + else: + rv = ci.rpc_wallet(method, params) if not isinstance(rv, str): rv = json.dumps(rv, indent=4) result = cmd + '\n' + rv else: result = cmd + '\n' + swap_client.callcoincli(coin_type, cmd) except Exception as ex: - result = str(ex) + result = cmd + '\n' + str(ex) if self.server.swap_client.debug is True: self.server.swap_client.log.error(traceback.format_exc()) @@ -330,6 +344,8 @@ class HttpHandler(BaseHTTPRequestHandler): with_xmr: bool = any(c[0] == Coins.XMR for c in coins) coins = [c for c in coins if c[0] != Coins.XMR] + if any(c[0] == Coins.DCR for c in coins): + coins.append((-6, 'Decred Wallet')) if any(c[0] == Coins.LTC for c in coins): coins.append((-5, 'Litecoin MWEB Wallet')) if with_xmr: diff --git a/basicswap/interface/dcr/dcr.py b/basicswap/interface/dcr/dcr.py index bf00637..15d2676 100644 --- a/basicswap/interface/dcr/dcr.py +++ b/basicswap/interface/dcr/dcr.py @@ -564,7 +564,7 @@ class DCRInterface(Secp256k1Interface): def withdrawCoin(self, value: float, addr_to: str, subfee: bool = False) -> str: if subfee: raise ValueError('TODO') - params = [addr_to, value] + params = [addr_to, float(value)] return self.rpc_wallet('sendtoaddress', params) def isAddressMine(self, address: str, or_watch_only: bool = False) -> bool: diff --git a/basicswap/interface/firo.py b/basicswap/interface/firo.py index 8943cef..c4d56af 100644 --- a/basicswap/interface/firo.py +++ b/basicswap/interface/firo.py @@ -49,6 +49,9 @@ class FIROInterface(BTCInterface): # load with -hdseed= parameter pass + def checkWallets(self) -> int: + return 1 + def getNewAddress(self, use_segwit, label='swap_receive'): return self.rpc('getnewaddress', [label]) # addr_plain = self.rpc('getnewaddress', [label]) diff --git a/basicswap/interface/nav.py b/basicswap/interface/nav.py index 82c7019..ce97fee 100644 --- a/basicswap/interface/nav.py +++ b/basicswap/interface/nav.py @@ -84,6 +84,9 @@ class NAVInterface(BTCInterface): # Load with -importmnemonic= parameter pass + def checkWallets(self) -> int: + return 1 + def getWalletSeedID(self): return self.rpc('getwalletinfo')['hdmasterkeyid'] diff --git a/basicswap/interface/pivx.py b/basicswap/interface/pivx.py index a88a6a1..038744c 100644 --- a/basicswap/interface/pivx.py +++ b/basicswap/interface/pivx.py @@ -35,6 +35,9 @@ class PIVXInterface(BTCInterface): # No multiwallet support self.rpc_wallet = make_rpc_func(self._rpcport, self._rpcauth, host=self._rpc_host) + def checkWallets(self) -> int: + return 1 + def signTxWithWallet(self, tx): rv = self.rpc('signrawtransaction', [tx.hex()]) return bytes.fromhex(rv['hex']) diff --git a/basicswap/templates/offer_confirm.html b/basicswap/templates/offer_confirm.html index 09f548b..b5d2cbf 100644 --- a/basicswap/templates/offer_confirm.html +++ b/basicswap/templates/offer_confirm.html @@ -113,7 +113,7 @@ - +
@@ -129,7 +129,7 @@
@@ -145,11 +145,11 @@
-

Coin You Send:

+

Coin You Send:

{{ input_down_arrow_offer_svg | safe }} - {% for c in coins_from %} {{ c[1] }} @@ -162,9 +162,9 @@
-

Amount You Send

+

Amount You Send

-
+
{% if data.swap_style == 'xmr' %} @@ -216,11 +216,11 @@
-

Coin You Get

+

Coin You Get

{{ input_down_arrow_offer_svg | safe }} - {% for c in coins %} {{ c[1] }} @@ -233,9 +233,9 @@
-

Amount You Get

+

Amount You Get

-
+
{% if data.swap_style == 'xmr' and coin_to != '6' %} @@ -301,7 +301,7 @@
{{ select_rate_svg | safe }}
- +
@@ -426,7 +426,7 @@
+
diff --git a/basicswap/templates/rpc.html b/basicswap/templates/rpc.html index 918a562..fc0c74f 100644 --- a/basicswap/templates/rpc.html +++ b/basicswap/templates/rpc.html @@ -1,5 +1,5 @@ {% include 'header.html' %} -{% from 'style.html' import breadcrumb_line_svg, input_arrow_down_svg %} +{% from 'style.html' import breadcrumb_line_svg, input_arrow_down_svg %}
@@ -62,8 +62,8 @@
- {{ input_arrow_down_svg| safe }} - {% for c in coins %} @@ -72,21 +72,21 @@
- +
- {{ input_arrow_down_svg| safe }} -
- +
@@ -148,7 +148,7 @@
-
+
@@ -176,4 +176,28 @@ {% include 'footer.html' %} +