ruimarinho / bitcoin-core

A modern Bitcoin Core REST and RPC client.
483 stars 188 forks source link

no auth method defined #29

Closed jandrieu closed 7 years ago

jandrieu commented 7 years ago

When trying to get a balance, I get the error "no auth method defined".

I didn't set up a username/passwd with the bitcoin core. What should i be doing here?

Ollemesh commented 7 years ago

You have to set it: Open or create your bitcoin.conf file (path for linux: ~/.bitcoin/.bitcoin.conf ), and write there:

rpcuser=user
rpcpassword=pass

after that make necessary changes in the bitcoin-core module options:

const Bitcoin = require('bitcion-core')
const bitcoin = new Bitcoin({
    username: 'user',
    password: 'pass',
    /* other options */
})
pedrobranco commented 7 years ago

For increasing the security in the configuration file, instead of using rpcuser or rpcpassword use rpcauth.

Check rpcauth help here. To generate an encrypted version of the password you can use this script.

wmitsuda commented 7 years ago

bitcoin-cli works fine without setting a user/password and is the default configuration of bitcoind. I think this client should support running with no user/pass.

pedrobranco commented 7 years ago

@wmitsuda It works fine without setting a user/password because it uses the same bitcoind.conf.

Check the source here.

All three programs get settings from bitcoin.conf in the Bitcoin application directory

To use bitcoind and bitcoin-cli, you will need to add a RPC password to your bitcoin.conf file. Both programs will read from the same file if both run on the same system as the same user, so any long random password will work

wmitsuda commented 7 years ago

@pedrobranco currently I'm using a bitcoin.conf with no rpc user/pass at ~/Library/Application Support/Bitcoin/ on macos, and it is working fine.

Can you confirm if the user/pass is required in your environment?

jandrieu commented 7 years ago

FWIW, @Ollemesh's suggestion worked. Out of the box, however, the module did not. Maybe it would have on Linux, but I was on Windows.

larafale commented 6 years ago

I'm on osx, using bitcoin core 0.15.0.1, bitcoin-cli by default work out of the box without password. but for this module, having no password set in bitcoin.conf result in the no auth method defined error. which can be a pain because now I have to specify auth creds for bitcoin-cli to work.

ruimarinho commented 6 years ago

It works because it's using the cookie based authentication system which requires local file access. Figuring out the data location is not a trivial process. It works fine on bitcoin-cli because it runs the GetDataDir() function provided by Qt. On node, we would have to figure out not only the standard path but also its possible modification (via -datadir argument) by reading the bitcoin.conf file (whose location can also be changed).

In addition to all of this, it would also require setting up dedicated machines for Windows and Linux on Travis instead of just using Docker.

If you have any other suggestion, feel free to add a comment. Be sure to take a look at the Docker version instructions for easier testing.