Authentication and Bug fixes

pull/47/head
ShahanaFarooqui 5 years ago
parent 3452a8f4ff
commit f4e3a8dd67

1
.gitignore vendored

@ -57,3 +57,4 @@ typings/
# dotenv environment variables file
.env
RTL.conf

@ -53,45 +53,60 @@ Reset Git (for the changes you may have made to the config file).
Warning: This step will revert the UI settings, you may have changed on RTL (We will address this in future revisions).
```
$ git reset --hard HEAD
`$ git reset --hard HEAD`
$ git clean -f -d
`$ git clean -f -d`
$ git pull
`$ git pull`
$ npm install
```
`$ npm install`
### Execution
### Prep for Execution
Make sure you are in the RTL directory, where the application was built.
Locate the complete path of the readable macroon file (admin.macroon) on your node.
RTL requires a config file `RTL.conf` to start the server and provide user authentication for the app.
Locate the complete path of the readable macroon file (admin.macroon) on your node and lnd.conf file
If you followed Stacidus's guide referenced above, and you are on lnd version 0.4.2 or below it should be `/home/admin/.lnd`.
For lnd versions 0.5 and above, it should be `/home/admin/.lnd/data/chain/bitcoin/testnet`.
Other platform users should accordingly locate the directory of the readable macroon file.
The path of the macroon directory needs to be provided as a command line argument to start the server.
### Start the Webserver
Run the following command:
Other platform users should accordingly locate the directory of the readable macroon and lnd.conf files.
`node rtl --lndir <macaroon-path>`
The path of the macroon directory and lnd.conf needs to be provided in the RTL.conf file to start the server.
For example:
Sample RTL.conf:
```
[Authentication]
lndServerUrl=https://localhost:8080/v1
macroonPath=C:\Users\suheb\AppData\Local\Lnd\data\chain\bitcoin\testnet
nodeAuthType=DEFAULT
lndConfigPath=C:\Users\Suheb\AppData\Local\Lnd\lnd.conf
[Settings]
flgSidenavOpened=true
flgSidenavPinned=true
menu=Vertical
menuType=Regular
theme=dark-blue
satsToBTC=false
```
`$ node rtl --lndir /home/admin/.lnd`
#### User Authentication on RTL
Basic user authentication has now been added on RTL. This requires user to login to RTL server first, before accessing LND functions.
There are two options to configure authentication on RTL, depending on the `nodeAuthtype` value provided in RTL.conf.
or
For `nodeAuthType=DEFAULT`
Password provided in lnd.conf for the rpc setting for bitcoind will be used for authentication.
`$ node rtl --lndir /home/admin/.lnd/data/chain/bitcoin/testnet`
For `nodeAuthType=CUSTOM`
Specific password can be provided in RTL.conf, to be used by RTL for authentication.
Password should be set with `rtlPass=<user defined>` in the [Authentication] section of RTL.conf
or (for windows)
### Start the Webserver
Run the following command:
`$ node rtl --lndir C:\Users\<your user directory>\AppData\Local\Lnd\data\chain\bitcoin\testnet`
`node rtl`
If the server started successfully, you should get the below output on the console:
@ -111,7 +126,7 @@ Wants=lnd.service
After=lnd.service
[Service]
ExecStart=/usr/bin/node /home/admin/Projects/RTL/rtl --lndir /home/admin/.lnd/data/chain/bitcoin/testnet/
ExecStart=/usr/bin/node /home/admin/Projects/RTL/rtl
User=<user>
Restart=always
TimeoutSec=120

@ -23,9 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@angular/router
MIT
hammerjs
MIT
The MIT License (MIT)
@ -51,6 +48,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@angular/core
MIT
tslib
Apache-2.0
Apache License
@ -316,9 +316,21 @@ Apache-2.0
@angular/router
MIT
@angular/common
MIT
@angular/platform-browser
MIT
@ngrx/store
MIT
@ngrx/effects
MIT
@angular/material/dialog
@angular/material
@ -374,17 +386,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@angular/common
MIT
@angular/platform-browser
MIT
@angular/material/tooltip
@angular/flex-layout
MIT
<<<<<<< HEAD
The MIT License
Copyright (c) 2018 Google LLC.
@ -406,210 +411,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
=======
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
>>>>>>> Initial commit
@angular/material/icon
@ -637,9 +438,6 @@ MIT
@angular/material/table
@ngrx/effects
MIT
@angular/material/select
angular2-qrcode
@ -1609,12 +1407,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@angular/core
MIT
@angular/compiler
MIT
core-js
MIT
Copyright (c) 2014-2018 Denis Pushkarev

