python-bitcoinrpc icon indicating copy to clipboard operation
python-bitcoinrpc copied to clipboard

401 Unauthorized

Open iamdiwang opened this issue 4 years ago • 1 comments

File "censored", line 197, in _get_response raise JSONRPCException({ bitcoinrpc.authproxy.JSONRPCException: -342: non-JSON HTTP response with '401 Unauthorized' from server

iamdiwang avatar Sep 29 '21 15:09 iamdiwang

File "censored", line 197, in _get_response raise JSONRPCException({ bitcoinrpc.authproxy.JSONRPCException: -342: non-JSON HTTP response with '401 Unauthorized' from server

it looks like the daemon or wallet you are trying to connect to is not recognizing you.

please check the "~/.bitcoin/bitcoin.conf " and confirm you are using the correct values for "rpcuser", "rpcpassword", "rpcport"

also if you are attempting to connect to a wallet that is not on your localhost, make sure that the value for "rpcallowip" in your"~/.bitcoin/bitcoin.conf " is the same as the ip address that you are making the call from

example

*your_script.py

rpc_user="YOURUSERNAME"
rpc_password="YOURPASSWORD"
rpc_port="RPCPORT"
import logging
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
rpc_conn = AuthServiceProxy("http://%s:%[email protected]:%s"%(rpc_user, rpc_password, rpc_port))
wallet_info = rpc_conn.getinfo()

*your coindaemon.conf (ex: bitcoin.conf, litecoin.conf, dogecoin.conf)

rpcuser="YOURUSERNAME"
rpcpassword="YOURPASSWORD"
server=1
daemon=1
listen=1
rpcallowip=127.0.0.1 (if the daemon is on the same computer that you are making the call from, leave this as "127.0.0.1")
rpcallowip="IP OF_THE_PC_USING_THE_SCRIPT" (if the daemon is on a different computer that you are making the call from, change to the ip of the computer making the call.)
rpcport="RPCPORT"

krewshul avatar Oct 03 '21 21:10 krewshul