api: Add wallet lock/unlock commands and getcoinseed.

This commit is contained in:
tecnovert
2022-11-12 01:51:30 +02:00
parent 020a65db8a
commit fc31615a97
21 changed files with 412 additions and 121 deletions

View File

@@ -217,13 +217,23 @@ def post_json_req(url, json_data):
req.add_header('Content-Type', 'application/json; charset=utf-8')
post_bytes = json.dumps(json_data).encode('utf-8')
req.add_header('Content-Length', len(post_bytes))
return urlopen(req, post_bytes).read()
return urlopen(req, post_bytes, timeout=300).read()
def read_json_api(port, path=None):
def read_text_api(port, path=None):
url = f'http://127.0.0.1:{port}/json'
if path is not None:
url += '/' + path
return urlopen(url, timeout=300).read().decode('utf-8')
def read_json_api(port, path=None, json_data=None):
url = f'http://127.0.0.1:{port}/json'
if path is not None:
url += '/' + path
if json_data is not None:
return json.loads(post_json_req(url, json_data))
return json.loads(urlopen(url, timeout=300).read())