Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Send readonly macaroon along with lndconnect urls #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions logic/disk.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ function readLndAdminMacaroon() {
return diskService.readFile(constants.LND_ADMIN_MACAROON_FILE);
}

function readLndReadonlyMacaroon() {
return diskService.readFile(constants.LND_READONLY_MACAROON_FILE);
}

function readUmbrelVersionFile() {
return diskService.readJsonFile(constants.UMBREL_VERSION_FILE);
}
Expand Down
25 changes: 17 additions & 8 deletions logic/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,18 @@ async function getLndConnectUrls() {
throw new NodeError('Unable to read lnd cert file');
}

let macaroon;
let adminMacaroon;
try {
macaroon = await diskLogic.readLndAdminMacaroon();
adminMacaroon = await diskLogic.readLndAdminMacaroon();
} catch (error) {
throw new NodeError('Unable to read lnd macaroon file');
throw new NodeError('Unable to read lnd admin.macaroon file');
}

let readonlyMacaroon;
try {
readonlyMacaroon = await diskLogic.readLndReadonlyMacaroon();
} catch (error) {
throw new NodeError('Unable to read lnd readonly.macaroon file');
}

let restTorHost;
Expand All @@ -217,7 +224,7 @@ async function getLndConnectUrls() {
const restTor = encode({
host: restTorHost,
cert,
macaroon,
macaroon: adminMacaroon,
});

let grpcTorHost;
Expand All @@ -230,28 +237,30 @@ async function getLndConnectUrls() {
const grpcTor = encode({
host: grpcTorHost,
cert,
macaroon,
macaroon: adminMacaroon,
});

let restLocalHost = `${constants.DEVICE_HOSTNAME}:8080`;
const restLocal = encode({
host: restLocalHost,
cert,
macaroon,
macaroon: adminMacaroon,
});

let grpcLocalHost = `${constants.DEVICE_HOSTNAME}:10009`;
const grpcLocal = encode({
host: grpcLocalHost,
cert,
macaroon,
macaroon: adminMacaroon,
});

return {
restTor,
restLocal,
grpcTor,
grpcLocal
grpcLocal,
adminMacaroonHex: adminMacaroon.toString('hex'),
readonlyMacaroonHex: readonlyMacaroon.toString('hex')
};

}
Expand Down
1 change: 1 addition & 0 deletions utils/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
LND_GRPC_HIDDEN_SERVICE_FILE: process.env.LND_GRPC_HIDDEN_SERVICE_FILE || '/var/lib/tor/lnd-grpc/hostname',
LND_CERT_FILE: process.env.LND_CERT_FILE || '/lnd/tls.cert',
LND_ADMIN_MACAROON_FILE: process.env.LND_ADMIN_MACAROON_FILE || '/lnd/data/chain/bitcoin/mainnet/admin.macaroon',
LND_READONLY_MACAROON_FILE: process.env.LND_READONLY_MACAROON_FILE || '/lnd/data/chain/bitcoin/mainnet/readonly.macaroon',
GITHUB_REPO: process.env.GITHUB_REPO || 'getumbrel/umbrel',
UMBREL_VERSION_FILE: process.env.UMBREL_VERSION_FILE || '/info.json',
UPDATE_STATUS_FILE: process.env.UPDATE_STATUS_FILE || '/statuses/update-status.json',
Expand Down