Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cookie connection #5

Open
somoza opened this issue Apr 3, 2023 · 1 comment
Open

Add support for cookie connection #5

somoza opened this issue Apr 3, 2023 · 1 comment

Comments

@somoza
Copy link

somoza commented Apr 3, 2023

Is there some way to add support for .cookie connection? I was not able to establish a connection.

Thanks!

@GregorWedlich
Copy link

You can use your cookie file out of the box!

Its easy, the only think what you do is to create an small script which you must load before your app starts.

Example:

set-env-vars.js:

import fs from 'fs';

const COOKIE_FILE_PATH = '/<PATH_TO_YOUR_COOKIE_FILE>/.cookie';
const content = fs.readFileSync(COOKIE_FILE_PATH, 'utf8');
const [user, pass] = content.split(':');

process.env.BITCOIN_RPC_USER = user;
process.env.BITCOIN_RPC_PASS = pass;

Load this script on the start of your application by adding import './set-env-vars.js';

Thats is it. You can test it with restart your bitcoin-node and comparing the .cookie files with the console.log output ;)

console.log(`${process.env.BITCOIN_RPC_USER} : ${process.env.BITCOIN_RPC_PASS}`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants