justinmoon / junction

UI For Using Hardware Wallets With Bitcoin Core
MIT License
60 stars 13 forks source link

RPC Wallet Creation / Retrieval with names which include spaces will fail #33

Open ghost opened 5 years ago

ghost commented 5 years ago

Steps to reproduce

  1. Create a new wallet which includes a space character in the name.

e.g. POST http://localhost:37128/wallets ({"name":"TEST SPACE","m":1,"n":1})

Expected Result:

Actual Resut:

Junction Server Response:

{
  "error": "URL can't contain control characters. '/wallet/TEST SPACE' (found at least ' ')"
}

Python console error:

URL can't contain control characters. '/wallet/TEST SPACE' (found at least ' ')
Traceback (most recent call last):
  File "/Users/rich/projects/junction/junction.py", line 316, in balances
    balances = self.wallet_rpc.getbalances()
  File "/Users/rich/projects/junction/venv/lib/python3.7/site-packages/bitcoinrpc/authproxy.py", line 136, in __call__
    'Content-type': 'application/json'})
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1255, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1117, in putrequest
    raise InvalidURL(f"URL can't contain control characters. {url!r} "
http.client.InvalidURL: URL can't contain control characters. '/wallet/TEST SPACE' (found at least ' ')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rich/projects/junction/venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/rich/projects/junction/venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/rich/projects/junction/venv/lib/python3.7/site-packages/flask_json_schema/__init__.py", line 46, in decorated
    return fn(*args, **kwargs)
  File "/Users/rich/projects/junction/api.py", line 117, in create_wallet
    return jsonify(wallet.to_dict(True))
  File "/Users/rich/projects/junction/junction.py", line 141, in to_dict
    unconfirmed, confirmed = self.balances()
  File "/Users/rich/projects/junction/junction.py", line 326, in balances
    unspent = self.wallet_rpc.listunspent(0, 9999999, [], True)
  File "/Users/rich/projects/junction/venv/lib/python3.7/site-packages/bitcoinrpc/authproxy.py", line 136, in __call__
    'Content-type': 'application/json'})
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1244, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1255, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1117, in putrequest
    raise InvalidURL(f"URL can't contain control characters. {url!r} "
http.client.InvalidURL: URL can't contain control characters. '/wallet/TEST SPACE' (found at least ' ')