Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 8601b90

Browse files
Fix path to macaroon file due to lnd changes
Now, each network has its own macaroons.
1 parent d0b2b32 commit 8601b90

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

public/electron.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { startLndProcess, startBtcdProcess } = require('./lnd-child-process');
99
const grcpClient = require('./grpc-client');
1010
const {
1111
PREFIX_NAME,
12+
NETWORK,
1213
LND_PORT,
1314
LND_PEER_PORT,
1415
LND_INIT_DELAY,
@@ -122,6 +123,7 @@ function createWindow() {
122123
ipcMain,
123124
lndSettingsDir,
124125
lndPort: LND_PORT,
126+
network: NETWORK,
125127
});
126128
}
127129

public/grpc-client.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,25 @@ async function getCredentials(lndSettingsDir) {
3232
return grpc.credentials.createSsl(lndCert);
3333
}
3434

35-
function getMacaroonCreds(lndSettingsDir) {
35+
function getMacaroonCreds(lndSettingsDir, network) {
3636
return grpc.credentials.createFromMetadataGenerator(function(args, callback) {
3737
const metadata = new grpc.Metadata();
38-
const macaroonPath = path.join(lndSettingsDir, 'admin.macaroon');
38+
const macaroonPath = path.join(
39+
lndSettingsDir,
40+
`data/chain/bitcoin/${network}/admin.macaroon`
41+
);
3942
const macaroonHex = fs.readFileSync(macaroonPath).toString('hex');
4043
metadata.add('macaroon', macaroonHex);
4144
callback(null, metadata);
4245
});
4346
}
4447

45-
module.exports.init = async function({ ipcMain, lndPort, lndSettingsDir }) {
48+
module.exports.init = async function({
49+
ipcMain,
50+
lndPort,
51+
lndSettingsDir,
52+
network,
53+
}) {
4654
let credentials;
4755
let protoPath;
4856
let lnrpc;
@@ -65,7 +73,7 @@ module.exports.init = async function({ ipcMain, lndPort, lndSettingsDir }) {
6573
});
6674

6775
ipcMain.on('lndInit', event => {
68-
const macaroonCreds = getMacaroonCreds(lndSettingsDir);
76+
const macaroonCreds = getMacaroonCreds(lndSettingsDir, network);
6977
credentials = grpc.credentials.combineChannelCredentials(
7078
credentials,
7179
macaroonCreds

src/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports.RATE_DELAY = 15 * 60 * 1000;
99

1010
module.exports.LND_PORT = 10009;
1111
module.exports.LND_PEER_PORT = 10019;
12+
module.exports.NETWORK = 'testnet';
1213
module.exports.BTCD_MINING_ADDRESS = 'rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5';
1314

1415
const prefixName = 'lightning';

test/integration/action/action-integration.spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const grcpClient = require('../../../public/grpc-client');
2525
/* eslint-disable no-unused-vars */
2626

2727
const isDev = true;
28+
const NETWORK = 'simnet';
2829
const BTCD_PORT = 18555;
2930
const BTCD_SETTINGS_DIR = 'test/data/btcd';
3031
const LND_SETTINGS_DIR_1 = 'test/data/lnd_1';
@@ -132,11 +133,13 @@ describe('Action Integration Tests', function() {
132133
ipcMain: ipcMainStub1,
133134
lndPort: LND_PORT_1,
134135
lndSettingsDir: LND_SETTINGS_DIR_1,
136+
network: NETWORK,
135137
});
136138
await grcpClient.init({
137139
ipcMain: ipcMainStub2,
138140
lndPort: LND_PORT_2,
139141
lndSettingsDir: LND_SETTINGS_DIR_2,
142+
network: NETWORK,
140143
});
141144

142145
db1 = sinon.createStubInstance(AppStorage);

0 commit comments

Comments
 (0)