jgarzik / python-bitcoinrpc

Python interface to bitcoin's JSON-RPC API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

authentication in example outdated?

opened this issue · comments

Authentication in the example did not work for me:
# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%(rpc_user, rpc_password))

Instead I followed this source:
https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md#json-rpc-interface

Secure authentication: By default, Bitcoin Core generates unique login credentials each time it restarts and puts them into a file readable only by the user that started Bitcoin Core, allowing any of that user's RPC clients with read access to the file to login automatically. The file is .cookie in the Bitcoin Core configuration directory, and using these credentials is the preferred RPC authentication method. If you need to generate static login credentials for your programs, you can use the script in the share/rpcauth directory in the Bitcoin Core source tree. As a final fallback, you can directly use manually-chosen rpcuser and rpcpassword configuration parameters---but you must ensure that you choose a strong and unique passphrase (and still don't use insecure networks, as mentioned above).

The cookie-method worked for me. With the this mehtod, the example would look like this::
#The file .cookie in the Bitcoin Core configuration directory specifies your login credentials each time bitcoin core is started
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%("__cookie__", "yourpassword")

I'm facing the same issue but don't need cookie-based authentication for local experiments on regtest... But I also don't see any .cookie file in ~/.bitcoin (if that's what is meant by configuration directory).

Is there a way to force authentication based on static credentials?