@ -6,8 +6,8 @@
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
<link rel="stylesheet" href="styles.2a5891112b56c0c8c573.css"></head>
<link rel="stylesheet" href="styles.ee9276924333890ee9f9.css"></head>
<body>
<rtl-app></rtl-app>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.b2575713cefb95077d85.js"></script><script type="text/javascript" src="main.4b62eaf3dae6e94d4dbf.js"></script></body>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.418928a701f2040ada02.js"></script><script type="text/javascript" src="main.0dcfb55f2edbb6c714fc.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -4,6 +4,7 @@ const bodyParser = require("body-parser");
const app = express();
//Declare all Routes here
const authenticateRoutes = require("./routes/authenticate");
const infoRoutes = require("./routes/getInfo");
const channelsRoutes = require("./routes/channels");
const peersRoutes = require("./routes/peers");
@ -15,8 +16,7 @@ const newAddressRoutes = require("./routes/newAddress");
const transactionsRoutes = require("./routes/transactions");
const payReqRoutes = require("./routes/payReq");
const paymentsRoutes = require("./routes/payments");
const UISettingsRoutes = require("./routes/UISettings");
const LNDSettingsRoutes = require("./routes/lndConfSettings");
const RTLConfRoutes = require("./routes/RTLConf");
const invoiceRoutes = require("./routes/invoices");
app.use(bodyParser.json());
@ -39,6 +39,7 @@ app.use((req, res, next) => {
// CORS fix, Only required for developement due to separate backend and frontend servers
// Use declared routes here
app.use("/api/authenticate", authenticateRoutes);
app.use("/api/getinfo", infoRoutes);
app.use("/api/channels", channelsRoutes);
app.use("/api/peers", peersRoutes);
@ -50,8 +51,7 @@ app.use("/api/newaddress", newAddressRoutes);
app.use("/api/transactions", transactionsRoutes);
app.use("/api/payreq", payReqRoutes);
app.use("/api/payments", paymentsRoutes);
app.use("/api/uisettings", UISettingsRoutes);
app.use("/api/lndconf", LNDSettingsRoutes);
app.use("/api/rtlconf", RTLConfRoutes);
app.use("/api/invoices", invoiceRoutes);
// sending angular application when route doesn't match

@ -1,7 +1,6 @@
var common = {};
common.lnd_server_url = 'https://localhost:8080/v1';
common.lnd_dir = '';
common.lnd_server_url = '';
common.convertToBTC = (num) => {
return (num / 100000000).toFixed(6);
@ -9,10 +8,6 @@ common.convertToBTC = (num) => {
common.convertTimestampToDate = (num) => {
return new Date(+num*1000).toUTCString();
// datetoConvert = new Date(+num*1000);
// // (datetoConvert.getMonth() + 1) // Because in JS, months is an array and index starts with 0 (January gives 0)
// return (datetoConvert.getMonth() + 1) + '/' + datetoConvert.getDate() + '/' + datetoConvert.getFullYear() + ' ' +
// datetoConvert.getHours() + ':' + datetoConvert.getMinutes() + ':' + datetoConvert.getSeconds();
};
module.exports = common;

@ -1,25 +1,101 @@
var fs = require('fs');
var common = require('./common');
var clArgs = require('optimist').argv;
var ini = require('ini');
var file_path = './RTL.conf';
var common = require('./common');
var upperCase = require('upper-case');
var macaroonPath = '';
var options = {};
var defaultConfig = {
authentication: {
lndServerUrl:'https://localhost:8080/v1',
macroonPath:'',
nodeAuthType:'DEFAULT',
lndConfigPath:'',
rtlPass:''
},
settings: {
flgSidenavOpened:true,
flgSidenavPinned:true,
menu:'Vertical',
menuType:'Regular',
theme:'dark-blue',
satsToBTC:false
}
};
if(undefined !== clArgs.lndir) {
common.lnd_dir = clArgs.lndir;
} else {
if(common.lnd_dir === '') {
common.lnd_dir = __dirname;
var setMacaroonPath = (clArgs, config) => {
if(undefined !== clArgs.lndir) {
macaroonPath = clArgs.lndir;
} else {
if(config.Authentication.macroonPath !== '') {
macaroonPath = config.Authentication.macroonPath;
}
}
}
var macaroon = fs.readFileSync(common.lnd_dir + '/admin.macaroon').toString('hex');
var options = {
url: '',
rejectUnauthorized: false,
// resolveWithFullResponse: true,
json: true,
headers: {
'Grpc-Metadata-macaroon': macaroon,
},
form: ''
};
var validateConfigFile = (macaroonPath, config) => {
if(macaroonPath === '' || undefined === macaroonPath) {
errMsg = 'Please set macaroon path in RTL.conf';
}
if(config.Authentication.lndServerUrl === '' || undefined === config.Authentication.lndServerUrl) {
errMsg = errMsg + '\nPlease set LND Server URL in RTL.conf';
} else {
common.lnd_server_url = config.Authentication.lndServerUrl;
}
if(config.Authentication.nodeAuthType === '' || undefined === config.Authentication.nodeAuthType) {
errMsg = errMsg + '\nPlease set Node Auth Type in RTL.conf';
}
if(upperCase(config.Authentication.nodeAuthType) === 'DEFAULT' && (config.Authentication.lndConfigPath === '' || undefined === config.Authentication.lndConfigPath)) {
errMsg = errMsg + '\nDefault Node Authentication can be set with LND Config Path only. Please set LND Config Path in RTL.conf';
}
if(upperCase(config.Authentication.nodeAuthType) === 'CUSTOM' && (config.Authentication.rtlPass === '' || undefined === config.Authentication.rtlPass)) {
errMsg = errMsg + '\nCustom Node Authentication can be set with RTL password only. Please set RTL Password in RTL.conf';
}
if(errMsg !== '') {
throw new Error(errMsg);
}
}
var setOptions = (macaroonPath) => {
var macaroon = fs.readFileSync(macaroonPath + '/admin.macaroon').toString('hex');
options = {
url: '',
rejectUnauthorized: false,
json: true,
headers: {
'Grpc-Metadata-macaroon': macaroon,
},
form: ''
};
}
module.exports = options;
var errMsg = '';
var configFileExists = () => {
let exists = fs.existsSync(file_path);
if (exists) {
var config = ini.parse(fs.readFileSync(file_path, 'utf-8'));
setMacaroonPath(clArgs, config)
validateConfigFile(macaroonPath, config);
setOptions(macaroonPath);
} else {
try {
fs.writeFileSync(file_path, ini.stringify(defaultConfig));
var config = ini.parse(fs.readFileSync(file_path, 'utf-8'));
setMacaroonPath(clArgs, config)
validateConfigFile(macaroonPath, config);
setOptions(macaroonPath);
}
catch(err) {
console.error('Something went wrong, unable to create config file!' + err);
}
}
}
configFileExists();
module.exports = options;

@ -0,0 +1,59 @@
var ini = require('ini');
var path = require('path');
var fs = require('fs');
var file_path = path.normalize(__dirname + '/..') + '/RTL.conf';
exports.getUISettings = (req, res, next) => {
console.log('Getting UI Settings!');
fs.readFile(file_path, 'utf8', function(err, data) {
if (err) {
console.log('Reading UI Settings Failed!');
res.status(500).json({
message: "Reading UI Settings Failed!",
error: err
});
} else {
const jsonConfig = ini.parse(data);
console.log('UI settings read successfully');
res.status(200).json({settings: jsonConfig.Settings});
}
});
};
exports.updateUISettings = (req, res, next) => {
var config = ini.parse(fs.readFileSync(file_path, 'utf-8'));
delete config.Settings;
fs.writeFileSync(file_path, ini.stringify(config));
fs.appendFile(file_path, ini.stringify(req.body.updatedSettings, { section: 'Settings' }), function(err) {
if (err) {
console.log('Updating UI Settings Failed!');
res.status(500).json({
message: "Updating UI Settings Failed!",
error: 'Updating UI Settings Failed!'
});
} else {
console.log('UI Settings Updated Successfully');
res.status(201).json({message: 'UI Settings Updated Successfully'});
}
});
};
exports.getLNDConfig = (req, res, next) => {
console.log('Getting LND Conf Settings!');
fs.readFile(req.headers.filepath, 'utf8', function(err, data) {
if (err) {
console.log('Reading Config File Failed!');
res.status(500).json({
message: "Reading Config File Failed!",
error: err
});
} else {
const jsonConfig = ini.parse(data);
console.log('LND Conf read successfully');
if (undefined !== jsonConfig.Bitcoind && undefined !== jsonConfig.Bitcoind['bitcoind.rpcpass']) {
jsonConfig.Bitcoind['bitcoind.rpcpass'] = jsonConfig.Bitcoind['bitcoind.rpcpass'].replace(/./g, '*');
}
res.status(200).json(ini.stringify(jsonConfig));
}
});
};

@ -0,0 +1,81 @@
var ini = require('ini');
var path = require('path');
var fs = require('fs');
var rtl_config_path = path.normalize(__dirname + '/..') + '/RTL.conf';
const jwt = require("jsonwebtoken");
var upperCase = require('upper-case');
var atob = require('atob');
exports.authenticateUser = (req, res, next) => {
password = atob(req.body.password);
fs.readFile(rtl_config_path, 'utf8', function (err, data) {
if (err) {
console.log('RTL Config Reading Failed!');
res.status(500).json({
message: "RTL Config Reading Failed!",
error: err
});
} else {
var jsonRTLConfig = ini.parse(data);
const nodeAuthType = jsonRTLConfig.Authentication.nodeAuthType;
const macaroonPath = jsonRTLConfig.Authentication.macroonPath;
const lndConfigPath = (undefined !== jsonRTLConfig.Authentication.lndConfigPath) ? jsonRTLConfig.Authentication.lndConfigPath : '';
if(upperCase(nodeAuthType) === 'CUSTOM') {
const rtlPass = jsonRTLConfig.Authentication.rtlPass;
if (rtlPass === password) {
var rpcUser = 'Custom_User';
const token = jwt.sign(
{ user: rpcUser, lndConfigPath: lndConfigPath, macaroonPath: macaroonPath },
'RTL_default_secret_it_can_be_changed_by_user',
{ expiresIn: "1h" }
);
res.status(200).json({
token: token,
expiresIn: 3600
});
} else {
res.status(401).json({
message: "Authentication Failed!",
error: "Password Validation Failed!"
});
}
} else {
fs.readFile(lndConfigPath, 'utf8', function (err, data) {
if (err) {
console.log('LND Config Reading Failed!');
res.status(500).json({
message: "LND Config Reading Failed!",
error: err
});
} else {
const jsonLNDConfig = ini.parse(data);
if (undefined !== jsonLNDConfig.Bitcoind && undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcpass']) {
if (jsonLNDConfig.Bitcoind['bitcoind.rpcpass'] === password) {
var rpcUser = (undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcuser']) ? jsonLNDConfig.Bitcoind['bitcoind.rpcuser'] : '';
const token = jwt.sign(
{ user: rpcUser, lndConfigPath: lndConfigPath, macaroonPath: macaroonPath },
'RTL_default_secret_it_can_be_changed_by_user',
{ expiresIn: "1h" }
);
res.status(200).json({
token: token,
expiresIn: 3600
});
} else {
res.status(401).json({
message: "Authentication Failed!",
error: "Password Validation Failed!"
});
}
} else {
res.status(401).json({
message: "Authentication Failed!",
error: "Password Not Found In LND Config!"
});
}
}
});
}
}
})
};

@ -1,28 +1,24 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.getBalance = (req, res, next) => {
// setTimeout(()=>{res.status(201).json({"balance":{"total_balance":"15305209","confirmed_balance":"15305209"}});}, 5000);
// setTimeout(()=>{res.status(201).json({"balance":{"balance":"5983797"}});}, 5000);
options.url = common.lnd_server_url + '/balance/' + req.params.source;
options.qs = req.query;
request.get(options, (error, response, body) => {
request(options).then((body) => {
console.log('Request params: ' + JSON.stringify(req.params) + '\nRequest Query: ' + JSON.stringify(req.query) + ' \nBalance Received: ' + JSON.stringify(body));
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Balance Information Received: ' + body_str);
if(undefined === body || search_idx > -1 || body.error) {
res.status(500).json({
message: "Fetching balance failed!",
error: (undefined === body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
if(undefined !== body) {
body.btc_balance = (undefined === body.balance) ? 0 : common.convertToBTC(body.balance);
body.btc_total_balance = (undefined === body.total_balance) ? 0 : common.convertToBTC(body.total_balance);
body.btc_confirmed_balance = (undefined === body.confirmed_balance) ? 0 : common.convertToBTC(body.confirmed_balance);
body.btc_unconfirmed_balance = (undefined === body.unconfirmed_balance) ? 0 : common.convertToBTC(body.unconfirmed_balance);
res.status(200).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching balance failed!",
error: err.error
});
});
};

@ -12,8 +12,7 @@ getAliasForChannel = (channel, channelType) => {
options.url = common.lnd_server_url + '/graph/node/' + channel.channel.remote_node_pub;
}
console.log('URL: ' + options.url);
request(options)
.then(function(aliasBody) {
request(options).then(function(aliasBody) {
console.log('Alias: ' + JSON.stringify(aliasBody.node.alias));
if (undefined === channelType || channelType === 'all') {
channel.remote_alias = aliasBody.node.alias;
@ -60,6 +59,12 @@ exports.getChannels = (req, res, next) => {
console.log(`\nPending Channels Fetched: ${JSON.stringify(body)}`);
res.status(200).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching channels failed!",
error: err.error
});
});
};
@ -70,7 +75,7 @@ exports.postChannel = (req, res, next) => {
node_pubkey_string: req.body.node_pubkey,
local_funding_amount: req.body.local_funding_amount
});
request.post(options, (error, response, body) => {
request.post(options).then((body) => {
console.log('Channel Open Response: ');
console.log(body);
if(undefined === body || body.error) {
@ -81,6 +86,12 @@ exports.postChannel = (req, res, next) => {
} else {
res.status(201).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Open Channel failed!",
error: err.error
});
});
};
@ -90,7 +101,7 @@ exports.postTransactions = (req, res, next) => {
payment_request: req.body.paymentReq
});
console.log('Send Payment Options Form:' + options.form);
request.post(options, (error, response, body) => {
request.post(options).then((body) => {
console.log('Send Payment Response: ');
console.log(body);
if(undefined === body || body.error) {
@ -101,6 +112,12 @@ exports.postTransactions = (req, res, next) => {
} else {
res.status(201).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Send Payment Failed!",
error: err.error
});
});
};
@ -109,7 +126,7 @@ exports.closeChannel = (req, res, next) => {
options.url = common.lnd_server_url + '/channels/' + channelpoint + '?force=' + req.query.force;
console.log('\nClosing Channel URL: ');
console.log(options.url);
request.delete(options, (error, response, body) => {
request.delete(options).then((body) => {
console.log('\nClose Channel Response: ');
console.log(body);
if(undefined === body || body.error) {
@ -120,5 +137,11 @@ exports.closeChannel = (req, res, next) => {
} else {
res.status(204).json({message: 'Channel Closed!'});
}
})
.catch(function (err) {
return res.status(500).json({
message: "Close Channel failed!",
error: err.error
});
});
}

@ -1,11 +1,10 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.getFees = (req, res, next) => {
// setTimeout(()=>{res.status(201).json({"fees":{"channel_fees":[{"chan_point":"a75eabb7386e977210a9796032f5bc3c793b474630ca373669f3c09d0fa095a5:0","base_fee_msat":"1000","fee_per_mil":"1","fee_rate":0.000001},{"chan_point":"acda63cdb77c5feffa41342e376968865bc1578f9e13a04d6b5d02af60f21425:0","base_fee_msat":"1000","fee_per_mil":"1","fee_rate":0.000001},{"chan_point":"3d387f17ee1937faf93b9355d9b351dd9227a424b3c3f0ae4120b275957fef1c:0","base_fee_msat":"1000","fee_per_mil":"1","fee_rate":0.000001},{"chan_point":"d437c5c67aabcb9e8ca36ffd3458068edb20bd15bba7cae60a99cdfa5ac71d3c:0","base_fee_msat":"1000","fee_per_mil":"1","fee_rate":0.000001},{"chan_point":"e799a7e18f99398c9849391947bbbce46b14b651181dac57bfcbb7705796ce52:0","base_fee_msat":"1000","fee_per_mil":"1","fee_rate":0.000001},{"chan_point":"aefc7a8269998ad5617a2e4fb5fa40c7f6716ca5e09b065f50b80473624a0b8b:0","base_fee_msat":"1000","fee_per_mil":"1","fee_rate":0.000001}],"day_fee_sum":0,"week_fee_sum":0,"month_fee_sum":0}});}, 5000);
options.url = common.lnd_server_url + '/fees';
request.get(options, (error, response, body) => {
request(options).then((body) => {
console.log("Fee Received: " + JSON.stringify(body));
if(undefined === body || body.error) {
res.status(500).json({
@ -33,5 +32,11 @@ exports.getFees = (req, res, next) => {
}
res.status(200).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching fee failed!",
error: err.error
});
});
};

@ -1,10 +1,12 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.getInfo = (req, res, next) => {
options.url = common.lnd_server_url + '/getinfo';
request.get(options, (error, response, body) => {
request(options).then((body) => {
console.log('body');
console.log(body);
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Information Received: ' + body_str);
@ -16,5 +18,11 @@ exports.getInfo = (req, res, next) => {
} else {
res.status(200).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching Info failed!",
error: err.error
});
});
};

@ -4,7 +4,7 @@ var common = require('../common');
exports.getDescribeGraph = (req, res, next) => {
options.url = common.lnd_server_url + '/graph';
request.get(options, (error, response, body) => {
request.get(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Describe Graph Received: ' + body_str);
@ -16,12 +16,18 @@ exports.getDescribeGraph = (req, res, next) => {
} else {
res.status(200).json(body);
}
})
.catch((err) => {
return res.status(500).json({
message: "Fetching Describe Graph Failed!",
error: err.error
});
});
};
exports.getGraphInfo = (req, res, next) => {
options.url = common.lnd_server_url + '/graph/info';
request.get(options, (error, response, body) => {
request.get(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Network Information Received: ' + body_str);
@ -38,6 +44,12 @@ exports.getGraphInfo = (req, res, next) => {
console.log('Network Information After Rounding and Conversion: ' + body_str);
res.status(200).json(body);
}
})
.catch((err) => {
return res.status(500).json({
message: "Fetching network Info failed!",
error: err.error
});
});
};
@ -54,10 +66,9 @@ exports.getGraphNode = (req, res, next) => {
res.status(200).json(body);
})
.catch((err) => {
console.error(`Fetching node Info failed! ${err}`);
res.status(500).json({
return res.status(500).json({
message: "Fetching node Info failed!",
error: (undefined !== err.error) ? err.error : 'Error From Server!'
error: err.error
});
});
};

@ -1,10 +1,10 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.listInvoices = (req, res, next) => {
options.url = common.lnd_server_url + '/invoices';
request.get(options, (error, response, body) => {
request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Information Received: ' + body_str);
@ -25,6 +25,12 @@ exports.listInvoices = (req, res, next) => {
console.log('\nInvoices Received: ' + JSON.stringify(body));
res.status(200).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching Invoice Info failed!",
error: err.error
});
});
};
@ -35,7 +41,7 @@ exports.addInvoice = (req, res, next) => {
value: req.body.amount
});
console.log('Add Invoice Options Form:' + options.form);
request.post(options, (error, response, body) => {
request.post(options).then((body) => {
console.log('Add Invoice Response: ');
console.log(body);
if(undefined === body || body.error) {
@ -46,5 +52,11 @@ exports.addInvoice = (req, res, next) => {
} else {
res.status(201).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Add Invoice Failed!",
error: err.error
});
});
};

@ -1,4 +1,4 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
@ -6,7 +6,7 @@ exports.getNewAddress = (req, res, next) => {
options.url = common.lnd_server_url + '/newaddress?type=' + req.query.type;
console.log('Request Query Params: ' + JSON.stringify(req.query));
console.log('Options URL: ' + JSON.stringify(options.url));
request.get(options, (error, response, body) => {
request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log("New Address Received: " + body_str);
@ -18,5 +18,11 @@ exports.getNewAddress = (req, res, next) => {
} else {
res.status(200).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching new address failed!",
error: err.error
});
});
};

@ -1,11 +1,11 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.decodePayment = (req, res, next) => {
options.url = common.lnd_server_url + '/payreq/' + req.params.payRequest;
console.log('Options URL: ' + JSON.stringify(options.url));
request.get(options, (error, response, body) => {
request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log("Payment Request Decoded Received: " + body_str);
@ -19,5 +19,11 @@ exports.decodePayment = (req, res, next) => {
body.timestamp_str = (undefined === body.timestamp) ? '' : common.convertTimestampToDate(body.timestamp);
res.status(200).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Payment Request Decode Failed!",
error: err.error
});
});
};

@ -1,11 +1,10 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.getPayments = (req, res, next) => {
options.url = common.lnd_server_url + '/payments';
console.log('Options URL: ' + JSON.stringify(options.url));
request.get(options, (error, response, body) => {
request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log("Payment Request Decoded Received: " + body_str);
@ -22,5 +21,11 @@ exports.getPayments = (req, res, next) => {
}
res.status(200).json(body.payments);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Payments List Failed!",
error: err.error
});
});
};

@ -29,11 +29,16 @@ exports.getPeers = (req, res, next) =>
console.log(`\nPeers Fetched with Alias: ${JSON.stringify(body)}`);
res.status(200).json(body.peers);
});
})
.catch((err) => {
return res.status(500).json({
message: "Peers Fetched Failed!",
error: err.error
});
});
};
exports.postPeer = (req, res, next) => {
// setTimeout(()=>{res.status(201).json({message: 'Peer Added!'});}, 5000);
options.url = common.lnd_server_url + '/peers';
options.form = JSON.stringify({
addr: { host: req.body.host, pubkey: req.body.pubkey },
@ -57,8 +62,15 @@ exports.postPeer = (req, res, next) => {
return getAliasForPeers(peer);
}))
.then(function(values) {
console.log(`\nPeer Added Succesfully!`);
console.log(`\nPeers Fetched with Alias: ${JSON.stringify(body)}`);
res.status(201).json(body.peers);
})
.catch((err) => {
return res.status(500).json({
message: "Peer Add Failed!",
error: err.error
});
});
})
}
@ -69,7 +81,7 @@ exports.deletePeer = (req, res, next) => {
options.url = common.lnd_server_url + '/peers/' + req.params.peerPubKey;
console.log('Detach Peer Options: ');
console.log(options.url);
request.delete(options, (error, response, body) => {
request.delete(options).then((body) => {
console.log('Detach Peer Response: ');
console.log(body);
if(undefined === body || body.error) {
@ -79,7 +91,13 @@ exports.deletePeer = (req, res, next) => {
});
} else {
console.log('\nPeer Detached: ' + req.params.peerPubKey);
res.status(204).json({message: 'Peer Detached!'});
res.status(204).json({});
}
})
.catch((err) => {
return res.status(500).json({
message: "Detach Peer Failed!",
error: err.error
});
});
};

@ -1,4 +1,4 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
@ -10,7 +10,7 @@ exports.postTransactions = (req, res, next) => {
sat_per_byte: req.body.fees,
target_conf: req.body.blocks
});
request.post(options, (error, response, body) => {
request.post(options).then((body) => {
console.log('Transactions Post Response: ');
console.log(body);
if(undefined === body || body.error) {
@ -21,5 +21,11 @@ exports.postTransactions = (req, res, next) => {
} else {
res.status(201).json(body);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Transactions post failed!",
error: err.error
});
});
};

@ -1,4 +1,4 @@
var request = require('request');
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
@ -6,8 +6,6 @@ exports.operateWallet = (req, res, next) => {
var requestBody = {
wallet_password: Buffer.from(req.body.wallet_password).toString('base64')
};
// console.log('\nRequest Body after conversion into Uint8Array: ');
// console.log(requestBody);
if (undefined === req.params.operation || req.params.operation === 'unlock') {
options.url = common.lnd_server_url + '/unlockwallet';
options.form = JSON.stringify(requestBody);
@ -18,8 +16,7 @@ exports.operateWallet = (req, res, next) => {
err_message = 'Initializing wallet failed!';
}
options.qs = req.query;
// console.log('\nForm: ' + options.form);
request.post(options, (error, response, body) => {
request.post(options).then((body) => {
console.log('\nUnlock Wallet Response: ');
console.log(body);
const body_str = (undefined === body) ? '' : JSON.stringify(body);
@ -35,7 +32,7 @@ exports.operateWallet = (req, res, next) => {
error: 'Unlocking wallet failed! Verify that lnd is running!'
});
} else if(body.error) {
if(body.code === 1 && body.error === 'context canceled') {
if((body.code === 1 && body.error === 'context canceled') || (body.code === 14 && body.error === 'transport is closing')) {
res.status(201).json({wallet: 'successful'});
} else {
res.status(500).json({
@ -46,5 +43,15 @@ exports.operateWallet = (req, res, next) => {
} else {
res.status(201).json({wallet: 'successful'});
}
})
.catch(function (err) {
if((err.error.code === 1 && err.error.error === 'context canceled') || (err.error.code === 14 && err.error.error === 'transport is closing')) {
res.status(201).json({wallet: 'successful'});
} else {
res.status(500).json({
message: err_message,
error: err.error.error
});
}
});
};

2056
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.0.3-alpha",
"version": "0.0.4-alpha",
"license": "MIT",
"scripts": {
"ng": "ng",
@ -32,25 +32,29 @@
"@ngrx/store-devtools": "^6.1.2",
"@swimlane/ngx-charts": "^10.0.0",
"angular2-qrcode": "^2.0.1",
"atob": "^2.1.2",
"core-js": "^2.5.4",
"express": "^4.16.4",
"hammerjs": "^2.0.8",
"ini": "^1.3.5",
"jsonwebtoken": "^8.4.0",
"ngx-perfect-scrollbar": "^6.3.1",
"node-sass": "^4.9.4",
"optimist": "^0.6.1",
"request-promise": "^4.2.2",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.3.3",
"upper-case": "^1.1.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.10.0",
"@angular-devkit/build-angular": "^0.11.4",
"@angular/cli": "~7.0.1",
"@angular/compiler-cli": "^7.0.0",
"@angular/language-service": "^7.0.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"@types/node": "^8.9.5",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",

@ -0,0 +1,10 @@
const RTLConfController = require("../controllers/RTLConf");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/lndconfig", authCheck, RTLConfController.getLNDConfig);
router.get("/uisettings", RTLConfController.getUISettings);
router.post("/", authCheck, RTLConfController.updateUISettings);
module.exports = router;

@ -0,0 +1,14 @@
const jwt = require("jsonwebtoken");
module.exports = (req, res, next) => {
try {
const token = req.headers.authorization.split(" ")[1];
jwt.verify(token, "RTL_default_secret_it_can_be_changed_by_user");
next();
} catch (error) {
res.status(401).json({
message: "Authentication Failed!",
error: "Authentication Failed! Please Login First!"
});
}
};

@ -0,0 +1,7 @@
const AuthenticateController = require("../controllers/authenticate");
const express = require("express");
const router = express.Router();
router.post("/", AuthenticateController.authenticateUser);
module.exports = router;

@ -1,8 +1,8 @@
const BalanceController = require("../controllers/balance");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", BalanceController.getBalance);
router.get("/:source", BalanceController.getBalance);
router.get("/:source", authCheck, BalanceController.getBalance);
module.exports = router;

@ -1,11 +1,12 @@
const ChannelsController = require("../controllers/channels");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", ChannelsController.getChannels);
router.get("/:channelType", ChannelsController.getChannels);
router.post("/", ChannelsController.postChannel);
router.post("/transactions", ChannelsController.postTransactions);
router.delete("/:channelPoint", ChannelsController.closeChannel);
router.get("/", authCheck, ChannelsController.getChannels);
router.get("/:channelType", authCheck, ChannelsController.getChannels);
router.post("/", authCheck, ChannelsController.postChannel);
router.post("/transactions", authCheck, ChannelsController.postTransactions);
router.delete("/:channelPoint", authCheck, ChannelsController.closeChannel);
module.exports = router;

@ -1,7 +1,8 @@
const FeesController = require("../controllers/fees");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", FeesController.getFees);
router.get("/", authCheck, FeesController.getFees);
module.exports = router;

@ -1,7 +1,8 @@
const infoController = require("../controllers/getInfo");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", infoController.getInfo);
router.get("/", authCheck, infoController.getInfo);
module.exports = router;

@ -1,9 +1,10 @@
const graphController = require("../controllers/graph");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", graphController.getDescribeGraph);
router.get("/info", graphController.getGraphInfo);
router.get("/node/:pubKey", graphController.getGraphNode);
router.get("/", authCheck, graphController.getDescribeGraph);
router.get("/info", authCheck, graphController.getGraphInfo);
router.get("/node/:pubKey", authCheck, graphController.getGraphNode);
module.exports = router;

@ -1,8 +1,9 @@
const invoicesController = require("../controllers/invoices");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", invoicesController.listInvoices);
router.post("/", invoicesController.addInvoice);
router.get("/", authCheck, invoicesController.listInvoices);
router.post("/", authCheck, invoicesController.addInvoice);
module.exports = router;

@ -1,7 +1,8 @@
const NewAddressController = require("../controllers/newAddress");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", NewAddressController.getNewAddress);
router.get("/", authCheck, NewAddressController.getNewAddress);
module.exports = router;

@ -1,7 +1,8 @@
const PayRequestController = require("../controllers/payReq");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/:payRequest", PayRequestController.decodePayment);
router.get("/:payRequest", authCheck, PayRequestController.decodePayment);
module.exports = router;

@ -1,7 +1,8 @@
const PaymentsController = require("../controllers/payments");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", PaymentsController.getPayments);
router.get("/", authCheck, PaymentsController.getPayments);
module.exports = router;

@ -1,9 +1,10 @@
const PeersController = require("../controllers/peers");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", PeersController.getPeers);
router.post("/", PeersController.postPeer);
router.delete("/:peerPubKey", PeersController.deletePeer);
router.get("/", authCheck, PeersController.getPeers);
router.post("/", authCheck, PeersController.postPeer);
router.delete("/:peerPubKey", authCheck, PeersController.deletePeer);
module.exports = router;

@ -1,7 +1,8 @@
const TransactionsController = require("../controllers/transactions");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.post("/", TransactionsController.postTransactions);
router.post("/", authCheck, TransactionsController.postTransactions);
module.exports = router;

@ -1,7 +1,8 @@
const WalletController = require("../controllers/wallet");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.post("/:operation", WalletController.operateWallet);
router.post("/:operation", authCheck, WalletController.operateWallet);
module.exports = router;

@ -32,7 +32,11 @@ const onError = error => {
console.error(bind + " is already in use");
process.exit(1);
break;
case "ECONNREFUSED":
console.error("LND Server is down/locked");
default:
console.error("DEFUALT ERROR");
console.error(error.code);
throw error;
}
};

Loading…
Cancel
Save