3

I have a view-only wallet opened, and from another terminal, I try to run the getbalance example from the Wallet RPC documentation. However, I get a Connection refused error:

mac:~ user$ curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getbalance"}' -H 'Content-Type: application/json'
curl: (7) Failed connect to 127.0.0.1:18082; Connection refused

This is on macOS (Mavericks). Anyone knows why? Should I start the wallet with extra parameters?

2
  • Are you really really sure you ran the wallet in RPC mode (--bind-port 18082) ?
    – user36303
    Commented Oct 9, 2016 at 10:56
  • I tried those, i.e. adding --rpc-bind-ip 127.0.0.1 --rpc-bind-port 18082, but then I get: Error: Wallet password not set. when starting monero-wallet-cli. This is a view-only wallet with an empty password. Update: getting the same error when doing this for a regular wallet.
    – dpzz
    Commented Oct 9, 2016 at 14:57

2 Answers 2

2

If I recall, RPC is disabled by default, and needs to be explicitly enabled when running the wallet.

I tried it out and got it working by using the command:

monero-wallet-cli --restricted-rpc --rpc-bind-port 18082 --wallet-file <wallet path here> --password <wallet password here>

The program will then listen and wait for rpc commands sent to it on 127.0.0.1 . The command in your post should then work.

1
  • 1
    The above works. The thing I was missing is --password "" or --password-file <empty-password-file>. I have to say this isn't very obvious from the syntax, although the error message should have rung a bell. Also, I would have expected --rpc-bind-ip <ip> to be enough, but it is really --rpc-bind-port <port> that is necessary. No idea how to accept the default port if you need to specify the parameter anyway.
    – dpzz
    Commented Oct 9, 2016 at 15:09
0

I believe for wallet RPC calls you need to set the --user-agent field now. So, when you launch the wallet in RPC mode (you need to set --rpc-bind-port 18082, as user36303 mentioned), you need to set the --user-agent to be some string of your choice. This is in response to the vulnerability disclosed here:
https://labs.mwrinfosecurity.com/advisories/csrf-vulnerability-allows-for-remote-compromise-of-monero-wallets/

Then, when you make the RPC call you need to set the User-Agent field of the http header to whatever you set it on the command line when launching monero-wallet-cli.

It looks like from the error message that maybe you're not binding an rpc-port though, and the connection is just being refused because monero-wallet-cli isn't listening on that (or any) port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.