My problem i that I'm trying to communicate my python code with bitcoin-cli (Bitcoin ABC) and I'm suppose to set rpcuser, and rpcpassword on bitcoin.conf file on .bitcoin folder. Right? Well, when I do so I still can call bitcoin-cli without prompting any password, and, worst, the code does not work:
from __future__ import print_function
import requests, json
rpcPort = 8332
rpcUser = 'xxxxx'
rpcPassword = 'xxxxx'
serverURL = 'http://' + rpcUser + ':' + rpcPassword + '@localhost:' + str(rpcPort)
headers = {'content-type': 'application/json'}
payload = json.dumps({"method": 'getblock', "params": ["0000000000005e5fd51f764d230441092f1b69d1a1eeab334c5bb32412e8dc51"], "jsonrpc": "2.0"})
response = requests.get(serverURL, headers=headers, data=payload)
print(response.json()['result'])
My results:
Traceback (most recent call last):
File "/home/phglz/Desktop/pruebapython.py", line 17, in <module>
print(response.json()['result'])
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/home/phglz/Desktop/pruebapython.py"]
[dir: /home/phglz/Desktop]
[path: /home/phglz/bin:/home/phglz/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
I'm quite lost now as you can see I'm not an expert on this. My bitcoin.conf looks like:
rpcuser=xxxx
rpcpassword=xxxx
daemon=1
keypool=10000
maxuploadtarget=20
maxconnections=16
Thanks in advance for your valued help.