spesmilo / electrum-docs

Documentation for Electrum Bitcoin Wallet
https://docs.electrum.org/
MIT License
126 stars 146 forks source link

Issue in connecting with rpc #107

Closed SnpGroup closed 4 years ago

SnpGroup commented 4 years ago

I am trying to connect with electrum rpc installed from windows gui version of installer.

followed these guidelines: (here electrum is replaced with "electrum-3.3.8" executable name) electrum setconfig rpcport 7777 electrum getconfig rpcuser - it returned empty electrum getconfig rpcpassword - it returned empty

I tried sending postman request with basic_auth with username/password empty and body raw request: {"jsonrpc":"2.0","id":"curltext","method":"getbalance","params":[]}

it's returning following error:

Error code: 401 Message: Authentication failed (missing credentials). Error code explanation: 401 - No permission -- see authorization schemes.

I even tried chaning username & password with following commands electrum setconfig rpcuser dummy electrum setconfig rpcpassword dummy123$

still it did not help me, as running following commands returns electrum getconfig rpcuser - it returned empty electrum getconfig rpcpassword - it returned empty

please guide me, my development is stuck due to this.

Thanks

SomberNight commented 4 years ago

electrum getconfig rpcuser - it returned empty electrum getconfig rpcpassword - it returned empty

Note that this is due to this known bug: https://github.com/spesmilo/electrum/issues/2592. Command line return values basically do not work with the Windows binaries.

SnpGroup commented 4 years ago

But after setting rpcuser and rpcpassword and trying with that it should work....right?

I set rpcuser, rpcpassword and restarted the daemon

electrum setconfig rpcuser dummy electrum setconfig rpcpassword dummy123$

now tried to connect with new set login/password, still it returns same error

Error code: 401 Message: Authentication failed (missing credentials). Error code explanation: 401 - No permission -- see authorization schemes.

SomberNight commented 4 years ago

Yes, it should work. Are you sure the basic auth details are included in the request? What is the full URL you are testing with?

SnpGroup commented 4 years ago

I am using postman to test it first.

  1. Using authorization tab in postman to set login / password in request.
  2. Raw body to send with {"jsonrpc":"2.0","id":"curltext","method":"getbalance","params":[]}
  3. Url is set to "http://localhost:7777"

In response, I am getting above mentioned error.

You can have a look at uploaded confirguration screenshots at https://drive.google.com/open?id=1hs8GjjYWChh776NZAETZ8nfeSPAdhL28

SomberNight commented 4 years ago

I have never used postman. Can you try with an URL that contains the basic auth details in it directly, as in the docs? E.g.: http://username:password@127.0.0.1:7777

SnpGroup commented 4 years ago

I am getting same error

SnpGroup commented 4 years ago

Please help....I am stuck

SnpGroup commented 4 years ago

Previously request was not going through as "sending username:pasword in url capability was removed from Chrome 19+" and I was using chrome.

Now I tried with postman.

I am able to send request to electrum server now, but getting following error now:

{ "id": "curltext", "jsonrpc": "2.0", "error": { "code": -32603, "message": "Server error: File \"electrum\commands.py\", line 93, in func_wrapper | Exception: wallet not loaded. Use 'electrum daemon load_wallet'\n" } }

I tried running mentioned command "electrum daemon load_wallet" as well, but still getting same error.

SnpGroup commented 4 years ago

you can close this issue now.

I have used this method to load wallet and things are working now for me

curl --data-binary '{"id":"curltext","method":"daemon","params":{"config_options":{"subcommand":"load_wallet", "wallet_path":"/home/user/.electrum/testnet/wallets/default_wallet", "password":"1234"}}}' http://user:pass@127.0.0.1:7777