Title: JSON-RPC validation error
Post by: Mikolo on November 10, 2015, 12:08:07 PM
I'm trying to make connection to my JSON RPC via python script. I've tried several different libraries, the one I got most success gives me that message: Traceback (most recent call last): File "test_conn_btc.py", line 6, in <module> x = server.request('getinfo') File "/usr/local/lib/python3.4/dist-packages/jsonrpcclient/server.py", line 98, in request return self.handle_response(self.send_message(request), True) File "/usr/local/lib/python3.4/dist-packages/jsonrpcclient/server.py", line 133, in handle_response json_validator.validate(response_dict) File "/usr/local/lib/python3.4/dist-packages/jsonschema/validators.py", line 123, in validate raise error jsonschema.exceptions.ValidationError: 'jsonrpc' is a required property
Failed validating 'required' in schema['allOf'][0]: {'properties': {'id': {'oneOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'null'}]}, 'jsonrpc': {'enum': ['2.0'], 'type': 'string'}}, 'required': ['jsonrpc', 'id'], 'type': 'object'}
On instance: {'error': None, 'id': 1, 'result': {'balance': 1.89, 'blocks': 598181, 'connections': 8, 'difficulty': 7150.92333102, 'errors': 'WARNING: abnormally high number of blocks ' 'generated, 11409 blocks received in the last ' '4 hours (24 expected)', 'keypoololdest': 1447081146, 'keypoolsize': 104, 'paytxfee': 0.0, 'protocolversion': 70002, 'proxy': '', 'relayfee': 5e-05, 'testnet': True, 'timeoffset': -1, 'version': 110100, 'walletversion': 60000}}
Here is the code of script: from jsonrpcclient.http_server import HTTPServer import json # docs at https://jsonrpcclient.readthedocs.org/http.html server = HTTPServer('http://127.0.0.1:18332', auth=('user', 'password'))
x = server.request('getinfo') print(x)
What may be the problem?
Title: Re: JSON-RPC validation error
Post by: ca333 on November 19, 2015, 11:06:57 AM
I'm trying to make connection to my JSON RPC via python script. I've tried several different libraries, the one I got most success gives me that message: Traceback (most recent call last): File "test_conn_btc.py", line 6, in <module> x = server.request('getinfo') File "/usr/local/lib/python3.4/dist-packages/jsonrpcclient/server.py", line 98, in request return self.handle_response(self.send_message(request), True) File "/usr/local/lib/python3.4/dist-packages/jsonrpcclient/server.py", line 133, in handle_response json_validator.validate(response_dict) File "/usr/local/lib/python3.4/dist-packages/jsonschema/validators.py", line 123, in validate raise error jsonschema.exceptions.ValidationError: 'jsonrpc' is a required property
Failed validating 'required' in schema['allOf'][0]: {'properties': {'id': {'oneOf': [{'type': 'string'}, {'type': 'integer'}, {'type': 'null'}]}, 'jsonrpc': {'enum': ['2.0'], 'type': 'string'}}, 'required': ['jsonrpc', 'id'], 'type': 'object'}
On instance: {'error': None, 'id': 1, 'result': {'balance': 1.89, 'blocks': 598181, 'connections': 8, 'difficulty': 7150.92333102, 'errors': 'WARNING: abnormally high number of blocks ' 'generated, 11409 blocks received in the last ' '4 hours (24 expected)', 'keypoololdest': 1447081146, 'keypoolsize': 104, 'paytxfee': 0.0, 'protocolversion': 70002, 'proxy': '', 'relayfee': 5e-05, 'testnet': True, 'timeoffset': -1, 'version': 110100, 'walletversion': 60000}}
Here is the code of script: from jsonrpcclient.http_server import HTTPServer import json # docs at https://jsonrpcclient.readthedocs.org/http.html server = HTTPServer('http://127.0.0.1:18332', auth=('user', 'password'))
x = server.request('getinfo') print(x)
What may be the problem? looks like json validation error. why not use the python library from Peter Todd? You may have a look. Its very mighty and you can do lots more than only using a standard rpc interface for communication with btc-core. https://github.com/petertodd/python-bitcoinlib p.s. jgarzik also has a python-lib for btc. https://github.com/jgarzik/python-bitcoinrpc
Title: Re: JSON-RPC validation error
Post by: chrisvl on November 19, 2015, 12:46:03 PM
from jsonrpc import ServiceProxy access = ServiceProxy("http://user:password@127.0.0.1:8332") access.getinfo() require http://json-rpc.org/wiki/python-json-rpc
|