me-foundation / msigner

msigner is an open source Bitcoin Ordinals Partially Signed Bitcoin Transactions (PSBT) signer library. It supports atomic swap of the inscription and provides a simple and secure way to structure Bitcoin transactions for marketplaces.
Apache License 2.0
229 stars 76 forks source link

Add support for cookie connection #5

Open somoza opened 1 year ago

somoza commented 1 year ago

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

Thanks!

TheRealFuture42 commented 1 year ago

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}`);