From d8b4f38a16c16feb31bbe1b4cf30c34d2f639cf9 Mon Sep 17 00:00:00 2001 From: junderw Date: Sat, 6 Mar 2021 19:16:07 +0900 Subject: [PATCH 1/2] Send readonly macaroon along with lndconnect urls --- logic/disk.js | 4 ++++ logic/system.js | 11 ++++++++++- utils/const.js | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/logic/disk.js b/logic/disk.js index 2d17fda..891b634 100644 --- a/logic/disk.js +++ b/logic/disk.js @@ -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); } diff --git a/logic/system.js b/logic/system.js index 9ffc7f8..3810d9f 100644 --- a/logic/system.js +++ b/logic/system.js @@ -207,6 +207,13 @@ async function getLndConnectUrls() { throw new NodeError('Unable to read lnd macaroon file'); } + let macaroonReadonly; + try { + macaroonReadonly = await diskLogic.readLndReadonlyMacaroon(); + } catch (error) { + throw new NodeError('Unable to read lnd readonly.macaroon file'); + } + let restTorHost; try { restTorHost = await diskLogic.readLndRestHiddenService(); @@ -251,7 +258,9 @@ async function getLndConnectUrls() { restTor, restLocal, grpcTor, - grpcLocal + grpcLocal, + adminMacaroonHex: macaroon.toString('hex'), + readonlyMacaroonHex: macaroonReadonly.toString('hex') }; } diff --git a/utils/const.js b/utils/const.js index 0fdfe21..829fd0d 100644 --- a/utils/const.js +++ b/utils/const.js @@ -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', From 60531c48df77d29b09e6f984c201821b1997bcbd Mon Sep 17 00:00:00 2001 From: junderw Date: Sat, 6 Mar 2021 19:49:51 +0900 Subject: [PATCH 2/2] Naming conventions --- logic/system.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/logic/system.js b/logic/system.js index 3810d9f..b56181a 100644 --- a/logic/system.js +++ b/logic/system.js @@ -200,16 +200,16 @@ 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 macaroonReadonly; + let readonlyMacaroon; try { - macaroonReadonly = await diskLogic.readLndReadonlyMacaroon(); + readonlyMacaroon = await diskLogic.readLndReadonlyMacaroon(); } catch (error) { throw new NodeError('Unable to read lnd readonly.macaroon file'); } @@ -224,7 +224,7 @@ async function getLndConnectUrls() { const restTor = encode({ host: restTorHost, cert, - macaroon, + macaroon: adminMacaroon, }); let grpcTorHost; @@ -237,21 +237,21 @@ 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 { @@ -259,8 +259,8 @@ async function getLndConnectUrls() { restLocal, grpcTor, grpcLocal, - adminMacaroonHex: macaroon.toString('hex'), - readonlyMacaroonHex: macaroonReadonly.toString('hex') + adminMacaroonHex: adminMacaroon.toString('hex'), + readonlyMacaroonHex: readonlyMacaroon.toString('hex') }; }