Marselo Bonagi
Marselo Bonagi

Reputation: 173

bitcoinrpc calls return nothing

I am using bitcoind in my project and when I deploy it on my server bitcoind works strange. I use this lib to work with rpc https://github.com/jgarzik/python-bitcoinrpc. On local dev server everything is fine but when I deploy it to vps it stops return data. The data is empty. I made some tests like this:

bitcoin.conf file:
server=1
rpcuser=myuser
rpcpassword=mypassword
rpcconnect=127.0.0.1
rpcport=8332

some view.py:

def btc_rpc_connect(config):

    rpc_server_url = ("http://{user}:{password}@{host}:{port}").format(
        user=config.rpc_user,
        password=config.rpc_pass,
        host=config.rpc_host,
        port=config.rpc_port
    )
    rpc_conn = AuthServiceProxy(rpc_server_url)
    return rpc_conn

user = request.user
# getting rpc settings from db
config = ProjectSettings.objects.get(id=1)
rpc_connection = btc_rpc_connect(config)
btc_address = rpc_connection.getnewaddress(user.username)

I also tried to test from django's ./manage.py shell and entered this code manually. The fact is works on dev server and i have an address in btc_address, but on vps btc_address is empty! Please help me. Can it happen because of permission troubles? Anyways bitcoind accept the connection and do not return authentification exception, but no reaction to any command.

But if I use it from console:

bitcoin-cli getnewaddress 

it works fine and give me an address.

Upvotes: 2

Views: 469

Answers (1)

Marselo Bonagi
Marselo Bonagi

Reputation: 173

Omg that was bug in the repo, and I fixed it locally several month ago and forgot about that! If you have the same problem you can mannually edit lib/python2.7/site-packages/bitcoinrpc/authproxy.py delete else: on 146 line and move out return response['result'] from elif block like in here: https://github.com/jgarzik/python-bitcoinrpc/commit/8c0114bfbf7650d40a88b20d1e16ff79d768f3a9

Another way is delete python-bitcoinrpc:

pip uninstall python-bitcoinrpc

And reinstall correct version:

pip install git+https://github.com/jgarzik/python-bitcoinrpc.git

Hope they will fix it in repo soon.

Upvotes: 1

Related Questions