Skip to content

Commit

Permalink
fix-auth-cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
st3b1t committed Jul 12, 2023
1 parent 3fa7ef5 commit b8cdaae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ $ npm install satop -g
$ satop --rpccookiefile=/home/user/.bitcoin/.cookie
```

Or using username and password:
Or using username and password, if `rpccookiefile` has valid value(file exists and readble) auth method
bypass any values of `rpcuser/rpcpassword` and satop use the cookie file.
```sh
$ satop --rpcuser=<username> --rpcpassword=<password>
```
Expand Down
8 changes: 4 additions & 4 deletions lib/bitcoin/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const loadAuth = async opts => {

let authType = 'usernamePassword';

if (fs.existsSync(rpccookiefile) && (!rpcuser || !rpcpassword) ) {
if (fs.existsSync(rpccookiefile)) {
authType = 'cookie';
}

Expand All @@ -37,7 +37,7 @@ const loadAuth = async opts => {
connect();
});*/

if (!rpcpassword) {
if (!rpcuser || !rpcpassword) {
throw new Error(`Cookie file ${rpccookiefile} in unexpected format`);
}
}
Expand All @@ -46,8 +46,8 @@ const loadAuth = async opts => {
host: rpcconnect,
port: Number(rpcport),
//authType,
username: rpcuser,
password: rpcpassword,
username: `${rpcuser}`.trim(),
password: `${rpcpassword}`.trim(),
timeout: 1000 //TODO Number(rpctimeout),
};
};
Expand Down

0 comments on commit b8cdaae

Please sign in to comment.