Release 0.11.0 (#713)

- Package updates
    Updated docker NodeJS from 10 to 14
    Updated Angular from 11 to 12
    Updated Material from 11 to 12
    Updated Angular cli from 11 to 12
    Updated Karma from 5 to 6
    Updated rxjs from 6 to 7
    Updated ngrx from 10 to 12
    Updated angularx-qrcode from 10 to 11
    Updated @angular/flex-layout from 11 to 12
    Updated angular-user-idle from 2.2.4 to 2.2.5
    Updated typescript from 4.0.2 to 4.2.4
    Updated zone.js from 0.10.2 to 0.11.4
    Migrated from TSLint to ESLint
    Installed save-dev crypto-browserify & stream-browserify

- Mask password with fixed length #689
- CSRF Token (#696)
- Route lock default password (#700)
- ECL Invoice amount mislabeled #694
- ECL & LND Fee report time zone offset bug fixes #692 & #693
- Loop remove max routing fee validation #690
- Child route refresh bug
- Adding Password Blacklist (#704)
- Fee rate in percentage #621 (#705)
- ECL Adding BaseFee and FeeRate on Channels
- LND Invoice and Payment pagination fix (#707)
- Keysend missing QR code bug fix
- Login page XS layout fix
- Reports tables load time improved (#709)
- Report initial table load bug fix
This commit is contained in:
ShahanaFarooqui 2021-06-20 16:27:08 -04:00 committed by GitHub
parent e4d6256803
commit e45d6d598a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
306 changed files with 7933 additions and 8522 deletions

View File

@ -11,7 +11,7 @@ jobs:
command: |
LATEST_TAG="${CIRCLE_TAG:1}"
DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-amd64"
DOCKERHUB_DOCKERFILE="Dockerfile"
DOCKERHUB_DOCKERFILE="docker/Dockerfile"
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" .
sudo docker push "$DOCKERHUB_DESTINATION"
@ -26,7 +26,7 @@ jobs:
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
LATEST_TAG="${CIRCLE_TAG:1}"
DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-arm32v7"
DOCKERHUB_DOCKERFILE="Dockerfile.arm32v7"
DOCKERHUB_DOCKERFILE="docker/Dockerfile.arm32v7"
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" .
sudo docker push "$DOCKERHUB_DESTINATION"
@ -41,7 +41,7 @@ jobs:
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
LATEST_TAG="${CIRCLE_TAG:1}"
DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-arm64v8"
DOCKERHUB_DOCKERFILE="Dockerfile.arm64v8"
DOCKERHUB_DOCKERFILE="docker/Dockerfile.arm64v8"
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKERFILE" .
sudo docker push "$DOCKERHUB_DESTINATION"

50
.eslintrc.json Normal file
View File

@ -0,0 +1,50 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"prefix": "rtl",
"style": "kebab-case",
"type": "element"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"style": "camelCase",
"type": "attribute"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
}
]
}

View File

@ -1,33 +0,0 @@
FROM node:10-jessie-slim AS builder
ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini-static-armel /tini
ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini-static-armel.asc /tini.asc
RUN apt-get install gnupg
RUN gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
&& gpg --batch --verify /tini.asc /tini
RUN chmod +x /tini
WORKDIR /RTL
COPY . /RTL
COPY package.json /RTL/package.json
COPY package-lock.json /RTL/package-lock.json
# Install dependencies
RUN npm install --only=prod
COPY . /RTL
FROM arm32v7/node:10-jessie-slim
WORKDIR /RTL
COPY --from=builder "/RTL" .
COPY --from=builder "/tini" /sbin/tini
EXPOSE 3000
ENTRYPOINT ["/sbin/tini", "-g", "--"]
CMD ["node", "rtl"]

View File

@ -25,10 +25,8 @@
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"tsConfig": "src/tsconfig.app.json",
"allowedCommonJsDependencies": [
"hammerjs",
"sha256",
"qrcode",
"otplib"
@ -39,7 +37,13 @@
"styles": [
"src/app/shared/theme/styles/styles.scss"
],
"scripts": []
"scripts": [],
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"optimization": false,
"namedChunks": true
},
"configurations": {
"production": {
@ -59,13 +63,13 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "5mb",
"maximumError": "5mb"
"maximumWarning": "12mb",
"maximumError": "12mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "1mb",
"maximumError": "5mb"
"maximumWarning": "5mb",
"maximumError": "10mb"
}
]
}
@ -93,8 +97,8 @@
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"assets": [
"src/assets"
],
@ -105,15 +109,11 @@
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"builder": "@angular-eslint/builder:lint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
},
@ -132,5 +132,8 @@
}
}
},
"defaultProject": "RTLApp"
"defaultProject": "RTLApp",
"cli": {
"defaultCollection": "@angular-eslint/schematics"
}
}

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@ MIT
MIT
The MIT License
Copyright (c) 2020 Google LLC.
Copyright (c) 2021 Google LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -64,7 +64,7 @@ MIT
MIT
The MIT License
Copyright (c) 2020 Google LLC.
Copyright (c) 2021 Google LLC.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -116,44 +116,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@fortawesome/fontawesome-svg-core
MIT
Font Awesome Free License
-------------------------
Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
packaged as SVG and JS file types.
# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.
# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.
# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.
We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.
# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**
@fortawesome/free-regular-svg-icons
(CC-BY-4.0 AND MIT)
Font Awesome Free License
@ -364,9 +326,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
angular-user-idle
MIT
angularx-qrcode
MIT
@ -422,6 +381,26 @@ THE SOFTWARE.
bn.js
MIT
Copyright Fedor Indutny, 2015.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.
brorand
MIT
@ -622,29 +601,6 @@ convert-hex
convert-string
core-util-is
MIT
Copyright Node.js contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.
create-ecdh
MIT
The MIT License (MIT)
@ -747,588 +703,6 @@ 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.
css-loader
MIT
Copyright JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE 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.
d3-array
BSD-3-Clause
Copyright 2010-2020 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-brush
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-color
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-dispatch
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-drag
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-ease
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
Copyright 2001 Robert Penner
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-format
BSD-3-Clause
Copyright 2010-2015 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-hierarchy
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-interpolate
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-path
BSD-3-Clause
Copyright 2015-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-scale
BSD-3-Clause
Copyright 2010-2015 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-selection
BSD-3-Clause
Copyright (c) 2010-2018, Michael Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name Michael Bostock may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-shape
BSD-3-Clause
Copyright 2010-2015 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-time
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-time-format
BSD-3-Clause
Copyright 2010-2017 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-timer
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d3-transition
BSD-3-Clause
Copyright (c) 2010-2015, Michael Bostock
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name Michael Bostock may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright 2001 Robert Penner
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
des.js
MIT
@ -1432,31 +806,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
hammerjs
MIT
The MIT License (MIT)
Copyright (C) 2011-2014 by Jorik Tangelder (Eight Media)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.
hash-base
MIT
The MIT License (MIT)
@ -1525,6 +874,28 @@ PERFORMANCE OF THIS SOFTWARE.
isarray
MIT
MIT License
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.
md5.js
MIT
@ -1643,78 +1014,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
perfect-scrollbar
MIT
The MIT License (MIT) Copyright (c) 2012-2019 Hyunje Jun, MDBootstrap.com and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.
process
MIT
(The MIT License)
Copyright (c) 2013 Roman Shtylman <shtylman@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE 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.
process-nextick-args
MIT
# Copyright (c) 2015 Calvin Metcalf
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.**
public-encrypt
MIT
Copyright (c) 2017 Calvin Metcalf
@ -1853,31 +1152,6 @@ IN THE SOFTWARE.
"""
resize-observer-polyfill
MIT
The MIT License (MIT)
Copyright (c) 2016 Denis Rul
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
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.
ripemd160
MIT
The MIT License (MIT)
@ -2216,7 +1490,7 @@ sha256
stream-browserify
MIT
This software is released under the MIT license:
MIT License
Copyright (c) James Halliday
@ -2354,35 +1628,11 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
webpack
MIT
Copyright JS Foundation and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE 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.
zone.js
MIT
The MIT License
Copyright (c) 2010-2020 Google LLC. http://angular.io/license
Copyright (c) 2010-2020 Google LLC. https://angular.io/license
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

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

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

View File

@ -1,6 +1,4 @@
<!doctype html>
<html lang="en">
<head>
<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<title>RTL</title>
<base href="/rtl/">
@ -12,8 +10,9 @@
<link rel="mask-icon" href="assets/images/favicon-light/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="styles.34373e0f495fd5a53b6a.css"></head>
<style>@font-face{font-family:Roboto;src:url(Roboto-Thin.dbd56bd3357dc3617fe5.woff2) format("woff2"),url(Roboto-Thin.e7f7c82374bd0ebef14b.woff) format("woff");font-weight:100;font-style:normal;}@font-face{font-family:Roboto;src:url(Roboto-ThinItalic.a8cef84f735ef887abdc.woff2) format("woff2"),url(Roboto-ThinItalic.5dd9349c940073834e9a.woff) format("woff");font-weight:100;font-style:italic;}@font-face{font-family:Roboto;src:url(Roboto-Light.c27d89ac77468ae18f28.woff2) format("woff2"),url(Roboto-Light.d923dfafc0c5183b59aa.woff) format("woff");font-weight:300;font-style:normal;}@font-face{font-family:Roboto;src:url(Roboto-LightItalic.506274c7228cf81cae4d.woff2) format("woff2"),url(Roboto-LightItalic.d4b8c137518d9d92bb28.woff) format("woff");font-weight:300;font-style:italic;}@font-face{font-family:Roboto;src:url(Roboto-Regular.64cfb66c866ea50cad47.woff2) format("woff2"),url(Roboto-Regular.e02e9d6ff5547f7e9962.woff) format("woff");font-weight:400;font-style:normal;}@font-face{font-family:Roboto;src:url(Roboto-RegularItalic.4dd2af1e8df532f41db8.woff2) format("woff2"),url(Roboto-RegularItalic.5ea38fff9eebef99c5df.woff) format("woff");font-weight:400;font-style:italic;}@font-face{font-family:Roboto;src:url(Roboto-Medium.1d3bced88509b0838984.woff2) format("woff2"),url(Roboto-Medium.092c6130df8fd2199888.woff) format("woff");font-weight:500;font-style:normal;}@font-face{font-family:Roboto;src:url(Roboto-MediumItalic.d620b8f53f75966fe42e.woff2) format("woff2"),url(Roboto-MediumItalic.18ff1628c628080166c1.woff) format("woff");font-weight:500;font-style:italic;}@font-face{font-family:Roboto;src:url(Roboto-Bold.92fbd4e93cf0a5dbebaa.woff2) format("woff2"),url(Roboto-Bold.73288d91c325e82a5b92.woff) format("woff");font-weight:700;font-style:normal;}@font-face{font-family:Roboto;src:url(Roboto-BoldItalic.5f600d98a73d800ae575.woff2) format("woff2"),url(Roboto-BoldItalic.6d89acbd21d7e3fbecb2.woff) format("woff");font-weight:700;font-style:italic;}@font-face{font-family:Roboto;src:url(Roboto-Black.41ed1105a6ebb8ffe34e.woff2) format("woff2"),url(Roboto-Black.937491dfcbe64ca9a9f1.woff) format("woff");font-weight:900;font-style:normal;}@font-face{font-family:Roboto;src:url(Roboto-BlackItalic.50ca4c51ebc27e7e7d2f.woff2) format("woff2"),url(Roboto-BlackItalic.2e1ee657996854c6f427.woff) format("woff");font-weight:900;font-style:italic;}html{width:100%;height:99%;line-height:1.5;overflow-x:hidden;font-family:Roboto,sans-serif!important;font-size:62.5%;}body{box-sizing:border-box;margin:0;}body{height:100%;overflow:hidden;}*{margin:0;padding:0;}</style><link rel="stylesheet" href="styles.97554e699a42acff6579.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.97554e699a42acff6579.css"></noscript></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.76e78b7c520ee74ce1af.js" defer></script><script src="polyfills.a290c5ced4c403cfee17.js" defer></script><script src="main.023be7f19d26fb1d812e.js" defer></script></body>
</html>
<script src="runtime.28bc9723e141277838d0.js" defer></script><script src="polyfills.99f4d82f067fba7525c4.js" defer></script><script src="main.0fde3abb5a45cd8835db.js" defer></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

View File

@ -0,0 +1 @@
(()=>{"use strict";var e,r,t,a={},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var t=o[e]={id:e,loaded:!1,exports:{}};return a[e].call(t.exports,t,t.exports,n),t.loaded=!0,t.exports}n.m=a,e=[],n.O=(r,t,a,o)=>{if(!t){var l=1/0;for(s=0;s<e.length;s++){for(var[t,a,o]=e[s],d=!0,i=0;i<t.length;i++)(!1&o||l>=o)&&Object.keys(n.O).every(e=>n.O[e](t[i]))?t.splice(i--,1):(d=!1,o<l&&(l=o));d&&(e.splice(s--,1),r=a())}return r}o=o||0;for(var s=e.length;s>0&&e[s-1][2]>o;s--)e[s]=e[s-1];e[s]=[t,a,o]},n.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return n.d(r,{a:r}),r},n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+"."+{432:"635dd65c825f8e4ca25b",646:"4d1e1dc02d21b483a9c9",891:"65e70a7da1bfef9d82e4",958:"9a3ae49eb9fc6ea729f7"}[e]+".js",n.miniCssF=e=>"styles.97554e699a42acff6579.css",n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r={},t="rtl:",n.l=(e,a,o,l)=>{if(r[e])r[e].push(a);else{var d,i;if(void 0!==o)for(var s=document.getElementsByTagName("script"),u=0;u<s.length;u++){var c=s[u];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")==t+o){d=c;break}}d||(i=!0,(d=document.createElement("script")).charset="utf-8",d.timeout=120,n.nc&&d.setAttribute("nonce",n.nc),d.setAttribute("data-webpack",t+o),d.src=e),r[e]=[a];var f=(t,a)=>{d.onerror=d.onload=null,clearTimeout(p);var o=r[e];if(delete r[e],d.parentNode&&d.parentNode.removeChild(d),o&&o.forEach(e=>e(a)),t)return t(a)},p=setTimeout(f.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=f.bind(null,d.onerror),d.onload=f.bind(null,d.onload),i&&document.head.appendChild(d)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n.p="",(()=>{var e={666:0};n.f.j=(r,t)=>{var a=n.o(e,r)?e[r]:void 0;if(0!==a)if(a)t.push(a[2]);else if(666!=r){var o=new Promise((t,o)=>a=e[r]=[t,o]);t.push(a[2]=o);var l=n.p+n.u(r),d=new Error;n.l(l,t=>{if(n.o(e,r)&&(0!==(a=e[r])&&(e[r]=void 0),a)){var o=t&&("load"===t.type?"missing":t.type),l=t&&t.target&&t.target.src;d.message="Loading chunk "+r+" failed.\n("+o+": "+l+")",d.name="ChunkLoadError",d.type=o,d.request=l,a[1](d)}},"chunk-"+r,r)}else e[r]=0},n.O.j=r=>0===e[r];var r=(r,t)=>{var a,o,[l,d,i]=t,s=0;for(a in d)n.o(d,a)&&(n.m[a]=d[a]);if(i)var u=i(n);for(r&&r(t);s<l.length;s++)n.o(e,o=l[s])&&e[o]&&e[o][0](),e[l[s]]=0;return n.O(u)},t=self.webpackChunkrtl=self.webpackChunkrtl||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();

View File

@ -1 +0,0 @@
!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise(function(r,n){t=o[e]=[r,n]});r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"237c2154eb3e4109a251",5:"25446aaee9f74a416633",6:"eee0e0f329ec52d3bce7",7:"e4068d65b9329bce7749"}[e]+".js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout(function(){u({type:"timeout",target:i})},12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,13 +1,14 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getBalance = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Balance', msg: 'Getting Balance..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/getBalance';
request(options).then((body) => {
logger.info({fileName: 'Balance', msg: 'Balance Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Balance', msg: 'Balance Received', data: body});
if(!body.totalBalance) {
body.totalBalance = 0;
body.btc_totalBalance = 0;
@ -26,6 +27,7 @@ exports.getBalance = (req, res, next) => {
} else {
body.btc_unconfBalance = common.convertToBTC(body.unconfBalance);
}
logger.log({level: 'INFO', fileName: 'Balance', msg: 'Balance Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -36,7 +38,7 @@ exports.getBalance = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Balance', lineNum: 38, msg: 'Balance Fetch Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Balance', msg: 'Balance Fetch Error', error: err});
return res.status(500).json({
message: "Fetching balance failed!",
error: err.error

View File

@ -1,13 +1,14 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.listChannels = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Getting Channels..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channel/listChannels';
request(options).then(function (body) {
logger.info({fileName: 'Channels', msg: 'List Channels: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'List Channels', data: body});
body.map(channel => {
if (!channel.alias || channel.alias === '') { channel.alias = channel.id.substring(0, 20); }
local = (channel.msatoshi_to_us) ? channel.msatoshi_to_us : 0;
@ -15,6 +16,7 @@ exports.listChannels = (req, res, next) => {
total = channel.msatoshi_total ? channel.msatoshi_total : 0;
channel.balancedness = (total == 0) ? 1 : (1 - Math.abs((local-remote)/total)).toFixed(3);
})
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channels Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -25,7 +27,7 @@ exports.listChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Channels', lineNum: 26, msg: 'List Channels: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'List Channels Error', error: err});
return res.status(500).json({
message: 'Fetching List Channels Failed!',
error: err.error
@ -34,19 +36,21 @@ exports.listChannels = (req, res, next) => {
}
exports.openChannel = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Opening Channel..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channel/openChannel';
options.body = req.body;
logger.info({fileName: 'Channels', msg: 'Open Channel Options: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Options', data: options.body});
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Open Channel Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 42, msg: 'Open Channel Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Open Channel Error', error: body.error});
res.status(500).json({
message: 'Open Channel Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Opened'});
res.status(201).json(body);
}
})
@ -58,7 +62,7 @@ exports.openChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Channels', lineNum: 58, msg: 'Open Channel Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Open Channel Error', error: err});
return res.status(500).json({
message: 'Open Channel Failed!',
error: err.error
@ -67,19 +71,21 @@ exports.openChannel = (req, res, next) => {
}
exports.setChannelFee = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Setting Channel Fee..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channel/setChannelFee';
options.body = req.body;
logger.info({fileName: 'Channels', msg: 'Update Channel Policy Options: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Update Channel Policy Options', data: options.body});
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Update Channel Policy: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Update Channel Policy', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 74, msg: 'Update Channel Policy Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Update Channel Policy Error', error: body.error});
res.status(500).json({
message: 'Update Channel Policy Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Fee Set'});
res.status(201).json(body);
}
})
@ -91,7 +97,7 @@ exports.setChannelFee = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Channels', lineNum: 90, msg: 'Update Channel Policy: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Update Channel Policy Error', error: err});
return res.status(500).json({
message: 'Update Channel Policy Failed!',
error: err.error
@ -100,20 +106,22 @@ exports.setChannelFee = (req, res, next) => {
}
exports.closeChannel = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Closing Channel..'});
req.setTimeout(60000 * 10); // timeout 10 mins
options = common.getOptions();
const unilateralTimeoutQuery = req.query.force ? '?unilateralTimeout=1' : '';
options.url = common.getSelLNServerUrl() + '/v1/channel/closeChannel/' + req.params.channelId + unilateralTimeoutQuery;
logger.info({fileName: 'Channels', msg: 'Closing Channel: ' + options.url});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Closing Channel', data: options.url});
request.delete(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Close Channel Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Close Channel Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 106, msg: 'Close Channel Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Close Channel Error', error: body.error});
res.status(500).json({
message: 'Close Channel Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Closed'});
res.status(204).json(body);
}
})
@ -125,7 +133,7 @@ exports.closeChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Channels', lineNum: 122, msg: 'Close Channel Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Close Channel Error', error: err});
return res.status(500).json({
message: 'Close Channel Failed!',
error: err.error
@ -134,10 +142,11 @@ exports.closeChannel = (req, res, next) => {
}
exports.getLocalRemoteBalance = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Getting Local & Remote Balances..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channel/localremotebal';
request(options).then(function (body) {
logger.info({fileName: 'Channels', msg: 'Local Remote Balance: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Local Remote Balance', data: body});
if(!body.localBalance) {
body.localBalance = 0;
body.btc_localBalance = 0;
@ -150,6 +159,7 @@ exports.getLocalRemoteBalance = (req, res, next) => {
} else {
body.btc_remoteBalance = common.convertToBTC(body.remoteBalance);
}
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Local & Remote Balances Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -160,7 +170,7 @@ exports.getLocalRemoteBalance = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Channels', lineNum: 156, msg: 'Local Remote Balance Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Local Remote Balance Error', error: err});
return res.status(500).json({
message: 'Fetching Local Remote Balance Failed!',
error: err.error
@ -169,25 +179,23 @@ exports.getLocalRemoteBalance = (req, res, next) => {
};
exports.listForwards = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Getting Channel List Forwards..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channel/listForwards/';
request.get(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Forwarding History Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 170, msg: 'Forwarding History Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Forwarding History Error', error: body.error});
res.status(500).json({
message: "Forwarding History Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
if (body && body.length > 0) {
body.forEach(event => {
event.received_time_str = (!event.received_time) ? '' : common.convertTimestampToDate(event.received_time);
event.resolved_time_str = (!event.resolved_time) ? '' : common.convertTimestampToDate(event.resolved_time);
});
body = common.sortDescByKey(body, 'received_time');
}
logger.info({fileName: 'Channels', msg: 'Forwarding History Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Forwarding History Received', data: body});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel List Forwards Received'});
res.status(200).json({ last_offset_index: 0, forwarding_events: body });
}
})
@ -199,7 +207,7 @@ exports.listForwards = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Channels', lineNum: 194, msg: 'Forwarding History Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Forwarding History Error', error: err});
return res.status(500).json({
message: "Forwarding History Failed!",
error: err.error

View File

@ -1,15 +1,16 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getFees = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Getting Fees..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/getFees';
request(options).then((body) => {
logger.info({fileName: 'Fees', msg: 'Fee Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Fee Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Fees', lineNum: 12, msg: 'Get Fee Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Fees', msg: 'Get Fee Error', error: body.error});
res.status(500).json({
message: "Fetching fee failed!",
error: (!body) ? 'Error From Server!' : body.error
@ -21,6 +22,7 @@ exports.getFees = (req, res, next) => {
} else {
body.btc_feeCollected = common.convertToBTC(body.feeCollected);
}
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Fees Received'});
res.status(200).json(body);
}
})
@ -32,7 +34,7 @@ exports.getFees = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Fees', lineNum: 34, msg: 'Get Fees Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Fees', msg: 'Get Fees Error', error: err});
return res.status(500).json({
message: "Fetching fee failed!",
error: err.error

View File

@ -1,27 +1,28 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getInfo = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'GetInfo', msg: 'Getting CLightning Node Information..'});
common.setOptions();
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/getinfo';
logger.info({fileName:'GetInfo', msg: 'Selected Node: ' + JSON.stringify(common.selectedNode.ln_node)});
logger.info({fileName: 'GetInfo', msg: 'Calling Info from C-Lightning server url: ' + options.url});
logger.log({level: 'DEBUG', fileName:'GetInfo', msg: 'Selected Node', data: common.selectedNode.ln_node});
logger.log({level: 'DEBUG', fileName: 'GetInfo', msg: 'Calling Info from C-Lightning server url', data: options.url});
if (!options.headers || !options.headers.macaroon) {
logger.error({fileName: 'GetInfo', lineNum: 13, msg: 'C-Lightning Get info failed due to bad or missing macaroon!'});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'C-Lightning Get info failed due to bad or missing macaroon!', error: {error: 'Bad macaroon.'}});
res.status(502).json({
message: "Fetching Info Failed!",
error: "Bad Macaroon"
});
} else {
request(options).then((body) => {
logger.info({fileName: 'GetInfo', msg: JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'GetInfo', msg: 'Node Information', data: body});
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'GetInfo', lineNum: 24, msg: 'Get Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'Get Info Error', error: body.error});
res.status(500).json({
message: "Fetching Info failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
@ -51,6 +52,7 @@ exports.getInfo = (req, res, next) => {
body.uris.push(body.id + '@' + addr.address + ':' + addr.port);
});
}
logger.log({level: 'INFO', fileName: 'GetInfo', msg: 'CLightning Node Information Received'});
res.status(200).json(body);
}
})
@ -62,7 +64,7 @@ exports.getInfo = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'GetInfo', lineNum: 57, msg: 'Get Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'Get Info Error', error: err});
return res.status(500).json({
message: "Fetching Info failed!",
error: err.error

View File

@ -1,21 +1,23 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.deleteExpiredInvoice = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Deleting Expired Invoices..'});
options = common.getOptions();
const queryStr = req.query.maxExpiry ? '?maxexpiry=' + req.query.maxExpiry : '';
options.url = common.getSelLNServerUrl() + '/v1/invoice/delExpiredInvoice' + queryStr;
request.delete(options).then((body) => {
logger.info({fileName: 'Invoice', msg: 'Invoices Deleted: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices Deleted', data: body});
if(!body || body.error) {
logger.error({fileName: 'Invoice', lineNum: 13, msg: 'Invoice Delete Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Invoice Delete Error', error: body.error});
res.status(500).json({
message: "Deleting Invoice Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
}
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Expired Invoices Deleted'});
res.status(204).json({status: 'Invoice Deleted Successfully'});
})
.catch(errRes => {
@ -26,7 +28,7 @@ exports.deleteExpiredInvoice = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Invoice', lineNum: 28, msg: 'Invoice Delete Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Invoice Delete Error', error: err});
return res.status(500).json({
message: "Deleting Invoice Failed!",
error: err.error
@ -35,26 +37,24 @@ exports.deleteExpiredInvoice = (req, res, next) => {
};
exports.listInvoices = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Getting Invoices..'});
options = common.getOptions();
const labelQuery = req.query.label ? '?label=' + req.query.label : '';
options.url = common.getSelLNServerUrl() + '/v1/invoice/listInvoices' + labelQuery;
request(options).then((body) => {
logger.info({fileName: 'Invoice', msg: 'Invoices List Received: ' + body});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Invoice', lineNum: 43, msg: 'List Invoice Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'List Invoice Error', error: body.error});
res.status(500).json({
message: "Fetching Invoice Info failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
if ( body.invoices && body.invoices.length > 0) {
body.invoices.forEach(invoice => {
invoice.paid_at_str = (!invoice.paid_at) ? '' : common.convertTimestampToDate(invoice.paid_at);
invoice.expires_at_str = (!invoice.expires_at) ? '' : common.convertTimestampToDate(invoice.expires_at);
});
body.invoices = common.sortDescByKey(body.invoices, 'expires_at');
}
logger.info({fileName: 'Invoice', msg: 'Invoices List Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body});
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Invoices Received'});
res.status(200).json(body);
}
})
@ -66,7 +66,7 @@ exports.listInvoices = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Invoice', lineNum: 67, msg: 'List Invoice Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'List Invoice Error', error: err});
return res.status(500).json({
message: "Fetching Invoice Info failed!",
error: err.error
@ -75,18 +75,20 @@ exports.listInvoices = (req, res, next) => {
};
exports.addInvoice = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Creating Invoice..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/invoice/genInvoice';
options.body = req.body;
request.post(options).then((body) => {
logger.info({fileName: 'Invoice', msg: 'Add Invoice Responce: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Add Invoice Responce', data: body});
if(!body || body.error) {
logger.error({fileName: 'Invoice', lineNum: 82, msg: 'Add Invoice Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Add Invoice Error', error: body.error});
res.status(500).json({
message: "Add Invoice Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Invoice Created'});
res.status(201).json(body);
}
})
@ -98,7 +100,7 @@ exports.addInvoice = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Invoice', lineNum: 98, msg: 'Add Invoice Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Add Invoice Error', error: err});
return res.status(500).json({
message: "Add Invoice Failed!",
error: err.error

View File

@ -1,21 +1,23 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.signMessage = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Signing Message..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/utility/signMessage';
options.form = { message: req.body.message };
request.post(options, (error, response, body) => {
logger.info({fileName: 'Messages', msg: 'Message Signed: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Messages', msg: 'Message Signed', data: body});
if(!body || body.error) {
logger.error({fileName: 'Messages', lineNum: 13, msg: 'Message Sign Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Message Sign Error', error: body.error});
res.status(500).json({
message: "Sign message failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Message Signed'});
res.status(201).json(body);
}
})
@ -27,7 +29,7 @@ exports.signMessage = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Messages', lineNum: 29, msg: 'Sign Message Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Sign Message Error', error: err});
return res.status(500).json({
message: 'Sign Message Failed!',
error: err.error
@ -36,17 +38,19 @@ exports.signMessage = (req, res, next) => {
};
exports.verifyMessage = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Verifying Message..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/utility/checkMessage/' + req.body.message + '/' + req.body.signature;
request.get(options, (error, response, body) => {
logger.info({fileName: 'Messages', msg: 'Message Verified: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Messages', msg: 'Message Verified', data: body});
if(!body || body.error) {
logger.error({fileName: 'Messages', lineNum: 43, msg: 'Verify Message Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Verify Message Error', error: body.error});
res.status(500).json({
message: "Verify message failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Message Verified'});
res.status(201).json(body);
}
})
@ -58,7 +62,7 @@ exports.verifyMessage = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Messages', lineNum: 59, msg: 'Message Verification Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Message Verification Error', error: err});
return res.status(500).json({
message: 'Verify Message Failed!',
error: err.error

View File

@ -1,20 +1,22 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getRoute = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Network', msg: 'Getting Network Routes..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/network/getRoute/' + req.params.destPubkey + '/' + req.params.amount;
request(options).then((body) => {
logger.info({fileName: 'Network', msg: 'Query Routes Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Network', msg: 'Query Routes Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Network', lineNum: 12, msg: 'Query Routes Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Network', msg: 'Query Routes Error', error: body.error});
res.status(500).json({
message: "Fetching Query Routes Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
}
logger.log({level: 'INFO', fileName: 'Network', msg: 'Network Routes Received'});
res.status(200).json({routes: body});
})
.catch(errRes => {
@ -25,7 +27,7 @@ exports.getRoute = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Network', lineNum: 27, msg: 'Query Routes Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Network', msg: 'Query Routes Error', error: err});
return res.status(500).json({
message: "Fetching Query Routes Failed!",
error: err.error
@ -34,13 +36,12 @@ exports.getRoute = (req, res, next) => {
};
exports.listNode = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Network', msg: 'Node Lookup..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/network/listNode/' + req.params.id;
request(options).then(function (body) {
logger.info({fileName: 'Network', msg: 'Node Lookup: ' + JSON.stringify(body)});
body.forEach(node => {
node.last_timestamp_str = (node.last_timestamp) ? common.convertTimestampToDate(node.last_timestamp) : '';
});
logger.log({level: 'DEBUG', fileName: 'Network', msg: 'Node Lookup', data: body});
logger.log({level: 'INFO', fileName: 'Network', msg: 'Node Lookup Finished'});
res.status(200).json(body);
})
.catch(errRes => {
@ -51,7 +52,7 @@ exports.listNode = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Network', lineNum: 52, msg: 'Node Lookup Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Network', msg: 'Node Lookup Error', error: err});
return res.status(500).json({
message: "Node Lookup Failed!",
error: err.error
@ -60,12 +61,12 @@ exports.listNode = (req, res, next) => {
};
exports.listChannel = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Network', msg: 'Channel Lookup..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/network/listChannel/' + req.params.channelShortId;
request(options).then(function (body) {
logger.info({fileName: 'Network', msg: 'Channel Lookup: ' + JSON.stringify(body)});
body[0].last_update_str = (body.length > 0 && body[0].last_update) ? common.convertTimestampToDate(body[0].last_update) : '';
body[1].last_update_str = (body.length > 1 && body[1].last_update) ? common.convertTimestampToDate(body[1].last_update) : '';
logger.log({level: 'DEBUG', fileName: 'Network', msg: 'Channel Lookup', data: body});
logger.log({level: 'INFO', fileName: 'Network', msg: 'Channel Lookup Finished'});
res.status(200).json(body);
})
.catch(errRes => {
@ -76,7 +77,7 @@ exports.listChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Network', lineNum: 76, msg: 'Channel Lookup Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Network', msg: 'Channel Lookup Error', error: err});
return res.status(500).json({
message: "Channel Lookup Failed!",
error: err.error
@ -85,9 +86,11 @@ exports.listChannel = (req, res, next) => {
};
exports.feeRates = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Network', msg: 'Getting Network Fee Rates..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/network/feeRates/' + req.params.feeRateStyle;
request(options).then(function (body) {
logger.log({level: 'INFO', fileName: 'Network', msg: 'Network Fee Rates Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -98,7 +101,7 @@ exports.feeRates = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Network', lineNum: 97, msg: 'Fee Rates Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Network', msg: 'Fee Rates Error', error: err});
return res.status(500).json({
message: "Fee Rates Failed!",
error: err.error

View File

@ -1,12 +1,14 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getNewAddress = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'Generating New Address..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/newaddr?addrType=' + req.query.type;
request(options).then((body) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'New Address Generated'});
res.status(200).json(body);
})
.catch(errRes => {
@ -17,7 +19,7 @@ exports.getNewAddress = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'OnChain', lineNum: 19, msg: 'OnChain New Address Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'OnChain', msg: 'OnChain New Address Error', error: err});
return res.status(500).json({
message: "Fetching new address failed!",
error: err.error
@ -26,19 +28,21 @@ exports.getNewAddress = (req, res, next) => {
};
exports.onChainWithdraw = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'Withdrawing from On Chain..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/withdraw';
options.body = req.body;
logger.info({fileName: 'OnChain', msg: 'OnChain Withdraw Options: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'OnChain', msg: 'OnChain Withdraw Options', data: options.body});
request.post(options).then((body) => {
logger.info({fileName: 'OnChain', msg: 'OnChain Withdraw Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'OnChain', msg: 'OnChain Withdraw Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'OnChain', lineNum: 35, msg: 'OnChain Withdraw Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'OnChain', msg: 'OnChain Withdraw Error', error: body.error});
res.status(500).json({
message: 'OnChain Withdraw Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'Withdraw Finished'});
res.status(201).json(body);
}
})
@ -50,7 +54,7 @@ exports.onChainWithdraw = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'OnChain', lineNum: 51, msg: 'OnChain Withdraw Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'OnChain', msg: 'OnChain Withdraw Error', error: err});
return res.status(500).json({
message: 'OnChain Withdraw Failed!',
error: err
@ -59,10 +63,12 @@ exports.onChainWithdraw = (req, res, next) => {
}
exports.getUTXOs = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'List Funds..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/listFunds';
request(options).then((body) => {
if (body.outputs) { body.outputs = common.sortDescByStrKey(body.outputs, 'status'); }
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'List Funds Received'});
res.status(200).json(body);
}).catch(errRes => {
let err = JSON.parse(JSON.stringify(errRes));
@ -72,7 +78,7 @@ exports.getUTXOs = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'OnChain', lineNum: 19, msg: 'OnChain List Funds Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'OnChain', msg: 'OnChain List Funds Error', error: err});
return res.status(500).json({
message: "Fetching list funds failed!",
error: err.error

View File

@ -1,5 +1,5 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
@ -39,30 +39,29 @@ function groupBy(payments) {
let paySummary = curr.reduce(summaryReducer, {msatoshi: 0, msatoshi_sent: 0, status: (curr[0] && curr[0].status) ? curr[0].status : 'failed'});
temp = {is_group: true, is_expanded: false, total_parts: (curr.length ? curr.length : 0), status: paySummary.status, payment_hash: curr[0].payment_hash,
destination: curr[0].destination, msatoshi: paySummary.msatoshi, msatoshi_sent: paySummary.msatoshi_sent, created_at: curr[0].created_at,
created_at_str: curr[0].created_at_str, mpps: curr};
mpps: curr};
}
return acc.concat(temp);
}, []);
}
exports.listPayments = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'List Payments..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/pay/listPayments';
request(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Payment List Received: ' + JSON.stringify(body.payments)});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Payment List Received', data: body.payments});
if(!body || body.error) {
logger.error({fileName: 'Payments', lineNum: 12, msg: 'Payments List Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Payments List Error', error: body.error});
res.status(500).json({
message: "Payments List Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
if ( body && body.payments && body.payments.length > 0) {
body.payments.forEach(payment => {
payment.created_at_str = (!payment.created_at) ? '' : common.convertTimestampToDate(payment.created_at);
});
body.payments = common.sortDescByKey(body.payments, 'created_at');
}
logger.log({level: 'INFO', fileName: 'Payments', msg: 'List Payments Received'});
res.status(200).json(groupBy(body.payments));
}
})
@ -74,7 +73,7 @@ exports.listPayments = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Payments', lineNum: 34, msg: 'Payments List Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Payments List Error', error: err});
return res.status(500).json({
message: "Payments List Failed!",
error: err.error
@ -83,19 +82,19 @@ exports.listPayments = (req, res, next) => {
};
exports.decodePayment = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Decoding Payment..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/pay/decodePay/' + req.params.invoice;
request(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Payment Decode Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Payment Decode Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Payments', lineNum: 48, msg: 'Payment Decode Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Payment Decode Error', error: body.error});
res.status(500).json({
message: "Payment Request Decode Failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
body.created_at_str = (!body.created_at) ? '' : common.convertTimestampToDate(body.created_at);
body.expire_at_str = (!body.created_at || !body.expiry) ? '' : common.convertTimestampToDate(body.created_at + body.expiry);
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded'});
res.status(200).json(body);
}
})
@ -107,7 +106,7 @@ exports.decodePayment = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Payments', lineNum: 66, msg: 'Payment Decode Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Payment Decode Error', error: err});
return res.status(500).json({
message: "Payment Request Decode Failed!",
error: err.error
@ -118,20 +117,23 @@ exports.decodePayment = (req, res, next) => {
exports.postPayment = (req, res, next) => {
options = common.getOptions();
if (req.params.type === 'keysend') {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Keysend Payment..'});
options.url = common.getSelLNServerUrl() + '/v1/pay/keysend';
} else {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Send Payment..'});
options.url = common.getSelLNServerUrl() + '/v1/pay';
}
options.body = req.body;
request.post(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Send Payment Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Send Payment Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Payments', lineNum: 81, msg: 'Send Payment Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Send Payment Error', error: body.error});
res.status(500).json({
message: "Send Payment Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Payment Sent'});
res.status(201).json(body);
}
})
@ -143,7 +145,7 @@ exports.postPayment = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Payments', lineNum: 97, msg: 'Send Payments Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Send Payments Error', error: err});
return res.status(500).json({
message: "Send Payment Failed!",
error: err.error

View File

@ -1,15 +1,17 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getPeers = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'List Peers..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/peer/listPeers';
request(options).then(function (body) {
body.forEach(peer => { if (!peer.alias || peer.alias === '') { peer.alias = peer.id.substring(0, 20);}});
let peers = (body) ? common.sortDescByStrKey(body, 'alias') : [];
logger.info({fileName: 'Peers', msg: 'Peers with Alias: ' + JSON.stringify(peers)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peers with Alias', data: peers});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peers Received'});
res.status(200).json(peers);
})
.catch(errRes => {
@ -20,7 +22,7 @@ exports.getPeers = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Peers', lineNum: 21, msg: 'Peers List Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Peers List Error', error: err});
return res.status(500).json({
message: "Peers Fetch Failed!",
error: err.error
@ -29,24 +31,26 @@ exports.getPeers = (req, res, next) => {
};
exports.postPeer = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Connecting Peer..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/peer/connect';
options.body = req.body;
request.post(options, (error, response, body) => {
if(!body || body.error) {
logger.error({fileName: 'Peers', lineNum: 35, msg: 'Connect Peer Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Connect Peer Error', error: body.error});
res.status(500).json({
message: "Adding peer failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.info({fileName: 'Peers', msg: 'Peer Added: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Added', data: body});
options.url = common.getSelLNServerUrl() + '/v1/peer/listPeers';
request(options).then(function (body) {
let peers = ( body) ? common.sortDescByStrKey(body, 'alias') : [];
peers = common.newestOnTop(peers, 'id', req.body.id);
logger.info({fileName: 'Peers', msg: 'Peer with Newest On Top: ' + JSON.stringify(peers)});
logger.info({fileName: 'Peers', msg: 'Peer Added Successfully'});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer with Newest On Top', data: peers});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Added Successfully'});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peer Connected'});
res.status(201).json(peers);
}).catch(errRes => {
let err = JSON.parse(JSON.stringify(errRes));
@ -56,7 +60,7 @@ exports.postPeer = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Peers', lineNum: 56, msg: 'Connect Peer Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Connect Peer Error', error: err});
return res.status(500).json({
message: "Peer Add Failed!",
error: err.error
@ -67,18 +71,20 @@ exports.postPeer = (req, res, next) => {
};
exports.deletePeer = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Disconnecting Peer..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/peer/disconnect/' + req.params.peerId + '?force=' + req.query.force;
request.delete(options).then((body) => {
logger.info({fileName: 'Peers', msg: 'Detach Peer Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Detach Peer Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Peers', lineNum: 72, msg: 'Detach Peer Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Detach Peer Error', error: body.error});
res.status(500).json({
message: "Detach peer failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.info({fileName: 'Peers', msg: 'Peer Detached: ' + req.params.peerId});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Detached', data: req.params.peerId});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peer Disconnected'});
res.status(204).json({});
}
})
@ -90,7 +96,7 @@ exports.deletePeer = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'Peers', lineNum: 89, msg: 'Detach Peer Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Detach Peer Error', error: err});
return res.status(500).json({
message: "Detach Peer Failed!",
error: err.error

View File

@ -1,5 +1,5 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
@ -35,10 +35,10 @@ arrangeChannels = (simplifiedChannels) => {
});
lightningBalances = { localBalance: totalLocalBalance, remoteBalance: totalRemoteBalance };
activeChannels = common.sortDescByKey(activeChannels, 'balancedness');
logger.info({fileName: 'Channels', msg: 'Lightning Balances: ' + JSON.stringify(lightningBalances)});
logger.info({fileName: 'Channels', msg: 'Active Channels: ' + JSON.stringify(activeChannels)});
logger.info({fileName: 'Channels', msg: 'Pending Channels: ' + JSON.stringify(pendingChannels)});
logger.info({fileName: 'Channels', msg: 'Inactive Channels: ' + JSON.stringify(inactiveChannels)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Lightning Balances', data: lightningBalances});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Active Channels', data: activeChannels});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Pending Channels', data: pendingChannels});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Inactive Channels', data: inactiveChannels});
return ({activeChannels: activeChannels, pendingChannels: pendingChannels, inactiveChannels: inactiveChannels, lightningBalances: lightningBalances, channelStatus: channelStatus});
};
@ -58,49 +58,51 @@ simplifyAllChannels = (channels) => {
isFunder: channel.data && channel.data.commitments && channel.data.commitments.localParams && channel.data.commitments.localParams.isFunder ? channel.data.commitments.localParams.isFunder : false,
buried: channel.data && channel.data.buried ? channel.data.buried : false,
feeBaseMsat: channel.data && channel.data.channelUpdate && channel.data.channelUpdate.feeBaseMsat ? channel.data.channelUpdate.feeBaseMsat : 0,
feeRatePerKw: (channel.data.commitments.localCommit.spec.feeratePerKw) ? channel.data.commitments.localCommit.spec.feeratePerKw : 0,
feeProportionalMillionths: channel.data && channel.data.channelUpdate && channel.data.channelUpdate.feeProportionalMillionths ? channel.data.channelUpdate.feeProportionalMillionths : 0,
alias: ''
});
});
channelNodeIds = channelNodeIds.substring(1);
return new Promise(function(resolve, reject) {
options.url = common.getSelLNServerUrl() + '/nodes';
options.form = { nodeIds: channelNodeIds };
logger.info({fileName: 'Channels', msg: 'Node Ids to find alias: ' + channelNodeIds});
request.post(options).then(function(nodes) {
logger.info({fileName: 'Channels', msg: 'Filtered Nodes: ' + JSON.stringify(nodes)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Node Ids to find alias', data: channelNodeIds});
return request.post(options).then(function(nodes) {
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Filtered Nodes', data: nodes});
let foundPeer = {};
simplifiedChannels.map(channel => {
foundPeer = nodes.find(channelWithAlias => channel.nodeId === channelWithAlias.nodeId);
channel.alias = foundPeer ? foundPeer.alias : channel.nodeId.substring(0, 20);
});
resolve(simplifiedChannels);
return simplifiedChannels;
}).catch(err => {
resolve(simplifiedChannels);
});
return simplifiedChannels;
});
};
exports.getChannels = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'List Channels..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/channels';
options.form = {};
if (req.query && req.query.nodeId) {
options.form = req.query;
logger.info({fileName: 'Channels', msg: 'Channels Node Id: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Channels Node Id', data: options.form});
}
logger.info({fileName: 'Channels', msg: 'Options: ' + JSON.stringify(options)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Options', data: options});
if (common.read_dummy_data) {
common.getDummyData('Channels').then(function(data) { res.status(200).json(arrangeChannels(data)); });
} else {
request.post(options).then(function (body) {
logger.info({fileName: 'Channels', msg: 'All Channels: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'All Channels', data: body});
if(body && body.length) {
simplifyAllChannels(body).then(function(simplifiedChannels) {
logger.info({fileName: 'Channels', msg: 'Simplified Channels with Alias: ' + JSON.stringify(simplifiedChannels)});
return simplifyAllChannels(body).then(function(simplifiedChannels) {
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Simplified Channels with Alias', data: simplifiedChannels});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channels List Received'});
res.status(200).json(arrangeChannels(simplifiedChannels));
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Empty Channels List Received'});
res.status(200).json({activeChannels: [], pendingChannels: [], inactiveChannels: [], lightningBalances: { localBalance: 0, remoteBalance: 0 }, channelStatus: {active: { channels: 0, capacity: 0 }, inactive: { channels: 0, capacity: 0 }, pending: { channels: 0, capacity: 0 }}});
}
})
@ -112,7 +114,7 @@ exports.getChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Channels', lineNum: 35, msg: 'Get Channels Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Get Channels Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: 'Fetching Channels Failed!',
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -122,11 +124,13 @@ exports.getChannels = (req, res, next) => {
};
exports.getChannelStats = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Getting Channel States..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/channelstats';
options.form = {};
request.post(options).then((body) => {
logger.info({fileName: 'ChannelStats', msg: 'Channel Stats Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Channel Stats Response', data: body});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel States Received'});
res.status(201).json(body);
})
.catch(errRes => {
@ -137,7 +141,7 @@ exports.getChannelStats = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'ChannelStats', lineNum: 54, msg: 'Get Channel Stats Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'ChannelStats', msg: 'Get Channel Stats Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Channel Stats Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -146,19 +150,21 @@ exports.getChannelStats = (req, res, next) => {
}
exports.openChannel = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Opening Channel..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/open';
options.form = req.body;
logger.info({fileName: 'Channels', msg: 'Open Channel Params: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Params', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Open Channel Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Open Channel Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 140, msg: 'Open Channel Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Open Channel Error', error: body.error});
res.status(500).json({
message: 'Open Channel Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Opened'});
res.status(201).json(body);
}
})
@ -170,7 +176,7 @@ exports.openChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Channels', lineNum: 58, msg: 'Open Channel Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Open Channel Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Open Channel Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -179,12 +185,14 @@ exports.openChannel = (req, res, next) => {
}
exports.updateChannelRelayFee = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Updating Channel Relay Fee..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/updaterelayfee';
options.form = req.query;
logger.info({fileName: 'Channels', msg: 'Update Relay Fee Params: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Update Relay Fee Params', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Update Relay Fee Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Update Relay Fee Response', data: body});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Relay Fee Updated'});
res.status(201).json(body);
})
.catch(errRes => {
@ -195,7 +203,7 @@ exports.updateChannelRelayFee = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Channels', lineNum: 186, msg: 'Update Relay Fee Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Update Relay Fee Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Update Relay Fee Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -206,15 +214,17 @@ exports.updateChannelRelayFee = (req, res, next) => {
exports.closeChannel = (req, res, next) => {
options = common.getOptions();
if (req.query.force !== 'true') {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Closing Channel..'});
options.url = common.getSelLNServerUrl() + '/close';
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Force Closing Channel..'});
options.url = common.getSelLNServerUrl() + '/forceclose';
}
options.form = { channelId: req.query.channelId };
logger.info({fileName: 'Channels', msg: 'Close Channel URL: ' + JSON.stringify(options.url)});
logger.info({fileName: 'Channels', msg: 'Close Channel Params: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: '[Close URL, Close Params]', data: [options.url, options.form]});
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Close Channel Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Close Channel Response', data: body});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Closed'});
res.status(204).json(body);
})
.catch(errRes => {
@ -225,7 +235,7 @@ exports.closeChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Channels', lineNum: 217, msg: 'Close Channel Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Close Channel Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Close Channel Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"

View File

@ -1,16 +1,14 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
arrangeFees = (body, current_time) => {
let fees = { daily_fee: 0, daily_txs: 0, weekly_fee: 0, weekly_txs: 0, monthly_fee: 0, monthly_txs: 0 };
let month_start_time = current_time - 2629743000;
let week_start_time = current_time - 604800000;
let day_start_time = current_time - 86400000;
let fee = 0;
body.relayed.forEach(relayedEle => {
logger.info({fileName: 'Fees', msg: 'Fee Relayed Transaction: ' + JSON.stringify(relayedEle)});
fee = Math.round((relayedEle.amountIn - relayedEle.amountOut)/1000);
if (relayedEle.timestamp >= day_start_time) {
fees.daily_fee = fees.daily_fee + fee;
@ -20,12 +18,10 @@ arrangeFees = (body, current_time) => {
fees.weekly_fee = fees.weekly_fee + fee;
fees.weekly_txs = fees.weekly_txs + 1;
}
if (relayedEle.timestamp >= month_start_time) {
fees.monthly_fee = fees.monthly_fee + fee;
fees.monthly_txs = fees.monthly_txs + 1;
}
});
logger.info({fileName: 'Fees', msg: JSON.stringify(fees)});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Arranged Fee', data: fees});
return fees;
};
@ -39,10 +35,8 @@ arrangePayments = (body) => {
if (sentEle.recipientAmount) { sentEle.recipientAmount = Math.round(sentEle.recipientAmount/1000); }
if (sentEle.parts && sentEle.parts.length > 0) {
sentEle.firstPartTimestamp = sentEle.parts[0].timestamp;
sentEle.firstPartTimestampStr = (!sentEle.firstPartTimestamp) ? '' : common.convertTimestampToDate(Math.round(sentEle.firstPartTimestamp / 1000));
}
sentEle.parts.forEach(part => {
part.timestampStr = (!part.timestamp) ? '' : common.convertTimestampToDate(Math.round(part.timestamp / 1000));
if (part.amount) { part.amount = Math.round(part.amount/1000); }
if (part.feesPaid) { part.feesPaid = Math.round(part.feesPaid/1000); }
});
@ -50,41 +44,40 @@ arrangePayments = (body) => {
payments.received.forEach(receivedEle => {
if (receivedEle.parts && receivedEle.parts.length > 0) {
receivedEle.firstPartTimestamp = receivedEle.parts[0].timestamp;
receivedEle.firstPartTimestampStr = (!receivedEle.firstPartTimestamp) ? '' : common.convertTimestampToDate(Math.round(receivedEle.firstPartTimestamp / 1000));
}
receivedEle.parts.forEach(part => {
part.timestampStr = (!part.timestamp) ? '' : common.convertTimestampToDate(Math.round(part.timestamp / 1000));
if (part.amount) { part.amount = Math.round(part.amount/1000); }
});
});
payments.relayed.forEach(relayedEle => {
logger.info({fileName: 'Fees', msg: 'Payment Relayed Transaction: ' + JSON.stringify(relayedEle)});
relayedEle.timestampStr = (!relayedEle.timestamp) ? '' : common.convertTimestampToDate(Math.round(relayedEle.timestamp / 1000));
if (relayedEle.amountIn) { relayedEle.amountIn = Math.round(relayedEle.amountIn/1000); }
if (relayedEle.amountOut) { relayedEle.amountOut = Math.round(relayedEle.amountOut/1000); }
});
payments.sent = common.sortDescByKey(payments.sent, 'firstPartTimestamp');
payments.received = common.sortDescByKey(payments.received, 'firstPartTimestamp');
payments.relayed = common.sortDescByKey(payments.relayed, 'timestamp');
logger.info({fileName: 'Fees', msg: JSON.stringify(payments)});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Arranged Payments', data: payments});
return payments;
};
exports.getFees = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Getting Fees..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/audit';
let today = new Date(Date.now());
let tillToday = Math.floor(today / 1000);
let fromLastMonth = Math.round((new Date(today.getFullYear(), today.getMonth() - 1, today.getDate() + 1, 0, 0, 0).getTime()) / 1000);
let tillToday = (Math.round(today.getTime()/1000)).toString();
let fromLastMonth = (Math.round(new Date(today.getFullYear(), today.getMonth() - 1, today.getDate() + 1, 0, 0, 0).getTime()/1000)).toString();
options.form = {
from: fromLastMonth,
to: tillToday
};
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Fee Audit Options', data: options.form});
if (common.read_dummy_data) {
common.getDummyData('Fees').then(function(data) { res.status(200).json(arrangeFees(data, 1609796725000)); });
common.getDummyData('Fees').then(function(data) { res.status(200).json(arrangeFees(data, Math.round((new Date().getTime())))); });
} else {
request.post(options).then((body) => {
logger.info({fileName: 'Fees', msg: 'Fee Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Fee Response', data: body});
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Fee Received'});
res.status(200).json(arrangeFees(body, Math.round((new Date().getTime()))));
})
.catch(errRes => {
@ -95,7 +88,7 @@ exports.getFees = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Fees', lineNum: 51, msg: 'Get Fees Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Fees', msg: 'Get Fees Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Fetching Fees failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -105,6 +98,7 @@ exports.getFees = (req, res, next) => {
};
exports.getPayments = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Getting Payments..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/audit';
options.form = null;
@ -112,7 +106,8 @@ exports.getPayments = (req, res, next) => {
common.getDummyData('Payments').then(function(data) { res.status(200).json(arrangePayments(data)); });
} else {
request.post(options).then((body) => {
logger.info({fileName: 'Fees', msg: 'Payments Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Payments Response', data: body});
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Payments Received'});
res.status(200).json(arrangePayments(body));
})
.catch(errRes => {
@ -123,7 +118,7 @@ exports.getPayments = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Fees', lineNum: 113, msg: 'Get Payments Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Fees', msg: 'Get Payments Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Fetching Payments failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"

View File

@ -1,15 +1,16 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getInfo = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'GetInfo', msg: 'Getting Eclair Node Information..'});
common.setOptions();
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/getinfo';
options.form = {};
logger.info({fileName:'GetInfo', msg: 'Selected Node: ' + JSON.stringify(common.selectedNode.ln_node)});
logger.info({fileName: 'GetInfo', msg: 'Calling Info from Eclair server url: ' + options.url});
logger.log({level: 'DEBUG', fileName:'GetInfo', msg: 'Selected Node', data: common.selectedNode.ln_node});
logger.log({level: 'DEBUG', fileName: 'GetInfo', msg: 'Calling Info from Eclair server url', data: options.url});
if (common.read_dummy_data) {
common.getDummyData('GetInfo').then(function(data) {
data.currency_unit = 'BTC';
@ -19,19 +20,20 @@ exports.getInfo = (req, res, next) => {
});
} else {
if (!options.headers || !options.headers.authorization) {
logger.error({fileName: 'GetInfo', lineNum: 13, msg: 'Eclair Get info failed due to missing or wrong password!'});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'Eclair Get info failed due to missing or wrong password!', error: {error: 'Missing or wrong password.'}});
res.status(502).json({
message: "Fetching Info Failed!",
error: "Missing Or Wrong Password"
});
} else {
request.post(options).then((body) => {
logger.info({fileName: 'GetInfo', msg: 'Get Info Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'GetInfo', msg: 'Get Info Response', data: body});
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
body.currency_unit = 'BTC';
body.smaller_currency_unit = 'Sats';
body.lnImplementation = 'Eclair';
logger.log({level: 'INFO', fileName: 'GetInfo', msg: 'Eclair Node Information Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -42,7 +44,7 @@ exports.getInfo = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'GetInfo', lineNum: 57, msg: 'Get Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'Get Info Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Fetching Info failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"

View File

@ -1,42 +1,37 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
var pendingInvoices = [];
getReceivedPaymentInfo = (invoice) => {
logger.info({fileName: 'Invoice', msg: 'Invoice Received: ' + JSON.stringify(invoice)});
let idx = -1;
return new Promise(function(resolve, reject) {
invoice.timestampStr = (!invoice.timestamp) ? '' : common.convertTimestampToDate(invoice.timestamp);
invoice.expiresAt = (!invoice.expiry) ? null : (+invoice.timestamp + +invoice.expiry);
invoice.expiresAtStr = (!invoice.expiresAt) ? '' : common.convertTimestampToDate(invoice.expiresAt);
if (invoice.amount) { invoice.amount = Math.round(invoice.amount/1000); }
idx = pendingInvoices.findIndex(pendingInvoice => invoice.serialized === pendingInvoice.serialized);
if (idx < 0) {
options.url = common.getSelLNServerUrl() + '/getreceivedinfo';
options.form = { paymentHash: invoice.paymentHash };
request(options).then(response => {
return request(options).then(response => {
invoice.status = response.status.type;
if (response.status && response.status.type === 'received') {
invoice.amountSettled = response.status.amount ? Math.round(response.status.amount/1000) : 0;
invoice.receivedAt = response.status.receivedAt ? Math.round(response.status.receivedAt / 1000) : 0;
invoice.receivedAtStr = response.status.receivedAt ? common.convertTimestampToDate(invoice.receivedAt) : '';
}
resolve(invoice);
return invoice;
}).catch(err => {
invoice.status = 'unknown';
resolve(invoice);
return invoice;
});
} else {
pendingInvoices.splice(idx, 1);
invoice.status = 'unpaid';
resolve(invoice);
return invoice;
}
});
}
exports.listInvoices = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Getting List Invoices..'});
options = common.getOptions();
options.form = {};
options1 = JSON.parse(JSON.stringify(options));
@ -45,16 +40,28 @@ exports.listInvoices = (req, res, next) => {
options2 = JSON.parse(JSON.stringify(options));
options2.url = common.getSelLNServerUrl() + '/listpendinginvoices';
options2.form = {};
Promise.all([request(options1), request(options2)])
if (common.read_dummy_data) {
common.getDummyData('Invoices').then(function(body) {
let invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
return Promise.all(invoices.map(invoice => getReceivedPaymentInfo(invoice)))
.then(values => {
body = common.sortDescByKey(invoices, 'expiresAt');
res.status(200).json(invoices);
});
});
} else {
return Promise.all([request(options1), request(options2)])
.then(body => {
logger.info({fileName: 'Invoice', msg: 'Invoices List Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body});
let invoices = (!body[0] || body[0].length <= 0) ? [] : body[0];
pendingInvoices = (!body[1] || body[1].length <= 0) ? [] : body[1];
if (invoices && invoices.length > 0) {
Promise.all(invoices.map(invoice => getReceivedPaymentInfo(invoice)))
return Promise.all(invoices.map(invoice => getReceivedPaymentInfo(invoice)))
.then(values => {
body = common.sortDescByKey(invoices, 'expiresAt');
logger.info({fileName: 'Invoice', msg: 'Final Invoices List: ' + JSON.stringify(invoices)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Final Invoices List', data: invoices});
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'List Invoices Received'});
res.status(200).json(invoices);
})
.catch(errRes => {
@ -65,13 +72,14 @@ exports.listInvoices = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Invoice', lineNum: 66, msg: 'List Invoices Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'List Invoices Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Fetching Invoices failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
});
});
} else {
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Empty List Invoice Received'});
res.status(200).json([]);
}
})
@ -83,21 +91,24 @@ exports.listInvoices = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Invoice', lineNum: 84, msg: 'List Invoices Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'List Invoices Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Fetching Invoices failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
});
});
}
};
exports.createInvoice = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Creating Invoice..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/createinvoice';
options.form = req.body;
request.post(options).then((body) => {
logger.info({fileName: 'Invoice', msg: 'Create Invoice Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Create Invoice Response', data: body});
if (body.amount) { body.amount = Math.round(body.amount/1000); }
logger.log({level: 'INFO', fileName: 'Invoices', msg: 'Invoice Created'});
res.status(201).json(body);
})
.catch(errRes => {
@ -108,7 +119,7 @@ exports.createInvoice = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Invoice', lineNum: 108, msg: 'Create Invoice Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Create Invoice Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Create Invoice Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"

View File

@ -1,17 +1,16 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getNodes = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Network', msg: 'Node Lookup..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/nodes';
options.form = { nodeIds: req.params.id };
request.post(options).then(function (body) {
logger.info({fileName: 'Network', msg: 'Node Lookup: ' + JSON.stringify(body)});
body.forEach(node => {
node.timestampStr = (node.timestamp) ? common.convertTimestampToDate(node.timestamp) : '';
});
logger.log({level: 'DEBUG', fileName: 'Network', msg: 'Node Lookup', data: body});
logger.log({level: 'INFO', fileName: 'Network', msg: 'Node Lookup Finished'});
res.status(200).json(body);
})
.catch(errRes => {
@ -22,7 +21,7 @@ exports.getNodes = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Network', lineNum: 49, msg: 'Node Lookup Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Network', msg: 'Node Lookup Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: 'Node Lookup Failed!',
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"

View File

@ -1,5 +1,5 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
@ -22,11 +22,13 @@ arrangeBalances = (body) => {
};
exports.getNewAddress = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'Generating New Address..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/getnewaddress';
options.form = {};
request.post(options).then((body) => {
logger.info({fileName: 'Onchain', msg: JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Onchain', msg: 'New Address Generated', data: body});
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'New Address Generated'});
res.status(200).json(body);
})
.catch(errRes => {
@ -37,7 +39,7 @@ exports.getNewAddress = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Onchain', lineNum: 21, msg: 'Get New Address Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Onchain', msg: 'Get New Address Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Getting New Address failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -46,6 +48,7 @@ exports.getNewAddress = (req, res, next) => {
};
exports.getBalance = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'Getting On Chain Balance..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/onchainbalance';
options.form = {};
@ -53,7 +56,8 @@ exports.getBalance = (req, res, next) => {
common.getDummyData('OnChainBalance').then(function(data) { res.status(200).json(arrangeBalances(data)); });
} else {
request.post(options).then((body) => {
logger.info({fileName: 'Onchain', msg: 'Balance Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Onchain', msg: 'Balance Received', data: body});
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'On Chain Balance Received'});
res.status(200).json(arrangeBalances(body));
})
.catch(errRes => {
@ -64,7 +68,7 @@ exports.getBalance = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Onchain', lineNum: 58, msg: 'Fetch Balance Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Onchain', msg: 'Fetch Balance Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Fetching balance failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -74,20 +78,20 @@ exports.getBalance = (req, res, next) => {
};
exports.getTransactions = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'Getting On Chain Transactions..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/onchaintransactions';
options.form = {
count: req.query.count,
skip: req.query.skip
};
logger.log({level: 'DEBUG', fileName: 'OnChain', msg: 'Getting On Chain Transactions Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Transactions', msg: 'Transaction Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'OnChain', msg: 'Transaction Received', data: body});
if (body && body.length > 0) {
body.forEach(transaction => {
transaction.timestampStr = (!transaction.timestamp) ? '' : common.convertTimestampToDate(transaction.timestamp);
});
body = common.sortDescByKey(body, 'timestamp');
}
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'On Chain Transaction Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -98,7 +102,7 @@ exports.getTransactions = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Onchain', lineNum: 101, msg: 'Get Transactions Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Onchain', msg: 'Get Transactions Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Getting transactions failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -107,6 +111,7 @@ exports.getTransactions = (req, res, next) => {
};
exports.sendFunds = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'Sending On Chain Funds..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/sendonchain';
options.form = {
@ -114,8 +119,10 @@ exports.sendFunds = (req, res, next) => {
amountSatoshis: req.body.amount,
confirmationTarget: req.body.blocks
};
logger.log({level: 'DEBUG', fileName: 'Onchain', msg: 'Send Funds Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Onchain', msg: 'Send Funds Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Onchain', msg: 'Send Funds Response', data: body});
logger.log({level: 'INFO', fileName: 'OnChain', msg: 'On Chain Fund Sent'});
res.status(201).json(body);
})
.catch(errRes => {
@ -126,7 +133,7 @@ exports.sendFunds = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Onchain', lineNum: 129, msg: 'Send Funds Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Onchain', msg: 'Send Funds Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Send funds failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"

View File

@ -1,29 +1,28 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
getQueryNodes = (nodeIds) => {
return new Promise(function(resolve, reject) {
options.url = common.getSelLNServerUrl() + '/nodes';
options.form = { nodeIds: nodeIds };
request.post(options).then(function(nodes) {
logger.info({fileName: 'Payments', msg: 'Query Nodes: ' + JSON.stringify(nodes)});
resolve(nodes);
return request.post(options).then(function(nodes) {
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Query Nodes', data: nodes});
return nodes;
}).catch(err => {
resolve([]);
});
return [];
});
}
exports.decodePayment = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Decoding Payment..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/parseinvoice';
options.form = { invoice: req.params.invoice };
request.post(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Payment Decode Received: ' + JSON.stringify(body)});
body.timestampStr = (!body.timestamp) ? '' : common.convertTimestampToDate(body.timestamp);
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Payment Decode Received', data: body});
if (body.amount) { body.amount = Math.round(body.amount/1000); }
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Payment Decoded'});
res.status(200).json(body);
})
.catch(errRes => {
@ -34,7 +33,7 @@ exports.decodePayment = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Payments', lineNum: 22, msg: 'Payment Decode Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Payment Decode Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Payment Decode Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -43,11 +42,14 @@ exports.decodePayment = (req, res, next) => {
};
exports.postPayment = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Paying Invoice..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/payinvoice';
options.form = req.body;
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Send Payment Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Send Payment Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Send Payment Response', data: body});
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Invoice Paid'});
res.status(201).json(body);
})
.catch(errRes => {
@ -58,7 +60,7 @@ exports.postPayment = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Payments', lineNum: 46, msg: 'Send Payment Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Send Payment Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Send Payment Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -67,26 +69,30 @@ exports.postPayment = (req, res, next) => {
};
exports.queryPaymentRoute = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Querying Payment Route..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/findroutetonode';
options.form = {
nodeId: req.query.nodeId,
amountMsat: req.query.amountMsat
};
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Query Payment Route Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Query Payment Route Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Query Payment Route Received', data: body});
if (body && body.length) {
let queryRoutes = [];
getQueryNodes(body).then(function(hopsWithAlias) {
return getQueryNodes(body).then(function(hopsWithAlias) {
let foundPeer = {};
body.map(hop => {
foundPeer = hopsWithAlias.find(hopWithAlias => hop === hopWithAlias.nodeId);
queryRoutes.push({nodeId: hop, alias: foundPeer ? foundPeer.alias : ''});
});
logger.info({fileName: 'Payments', msg: 'Query Routes with Alias: ' + JSON.stringify(queryRoutes)});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Query Routes with Alias', data: queryRoutes});
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Payment Route Information Received'});
res.status(200).json(queryRoutes);
});
} else {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Empty Payment Route Information Received'});
res.status(200).json([]);
}
})
@ -98,7 +104,7 @@ exports.queryPaymentRoute = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Payments', lineNum: 109, msg: 'Query Payment Route Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Query Payment Route Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Query Payment Route Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -107,12 +113,15 @@ exports.queryPaymentRoute = (req, res, next) => {
};
exports.getSentPaymentsInformation = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Getting Sent Payment Information..'});
options = common.getOptions();
if (req.body.payments) {
let paymentsArr = req.body.payments.split(',');
Promise.all(paymentsArr.map(payment => {return getSentInfoFromPaymentRequest(payment)}))
return Promise.all(paymentsArr.map(payment => {return getSentInfoFromPaymentRequest(payment)}))
.then(function(values) {
logger.info({fileName: 'Payments', msg: 'Payment Sent Informations: ' + JSON.stringify(values)});
console.warn(values);
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Payment Sent Informations', data: values});
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Sent Payment Information Received'});
res.status(200).json(values);
})
.catch(errRes => {
@ -123,13 +132,14 @@ exports.getSentPaymentsInformation = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Payments', lineNum: 126, msg: 'Payment Sent Information Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'Payment Sent Information Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Payment Sent Information Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
});
});
} else {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Empty Sent Payment Information Received'});
res.status(200).json([]);
}
};
@ -137,16 +147,13 @@ exports.getSentPaymentsInformation = (req, res, next) => {
getSentInfoFromPaymentRequest = (payment) => {
options.url = common.getSelLNServerUrl() + '/getsentinfo';
options.form = { paymentHash: payment };
return new Promise(function(resolve, reject) {
request.post(options).then((body) => {
logger.info({fileName: 'Payments', msg: 'Payment Sent Information Received: ' + JSON.stringify(body)});
return request.post(options).then((body) => {
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Payment Sent Information Received', data: body});
body.forEach(sentPayment => {
sentPayment.createdAtStr = (!sentPayment.createdAt) ? '' : common.convertTimestampToDate(sentPayment.createdAt);
if (sentPayment.amount) { sentPayment.amount = Math.round(sentPayment.amount/1000); }
if (sentPayment.recipientAmount) { sentPayment.recipientAmount = Math.round(sentPayment.recipientAmount/1000); }
});
resolve(body);
return body;
})
.catch(err => resolve(err));
});
.catch(err => err);
}

View File

@ -1,22 +1,21 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
getFilteredNodes = (peersNodeIds) => {
return new Promise(function(resolve, reject) {
options.url = common.getSelLNServerUrl() + '/nodes';
options.form = { nodeIds: peersNodeIds };
request.post(options).then(function(nodes) {
logger.info({fileName: 'Peers', msg: 'Filtered Nodes: ' + JSON.stringify(nodes)});
resolve(nodes);
return request.post(options).then(function(nodes) {
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Filtered Nodes', data: nodes});
return nodes;
}).catch(err => {
resolve([]);
});
return [];
});
}
exports.getPeers = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Getting Peers..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/peers';
options.form = {};
@ -24,22 +23,24 @@ exports.getPeers = (req, res, next) => {
common.getDummyData('Peers').then(function(data) { res.status(200).json(data); });
} else {
request.post(options).then(function (body) {
logger.info({fileName: 'Peers', msg: 'Peers Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peers Received', data: body});
if (body && body.length) {
let peersNodeIds = '';
body.forEach(peer => { peersNodeIds = peersNodeIds + ',' + peer.nodeId; });
peersNodeIds = peersNodeIds.substring(1);
getFilteredNodes(peersNodeIds).then(function(peersWithAlias) {
return getFilteredNodes(peersNodeIds).then(function(peersWithAlias) {
let foundPeer = {};
body.map(peer => {
foundPeer = peersWithAlias.find(peerWithAlias => peer.nodeId === peerWithAlias.nodeId);
peer.alias = foundPeer ? foundPeer.alias : peer.nodeId.substring(0, 20);
});
body = common.sortDescByStrKey(body, 'alias');
logger.info({fileName: 'Peers', msg: 'Peers with Alias: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peers with Alias', data: body});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peers Received'});
res.status(200).json(body);
});
} else {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Empty Peers Received'});
res.status(200).json([]);
}
})
@ -51,7 +52,7 @@ exports.getPeers = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Peers', lineNum: 49, msg: 'Get Peers Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Get Peers Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: 'Fetching Peers Failed!',
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -61,15 +62,16 @@ exports.getPeers = (req, res, next) => {
};
exports.connectPeer = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Conneting Peer..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/connect';
options.form = {};
if (req.query) {
options.form = req.query;
logger.info({fileName: 'Peers', msg: 'Connect Peer Params: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Connect Peer Params', data: options.form});
}
request.post(options, (error, response, body) => {
logger.info({fileName: 'Peers', msg: 'Add Peer Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Add Peer Response', data: body});
if (body === 'already connected') {
return res.status(500).json({
message: "Connect Peer Failed!",
@ -84,12 +86,12 @@ exports.connectPeer = (req, res, next) => {
options.url = common.getSelLNServerUrl() + '/peers';
options.form = {};
request.post(options).then(function (body) {
logger.info({fileName: 'Peers', msg: 'Peers Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peers Received', data: body});
if (body && body.length) {
let peersNodeIds = '';
body.forEach(peer => { peersNodeIds = peersNodeIds + ',' + peer.nodeId; });
peersNodeIds = peersNodeIds.substring(1);
getFilteredNodes(peersNodeIds).then(function(peersWithAlias) {
return getFilteredNodes(peersNodeIds).then(function(peersWithAlias) {
let foundPeer = {};
body.map(peer => {
foundPeer = peersWithAlias.find(peerWithAlias => peer.nodeId === peerWithAlias.nodeId);
@ -97,8 +99,9 @@ exports.connectPeer = (req, res, next) => {
});
let peers = (body) ? common.sortDescByStrKey(body, 'alias') : [];
peers = common.newestOnTop(peers, 'nodeId', req.query.nodeId ? req.query.nodeId : req.query.uri ? req.query.uri.substring(0, req.query.uri.indexOf('@')) : '');
logger.info({fileName: 'Peers', msg: 'Peer with Newest On Top: ' + JSON.stringify(peers)});
logger.info({fileName: 'Peers', msg: 'Peer Added Successfully'});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer with Newest On Top', data: peers});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Added Successfully'});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peer Connected'});
res.status(201).json(peers);
});
} else {
@ -112,7 +115,7 @@ exports.connectPeer = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Peers', lineNum: 89, msg: 'Connect Peer Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Connect Peer Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Connect Peer Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -126,7 +129,7 @@ exports.connectPeer = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Peers', lineNum: 103, msg: 'Connect Peer Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Connect Peer Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Connect Peer Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"
@ -135,16 +138,18 @@ exports.connectPeer = (req, res, next) => {
};
exports.deletePeer = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Disconneting Peer..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/disconnect';
options.form = {};
if (req.params.nodeId) {
options.form = { nodeId: req.params.nodeId };
logger.info({fileName: 'Peers', msg: 'Disconnect Peer Params: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Disconnect Peer Params', data: options.form});
}
request.post(options, (error, response, body) => {
logger.info({fileName: 'Peers', msg: 'Disconnect Peer Response: ' + JSON.stringify(body)});
logger.info({fileName: 'Peers', msg: 'Peer Disconnected: ' + req.params.nodeId});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Disconnect Peer Response', data: body});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Disconnected: ' + req.params.nodeId});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peer Disconnected'});
res.status(204).json(body);
})
.catch(errRes => {
@ -155,7 +160,7 @@ exports.deletePeer = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.authorization) {
delete err.response.request.headers.authorization;
}
logger.error({fileName: 'Peers', lineNum: 132, msg: 'Disconnect Peer Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Disconnect Peer Error', error: err});
return res.status(err.statusCode ? err.statusCode : 500).json({
message: "Disconnect Peer Failed!",
error: err.error && err.error.error ? err.error.error : err.error ? err.error : "Unknown Server Error"

View File

@ -1,14 +1,15 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getBalance = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Balance', msg: 'Getting Balance..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/balance/' + req.params.source;
options.qs = req.query;
request(options).then((body) => {
logger.info({fileName: 'Balance', msg: 'Request params: ' + JSON.stringify(req.params) + 'Request Query: ' + JSON.stringify(req.query) + ' Balance Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Balance', msg: '[Request params, Request Query, Balance Received]', data: [req.params, req.query, body]});
if (body) {
if (req.params.source === 'blockchain') {
if (!body.total_balance) { body.total_balance = 0; }
@ -24,6 +25,7 @@ exports.getBalance = (req, res, next) => {
body.btc_balance = common.convertToBTC(body.balance);
body.btc_pending_open_balance = common.convertToBTC(body.pending_open_balance);
}
logger.log({level: 'INFO', fileName: 'Balance', msg: 'Balance Received'});
res.status(200).json(body);
}
})
@ -35,7 +37,7 @@ exports.getBalance = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Balance', lineNum: 38, msg: 'Fetch Balance Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Balance', msg: 'Fetch Balance Error', error: err});
return res.status(500).json({
message: "Fetching balance failed!",
error: err.error

View File

@ -1,25 +1,24 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
getAliasForChannel = (channel) => {
return new Promise(function(resolve, reject) {
let pubkey = (channel.remote_pubkey) ? channel.remote_pubkey : (channel.remote_node_pub) ? channel.remote_node_pub : '';
options.url = common.getSelLNServerUrl() + '/v1/graph/node/' + pubkey;
request(options).then(function(aliasBody) {
logger.info({fileName: 'Channels', msg: 'Alias: ' + JSON.stringify(aliasBody.node.alias)});
return request(options).then(function(aliasBody) {
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Alias', data: aliasBody.node.alias});
channel.remote_alias = aliasBody.node.alias;
resolve(aliasBody.node.alias);
return aliasBody.node.alias;
})
.catch(err => {
channel.remote_alias = pubkey.slice(0, 10) + '...' + pubkey.slice(-10);
resolve(pubkey);
});
return pubkey;
});
}
exports.getAllChannels = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Getting Channels..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channels';
options.qs = req.query;
@ -27,9 +26,9 @@ exports.getAllChannels = (req, res, next) => {
let remote = 0;
let total = 0;
request(options).then(function (body) {
logger.info({fileName: 'Channels', msg: 'All Channels Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'All Channels Received', data: body});
if(body.channels) {
Promise.all(
return Promise.all(
body.channels.map(channel => {
local = (channel.local_balance) ? +channel.local_balance : 0;
remote = (channel.remote_balance) ? +channel.remote_balance : 0;
@ -40,7 +39,8 @@ exports.getAllChannels = (req, res, next) => {
)
.then(function(values) {
body.channels = common.sortDescByKey(body.channels, 'balancedness');
logger.info({fileName: 'Channels', msg: 'All Channels with Alias: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'All Channels with Alias', data: body});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channels Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -51,7 +51,7 @@ exports.getAllChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 48, msg: 'Get All Channel Alias Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Get All Channel Alias Error', error: err});
res.status(500).json({
message: 'Fetching Channels Alias Failed!',
error: err.error
@ -59,6 +59,7 @@ exports.getAllChannels = (req, res, next) => {
});
} else {
body.channels = [];
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Empty Channels Received'});
res.status(200).json(body);
}
})
@ -70,7 +71,7 @@ exports.getAllChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 66, msg: 'Get All Channels Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Get All Channels Error', error: err});
return res.status(500).json({
message: 'Fetching All Channels Failed!',
error: err.error
@ -79,6 +80,7 @@ exports.getAllChannels = (req, res, next) => {
};
exports.getPendingChannels = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Getting Pending Channels..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channels/pending';
options.qs = req.query;
@ -102,8 +104,9 @@ exports.getPendingChannels = (req, res, next) => {
if(body.waiting_close_channels && body.waiting_close_channels.length > 0) {
body.waiting_close_channels.map(channel => { return promises.push(getAliasForChannel(channel.channel))});
}
Promise.all(promises).then(function(values) {
logger.info({fileName: 'Channels', msg: 'Pending Channels: ' + JSON.stringify(body)});
return Promise.all(promises).then(function(values) {
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Pending Channels', data: body});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Pending Channels Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -114,7 +117,7 @@ exports.getPendingChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 106, msg: 'Get Pending Channel Alias Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Get Pending Channel Alias Error', error: err});
res.status(500).json({
message: 'Fetching Pending Channels Failed!',
error: err.error
@ -129,7 +132,7 @@ exports.getPendingChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 97, msg: 'Get Pending Channel Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Get Pending Channel Error', error: err});
return res.status(500).json({
message: 'Fetching Pending Channels Failed!',
error: err.error
@ -138,12 +141,13 @@ exports.getPendingChannels = (req, res, next) => {
};
exports.getClosedChannels = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Getting Closed Channels..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channels/closed';
options.qs = req.query;
request(options).then(function (body) {
if (body.channels && body.channels.length > 0) {
Promise.all(
return Promise.all(
body.channels.map(channel => {
channel.close_type = (!channel.close_type) ? 'COOPERATIVE_CLOSE' : channel.close_type;
return getAliasForChannel(channel);
@ -151,7 +155,8 @@ exports.getClosedChannels = (req, res, next) => {
)
.then(function(values) {
body.channels = common.sortDescByKey(body.channels, 'close_height');
logger.info({fileName: 'Channels', msg: 'Closed Channels: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Closed Channels', data: body});
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Closed Channels Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -162,7 +167,7 @@ exports.getClosedChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 48, msg: 'Get All Channel Alias Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Get All Channel Alias Error', error: err});
res.status(500).json({
message: 'Fetching Channels Alias Failed!',
error: err.error
@ -181,7 +186,7 @@ exports.getClosedChannels = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 126, msg: 'Get Closed Channel Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Get Closed Channel Error', error: err});
return res.status(500).json({
message: 'Fetching Closed Channels Failed!',
error: err.error
@ -190,6 +195,7 @@ exports.getClosedChannels = (req, res, next) => {
};
exports.postChannel = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Opening Channel..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channels';
options.form = {
@ -205,14 +211,15 @@ exports.postChannel = (req, res, next) => {
}
options.form = JSON.stringify(options.form);
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Channel Open Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Channel Open Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 152, msg: 'Open New Channel Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Open New Channel Error', error: body.error});
res.status(500).json({
message: 'Open Channel Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channels Opened'});
res.status(201).json(body);
}
})
@ -224,7 +231,7 @@ exports.postChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 168, msg: 'Open New Channel Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Open New Channel Error', error: err});
return res.status(500).json({
message: 'Open Channel Failed!',
error: err.error
@ -233,6 +240,7 @@ exports.postChannel = (req, res, next) => {
};
exports.postTransactions = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Sending Payment..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channels/transactions';
options.form = { payment_request: req.body.paymentReq };
@ -244,22 +252,23 @@ exports.postTransactions = (req, res, next) => {
if (req.body.allowSelfPayment) { options.form.allow_self_payment = req.body.allowSelfPayment; }
if (req.body.lastHopPubkey) { options.form.last_hop_pubkey = Buffer.from(req.body.lastHopPubkey, 'hex').toString('base64'); }
options.form = JSON.stringify(options.form);
logger.info({fileName: 'Channels', msg: 'Send Payment Options: ' + options.form});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Send Payment Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Send Payment Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Send Payment Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 200, msg: 'Send Payment Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Send Payment Error', error: body.error});
res.status(500).json({
message: 'Send Payment Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else if (body.payment_error) {
logger.error({fileName: 'Channels', lineNum: 206, msg: 'Send Payment Error: ' + JSON.stringify(body.payment_error)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Send Payment Error: ' + JSON.stringify(body.payment_error)});
res.status(500).json({
message: 'Send Payment Failed!',
error: (!body) ? 'Error From Server!' : body.payment_error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Payment Sent'});
res.status(201).json(body);
}
})
@ -271,7 +280,7 @@ exports.postTransactions = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 222, msg: 'Send Payment Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Send Payment Error', error: err});
return res.status(500).json({
message: 'Send Payment Failed!',
error: err.error
@ -280,22 +289,24 @@ exports.postTransactions = (req, res, next) => {
};
exports.closeChannel = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Closing Channel..'});
req.setTimeout(60000 * 10); // timeout 10 mins
options = common.getOptions();
let channelpoint = req.params.channelPoint.replace(':', '/');
options.url = common.getSelLNServerUrl() + '/v1/channels/' + channelpoint + '?force=' + req.query.force;
if(req.query.target_conf) { options.url = options.url + '&target_conf=' + req.query.target_conf; }
if(req.query.sat_per_byte) { options.url = options.url + '&sat_per_byte=' + req.query.sat_per_byte; }
logger.info({fileName: 'Channels', msg: 'Closing Channel: ' + options.url});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Closing Channel Options URL', data: options.url});
request.delete(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Close Channel Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Close Channel Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 241, msg: 'Close Channel Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Close Channel Error', error: body.error});
res.status(500).json({
message: 'Close Channel Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Closed'});
res.status(204).json({message: 'Channel Closed!'});
}
})
@ -307,7 +318,7 @@ exports.closeChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 257, msg: 'Close Channel Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Close Channel Error', error: err});
return res.status(500).json({
message: 'Close Channel Failed!',
error: err.error
@ -316,6 +327,7 @@ exports.closeChannel = (req, res, next) => {
}
exports.postChanPolicy = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Updating Channel Policy..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/chanpolicy';
if(req.body.chanPoint === 'all') {
@ -336,16 +348,17 @@ exports.postChanPolicy = (req, res, next) => {
chan_point: {funding_txid_str: txid_str, output_index: parseInt(output_idx)}
});
}
logger.info({fileName: 'Channels', msg: 'Update Channel Policy Options: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Update Channel Policy Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Channels', msg: 'Update Channel Policy: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Channels', msg: 'Update Channel Policy', data: body});
if(!body || body.error) {
logger.error({fileName: 'Channels', lineNum: 290, msg: 'Update Channel Policy Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Update Channel Policy Error', error: body.error});
res.status(500).json({
message: 'Update Channel Failed!',
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Channels', msg: 'Channel Policy Updated'});
res.status(201).json(body);
}
})
@ -357,7 +370,7 @@ exports.postChanPolicy = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Channels', lineNum: 306, msg: 'Update Channel Policy Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Channels', msg: 'Update Channel Policy Error', error: err});
return res.status(500).json({
message: 'Update Channel Failed!',
error: err.error

View File

@ -1,6 +1,6 @@
var request = require('request-promise');
var fs = require('fs');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
@ -27,6 +27,7 @@ function getFilesList(callback) {
}
exports.getBackup = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'ChannelBackup', msg: 'Getting Channel Backup..'});
options = common.getOptions();
let channel_backup_file = '';
let message = '';
@ -55,13 +56,13 @@ exports.getBackup = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'ChannelsBackup', lineNum: 57, msg: 'Channels Backup Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'ChannelsBackup', msg: 'Channels Backup Error', error: err});
return res.status(500).json({ message: 'Channels Backup Failed!', error: err });
}
}
}
request(options).then(function (body) {
logger.info({fileName: 'ChannelsBackup', msg: 'Channel Backup: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'ChannelsBackup', msg: 'Channel Backup', data: body});
fs.writeFile(channel_backup_file, JSON.stringify(body), function(errRes) {
if (errRes) {
let err = JSON.parse(JSON.stringify(errRes));
@ -71,9 +72,10 @@ exports.getBackup = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'ChannelsBackup', lineNum: 72, msg: 'Channels Backup Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'ChannelsBackup', msg: 'Channels Backup Error', error: err});
return res.status(500).json({ message: 'Channels Backup Failed!', error: err.error });
} else {
logger.log({level: 'INFO', fileName: 'ChannelBackup', msg: 'Channel Backup Finished'});
res.status(200).json({ message: message });
}
});
@ -86,7 +88,7 @@ exports.getBackup = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'ChannelsBackup', lineNum: 86, msg: 'Channel Backup Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'ChannelsBackup', msg: 'Channel Backup Error', error: err});
return res.status(500).json({
message: 'Channels Backup Failed!',
error: err.error
@ -95,6 +97,7 @@ exports.getBackup = (req, res, next) => {
};
exports.postBackupVerify = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'ChannelBackup', msg: 'Verifying Channel Backup..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channels/backup/verify';
let channel_verify_file = '';
@ -111,10 +114,12 @@ exports.postBackupVerify = (req, res, next) => {
delete verify_backup.single_chan_backups;
options.form = JSON.stringify(verify_backup);
} else {
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Backup Verify Error. Channel backup to verify does not Exist!', error: {error: 'Channel backup to verify does not Exist.'}});
res.status(404).json({ message: 'Channels backup to verify does not Exist!' });
}
} else {
verify_backup = '';
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Backup Verify Error. Channel backup to verify does not Exist!', error: {error: 'Channel backup to verify does not Exist.'}});
res.status(404).json({ message: 'Channels backup to verify does not Exist!' });
}
} else {
@ -126,12 +131,14 @@ exports.postBackupVerify = (req, res, next) => {
options.form = JSON.stringify({ single_chan_backups: { chan_backups: [JSON.parse(verify_backup)] } });
} else {
verify_backup = '';
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Backup Verify Error. Channel backup to verify does not Exist!', error: {error: 'Channel backup to verify does not Exist.'}});
res.status(404).json({ message: 'Channel backup to verify does not Exist!' });
}
}
if (verify_backup !== '') {
request.post(options).then(function (body) {
logger.info({fileName: 'BackupVerify', msg: 'Channel Backup Verify: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'ChannelBackup', msg: 'Channel Backup Verify', data: body});
logger.log({level: 'INFO', fileName: 'ChannelBackup', msg: 'Channel Backup Verified'});
res.status(201).json({ message: message });
})
.catch(errRes => {
@ -142,7 +149,7 @@ exports.postBackupVerify = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'BackupVerify', lineNum: 141, msg: 'Channel Backup Verify Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Backup Verify Error', error: err});
return res.status(404).json({
message: 'Channel backup to Verify failed!',
error: err.error
@ -152,6 +159,7 @@ exports.postBackupVerify = (req, res, next) => {
};
exports.postRestore = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'ChannelBackup', msg: 'Restoring Channel Backup..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/channels/backup/restore';
let channel_restore_file = '';
@ -168,6 +176,7 @@ exports.postRestore = (req, res, next) => {
restore_backup = JSON.parse(restore_backup);
options.form = JSON.stringify({multi_chan_backup: restore_backup.multi_chan_backup.multi_chan_backup});
} else {
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Restore Error.Channels backup to restore does not Exist!', error: {error: 'Channel backup to restore does not Exist.'}});
res.status(404).json({ message: 'Channels backup to restore does not Exist!' });
}
} else if (downloaded_exists) {
@ -176,10 +185,12 @@ exports.postRestore = (req, res, next) => {
restore_backup = JSON.parse(restore_backup);
options.form = JSON.stringify({multi_chan_backup: restore_backup.multi_chan_backup.multi_chan_backup});
} else {
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Restore Error. Channels backup to restore does not Exist!', error: {error: 'Channel backup to restore does not Exist.'}});
res.status(404).json({ message: 'Channels backup to restore does not Exist!' });
}
} else {
restore_backup = '';
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Restore Error. Channels backup to restore does not Exist!', error: {error: 'Channel backup to restore does not Exist.'}});
res.status(404).json({ message: 'Channels backup to restore does not Exist!' });
}
} else {
@ -191,18 +202,20 @@ exports.postRestore = (req, res, next) => {
options.form = JSON.stringify({ chan_backups: { chan_backups: [JSON.parse(restore_backup)] } });
} else {
restore_backup = '';
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Restore Error. Channels backup to restore does not Exist!', error: {error: 'Channel backup to restore does not Exist.'}});
res.status(404).json({ message: 'Channel backup to restore does not Exist!' });
}
}
if (restore_backup !== '') {
request.post(options).then(function (body) {
logger.info({fileName: 'ChannelRestore', msg: 'Channel Backup Restore: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'ChannelBackup', msg: 'Channel Backup Restore', data: body});
fs.rename(channel_restore_file, channel_restore_file + '.restored', () => {
getFilesList(getFilesListRes => {
if (getFilesListRes.error) {
logger.error({fileName: 'ChannelRestore', lineNum: 190, msg: 'Channel Restore Error: ' + JSON.stringify(getFilesListRes.error)});
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Restore Error', error: getFilesListRes.error});
return res.status(500).json({ message: 'Channel restore failed!', list: getFilesListRes });
} else {
logger.log({level: 'INFO', fileName: 'ChannelBackup', msg: 'Channel Restored'});
return res.status(201).json({ message: message, list: getFilesListRes });
}
});
@ -216,7 +229,7 @@ exports.postRestore = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'ChannelRestore', lineNum: 205, msg: 'Channel Restore Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'ChannelBackup', msg: 'Channel Restore Error', error: err});
return res.status(404).json({
message: 'Channel restore failed!',
error: err.error.error

View File

@ -1,55 +1,50 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var swtch = require('./switch');
var options = {};
exports.getFees = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Getting Fees..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/fees';
request(options).then((body) => {
logger.info({fileName: 'Fees', msg: 'Fee Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Fee Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Fees', lineNum: 13, msg: 'Get Fee Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Fees', msg: 'Get Fee Error', error: body.error});
res.status(500).json({
message: "Fetching fee failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
if (!body.day_fee_sum) {
body.day_fee_sum = 0;
body.btc_day_fee_sum = 0;
} else {
body.btc_day_fee_sum = common.convertToBTC(body.day_fee_sum);
}
if (!body.week_fee_sum) {
body.week_fee_sum = 0;
body.btc_week_fee_sum = 0;
} else {
body.btc_week_fee_sum = common.convertToBTC(body.week_fee_sum);
}
if (!body.month_fee_sum) {
body.month_fee_sum = 0;
body.btc_month_fee_sum = 0;
} else {
body.btc_month_fee_sum = common.convertToBTC(body.month_fee_sum);
}
let today = new Date(Date.now());
let current_time = Math.round((today.getTime()) / 1000);
let month_start_time = Math.round((new Date(today.getFullYear(), today.getMonth() - 1, today.getDate() + 1, 0, 0, 0).getTime()) / 1000);
let start_date = new Date(today.getFullYear(), today.getMonth(), 1, 0, 0, 0);
let current_time = (Math.round(today.getTime()/1000)).toString();
let month_start_time = (Math.round(start_date.getTime()/1000)).toString();
let week_start_time = current_time - 604800;
let day_start_time = current_time - 86400;
swtch.getAllForwardingEvents(month_start_time, current_time, 0, (history) => {
logger.info({fileName: 'Fees', msg: 'Forwarding History Received: ' + JSON.stringify(history)});
let daily_tx_count = history.forwarding_events.filter(event => event.timestamp >= day_start_time);
body.daily_tx_count = daily_tx_count && daily_tx_count.length ? daily_tx_count.length : 0;
let weekly_tx_count = history.forwarding_events.filter(event => event.timestamp >= week_start_time);
body.weekly_tx_count = weekly_tx_count && weekly_tx_count.length ? weekly_tx_count.length : 0;
body.monthly_tx_count = history.forwarding_events && history.forwarding_events.length ? history.forwarding_events.length : 0;
return swtch.getAllForwardingEvents(month_start_time, current_time, 0, (history) => {
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Forwarding History Received', data: history});
daily_sum = history.forwarding_events.reduce((acc, curr) => (curr.timestamp >= day_start_time) ? [(acc[0] + 1), (acc[1] + +curr.fee_msat)] : acc, [0, 0]);
weekly_sum = history.forwarding_events.reduce((acc, curr) => (curr.timestamp >= week_start_time) ? [(acc[0] + 1), (acc[1] + +curr.fee_msat)] : acc, [0, 0]);
monthly_sum = history.forwarding_events.reduce((acc, curr) => [(acc[0] + 1), (acc[1] + +curr.fee_msat)], [0, 0]);
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Daily Sum (Transactions, Fee)', data: daily_sum});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Weekly Sum (Transactions, Fee)', data: weekly_sum});
logger.log({level: 'DEBUG', fileName: 'Fees', msg: 'Monthly Sum (Transactions, Fee)', data: monthly_sum});
body.daily_tx_count = daily_sum[0];
body.weekly_tx_count = weekly_sum[0];
body.monthly_tx_count = monthly_sum[0];
body.day_fee_sum = (daily_sum[1] / 1000).toFixed(2);
body.week_fee_sum = (weekly_sum[1] / 1000).toFixed(2);
body.month_fee_sum = (monthly_sum[1] / 1000).toFixed(2);
body.btc_day_fee_sum = common.convertToBTC(body.day_fee_sum);
body.btc_week_fee_sum = common.convertToBTC(body.week_fee_sum);
body.btc_month_fee_sum = common.convertToBTC(body.month_fee_sum);
body.forwarding_events_history = history;
if (history.error) {
logger.error({fileName: 'Fees', lineNum: 50, msg: 'Fetch Forwarding Events Error: ' + JSON.stringify(history.error)});
logger.log({level: 'ERROR', fileName: 'Fees', msg: 'Fetch Forwarding Events Error', error: history.error});
}
logger.log({level: 'INFO', fileName: 'Fees', msg: 'Fees Received'});
res.status(200).json(body);
})
}
@ -62,7 +57,7 @@ exports.getFees = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Fees', lineNum: 63, msg: 'Fetch Forwarding Events Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Fees', msg: 'Fetch Forwarding Events Error', error: err});
return res.status(500).json({
message: "Fetching fee failed!",
error: err.error

View File

@ -1,17 +1,18 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var connect = require('../../connect');
var connect = require('../../routes/connect');
var options = {};
exports.getInfo = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'GetInfo', msg: 'Getting LND Node Information..'});
common.setOptions();
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/getinfo';
logger.info({fileName:'GetInfo', msg: 'Selected Node: ' + JSON.stringify(common.selectedNode.ln_node)});
logger.info({fileName: 'GetInfo', msg: 'Calling Info from LND server url: ' + options.url});
logger.log({level: 'DEBUG', fileName:'GetInfo', msg: 'Selected Node', data: common.selectedNode.ln_node});
logger.log({level: 'DEBUG', fileName: 'GetInfo', msg: 'Calling Info from LND server url', data: options.url});
if (!options.headers || !options.headers['Grpc-Metadata-macaroon']) {
logger.error({fileName: 'GetInfo', lineNum: 17, msg: 'LND Get info failed due to bad or missing macaroon!'});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'LND Get info failed due to bad or missing macaroon!', error: {error: 'Bad or missing macaroon.'}});
res.status(502).json({
message: "Fetching Info Failed!",
error: "Bad Macaroon"
@ -19,16 +20,17 @@ exports.getInfo = (req, res, next) => {
} else {
common.nodes.map(node => { if (node.lnImplementation === 'LND') { connect.getAllNodeAllChannelBackup(node); }});
request(options).then((body) => {
logger.info({fileName: 'GetInfo', msg: JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'GetInfo', msg: 'Node Information', data: body});
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'GetInfo', lineNum: 26, msg: 'Get Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'Get Info Error', error: body.error});
res.status(500).json({
message: "Fetching Info Failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'GetInfo', msg: 'LND Node Information Received'});
res.status(200).json(body);
}
})
@ -40,7 +42,7 @@ exports.getInfo = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'GetInfo', lineNum: 42, msg: 'Get Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'GetInfo', msg: 'Get Info Error', error: err});
return res.status(500).json({
message: "Fetching Info Failed!",
error: err.error

View File

@ -1,34 +1,33 @@
var request = require("request-promise");
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
getAliasFromPubkey = (pubkey) => {
return new Promise(function(resolve, reject) {
options.url = common.getSelLNServerUrl() + '/v1/graph/node/' + pubkey;
request(options)
.then(function(res) {
logger.info({fileName: 'Graph', msg: 'Alias: ' + JSON.stringify(res.node.alias)});
resolve(res.node.alias);
return request(options).then(function(res) {
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Alias', data: res.node.alias});
return res.node.alias;
})
.catch(err => resolve(pubkey.substring(0, 17) + '...'));
});
.catch(err => pubkey.substring(0, 17) + '...');
}
exports.getDescribeGraph = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Getting Network Graph..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/graph';
request.get(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
logger.info({fileName: 'Graph', msg: 'Describe Graph Received: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Describe Graph Received', data: body_str});
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'Graph', lineNum: 27, msg: 'Describe Graph Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Describe Graph Error', error: body.error});
res.status(500).json({
message: "Fetching Describe Graph Failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Network Graph Received'});
res.status(200).json(body);
}
})
@ -40,7 +39,7 @@ exports.getDescribeGraph = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 43, msg: 'Describe Graph Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Describe Graph Error', error: err});
return res.status(500).json({
message: "Fetching Describe Graph Failed!",
error: err.error
@ -49,14 +48,15 @@ exports.getDescribeGraph = (req, res, next) => {
};
exports.getGraphInfo = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Information..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/graph/info';
request.get(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
logger.info({fileName: 'Graph', msg: 'Network Info Received: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Network Info Received', data: body_str});
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'Graph', lineNum: 59, msg: 'Network Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Network Info Error', error: body.error});
res.status(500).json({
message: "Fetching network Info failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
@ -66,7 +66,8 @@ exports.getGraphInfo = (req, res, next) => {
body.btc_avg_channel_size = (!body.avg_channel_size) ? 0 : common.convertToBTC(body.avg_channel_size);
body.btc_min_channel_size = (!body.min_channel_size) ? 0 : common.convertToBTC(body.min_channel_size);
body.btc_max_channel_size = (!body.max_channel_size) ? 0 : common.convertToBTC(body.max_channel_size);
logger.info({fileName: 'Graph', msg: 'Network Information After Rounding and Conversion: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Network Information After Rounding and Conversion', data: body_str});
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Graph Information Received'});
res.status(200).json(body);
}
})
@ -78,7 +79,7 @@ exports.getGraphInfo = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 80, msg: 'Fetch Network Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Network Info Error', error: err});
return res.status(500).json({
message: "Fetching network Info failed!",
error: err.error
@ -87,20 +88,19 @@ exports.getGraphInfo = (req, res, next) => {
};
exports.getGraphNode = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Node Information..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/graph/node/' + req.params.pubKey;
request(options).then((body) => {
logger.info({fileName: 'Graph', msg: 'Node Info Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Node Info Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Graph', lineNum: 94, msg: 'Fetch Node Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Node Info Error', error: body.error});
res.status(500).json({
message: "Fetching node Info failed!",
error: (!body) ? 'Error From Server!' : body.error
});
}
if (body) {
body.node.last_update_str = (!body.node.last_update) ? '' : common.convertTimestampToDate(body.node.last_update);
}
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Graph Node Information Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -111,7 +111,7 @@ exports.getGraphNode = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 112, msg: 'Fetch Node Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Node Info Error', error: err});
return res.status(500).json({
message: "Fetching node Info failed!",
error: err.error
@ -120,20 +120,19 @@ exports.getGraphNode = (req, res, next) => {
};
exports.getGraphEdge = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Edge Information..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/graph/edge/' + req.params.chanid;
request(options).then((body) => {
logger.info({fileName: 'Graph', msg: 'Edge Info Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Edge Info Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Graph', lineNum: 126, msg: 'Fetch Edge Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Edge Info Error', error: body.error});
res.status(500).json({
message: "Fetching Edge Info Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
}
if (body) {
body.last_update_str = (!body.last_update) ? '' : common.convertTimestampToDate(body.last_update);
}
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Graph Edge Information Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -144,7 +143,7 @@ exports.getGraphEdge = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 144, msg: 'Fetch Edge Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Edge Info Error', error: err});
return res.status(500).json({
message: "Fetching Edge Info Failed!",
error: err.error
@ -153,30 +152,32 @@ exports.getGraphEdge = (req, res, next) => {
};
exports.getQueryRoutes = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Getting Graph Routes..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/graph/routes/' + req.params.destPubkey + '/' + req.params.amount;
if(req.query.outgoing_chan_id) {
options.url = options.url + '?outgoing_chan_id=' + req.query.outgoing_chan_id;
}
logger.info({fileName: 'Graph', msg: 'Query Routes URL: ' + options.url});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Query Routes URL', data: options.url});
request(options).then((body) => {
logger.info({fileName: 'Graph', msg: 'Query Routes Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Query Routes Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Graph', lineNum: 162, msg: 'Fetch Query Routes Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Query Routes Error', error: body.error});
res.status(500).json({
message: "Fetching Query Routes Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
}
if(body.routes && body.routes.length && body.routes.length > 0 && body.routes[0].hops && body.routes[0].hops.length && body.routes[0].hops.length > 0) {
Promise.all(body.routes[0].hops.map(hop => {return getAliasFromPubkey(hop.pub_key)}))
return Promise.all(body.routes[0].hops.map(hop => getAliasFromPubkey(hop.pub_key)))
.then(function(values) {
body.routes[0].hops.map((hop, i) => {
hop.hop_sequence = i + 1;
hop.pubkey_alias = values[i];
return hop;
});
logger.info({fileName: 'Graph', msg: 'Hops with Alias: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Hops with Alias', data: body});
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Graph Routes Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -187,13 +188,14 @@ exports.getQueryRoutes = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 196, msg: 'Fetch Query Routes Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Query Routes Error', error: err});
return res.status(500).json({
message: "Fetching Query Routes Failed!",
error: err.error
});
});
} else {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Graph Routes Received'});
res.status(200).json(body);
}
})
@ -205,7 +207,7 @@ exports.getQueryRoutes = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 214, msg: 'Fetch Query Routes Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Query Routes Error', error: err});
return res.status(500).json({
message: "Fetching Query Routes Failed!",
error: err.error
@ -214,20 +216,18 @@ exports.getQueryRoutes = (req, res, next) => {
};
exports.getRemoteFeePolicy = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Getting Remote Fee Policy..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/graph/edge/' + req.params.chanid;
request(options).then((body) => {
logger.info({fileName: 'Graph', msg: 'Edge Info Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Edge Info Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Graph', lineNum: 218, msg: 'Fetch Edge Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Edge Info Error', error: body.error});
res.status(500).json({
message: "Fetching Edge Info Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
}
if (body) {
body.last_update_str = (!body.last_update) ? '' : common.convertTimestampToDate(body.last_update);
}
remoteNodeFee = {};
if(body.node1_pub === req.params.localPubkey){
remoteNodeFee = {
@ -242,6 +242,7 @@ exports.getRemoteFeePolicy = (req, res, next) => {
fee_rate_milli_msat: body.node1_policy.fee_rate_milli_msat
};
}
logger.log({level: 'INFO', fileName: 'Graph', msg: 'Remote Fee Policy Received'});
res.status(200).json(remoteNodeFee);
})
.catch(errRes => {
@ -252,7 +253,7 @@ exports.getRemoteFeePolicy = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 250, msg: 'Fetch Edge Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Fetch Edge Info Error', error: err});
return res.status(500).json({
message: "Fetching Edge Info Failed!",
error: err.error
@ -264,9 +265,9 @@ exports.getAliasesForPubkeys = (req, res, next) => {
options = common.getOptions();
if (req.query.pubkeys) {
let pubkeyArr = req.query.pubkeys.split(',');
Promise.all(pubkeyArr.map(pubkey => {return getAliasFromPubkey(pubkey)}))
return Promise.all(pubkeyArr.map(pubkey => getAliasFromPubkey(pubkey)))
.then(function(values) {
logger.info({fileName: 'Graph', msg: 'Node Alias: ' + JSON.stringify(values)});
logger.log({level: 'DEBUG', fileName: 'Graph', msg: 'Node Alias', data: values});
res.status(200).json(values);
})
.catch(errRes => {
@ -277,7 +278,7 @@ exports.getAliasesForPubkeys = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Graph', lineNum: 279, msg: 'Get Aliases for Pubkeys Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Graph', msg: 'Get Aliases for Pubkeys Error', error: err});
return res.status(500).json({
message: "Getting Aliases for Pubkeys Failed!",
error: err.error

View File

@ -1,39 +0,0 @@
var request = require('request-promise');
var common = require('../../common');
var options = {};
exports.getGraphInfo = (req, res, next) => {
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/graph/info';
request(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'GraphInfo', lineNum: 12, msg: 'Fetch Network Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
res.status(500).json({
message: "Fetching network Info failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
body.btc_total_network_capacity = (!body.total_network_capacity) ? 0 : common.convertToBTC(body.total_network_capacity);
body.btc_avg_channel_size = (!body.avg_channel_size) ? 0 : common.convertToBTC(body.avg_channel_size);
body.btc_min_channel_size = (!body.min_channel_size) ? 0 : common.convertToBTC(body.min_channel_size);
body.btc_max_channel_size = (!body.max_channel_size) ? 0 : common.convertToBTC(body.max_channel_size);
res.status(200).json(body);
}
})
.catch(errRes => {
let err = JSON.parse(JSON.stringify(errRes));
if (err.options && err.options.headers && err.options.headers['Grpc-Metadata-macaroon']) {
delete err.options.headers['Grpc-Metadata-macaroon'];
}
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'GraphInfo', lineNum: 32, msg: 'Fetch Network Info Error: ' + JSON.stringify(err)});
return res.status(500).json({
message: "Fetching Network Info Failed!",
error: err.error
});
});
};

View File

@ -1,20 +1,22 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getInvoice = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoice', msg: 'Getting Invoice Information..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/invoice/' + req.params.rHashStr;
request(options).then((body) => {
logger.info({fileName: 'Invoice', msg: 'Invoice Info Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Invoice Info Received', data: body});
if(!body || body.error) {
logger.error({fileName: 'Invoice', lineNum: 12, msg: 'Invoice Info Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Invoice Info Error', error: body.error});
res.status(500).json({
message: "Fetching Invoice Info Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
}
logger.log({level: 'INFO', fileName: 'Invoice', msg: 'Invoice Information Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -25,7 +27,7 @@ exports.getInvoice = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Invoice', lineNum: 27, msg: 'Fetch Invoice Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Fetch Invoice Info Error', error: err});
return res.status(500).json({
message: "Fetching Invoice Info Failed!",
error: err.error
@ -34,15 +36,16 @@ exports.getInvoice = (req, res, next) => {
};
exports.listInvoices = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoice', msg: 'Getting List Invoices..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/invoices?num_max_invoices=' + req.query.num_max_invoices + '&index_offset=' + req.query.index_offset +
'&reversed=' + req.query.reversed;
request(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
logger.info({fileName: 'Invoice', msg: 'Invoices List Received: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body_str});
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'Invoice', lineNum: 44, msg: 'List Invoices Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'List Invoices Error', error: body.error});
res.status(500).json({
message: "Fetching Invoice Info failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
@ -53,18 +56,13 @@ exports.listInvoices = (req, res, next) => {
invoice.r_preimage = invoice.r_preimage ? Buffer.from(invoice.r_preimage, 'base64').toString('hex') : '';
invoice.r_hash = invoice.r_hash ? Buffer.from(invoice.r_hash, 'base64').toString('hex') : '';
invoice.description_hash = invoice.description_hash ? Buffer.from(invoice.description_hash, 'base64').toString('hex') : null;
invoice.creation_date_str = (!invoice.creation_date) ? '' : common.convertTimestampToDate(invoice.creation_date);
invoice.settle_date_str = (!invoice.settle_date || invoice.settle_date === '0') ? '' : common.convertTimestampToDate(invoice.settle_date);
invoice.btc_value = (!invoice.value) ? 0 : common.convertToBTC(invoice.value);
invoice.btc_amt_paid_sat = (!invoice.amt_paid_sat) ? 0 : common.convertToBTC(invoice.amt_paid_sat);
invoice.htlcs.forEach(htlc => {
htlc.accept_time_str = (!htlc.accept_time) ? '' : common.convertTimestampToDate(htlc.accept_time);
htlc.resolve_time_str = (!htlc.resolve_time) ? '' : common.convertTimestampToDate(htlc.resolve_time);
});
});
body.invoices = common.sortDescByKey(body.invoices, 'creation_date');
}
logger.info({fileName: 'Invoice', msg: 'Invoices List Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Invoices List Received', data: body});
logger.log({level: 'INFO', fileName: 'Invoice', msg: 'Invoices List Received'});
res.status(200).json(body);
}
})
@ -76,7 +74,7 @@ exports.listInvoices = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Invoice', lineNum: 70, msg: 'List Invoice Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'List Invoice Error', error: err});
return res.status(500).json({
message: "Fetching Invoices failed!",
error: err.error
@ -85,6 +83,7 @@ exports.listInvoices = (req, res, next) => {
};
exports.addInvoice = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Invoice', msg: 'Adding Invoice..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/invoices';
options.form = {
@ -99,14 +98,15 @@ exports.addInvoice = (req, res, next) => {
}
options.form = JSON.stringify(options.form);
request.post(options).then((body) => {
logger.info({fileName: 'Invoice', msg: 'Add Invoice Responce: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Invoice', msg: 'Add Invoice Responce', data: body});
if(!body || body.error) {
logger.error({fileName: 'Invoice', lineNum: 95, msg: 'Add Invoice Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Add Invoice Error', error: body.error});
res.status(500).json({
message: "Add Invoice Failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Invoice', msg: 'Invoice Added'});
res.status(201).json(body);
}
})
@ -118,7 +118,7 @@ exports.addInvoice = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Invoice', lineNum: 111, msg: 'Add Invoice Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Invoice', msg: 'Add Invoice Error', error: err});
return res.status(500).json({
message: "Add Invoice Failed!",
error: err.error

View File

@ -1,22 +0,0 @@
var fs = require('fs');
exports.getLNDSettings = (req, res, next) => {
fs.readFile(req.headers.filepath, function(errRes, data) {
if (errRes) {
let err = JSON.parse(JSON.stringify(errRes));
if (err.options && err.options.headers && err.options.headers['Grpc-Metadata-macaroon']) {
delete err.options.headers['Grpc-Metadata-macaroon'];
}
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'LNDConfSetting', lineNum: 12, msg: 'Reading Config File Error: ' + JSON.stringify(err)});
res.status(500).json({
message: "Reading Config File Failed!",
error: err
});
} else {
res.status(200).json(data.toString('utf8'));
}
});
};

View File

@ -1,23 +1,25 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.signMessage = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Signing Message..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/signmessage';
options.form = JSON.stringify({
msg: Buffer.from(req.body.message).toString('base64')
});
request.post(options, (error, response, body) => {
logger.info({fileName: 'Messages', msg: 'Message Signed: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Messages', msg: 'Message Signed', data: body});
if(!body || body.error) {
logger.error({fileName: 'Messages', lineNum: 15, msg: 'Sign Message Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Sign Message Error', error: body.error});
res.status(500).json({
message: "Sign message failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Message Signed'});
res.status(201).json(body);
}
})
@ -29,7 +31,7 @@ exports.signMessage = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Messages', lineNum: 31, msg: 'Sign Message Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Sign Message Error', error: err});
return res.status(500).json({
message: 'Sign Message Failed!',
error: err.error
@ -38,6 +40,7 @@ exports.signMessage = (req, res, next) => {
};
exports.verifyMessage = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Verifying Message..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/verifymessage';
options.form = JSON.stringify({
@ -45,14 +48,15 @@ exports.verifyMessage = (req, res, next) => {
signature: req.body.signature
});
request.post(options, (error, response, body) => {
logger.info({fileName: 'Messages', msg: 'Message Verified: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Messages', msg: 'Message Verified', data: body});
if(!body || body.error) {
logger.error({fileName: 'Messages', lineNum: 49, msg: 'Verify Message Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Verify Message Error', error: body.error});
res.status(500).json({
message: "Verify message failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Message', msg: 'Message Verified'});
res.status(201).json(body);
}
})
@ -64,7 +68,7 @@ exports.verifyMessage = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Messages', lineNum: 65, msg: 'Message Verification Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Messages', msg: 'Message Verification Error', error: err});
return res.status(500).json({
message: 'Verify Message Failed!',
error: err.error

View File

@ -1,22 +1,24 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getNewAddress = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'NewAddress', msg: 'Getting New Address..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/newaddress?type=' + req.query.type;
request(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
logger.info({fileName: 'NewAddress', msg: 'New Address Received: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'NewAddress', msg: 'New Address Received', data: body_str});
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'NewAddress', lineNum: 14, msg: 'New Address Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'NewAddress', msg: 'New Address Error', error: body.error});
res.status(500).json({
message: "Fetching new address failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'NewAddress', msg: 'New Address Received'});
res.status(200).json(body);
}
})
@ -28,7 +30,7 @@ exports.getNewAddress = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'NewAddress', lineNum: 30, msg: 'New Address Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'NewAddress', msg: 'New Address Error', error: err});
return res.status(500).json({
message: "Fetching new address failed!",
error: err.error

View File

@ -1,24 +1,34 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
decodePaymentFromPaymentRequest = (payment) => {
options.url = common.getSelLNServerUrl() + '/v1/payreq/' + payment;
return request(options).then(function(res) {
logger.log({level: 'DEBUG', fileName: 'PayReq', msg: 'Description', data: res.description});
return res;
})
.catch(err => {});
}
exports.decodePayment = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'PayRequest', msg: 'Decoding Payment..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/payreq/' + req.params.payRequest;
request(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
logger.info({fileName: 'PayReq', msg: 'Payment Decode Received: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'PayReq', msg: 'Payment Decode Received', data: body_str});
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'PayReq', lineNum: 14, msg: 'Payment Decode Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'PayReq', msg: 'Payment Decode Error 1', error: body.error});
res.status(500).json({
message: "Payment Request Decode Failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
body.btc_num_satoshis = (!body.num_satoshis) ? 0 : common.convertToBTC(body.num_satoshis);
body.timestamp_str = (!body.timestamp) ? '' : common.convertTimestampToDate(body.timestamp);
logger.log({level: 'INFO', fileName: 'PayRequest', msg: 'Payment Decoded'});
res.status(200).json(body);
}
})
@ -30,7 +40,7 @@ exports.decodePayment = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'PayReq', lineNum: 32, msg: 'Payment Decode Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'PayReq', msg: 'Payment Decode Error 2', error: err.error});
return res.status(500).json({
message: "Payment Request Decode Failed!",
error: err.error
@ -39,12 +49,14 @@ exports.decodePayment = (req, res, next) => {
};
exports.decodePayments = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'PayRequest', msg: 'Decoding Payments List..'});
options = common.getOptions();
if (req.body.payments) {
let paymentsArr = req.body.payments.split(',');
Promise.all(paymentsArr.map(payment => {return decodePaymentFromPaymentRequest(payment)}))
return Promise.all(paymentsArr.map(payment => decodePaymentFromPaymentRequest(payment)))
.then(function(values) {
logger.info({fileName: 'PayReq', msg: 'Decoded Payments: ' + JSON.stringify(values)});
logger.log({level: 'DEBUG', fileName: 'PayReq', msg: 'Decoded Payments', data: values});
logger.log({level: 'INFO', fileName: 'PayRequest', msg: 'Payment List Decoded'});
res.status(200).json(values);
})
.catch(errRes => {
@ -55,25 +67,14 @@ exports.decodePayments = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'PayReq', lineNum: 58, msg: 'Decode Payments Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'PayReq', msg: 'Decode Payments Error', error: err});
return res.status(500).json({
message: "Decode Payments Failed!",
error: err.error
});
});
} else {
logger.log({level: 'INFO', fileName: 'PayRequest', msg: 'Empty Payment List Decoded'});
res.status(200).json([]);
}
};
decodePaymentFromPaymentRequest = (payment) => {
return new Promise(function(resolve, reject) {
options.url = common.getSelLNServerUrl() + '/v1/payreq/' + payment;
request(options)
.then(function(res) {
logger.info({fileName: 'PayReq', msg: 'Description: ' + JSON.stringify(res.description)});
resolve(res);
})
.catch(err => resolve({}));
});
}

View File

@ -1,34 +1,29 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getPayments = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Getting Payments List..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/payments';
options.url = common.getSelLNServerUrl() + '/v1/payments?max_payments=' + req.query.max_payments + '&index_offset=' + req.query.index_offset + '&reversed=' + req.query.reversed;
request(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
logger.info({fileName: 'Payments', msg: 'Payment List Received: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Payment List Received', data: body_str});
if(!body || search_idx > -1 || body.error) {
logger.error({fileName: 'Payments', lineNum: 14, msg: 'List Payments Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'List Payments Error', error: body.error});
res.status(500).json({
message: "Payments List Failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
if ( body.payments && body.payments.length > 0) {
body.payments.forEach(payment => {
payment.creation_date_str = (!payment.creation_date) ? '' : common.convertTimestampToDate(payment.creation_date);
payment.htlcs.forEach(htlc => {
htlc.attempt_time_str = (!htlc.attempt_time_ns) ? '' : common.convertTimestampToDate(Math.round(htlc.attempt_time_ns/1000000000));
htlc.resolve_time_str = (!htlc.resolve_time_ns) ? '' : common.convertTimestampToDate(Math.round(htlc.resolve_time_ns/1000000000));
});
});
if (body.payments && body.payments.length > 0) {
body.payments = common.sortDescByKey(body.payments, 'creation_date');
}
logger.info({fileName: 'Payments', msg: 'Payment List After Dates: ' + JSON.stringify(body.payments)});
res.status(200).json(body.payments);
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'Payments After Sort', data: body});
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Payments List Received'});
res.status(200).json(body);
}
})
.catch(errRes => {
@ -39,10 +34,37 @@ exports.getPayments = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Payments', lineNum: 36, msg: 'List Payments Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'List Payments Error', error: err});
return res.status(500).json({
message: "Payments List Failed!",
error: err.error
});
});
};
exports.getAllLightningTransactions = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Getting All Lightning Transactions..'});
const options1 = JSON.parse(JSON.stringify(common.getOptions()))
const options2 = JSON.parse(JSON.stringify(common.getOptions()))
options1.url = common.getSelLNServerUrl() + '/v1/payments?max_payments=1000000&index_offset=0&reversed=true';
options2.url = common.getSelLNServerUrl() + '/v1/invoices?num_max_invoices=1000000&index_offset=0&reversed=true';
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'All Payments Options', data: options1});
logger.log({level: 'DEBUG', fileName: 'Payments', msg: 'All Invoices Options', data: options2});
return Promise.all([request(options1), request(options2)]).then(function(values) {
logger.log({level: 'INFO', fileName: 'Payments', msg: 'Payments & Invoices Received'});
res.status(200).json({paymentsAll: values[0], invoicesAll: values[1]});
}).catch(errRes => {
let err = JSON.parse(JSON.stringify(errRes));
if (err.options && err.options.headers && err.options.headers['Grpc-Metadata-macaroon']) {
delete err.options.headers['Grpc-Metadata-macaroon'];
}
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.log({level: 'ERROR', fileName: 'Payments', msg: 'All Lightning Transactions Error', error: err});
return res.status(500).json({
message: "All Lightning Transactions Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
});
});
};

View File

@ -1,43 +1,38 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
getAliasForPeers = (peer) => {
return new Promise(function(resolve, reject) {
options.url = common.getSelLNServerUrl() + '/v1/graph/node/' + peer.pub_key;
request(options).then(function(aliasBody) {
logger.info({fileName: 'Peers', msg: 'Alias: ' + JSON.stringify(aliasBody.node.alias)});
return request(options).then(function(aliasBody) {
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Alias', data: aliasBody.node.alias});
peer.alias = aliasBody.node.alias;
resolve(aliasBody.node.alias);
return aliasBody.node.alias;
})
.catch(err => {
peer.alias = peer.pub_key.slice(0, 10) + '...' + peer.pub_key.slice(-10);
resolve(peer.pub_key);
});
return peer.pub_key;
});
}
exports.getPeers = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Getting Peers..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/peers';
request(options).then(function (body) {
logger.info({fileName: 'Peers', msg: 'Peers Received: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peers Received', data: body});
let peers = !body.peers ? [] : body.peers;
Promise.all(
peers.map(peer => {
return getAliasForPeers(peer);
}))
.then(function(values) {
logger.info({fileName: 'Peers', msg: 'Peers with Alias before Sort: ' + JSON.stringify(body)});
return Promise.all(peers.map(peer => getAliasForPeers(peer))).then(function(values) {
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peers with Alias before Sort', data: body});
if (body.peers) {
body.peers = common.sortDescByStrKey(body.peers, 'alias');
}
logger.info({fileName: 'Peers', msg: 'Peers with Alias after Sort: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peers with Alias after Sort', data: body});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peers Received'});
res.status(200).json(body.peers);
});
})
.catch(errRes => {
}).catch(errRes => {
let err = JSON.parse(JSON.stringify(errRes));
if (err.options && err.options.headers && err.options.headers['Grpc-Metadata-macaroon']) {
delete err.options.headers['Grpc-Metadata-macaroon'];
@ -45,7 +40,7 @@ exports.getPeers = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Peers', lineNum: 39, msg: 'List Peers Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'List Peers Error', error: err});
return res.status(500).json({
message: "Peers List Failed!",
error: err.error
@ -54,6 +49,7 @@ exports.getPeers = (req, res, next) => {
};
exports.postPeer = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Connecting Peer..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/peers';
options.form = JSON.stringify({
@ -61,9 +57,9 @@ exports.postPeer = (req, res, next) => {
perm: req.body.perm
});
request.post(options, (error, response, body) => {
logger.info({fileName: 'Peers', msg: 'Peer Added: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Added', data: body});
if(!body || body.error) {
logger.error({fileName: 'Peers', lineNum: 63, msg: 'Add Peer Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Add Peer Error', error: body.error});
res.status(500).json({
message: "Adding peer failed!",
error: (!body) ? 'Error From Server!' : body.error
@ -72,18 +68,15 @@ exports.postPeer = (req, res, next) => {
options.url = common.getSelLNServerUrl() + '/v1/peers';
request(options).then(function (body) {
let peers = (!body.peers) ? [] : body.peers;
Promise.all(
peers.map(peer => {
return getAliasForPeers(peer);
}))
.then(function(values) {
return Promise.all(peers.map(peer => getAliasForPeers(peer))).then(function(values) {
if (body.peers) {
body.peers = common.sortDescByStrKey(body.peers, 'alias');
logger.info({fileName: 'Peers', msg: 'Peer with Alias: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer with Alias', data: body});
body.peers = common.newestOnTop(body.peers, 'pub_key', req.body.pubkey);
logger.info({fileName: 'Peers', msg: 'Peer with Newest On Top: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer with Newest On Top', data: body});
}
logger.info({fileName: 'Peers', msg: 'Peer Added Successfully'});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Added Successfully'});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peer Connected'});
res.status(201).json(body.peers);
})
.catch(errRes => {
@ -94,7 +87,7 @@ exports.postPeer = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Peer', lineNum: 93, msg: 'Add Peer Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peer', msg: 'Add Peer Error', error: err});
return res.status(500).json({
message: "Peer Add Failed!",
error: err.error
@ -106,18 +99,20 @@ exports.postPeer = (req, res, next) => {
};
exports.deletePeer = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Disconnecting Peer..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/peers/' + req.params.peerPubKey;
request.delete(options).then((body) => {
logger.info({fileName: 'Peers', msg: 'Detach Peer Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Detach Peer Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Peers', lineNum: 110, msg: 'Detach Peer Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Detach Peer Error', error: body.error});
res.status(500).json({
message: "Detach peer failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.info({fileName: 'Peers', msg: 'Peer Detached: ' + req.params.peerPubKey});
logger.log({level: 'DEBUG', fileName: 'Peers', msg: 'Peer Detached', data: req.params.peerPubKey});
logger.log({level: 'INFO', fileName: 'Peers', msg: 'Peer Disconnected'});
res.status(204).json({});
}
})
@ -129,7 +124,7 @@ exports.deletePeer = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Peers', lineNum: 127, msg: 'Detach Peer Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Peers', msg: 'Detach Peer Error', error: err});
return res.status(500).json({
message: "Detach Peer Failed!",
error: err.error

View File

@ -1,13 +1,13 @@
var request = require('request-promise');
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
var num_max_events = 100;
var responseData = { forwarding_events: [], last_offset_index: 0 };
exports.forwardingHistory = (req, res, next) => {
this.getAllForwardingEvents(req.body.start_time, req.body.end_time, 0, (eventsResponse) => {
return this.getAllForwardingEvents(req.body.start_time, req.body.end_time, 0, (eventsResponse) => {
if (eventsResponse.error) {
res.status(500).json(eventsResponse);
} else {
@ -17,6 +17,7 @@ exports.forwardingHistory = (req, res, next) => {
};
exports.getAllForwardingEvents = (start, end, offset, callback) => {
logger.log({level: 'INFO', fileName: 'Switch', msg: 'Getting Forwarding Events..'});
if (offset === 0) { responseData = { forwarding_events: [], last_offset_index: 0 }; }
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/switch';
@ -26,23 +27,21 @@ exports.getAllForwardingEvents = (start, end, offset, callback) => {
options.form.num_max_events = num_max_events;
options.form.index_offset = offset;
options.form = JSON.stringify(options.form);
logger.info({fileName: 'Switch', msg: 'Forwarding History Params: ' + options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Switch', msg: 'Forwarding History: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Switch', msg: 'Forwarding History Params', data: options.form});
return request.post(options).then((body) => {
logger.log({level: 'DEBUG', fileName: 'Switch', msg: 'Forwarding History', data: body});
logger.log({level: 'INFO', fileName: 'Switch', msg: 'Forwarding Events Received'});
if (body.forwarding_events) {
responseData.forwarding_events.push(...body.forwarding_events);
}
if (!body.last_offset_index || body.last_offset_index < offset + num_max_events) {
responseData.last_offset_index = body.last_offset_index ? body.last_offset_index : 0
if (responseData.forwarding_events) {
responseData.forwarding_events.forEach(event => {
event.timestamp_str = !event.timestamp ? '' : common.convertTimestampToDate(event.timestamp);
});
responseData.forwarding_events = common.sortDescByKey(responseData.forwarding_events, 'timestamp');
}
callback(responseData);
return callback(responseData);
} else {
this.getAllForwardingEvents(start, end, offset + num_max_events, callback);
return this.getAllForwardingEvents(start, end, offset + num_max_events, callback);
}
})
.catch(errRes => {
@ -53,8 +52,8 @@ exports.getAllForwardingEvents = (start, end, offset, callback) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Switch', lineNum: 54, msg: 'Get All Forwarding Events Error: ' + JSON.stringify(err)});
callback({
logger.log({level: 'ERROR', fileName: 'Switch', msg: 'Get All Forwarding Events Error', error: err});
return callback({
message: "Forwarding Events Failed!",
error: err.error
});

View File

@ -1,28 +1,27 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getTransactions = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Transactions', msg: 'Getting Transactions..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/transactions';
request(options).then((body) => {
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
logger.info({fileName: 'Transactions', msg: 'Transaction Received: ' + body_str});
logger.log({level: 'DEBUG', fileName: 'Transactions', msg: 'Transaction Received', data: body_str});
if (!body || search_idx > -1 || body.error) {
logger.error({fileName: 'Transactions', lineNum: 14, msg: 'List Transactions Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Transactions', msg: 'List Transactions Error', error: body.error});
res.status(500).json({
message: "Fetching Transactions Failed!",
error: (!body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
if (body.transactions && body.transactions.length > 0) {
body.transactions.forEach(transaction => {
transaction.time_stamp_str = (!transaction.time_stamp) ? '' : common.convertTimestampToDate(transaction.time_stamp);
});
body.transactions = common.sortDescByKey(body.transactions, 'time_stamp');
}
logger.log({level: 'INFO', fileName: 'Transactions', msg: 'Transactions Received'});
res.status(200).json(body.transactions);
}
})
@ -34,7 +33,7 @@ exports.getTransactions = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Transactions', lineNum: 36, msg: 'List Transactions Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Transactions', msg: 'List Transactions Error', error: err});
return res.status(500).json({
message: "Fetching Transactions Failed!",
error: err.error
@ -43,6 +42,7 @@ exports.getTransactions = (req, res, next) => {
};
exports.postTransactions = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Transactions', msg: 'Sending Transaction..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v1/transactions';
options.form = {
@ -56,14 +56,15 @@ exports.postTransactions = (req, res, next) => {
}
options.form = JSON.stringify(options.form);
request.post(options).then((body) => {
logger.info({fileName: 'Transactions', msg: 'Transaction Post Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Transactions', msg: 'Transaction Post Response', data: body});
if(!body || body.error) {
logger.error({fileName: 'Transactions', lineNum: 60, msg: 'Post Transaction Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Transactions', msg: 'Post Transaction Error', error: body.error});
res.status(500).json({
message: "Transactions post failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Transactions', msg: 'Transaction Sent'});
res.status(201).json(body);
}
})
@ -75,7 +76,7 @@ exports.postTransactions = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Transactions', lineNum: 76, msg: 'Transaction Post Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Transactions', msg: 'Transaction Post Error', error: err});
return res.status(500).json({
message: "Transactions post failed!",
error: err.error

View File

@ -1,10 +1,11 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var atob = require('atob');
var logger = require('../shared/logger');
var options = {};
exports.genSeed = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Generating Seed..'});
options = common.getOptions();
if ( req.params.passphrase) {
options.url = common.getSelLNServerUrl() + '/v1/genseed?aezeed_passphrase=' + Buffer.from(atob(req.params.passphrase)).toString('base64');
@ -13,12 +14,13 @@ exports.genSeed = (req, res, next) => {
}
request(options).then((body) => {
if(!body || body.error) {
logger.error({fileName: 'Wallet', lineNum: 16, msg: 'Gen Seed Error: ' + ((!body || !body.error) ? 'Error From Server!' : JSON.stringify(body.error))});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Gen Seed Error', error: body.error});
res.status(500).json({
message: "Genseed failed!",
error: (!body) ? 'Error From Server!' : body.error
});
} else {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Seed Generated'});
res.status(200).json(body);
}
})
@ -30,7 +32,7 @@ exports.genSeed = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Wallet', lineNum: 32, msg: 'Gen Seed Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Gen Seed Error', error: err});
return res.status(500).json({
message: "Genseed failed!",
error: err.error
@ -42,12 +44,14 @@ exports.operateWallet = (req, res, next) => {
options = common.getOptions();
options.method = 'POST';
if (!req.params.operation || req.params.operation === 'unlockwallet') {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Unlocking Wallet..'});
options.url = common.getSelLNServerUrl() + '/v1/unlockwallet';
options.form = JSON.stringify({
wallet_password: Buffer.from(atob(req.body.wallet_password)).toString('base64')
});
err_message = 'Unlocking wallet failed! Verify that lnd is running and the wallet is locked!';
} else {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Initializing Wallet..'});
options.url = common.getSelLNServerUrl() + '/v1/initwallet';
if ( req.body.aezeed_passphrase && req.body.aezeed_passphrase !== '') {
options.form = JSON.stringify({
@ -64,17 +68,17 @@ exports.operateWallet = (req, res, next) => {
err_message = 'Initializing wallet failed!';
}
request(options).then((body) => {
logger.info({fileName: 'Wallet', msg: 'Wallet Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'Wallet Response', data: body});
const body_str = (!body) ? '' : JSON.stringify(body);
const search_idx = (!body) ? -1 : body_str.search('Not Found');
if(!body) {
logger.error({fileName: 'Wallet', lineNum: 70, msg: 'Wallet Error: ' + ((error) ? JSON.stringify(error) : err_message)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Wallet Error', error: {error: (error ? error : err_message)}});
res.status(500).json({
message: err_message,
error: (error) ? error : err_message
});
} else if(search_idx > -1) {
logger.error({fileName: 'Wallet', lineNum: 76, msg: 'Wallet Error: ' + err_message});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Wallet Error', error: {error: err_message}});
res.status(500).json({
message: err_message,
error: err_message
@ -83,13 +87,14 @@ exports.operateWallet = (req, res, next) => {
if((body.code === 1 && body.error === 'context canceled') || (body.code === 14 && body.error === 'transport is closing')) {
res.status(201).json('Successful');
} else {
logger.error({fileName: 'Wallet', lineNum: 85, msg: 'Wallet Error: ' + JSON.stringify(body.error)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Wallet Error', error: body.error});
res.status(500).json({
message: err_message,
error: body.error
});
}
} else {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Wallet Unlocked/Initialized'});
res.status(201).json('Successful');
}
})
@ -101,7 +106,7 @@ exports.operateWallet = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Wallet', lineNum: 101, msg: 'Wallet Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Wallet Error', error: 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('Successful');
} else {
@ -119,10 +124,12 @@ exports.updateSelNodeOptions = (req, res, next) => {
}
exports.getUTXOs = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Getting UTXOs..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v2/wallet/utxos?max_confs=' + req.query.max_confs;
request.post(options).then((body) => {
logger.info({fileName: 'Wallet', msg: 'UTXO List Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'UTXO List Response', data: body});
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'UTXOs Received'});
res.status(200).json(body.utxos ? body.utxos : []);
})
.catch(errRes => {
@ -133,7 +140,7 @@ exports.getUTXOs = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Wallet', lineNum: 143, msg: 'UTXOs Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'UTXOs Error', error: err});
return res.status(500).json({
message: "UTXO list failed!",
error: err.error
@ -142,6 +149,7 @@ exports.getUTXOs = (req, res, next) => {
}
exports.bumpFee = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Bumping Fee..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v2/wallet/bumpfee';
options.form = {};
@ -156,7 +164,8 @@ exports.bumpFee = (req, res, next) => {
}
options.form = JSON.stringify(options.form);
request.post(options).then((body) => {
logger.info({fileName: 'Wallet', msg: 'Bump Fee Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'Bump Fee Response', data: body});
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Fee Bumped'});
res.status(200).json(body);
})
.catch(errRes => {
@ -167,7 +176,7 @@ exports.bumpFee = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Wallet', lineNum: 170, msg: 'Bump Fee Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Bump Fee Error', error: err});
return res.status(500).json({
message: "Bump fee failed!",
error: err.error
@ -176,6 +185,7 @@ exports.bumpFee = (req, res, next) => {
}
exports.labelTransaction = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Labelling Transaction..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v2/wallet/tx/label';
options.form = {};
@ -183,9 +193,10 @@ exports.labelTransaction = (req, res, next) => {
options.form.label = req.body.label;
options.form.overwrite = req.body.overwrite;
options.form = JSON.stringify(options.form);
logger.info({fileName: 'Wallet', msg: 'Label Transaction Options: ' + JSON.stringify(options.form)});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'Label Transaction Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Wallet', msg: 'Label Transaction Post Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'Label Transaction Post Response', data: body});
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Transaction Labelled'});
res.status(200).json(body);
})
.catch(errRes => {
@ -196,7 +207,7 @@ exports.labelTransaction = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Wallet', lineNum: 253, msg: 'Label Transaction Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Label Transaction Error', error: err});
return res.status(500).json({
message: "Transaction label failed!",
error: err.error
@ -205,6 +216,7 @@ exports.labelTransaction = (req, res, next) => {
}
exports.leaseUTXO = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Leasing UTXO..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v2/wallet/utxos/lease';
options.form = {};
@ -214,9 +226,10 @@ exports.leaseUTXO = (req, res, next) => {
output_index: req.body.outputIndex
};
options.form = JSON.stringify(options.form);
logger.info({fileName: 'Wallet', msg: 'UTXO Lease Options: ' + options.form});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'UTXO Lease Options', data: options.form});
request.post(options).then((body) => {
logger.info({fileName: 'Wallet', msg: 'UTXO Lease Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'UTXO Lease Response', data: body});
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'UTXO Leased'});
res.status(200).json(body);
})
.catch(errRes => {
@ -227,7 +240,7 @@ exports.leaseUTXO = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Wallet', lineNum: 197, msg: 'Lease UTXO Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Lease UTXO Error', error: err});
return res.status(500).json({
message: "Lease UTXO failed!",
error: err.error
@ -236,6 +249,7 @@ exports.leaseUTXO = (req, res, next) => {
}
exports.releaseUTXO = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'Releasing UTXO..'});
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/v2/wallet/utxos/release';
options.form = {};
@ -246,7 +260,8 @@ exports.releaseUTXO = (req, res, next) => {
};
options.form = JSON.stringify(options.form);
request.post(options).then((body) => {
logger.info({fileName: 'Wallet', msg: 'UTXO Release Response: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Wallet', msg: 'UTXO Release Response', data: body});
logger.log({level: 'INFO', fileName: 'Wallet', msg: 'UTXO Released'});
res.status(200).json(body);
})
.catch(errRes => {
@ -257,7 +272,7 @@ exports.releaseUTXO = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Wallet', lineNum: 226, msg: 'Release UTXO Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Wallet', msg: 'Release UTXO Error', error: err});
return res.status(500).json({
message: "Release UTXO failed!",
error: err.error

View File

@ -2,28 +2,31 @@ var ini = require('ini');
var parseHocon = require('hocon-parser');
var fs = require('fs');
var logger = require('./logger');
var common = require('../../common');
var common = require('../../routes/common');
var request = require('request-promise');
var options = {};
exports.updateSelectedNode = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Updating Selected Node..'});
const selNodeIndex = req.body.selNodeIndex;
common.selectedNode = common.findNode(selNodeIndex);
const responseVal = common.selectedNode && common.selectedNode.ln_node ? common.selectedNode.ln_node : '';
logger.info({fileName: 'RTLConf', msg: 'Selected Node Updated To: ' + JSON.stringify(responseVal)});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: 'Selected Node Updated To', data: responseVal});
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Selected Node Updated'});
res.status(200).json({status: 'Selected Node Updated To: ' + JSON.stringify(responseVal) + '!'});
};
exports.getRTLConfig = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Getting RTL Configuration..'});
var confFile = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
logger.info({fileName: 'RTLConf', msg: 'Getting Node Config'});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: 'Getting Node Config'});
fs.readFile(confFile, 'utf8', function(err, data) {
if (err) {
if (err.code === 'ENOENT') {
logger.error({fileName: 'RTLConf', lineNum: 22, msg: 'Node config does not exist!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Node config does not exist!', error: {error: 'Node config does not exist.'}});
res.status(200).json({ defaultNodeIndex: 0, selectedNodeIndex: 0, sso: {}, nodes: [] });
} else {
logger.error({fileName: 'RTLConf', lineNum: 25, msg: 'Getting Node Config Failed!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Getting Node Config Failed!', error: err});
res.status(500).json({
message: "Reading Node Config Failed!",
error: err
@ -60,12 +63,14 @@ exports.getRTLConfig = (req, res, next) => {
authentication: authentication})
});
}
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'RTL Configuration Received'});
res.status(200).json({ defaultNodeIndex: nodeConfData.defaultNodeIndex, selectedNodeIndex: common.selectedNode.index, sso: sso, enable2FA: enable2FA, nodes: nodesArr });
}
});
};
exports.updateUISettings = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Updating UI Settings..'});
var RTLConfFile = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
var config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
config.nodes.find(node => {
@ -94,11 +99,12 @@ exports.updateUISettings = (req, res, next) => {
});
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.info({fileName: 'RTLConf', msg: 'Updating Node Settings Succesful!'});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: 'Updating Node Settings Succesful!'});
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'UI Settings Updated'});
res.status(201).json({message: 'Node Settings Updated Successfully'});
}
catch (err) {
logger.error({fileName: 'Conf', lineNum: 101, msg: 'Updating Node Settings Failed!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Updating Node Settings Failed!', error: {error: 'Updating node settings failed.'}});
res.status(500).json({
message: "Updating Node Settings Failed!",
error: 'Updating Node Settings Failed!'
@ -107,6 +113,7 @@ exports.updateUISettings = (req, res, next) => {
};
exports.update2FASettings = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Updating 2FA Settings..'});
var RTLConfFile = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
var config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
config.secret2fa = req.body.secret2fa;
@ -114,11 +121,12 @@ exports.update2FASettings = (req, res, next) => {
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
common.rtl_secret2fa = config.secret2fa;
logger.info({fileName: 'RTLConf', msg: message});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: message});
logger.log({level: 'INFO', fileName: 'RTLConf', msg: '2FA Updated'});
res.status(201).json({message: message});
}
catch (err) {
logger.error({fileName: 'Conf', lineNum: 121, msg: 'Updating 2FA Settings Failed!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Updating 2FA Settings Failed!', error: {error: 'Updating 2FA settings failed.'}});
res.status(500).json({
message: "Updating 2FA Settings Failed!",
error: 'Updating 2FA Settings Failed!'
@ -127,16 +135,18 @@ exports.update2FASettings = (req, res, next) => {
};
exports.updateDefaultNode = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Updating Default Node..'});
RTLConfFile = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
var config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
config.defaultNodeIndex = req.body.defaultNodeIndex;
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.info({fileName: 'RTLConf', msg: 'Updating Default Node Succesful!'});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: 'Updating Default Node Succesful!'});
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Default Node Updated'});
res.status(201).json({message: 'Default Node Updated Successfully'});
}
catch (err) {
logger.error({fileName: 'Conf', lineNum: 139, msg: 'Updating Default Node Failed!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Updating Default Node Failed!', error: {error: 'Updating dafault node failed.'}});
res.status(500).json({
message: "Updating Default Node Failed!",
error: 'Updating Default Node Failed!'
@ -145,6 +155,7 @@ exports.updateDefaultNode = (req, res, next) => {
};
exports.getConfig = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Reading Configuration File..'});
let confFile = '';
let fileFormat = 'INI';
switch (req.params.nodeType) {
@ -162,10 +173,10 @@ exports.getConfig = (req, res, next) => {
confFile = '';
break;
}
logger.info({fileName: 'RTLConf', msg: 'Node Type: ' + req.params.nodeType + ', File Path: ' + confFile});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: '[Node Type, File Path]', data: [req.params.nodeType, confFile]});
fs.readFile(confFile, 'utf8', function(err, data) {
if (err) {
logger.error({fileName: 'Conf', lineNum: 168, msg: 'Reading Conf Failed!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Reading Conf Failed!', error: err});
res.status(500).json({
message: "Reading Config File Failed!",
error: err
@ -184,17 +195,19 @@ exports.getConfig = (req, res, next) => {
}
jsonConfig = maskPasswords(jsonConfig);
const responseJSON = (fileFormat === 'JSON') ? jsonConfig : ini.stringify(jsonConfig);
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Configuration Data Received'});
res.status(200).json({format: fileFormat, data: responseJSON});
}
});
};
exports.getFile = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Getting File..'});
let file = req.query.path ? req.query.path : (common.selectedNode.channel_backup_path + common.path_separator + 'channel-' + req.query.channel.replace(':', '-') + '.bak');
logger.info({fileName: 'Conf', msg: 'Channel Point: ' + req.query.channel + ', File Path: ' + file});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: '[Channel Point, File Path]', data: [req.query.channel, file]});
fs.readFile(file, 'utf8', function(err, data) {
if (err) {
logger.error({fileName: 'Conf', lineNum: 207, msg: 'Reading File Failed!' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Reading File Failed!', error: err});
if (err.code && err.code === 'ENOENT') {
err.code = 'Backup File Not Found!';
}
@ -203,13 +216,15 @@ exports.getFile = (req, res, next) => {
error: err
});
} else {
logger.info({fileName: 'Conf', msg: 'File Data: ' + data});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: 'File Data', data: data});
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'File Data Received'});
res.status(200).json(data);
}
});
};
exports.getCurrencyRates = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Getting Currency Rates..'});
options.url = 'https://blockchain.info/ticker';
request(options).then((body) => {
if(!body || body.error) {
@ -218,12 +233,12 @@ exports.getCurrencyRates = (req, res, next) => {
error: (!body) ? 'Error From External Server!' : body.error
});
} else {
res.status(200).json(body);
body = JSON.parse(body);
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Currency Rates Received'});
res.status(200).json(JSON.parse(body));
}
})
.catch(function (err) {
logger.error({fileName: 'Conf', lineNum: 210, msg: 'Fetching Rates Failed! ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Fetching Rates Failed!', error: err});
return res.status(500).json({
message: "Fetching Rates Failed!",
error: err.error
@ -232,17 +247,19 @@ exports.getCurrencyRates = (req, res, next) => {
};
exports.updateSSO = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Updating SSO Settings..'});
RTLConfFile = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
var config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
delete config.SSO;
config.SSO = req.body.SSO;
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.info({fileName: 'RTLConf', msg: 'Updating SSO Succesful!'});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: 'Updating SSO Succesful!'});
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'SSO Setting Updated'});
res.status(201).json({message: 'SSO Updated Successfully'});
}
catch (err) {
logger.error({fileName: 'RTLConf', lineNum: 279, msg: 'Updating SSO Failed!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Updating SSO Failed!', error: {error: 'Updating SSO failed.'}});
res.status(500).json({
message: "Updating SSO Failed!",
error: 'Updating SSO Failed!'
@ -251,6 +268,7 @@ exports.updateSSO = (req, res, next) => {
};
exports.updateServiceSettings = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Updating Service Settings..'});
var RTLConfFile = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
var config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
const selectedNode = common.findNode(common.selectedNode.index);
@ -293,11 +311,12 @@ exports.updateServiceSettings = (req, res, next) => {
});
try {
fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8');
logger.info({fileName: 'RTLConf', msg: 'Updating Service Settings Succesful!'});
logger.log({level: 'DEBUG', fileName: 'RTLConf', msg: 'Updating Service Settings Succesful!'});
logger.log({level: 'INFO', fileName: 'RTLConf', msg: 'Service Settings Updated'});
res.status(201).json({message: 'Service Settings Updated Successfully'});
}
catch (err) {
logger.error({fileName: 'RTLConf', lineNum: 333, msg: 'Updating Service Settings Failed!'});
logger.log({level: 'ERROR', fileName: 'RTLConf', msg: 'Updating Service Settings Failed!', error: {error: 'Updating service settings failed.'}});
res.status(500).json({
message: "Updating Service Settings Failed!",
error: 'Updating Service Settings Failed!'
@ -317,7 +336,7 @@ var maskPasswords = function(obj) {
&& (keys[i].toLowerCase().includes('password') || keys[i].toLowerCase().includes('multipass')
|| keys[i].toLowerCase().includes('rpcpass') || keys[i].toLowerCase().includes('rpcpassword'))
) {
obj[keys[i]] = obj[keys[i]].replace(/./g, '*');
obj[keys[i]] = '********************';
}
}
}

View File

@ -1,5 +1,5 @@
var common = require('../../common');
var connect = require('../../connect');
var common = require('../../routes/common');
var connect = require('../../routes/connect');
var logger = require('./logger');
const jwt = require("jsonwebtoken");
const otplib = require("otplib");
@ -29,7 +29,7 @@ handleError = (failed, currentTime, errMsg) => {
if (failed.count >= ALLOWED_LOGIN_ATTEMPTS && (currentTime <= (failed.lastTried + LOCKING_PERIOD))) {
return {
message: "Multiple Failed Login Attempts!",
error: "Application locked for " + (LOCKING_PERIOD/ONE_MINUTE) + " minutes due to multiple failed login attempts! Try again after " + common.convertTimestampToLocalDate((failed.lastTried + LOCKING_PERIOD)/1000) + "!"
error: "Application locked for " + (LOCKING_PERIOD/ONE_MINUTE) + " minutes due to multiple failed login attempts! Try again after " + common.convertTimestampToTime((failed.lastTried + LOCKING_PERIOD)/1000) + "!"
};
} else {
return {
@ -47,8 +47,10 @@ exports.verifyToken = (twoFAToken) => {
};
exports.authenticateUser = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Authenticate', msg: 'Authenticating User..'});
if(+common.rtl_sso) {
if(req.body.authenticateWith === 'JWT' && jwt.verify(req.body.authenticationValue, common.secret_key)) {
logger.log({level: 'INFO', fileName: 'Authenticate', msg: 'User Authenticated'});
res.status(200).json({ token: token });
} else if (req.body.authenticateWith === 'PASSWORD' && common.cookie.trim().length >= 32 && crypto.timingSafeEqual(Buffer.from(crypto.createHash('sha256').update(common.cookie).digest('hex'), 'utf-8'), Buffer.from(req.body.authenticationValue, 'utf-8'))) {
connect.refreshCookie(common.rtl_cookie_path);
@ -56,9 +58,10 @@ exports.authenticateUser = (req, res, next) => {
{ user: 'SSO_USER', configPath: common.nodes[0].config_path, macaroonPath: common.nodes[0].macaroon_path },
common.secret_key
);
logger.log({level: 'INFO', fileName: 'Authenticate', msg: 'User Authenticated.'});
res.status(200).json({ token: token });
} else {
logger.error({fileName: 'Authenticate', lineNum: 61, msg: 'SSO Authentication Failed! Access key too short or does not match.'});
logger.log({level: 'ERROR', fileName: 'Authenticate', msg: 'SSO Authentication Failed! Access key too short or does not match.', error: {error: 'Access key too short or does not match.'}});
res.status(406).json({
message: "SSO Authentication Failed!",
error: "SSO failed. Access key too short or does not match."
@ -72,7 +75,7 @@ exports.authenticateUser = (req, res, next) => {
if (common.rtl_pass === password && failed.count < ALLOWED_LOGIN_ATTEMPTS) {
if (req.body.twoFAToken && req.body.twoFAToken !== '') {
if (!this.verifyToken(req.body.twoFAToken)) {
logger.error({fileName: 'Authenticate', lineNum: 75, msg: 'Invalid Token! Failed IP ' + reqIP});
logger.log({level: 'ERROR', fileName: 'Authenticate', msg: 'Invalid Token! Failed IP ' + reqIP, error: {error: 'Invalid token.'}});
failed.count = failed.count + 1;
failed.lastTried = currentTime;
return res.status(401).json(handleError(failed, currentTime, 'Invalid 2FA Token!'));
@ -84,9 +87,10 @@ exports.authenticateUser = (req, res, next) => {
{ user: rpcUser, configPath: common.nodes[0].config_path, macaroonPath: common.nodes[0].macaroon_path },
common.secret_key
);
logger.log({level: 'INFO', fileName: 'Authenticate', msg: 'User Authenticated'});
res.status(200).json({ token: token });
} else {
logger.error({fileName: 'Authenticate', lineNum: 89, msg: 'Invalid Password! Failed IP ' + reqIP});
logger.log({level: 'ERROR', fileName: 'Authenticate', msg: 'Invalid Password! Failed IP ' + reqIP, error: {error: 'Invalid password.'}});
failed.count = common.rtl_pass !== password ? (failed.count + 1) : failed.count;
failed.lastTried = common.rtl_pass !== password ? currentTime : failed.lastTried;
return res.status(401).json(handleError(failed, currentTime, 'Invalid Password!'));
@ -95,8 +99,9 @@ exports.authenticateUser = (req, res, next) => {
};
exports.resetPassword = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Authenticate', msg: 'Resetting Password..'});
if(+common.rtl_sso) {
logger.error({fileName: 'Authenticate', lineNum: 99, msg: 'Password Reset Failed!'});
logger.log({level: 'ERROR', fileName: 'Authenticate', msg: 'Password Reset Failed!', error: {error: 'Password reset failed.'}});
res.status(401).json({
message: "Password Reset Failed!",
error: "Password cannot be reset for SSO authentication!"
@ -110,9 +115,10 @@ exports.resetPassword = (req, res, next) => {
{ user: rpcUser, configPath: common.nodes[0].config_path, macaroonPath: common.nodes[0].macaroon_path },
common.secret_key
);
logger.log({level: 'INFO', fileName: 'Authenticate', msg: 'Password Reset Successful'});
res.status(200).json({ token: token });
} else {
logger.error({fileName: 'Authenticate', lineNum: 115, msg: 'Password Reset Failed!'});
logger.log({level: 'ERROR', fileName: 'Authenticate', msg: 'Password Reset Failed!', error: {error: 'Password reset failed.'}});
res.status(401).json({
message: "Password Reset Failed!",
error: "Old password is not correct!"

View File

@ -1,14 +1,16 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('../shared/logger');
var options = {};
exports.getInfo = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Getting Boltz Information..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Boltz Get Info Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/info';
request(options).then(function (body) {
logger.info({fileName: 'Boltz', msg: 'Boltz Get Info: ' + JSON.stringify(body)});
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Boltz Information Received'});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Boltz Get Info', data: body});
res.status(200).json(body);
})
.catch(errRes => {
@ -19,7 +21,7 @@ exports.getInfo = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 22, msg: 'Boltz Get Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Boltz Get Info Error', error: err});
return res.status(500).json({
message: "Boltz Get Info Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -28,11 +30,13 @@ exports.getInfo = (req, res, next) => {
};
exports.getServiceInfo = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Getting Service Information..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Boltz Get Service Info Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/serviceinfo';
request(options).then(function (body) {
logger.info({fileName: 'Boltz', msg: 'Boltz Get Service Info: ' + JSON.stringify(body)});
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Service Information Received'});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Boltz Get Service Info', data: body});
res.status(200).json(body);
})
.catch(errRes => {
@ -43,7 +47,7 @@ exports.getServiceInfo = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 46, msg: 'Boltz Get Service Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Boltz Get Service Info Error', error: err});
return res.status(500).json({
message: "Boltz Get Service Info Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -52,13 +56,15 @@ exports.getServiceInfo = (req, res, next) => {
};
exports.listSwaps = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Getting List Swaps..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Boltz List Swaps Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/listswaps';
request(options).then(function (body) {
logger.info({fileName: 'Boltz', msg: 'Boltz List Swaps Info: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Boltz List Swaps Info', data: body});
if (body && body.swaps && body.swaps.length && body.swaps.length > 0) { body.swaps = body.swaps.reverse(); }
if (body && body.reverseSwaps && body.reverseSwaps.length && body.reverseSwaps.length > 0) { body.reverseSwaps = body.reverseSwaps.reverse(); }
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'List Swaps Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -69,7 +75,7 @@ exports.listSwaps = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 70, msg: 'Boltz List Swaps Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Boltz List Swaps Error', error: err});
return res.status(500).json({
message: "Boltz List Swaps Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -78,11 +84,13 @@ exports.listSwaps = (req, res, next) => {
};
exports.getSwapInfo = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Getting Swap..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Boltz Swap Info Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/swap/' + req.params.swapId;
request(options).then(function (body) {
logger.info({fileName: 'Boltz', msg: 'Boltz Swap Info: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Boltz Swap Info', data: body});
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Swap Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -93,7 +101,7 @@ exports.getSwapInfo = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 94, msg: 'Boltz Swap Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Boltz Swap Info Error', error: err});
return res.status(500).json({
message: "Boltz Swap Info Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -102,21 +110,23 @@ exports.getSwapInfo = (req, res, next) => {
};
exports.createSwap = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Creating Swap..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Create Swap Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/createswap';
options.body = { amount: req.body.amount };
if (req.body.address !== '') { options.body.address = req.body.address; }
logger.info({fileName: 'Boltz', msg: 'Create Swap Body: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Create Swap Body', data: options.body});
request.post(options).then(createSwapRes => {
logger.info({fileName: 'Boltz', msg: 'Create Swap Response: ' + JSON.stringify(createSwapRes)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Create Swap Response', data: createSwapRes});
if(!createSwapRes || createSwapRes.error) {
logger.error({fileName: 'Boltz', lineNum: 112, msg: 'Create Swap Error: ' + JSON.stringify(createSwapRes.error)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Create Swap Error', error: createSwapRes.error});
res.status(500).json({
message: 'Create Swap Failed!',
error: (!createSwapRes) ? 'Error From Server!' : createSwapRes.error.message
});
} else {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Swap Created'});
res.status(201).json(createSwapRes);
}
})
@ -128,7 +138,7 @@ exports.createSwap = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 129, msg: 'Create Swap Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Create Swap Error', error: err});
return res.status(500).json({
message: "Create Swap Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -137,21 +147,23 @@ exports.createSwap = (req, res, next) => {
};
exports.createReverseSwap = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Creating Reverse Swap..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Create Reverse Swap Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/createreverseswap';
options.body = { amount: req.body.amount };
if (req.body.address !== '') { options.body.address = req.body.address; }
logger.info({fileName: 'Boltz', msg: 'Create Reverse Swap Body: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Create Reverse Swap Body', data: options.body});
request.post(options).then(createReverseSwapRes => {
logger.info({fileName: 'Boltz', msg: 'Create Reverse Swap Response: ' + JSON.stringify(createReverseSwapRes)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Create Reverse Swap Response', data: createReverseSwapRes});
if(!createReverseSwapRes || createReverseSwapRes.error) {
logger.error({fileName: 'Boltz', lineNum: 147, msg: 'Create Reverse Swap Error: ' + JSON.stringify(createReverseSwapRes.error)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Create Reverse Swap Error', error: createReverseSwapRes.error});
res.status(500).json({
message: 'Create Reverse Swap Failed!',
error: (!createReverseSwapRes) ? 'Error From Server!' : createReverseSwapRes.error.message
});
} else {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Reverse Swap Created'});
res.status(201).json(createReverseSwapRes);
}
})
@ -163,7 +175,7 @@ exports.createReverseSwap = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 164, msg: 'Create Reverse Swap Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Create Reverse Swap Error', error: err});
return res.status(500).json({
message: "Create Reverse Swap Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -172,21 +184,23 @@ exports.createReverseSwap = (req, res, next) => {
};
exports.createChannel = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Creating Boltz Channel..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Create Channel Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/createchannel';
options.body = { amount: req.body.amount };
if (req.body.address !== '') { options.body.address = req.body.address; }
logger.info({fileName: 'Boltz', msg: 'Create Channel Body: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Create Channel Body', data: options.body});
request.post(options).then(createChannelRes => {
logger.info({fileName: 'Boltz', msg: 'Create Channel Response: ' + JSON.stringify(createChannelRes)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Create Channel Response', data: createChannelRes});
if(!createChannelRes || createChannelRes.error) {
logger.error({fileName: 'Boltz', lineNum: 182, msg: 'Create Channel Error: ' + JSON.stringify(createChannelRes.error)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Create Channel Error', error: createChannelRes.error});
res.status(500).json({
message: 'Create Channel Failed!',
error: (!createChannelRes) ? 'Error From Server!' : createChannelRes.error.message
});
} else {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Boltz Channel Created'});
res.status(201).json(createChannelRes);
}
})
@ -198,7 +212,7 @@ exports.createChannel = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 199, msg: 'Create Channel Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Create Channel Error', error: err});
return res.status(500).json({
message: "Create Channel Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -207,18 +221,20 @@ exports.createChannel = (req, res, next) => {
};
exports.deposit = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Boltz Deposit Start..'});
options = common.getBoltzServerOptions();
if(options.url === '') { return res.status(500).json({message: "Deposit Failed!",error: { message: 'Boltz Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/deposit';
request.post(options).then(depositRes => {
logger.info({fileName: 'Boltz', msg: 'Deposit Response: ' + JSON.stringify(depositRes)});
logger.log({level: 'DEBUG', fileName: 'Boltz', msg: 'Deposit Response', data: depositRes});
if(!depositRes || depositRes.error) {
logger.error({fileName: 'Boltz', lineNum: 214, msg: 'Deposit Error: ' + JSON.stringify(depositRes.error)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Deposit Error', error: depositRes.error});
res.status(500).json({
message: 'Deposit Failed!',
error: (!depositRes) ? 'Error From Server!' : depositRes.error.message
});
} else {
logger.log({level: 'INFO', fileName: 'Boltz', msg: 'Boltz Deposit Finished'});
res.status(201).json(depositRes);
}
})
@ -230,7 +246,7 @@ exports.deposit = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Boltz', lineNum: 231, msg: 'Deposit Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Boltz', msg: 'Deposit Error', error: err});
return res.status(500).json({
message: "Deposit Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err

View File

@ -1,24 +1,11 @@
var fs = require('fs');
var common = require('../../common');
var common = require('../../routes/common');
exports.info = (msgJSON, selNode = common.selectedNode) => {
const msgStr = '\r\nINFO: ' + msgJSON.fileName + ' => ' + msgJSON.msg;
if (msgJSON.fileName !== 'Config Setup Variable') {
console.log(msgStr);
}
if(selNode && selNode.enable_logging) {
fs.appendFile(selNode.log_file, msgStr, function(err) {
if (err) {
return ({ error: 'Updating Log Failed!' });
} else {
return ({ message: 'Log Updated Successfully' });
}
});
}
}
exports.error = (msgJSON, selNode = common.selectedNode) => {
const msgStr = '\r\nERROR: ' + msgJSON.fileName + '(' + msgJSON.lineNum + ') => ' + msgJSON.msg;
exports.log = (msgJSON, selNode = common.selectedNode) => {
let msgStr = '\r\n[' + new Date().toISOString() + '] ' + msgJSON.level + ': ' + msgJSON.fileName + ' => ' + msgJSON.msg;
switch (msgJSON.level) {
case 'ERROR':
msgStr = msgStr + ': ' + (msgJSON.error && typeof msgJSON.error === 'object' ? JSON.stringify(msgJSON.error) : (msgJSON.error && typeof msgJSON.error === 'string') ? msgJSON.error : '');
console.error(msgStr);
if(selNode && selNode.enable_logging) {
fs.appendFile(selNode.log_file, msgStr, function(err) {
@ -29,4 +16,47 @@ exports.error = (msgJSON, selNode = common.selectedNode) => {
}
});
}
break;
case 'INFO':
if(selNode && selNode.enable_logging && msgJSON.data) {
msgStr = msgStr + ': ' + (msgJSON.data && typeof msgJSON.data === 'object' ? JSON.stringify(msgJSON.data) : (msgJSON.data && typeof msgJSON.data === 'string') ? msgJSON.data : '');
if (msgJSON.fileName !== 'Config Setup Variable') { console.log(msgStr); }
fs.appendFile(selNode.log_file, msgStr, function(err) {
if (err) {
return ({ error: 'Updating Log Failed!' });
} else {
return ({ message: 'Log Updated Successfully' });
}
});
} else {
console.log(msgStr + '.');
}
break;
case 'DEBUG':
if(selNode && selNode.enable_logging) {
if (msgJSON.data && typeof msgJSON.data !== 'string' && msgJSON.data.length && msgJSON.data.length > 0) {
msgStr = msgJSON.data.reduce((accumulator, dataEle) => {
return accumulator + (typeof dataEle === 'object' ? JSON.stringify(dataEle) : (typeof dataEle === 'string') ? dataEle : '') + ', ';
}, msgStr + ': [');
msgStr = msgStr.slice(0, -2) + ']';
} else {
msgStr = msgStr + ': ' + (msgJSON.data && typeof msgJSON.data === 'object' ? JSON.stringify(msgJSON.data) : (msgJSON.data && typeof msgJSON.data === 'string') ? msgJSON.data : '');
}
if (msgJSON.fileName !== 'Config Setup Variable') { console.log(msgStr); }
fs.appendFile(selNode.log_file, msgStr, function(err) {
if (err) {
return ({ error: 'Updating Log Failed!' });
} else {
return ({ message: 'Log Updated Successfully' });
}
});
}
break;
default:
console.log(msgStr, selNode);
break
}
}

View File

@ -1,9 +1,10 @@
var request = require('request-promise');
var common = require('../../common');
var common = require('../../routes/common');
var logger = require('./logger');
var options = {};
exports.loopOut = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Looping Out..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop Out Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/out';
@ -20,16 +21,17 @@ exports.loopOut = (req, res, next) => {
};
if (req.body.chanId !== '') { options.body['loop_out_channel'] = req.body.chanId; }
if (req.body.destAddress !== '') { options.body['dest'] = req.body.destAddress; }
logger.info({fileName: 'Loop', msg: 'Loop Out Body: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Body', data: options.body});
request.post(options).then(loopOutRes => {
logger.info({fileName: 'Loop', msg: 'Loop Out: ' + JSON.stringify(loopOutRes)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out', data: loopOutRes});
if(!loopOutRes || loopOutRes.error) {
logger.error({fileName: 'Loop', lineNum: 28, msg: 'Loop Out Error: ' + JSON.stringify(loopOutRes.error)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop Out Error', error: loopOutRes.error});
res.status(500).json({
message: 'Loop Out Failed!',
error: (!loopOutRes) ? 'Error From Server!' : loopOutRes.error.message
});
} else {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop Out Finished'});
res.status(201).json(loopOutRes);
}
})
@ -41,7 +43,7 @@ exports.loopOut = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 44, msg: 'Loop Out Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop Out Error', error: err});
return res.status(500).json({
message: "Loop Out Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -50,11 +52,13 @@ exports.loopOut = (req, res, next) => {
};
exports.loopOutTerms = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting Loop Out Terms..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop Out Terms Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/out/terms';
request(options).then(function (body) {
logger.info({fileName: 'Loop', msg: 'Loop Out Terms: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Terms', data: body});
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop Out Terms Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -65,7 +69,7 @@ exports.loopOutTerms = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 67, msg: 'Loop Out Terms Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop Out Terms Error', error: err});
return res.status(500).json({
message: "Loop Out Terms Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -74,14 +78,16 @@ exports.loopOutTerms = (req, res, next) => {
};
exports.loopOutQuote = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting Loop Out Quotes..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop Out Quote Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/out/quote/' + req.params.amount + '?conf_target=' + (req.query.targetConf ? req.query.targetConf : '2') + '&swap_publication_deadline=' + req.query.swapPublicationDeadline;
logger.info({fileName: 'Loop', msg: 'Loop Out Quote URL: ' + options.url});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Quote URL', data: options.url});
request(options).then(function (quoteRes) {
logger.info({fileName: 'Loop', msg: 'Loop Out Quote: ' + JSON.stringify(quoteRes)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Quote', data: quoteRes});
quoteRes.amount = +req.params.amount;
quoteRes.swap_payment_dest = quoteRes.swap_payment_dest ? Buffer.from(quoteRes.swap_payment_dest, 'base64').toString('hex') : '';
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop Out Quotes Received'});
res.status(200).json(quoteRes);
})
.catch(errRes => {
@ -92,7 +98,7 @@ exports.loopOutQuote = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 94, msg: 'Loop Out Quote Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop Out Quote Error', error: err});
return res.status(500).json({
message: "Loop Out Quote Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -101,23 +107,25 @@ exports.loopOutQuote = (req, res, next) => {
};
exports.loopOutTermsAndQuotes = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting Loop Out Terms & Quotes..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop Out Terms And Quotes Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/out/terms';
request(options).then(function(terms) {
logger.info({fileName: 'Loop', msg: 'Loop Out Terms: ' + JSON.stringify(terms)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Terms', data: terms});
const options1 = common.getSwapServerOptions(); const options2 = common.getSwapServerOptions();
options1.url = options1.url + '/v1/loop/out/quote/' + terms.min_swap_amount + '?conf_target=' + (req.query.targetConf ? req.query.targetConf : '2') + '&swap_publication_deadline=' + req.query.swapPublicationDeadline;
options2.url = options2.url + '/v1/loop/out/quote/' + terms.max_swap_amount + '?conf_target=' + (req.query.targetConf ? req.query.targetConf : '2') + '&swap_publication_deadline=' + req.query.swapPublicationDeadline;
logger.info({fileName: 'Loop', msg: 'Loop Out Min Quote Options: ' + JSON.stringify(options1)});
logger.info({fileName: 'Loop', msg: 'Loop Out Max Quote Options: ' + JSON.stringify(options2)});
Promise.all([request(options1), request(options2)]).then(function(values) {
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Min Quote Options', data: options1});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Max Quote Options', data: options2});
return Promise.all([request(options1), request(options2)]).then(function(values) {
values[0].amount = +terms.min_swap_amount;
values[1].amount = +terms.max_swap_amount;
values[0].swap_payment_dest = values[0].swap_payment_dest ? Buffer.from(values[0].swap_payment_dest, 'base64').toString('hex') : '';
values[1].swap_payment_dest = values[1].swap_payment_dest ? Buffer.from(values[1].swap_payment_dest, 'base64').toString('hex') : '';
logger.info({fileName: 'Loop', msg: 'Loop Out Quotes 1: ' + JSON.stringify(values[0])});
logger.info({fileName: 'Loop', msg: 'Loop Out Quotes 2: ' + JSON.stringify(values[1])});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Quotes 1', data: values[0]});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Out Quotes 2', data: values[1]});
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop Out Terms & Quotes Received'});
res.status(200).json(values);
})
.catch(errRes => {
@ -128,7 +136,7 @@ exports.loopOutTermsAndQuotes = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 132, msg: 'Loop Out Quotes Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop Out Quotes Error', error: err});
return res.status(500).json({
message: "Loop Out Quotes Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -143,7 +151,7 @@ exports.loopOutTermsAndQuotes = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 146, msg: 'Loop Out Terms Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop Out Terms Error', error: err});
return res.status(500).json({
message: "Loop Out Terms Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -152,6 +160,7 @@ exports.loopOutTermsAndQuotes = (req, res, next) => {
};
exports.loopIn = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Looping In..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop In Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/in';
@ -161,16 +170,17 @@ exports.loopIn = (req, res, next) => {
max_miner_fee: req.body.minerFee,
initiator: 'RTL'
};
logger.info({fileName: 'Loop', msg: 'Loop In Body: ' + JSON.stringify(options.body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Body', data: options.body});
request.post(options).then(function (body) {
logger.info({fileName: 'Loop', msg: 'Loop In: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In', data: body});
if(!body || body.error) {
logger.error({fileName: 'Loop', lineNum: 166, msg: 'Loop In Error: ' + JSON.stringify(body.error)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop In Error', error: body.error});
res.status(500).json({
message: 'Loop In Failed!',
error: (body.error && body.error.message) ? body.error.message : 'Error From Server!'
});
} else {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop In Finished'});
res.status(201).json(body);
}
})
@ -182,7 +192,7 @@ exports.loopIn = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 182, msg: 'Loop In Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop In Error', error: err});
return res.status(500).json({
message: "Loop In Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -191,11 +201,13 @@ exports.loopIn = (req, res, next) => {
};
exports.loopInTerms = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting Loop In Terms..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop In Terms Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/in/terms';
request(options).then(function (body) {
logger.info({fileName: 'Loop', msg: 'Loop In Terms: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Terms', data: body});
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop In Terms Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -206,7 +218,7 @@ exports.loopInTerms = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 205, msg: 'Loop In Terms Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop In Terms Error', error: err});
return res.status(500).json({
message: "Loop In Terms Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -215,14 +227,16 @@ exports.loopInTerms = (req, res, next) => {
};
exports.loopInQuote = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting Loop In Quotes..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop In Quote Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/in/quote/' + req.params.amount + '?conf_target=' + (req.query.targetConf ? req.query.targetConf : '2') + '&swap_publication_deadline=' + req.query.swapPublicationDeadline;
logger.info({fileName: 'Loop', msg: 'Loop In Quote Options: ' + options.url});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Quote Options', data: options.url});
request(options).then(function (body) {
logger.info({fileName: 'Loop', msg: 'Loop In Quote: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Quote', data: body});
body.amount = +req.params.amount;
body.swap_payment_dest = body.swap_payment_dest ? Buffer.from(body.swap_payment_dest, 'base64').toString('hex') : '';
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop In Qoutes Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -233,7 +247,7 @@ exports.loopInQuote = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 232, msg: 'Loop In Quote Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop In Quote Error', error: err});
return res.status(500).json({
message: "Loop In Quote Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -242,23 +256,25 @@ exports.loopInQuote = (req, res, next) => {
};
exports.loopInTermsAndQuotes = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting Loop In Terms & Quotes..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop In Terms And Quotes Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/in/terms';
request(options).then(function(terms) {
logger.info({fileName: 'Loop', msg: 'Loop In Terms: ' + JSON.stringify(terms)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Terms', data: terms});
const options1 = common.getSwapServerOptions(); const options2 = common.getSwapServerOptions();
options1.url = options1.url + '/v1/loop/in/quote/' + terms.min_swap_amount + '?conf_target=' + (req.query.targetConf ? req.query.targetConf : '2') + '&swap_publication_deadline=' + req.query.swapPublicationDeadline;
options2.url = options2.url + '/v1/loop/in/quote/' + terms.max_swap_amount + '?conf_target=' + (req.query.targetConf ? req.query.targetConf : '2') + '&swap_publication_deadline=' + req.query.swapPublicationDeadline;
logger.info({fileName: 'Loop', msg: 'Loop In Min Quote Options: ' + JSON.stringify(options1)});
logger.info({fileName: 'Loop', msg: 'Loop In Max Quote Options: ' + JSON.stringify(options2)});
Promise.all([request(options1), request(options2)]).then(function(values) {
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Min Quote Options', data: options1});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Max Quote Options', data: options2});
return Promise.all([request(options1), request(options2)]).then(function(values) {
values[0].amount = +terms.min_swap_amount;
values[1].amount = +terms.max_swap_amount;
values[0].swap_payment_dest = values[0].swap_payment_dest ? Buffer.from(values[0].swap_payment_dest, 'base64').toString('hex') : '';
values[1].swap_payment_dest = values[1].swap_payment_dest ? Buffer.from(values[1].swap_payment_dest, 'base64').toString('hex') : '';
logger.info({fileName: 'Loop', msg: 'Loop In Quotes 1: ' + JSON.stringify(values[0])});
logger.info({fileName: 'Loop', msg: 'Loop In Quotes 2: ' + JSON.stringify(values[1])});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Quotes 1', data: values[0]});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop In Quotes 2', data: values[1]});
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Loop In Terms & Qoutes Received'});
res.status(200).json(values);
})
.catch(errRes => {
@ -269,7 +285,7 @@ exports.loopInTermsAndQuotes = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 270, msg: 'Loop In Quotes Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop In Quotes Error', error: err});
return res.status(500).json({
message: "Loop In Quotes Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -284,7 +300,7 @@ exports.loopInTermsAndQuotes = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 284, msg: 'Loop In Terms Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Loop In Terms Error', error: err});
return res.status(500).json({
message: "Loop In Terms Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -293,19 +309,17 @@ exports.loopInTermsAndQuotes = (req, res, next) => {
};
exports.swaps = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting List Swaps..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop Out Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/swaps';
request(options).then(function (body) {
logger.info({fileName: 'Loop', msg: 'Loop Swaps: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Swaps', data: body});
if (body.swaps && body.swaps.length > 0) {
body.swaps.forEach(swap => {
swap.initiation_time_str = (!swap.initiation_time) ? '' : common.convertTimestampToDate(Math.round(swap.initiation_time/1000000000));
swap.last_update_time_str = (!swap.last_update_time) ? '' : common.convertTimestampToDate(Math.round(swap.last_update_time/1000000000));
});
body.swaps = common.sortDescByKey(body.swaps, 'initiation_time');
logger.info({fileName: 'Loop', msg: 'Loop Swaps after Sort: ' + JSON.stringify(body)});
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Swaps after Sort', data: body});
}
logger.log({level: 'INFO', fileName: 'Loop', msg: 'List Swaps Received'});
res.status(200).json(body.swaps);
})
.catch(errRes => {
@ -316,7 +330,7 @@ exports.swaps = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 327, msg: 'List Swaps Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'List Swaps Error', error: err});
return res.status(500).json({
message: "Loop Swaps Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err
@ -325,13 +339,13 @@ exports.swaps = (req, res, next) => {
};
exports.swap = (req, res, next) => {
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Getting Swap Information..'});
options = common.getSwapServerOptions();
if(options.url === '') { return res.status(500).json({message: "Loop Out Failed!",error: { message: 'Loop Server URL is missing in the configuration.'}}); }
options.url = options.url + '/v1/loop/swap/' + req.params.id;
request(options).then(function (body) {
logger.info({fileName: 'Loop', msg: 'Loop Swap: ' + body});
body.initiation_time_str = (!body.initiation_time) ? '' : common.convertTimestampToDate(Math.round(body.initiation_time/1000000000));
body.last_update_time_str = (!body.last_update_time) ? '' : common.convertTimestampToDate(Math.round(body.last_update_time/1000000000));
logger.log({level: 'DEBUG', fileName: 'Loop', msg: 'Loop Swap', data: body});
logger.log({level: 'INFO', fileName: 'Loop', msg: 'Swap Information Received'});
res.status(200).json(body);
})
.catch(errRes => {
@ -342,7 +356,7 @@ exports.swap = (req, res, next) => {
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
delete err.response.request.headers['Grpc-Metadata-macaroon'];
}
logger.error({fileName: 'Loop', lineNum: 342, msg: 'Swap Info Error: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Loop', msg: 'Swap Info Error', error: err});
return res.status(500).json({
message: "Loop Swap Failed!",
error: (err.error && err.error.error) ? err.error.error : (err.error) ? err.error : err

View File

@ -1,4 +1,4 @@
FROM node:10-alpine
FROM node:14-alpine
RUN apk add --no-cache tini
@ -8,7 +8,7 @@ COPY package.json /RTL/package.json
COPY package-lock.json /RTL/package-lock.json
# Install dependencies
RUN npm install --only=prod
RUN npm install --production
COPY . /RTL

33
docker/Dockerfile.arm32v7 Normal file
View File

@ -0,0 +1,33 @@
FROM node:14-stretch-slim AS builder
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-armel /tini
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-armel.asc /tini.asc
# RUN apt-get install gnupg
# RUN gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
# && gpg --batch --verify /tini.asc /tini
RUN chmod +x /tini
WORKDIR /RTL
COPY . /RTL
COPY package.json /RTL/package.json
COPY package-lock.json /RTL/package-lock.json
# Install dependencies
RUN npm install --production
COPY . /RTL
FROM arm32v7/node:14-stretch-slim
WORKDIR /RTL
COPY --from=builder "/RTL" .
COPY --from=builder "/tini" /sbin/tini
EXPOSE 3000
ENTRYPOINT ["/sbin/tini", "-g", "--"]
CMD ["node", "rtl"]

View File

@ -1,6 +1,6 @@
FROM node:10-stretch-slim AS builder
FROM node:14-stretch-slim AS builder
ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini-static-arm64 /tini
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini-static-arm64 /tini
RUN chmod +x /tini
WORKDIR /RTL
@ -11,11 +11,11 @@ COPY package.json /RTL/package.json
COPY package-lock.json /RTL/package-lock.json
# Install dependencies
RUN npm install --only=prod
RUN npm install --production
COPY . /RTL
FROM arm64v8/node:10-stretch-slim
FROM arm64v8/node:14-stretch-slim
WORKDIR /RTL

View File

@ -8,7 +8,7 @@ volumes:
services:
bitcoind:
container_name: ${COMPOSE_PROJECT_NAME}_bitcoind
image: bitcoind:0.17.1
image: bitcoind:0.19.0
build: ./bitcoind
command: [
"bitcoind",
@ -37,7 +37,7 @@ services:
lnd:
container_name: ${COMPOSE_PROJECT_NAME}_lnd
image: lnd:0.5.2-beta
image: lnd:0.12.0-beta
build: ./lnd
restart: unless-stopped
command: [
@ -101,7 +101,7 @@ services:
rtl:
container_name: ${COMPOSE_PROJECT_NAME}_rtl
image: shahanafarooqui/rtl:0.6.4
image: shahanafarooqui/rtl:0.10.2
restart: unless-stopped
depends_on:
- lnd

View File

@ -45,7 +45,7 @@ $ npm install --only=prod
```
### <a name="prep"></a>Prep for Execution
RTL requires its own config file `RTL-Config.json`, to start the server and provide user authentication on the app.
* Rename `sample-RTL-Config.json` file to `RTL-Config.json`.
* Copy the file `Sample-RTL-Config.json` from `./RTL/docs` to `./RTL` and rename it to `RTL-Config.json`.
* Locate the complete path of the readable `access.macaroon` from `cl-rest` on your node.
* Modify the RTL conf file per the example file below

View File

@ -40,7 +40,7 @@ $ npm install --only=prod
```
### <a name="prep"></a>Prep for Execution
RTL requires its own config file `RTL-Config.json`, to start the server and provide user authentication on the app.
* Rename `sample-RTL-Config.json` file to `RTL-Config.json`.
* Copy the file `Sample-RTL-Config.json` from `./RTL/docs` to `./RTL` and rename it to `RTL-Config.json`.
* Locate the complete path of the readable `eclair.conf` for your node.
* Modify the RTL conf file per the example file below

View File

@ -16,7 +16,7 @@ This step is only required to configure the nodes, which will be remotely connec
4. Restart LND
#### 2. Configure 'RTL-Config.json'
1. Rename the `sample-RTL-Config.json` on the root RTL location to `RTL-Config.json`
1. Copy the file `Sample-RTL-Config.json` from `./RTL/docs` to `./RTL` and rename it to `RTL-Config.json`
2. Set `multiPass` to the preferred password. This password will be used to authenticate the user for RTL. Once authenticated, the user will be able to access all the nodes configured in the json file
3. Set the `port` to the preferred port number over which to run RTL
4. Set the `defaultNodeIndex` to configure the default start up node at server restart

View File

@ -1,10 +1,10 @@
## Ride The Lightning (RTL)
![](screenshots/RTL-LND-Dashboard.png)
![](../screenshots/RTL-LND-Dashboard.png)
<a href="https://snyk.io/test/github/Ride-The-Lightning/RTL"><img src="https://snyk.io/test/github/Ride-The-Lightning/RTL/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/Ride-The-Lightning/RTL" style="max-width:100%;"></a>
[![license](https://img.shields.io/github/license/DAVFoundation/captain-n3m0.svg?style=flat-square)](https://github.com/DAVFoundation/captain-n3m0/blob/master/LICENSE)
**Intro** -- [Application Features](docs/Application_features.md) -- [Road Map](docs/Roadmap.md) -- [Application Configurations](docs/Application_configurations) -- [C-Lightning](docs/C-Lightning-setup.md) -- [Eclair](docs/Eclair-setup.md) -- [Contribution](docs/Contributing.md)
**Intro** -- [Application Features](Application_features.md) -- [Road Map](Roadmap.md) -- [Application Configurations](Application_configurations) -- [C-Lightning](C-Lightning-setup.md) -- [Eclair](Eclair-setup.md) -- [Contribution](Contributing.md)
* [Introduction](#intro)
* [Architecture](#arch)
@ -19,8 +19,8 @@
RTL is a full function, device agnostic, web user interface to help manage lightning node operations.
RTL is available on [LND](https://github.com/lightningnetwork/lnd), [C-Lightning](https://github.com/ElementsProject/lightning) and [Eclair](https://github.com/ACINQ/eclair) implementations.
* C-Lightning users, refer to [this](docs/C-Lightning-setup.md) page for install instructions.
* Eclair users, refer to [this](docs/Eclair-setup.md) page for install instructions.
* C-Lightning users, refer to [this](C-Lightning-setup.md) page for install instructions.
* Eclair users, refer to [this](Eclair-setup.md) page for install instructions.
* LND users, follow the instructions below
Lightning Network Daemon(LND) is an implementation of Lightning Network BOLT protocol by [Lightning Labs](https://lightning.engineering/).
@ -41,7 +41,7 @@ RTL is available on the below platforms/services:
Docker Image: https://hub.docker.com/r/shahanafarooqui/rtl
### <a name="arch"></a>Architecture
![](screenshots/RTL-LND-Arch-2.png)
![](../screenshots/RTL-LND-Arch-2.png)
### <a name="prereq"></a>Prerequisites
* Functioning and synced LND lightning node.
@ -69,9 +69,9 @@ $ npm install --only=prod
### <a name="prep"></a>Prep for Execution
RTL requires its own config file `RTL-Config.json`, to start the server and provide user authentication on the app.
*Advanced users can refer to [this page](docs/Multi-Node-setup.md), for config settings required to manage multiple nodes*
*Advanced users can refer to [this page](Multi-Node-setup.md), for config settings required to manage multiple nodes*
* Rename `sample-RTL-Config.json` file to `RTL-Config.json`.
* Copy the file `Sample-RTL-Config.json` from `./RTL/docs` to `./RTL` and rename it to `RTL-Config.json`.
* Locate the complete path of the readable macroon file (admin.macroon) on your node and the lnd.conf file.
* Modify the `RTL-Config.json` file per the example file below
@ -114,7 +114,7 @@ Example RTL-Config.json:
]
}
```
For details on all the configuration options refer to [this page](./docs/Application_configurations).
For details on all the configuration options refer to [this page](./Application_configurations).
#### User Authentication on RTL
RTL requires the user to be authenticated by the application first, before allowing access to LND functions.
@ -172,11 +172,11 @@ Open your browser at the following address: http://localhost:3000 to access the
* Determine the IP address of your node to access the application.
E.g. if the IP address of your node is 192.168.0.15 then open your browser at the following address: http://192.168.0.15:3000 to access RTL.
3. Config tweaks for running RTL server and LND on separate devices on the same network can be found [here](docs/RTL_setups.md).
3. Config tweaks for running RTL server and LND on separate devices on the same network can be found [here](RTL_setups.md).
4. Any Other setup: **Please be advised, if you are accessing your node remotely via RTL, its critical to encrypt the communication via use of https. You can use solutions like nginx and letsencrypt or TOR to setup secure access for RTL.**
- Sample SSL setup guide can be found [here](docs/RTL_SSL_setup.md)
- (For advanced users) A sample SSL guide to serve remote access over an encrypted Tor connection can be found [here](docs/RTL_TOR_setup.md)
- Sample SSL setup guide can be found [here](RTL_SSL_setup.md)
- (For advanced users) A sample SSL guide to serve remote access over an encrypted Tor connection can be found [here](RTL_TOR_setup.md)
### <a name="trouble"></a>Troubleshooting
In case you are running into issues with the application or if you have feedback, feel free to open issues on our github repo.

9910
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,15 @@
{
"name": "rtl",
"version": "0.10.2-beta",
"version": "0.11.0-beta",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --open",
"prebuild": "node ./prebuild",
"build": "ng analytics off && ng build --prod",
"prebuild": "node ./src/prebuild",
"build": "ng analytics off && ng lint && ng build --configuration production",
"devbuild": "ng build --configuration production",
"serve": "ng serve",
"server": "nodemon ./rtl.js",
"server": "set NODE_ENV=development&&nodemon ./rtl.js",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
@ -16,31 +17,31 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~11.0.4",
"@angular/cdk": "^11.0.3",
"@angular/common": "~11.0.4",
"@angular/compiler": "~11.0.4",
"@angular/compiler-cli": "~11.0.4",
"@angular/core": "~11.0.4",
"@angular/flex-layout": "^11.0.0-beta.33",
"@angular/forms": "~11.0.4",
"@angular/material": "^11.0.3",
"@angular/platform-browser": "~11.0.4",
"@angular/platform-browser-dynamic": "~11.0.4",
"@angular/router": "~11.0.4",
"@angular/animations": "~12.0.1",
"@angular/cdk": "^12.0.1",
"@angular/common": "~12.0.1",
"@angular/compiler": "~12.0.1",
"@angular/compiler-cli": "~12.0.1",
"@angular/core": "~12.0.1",
"@angular/flex-layout": "^12.0.0-beta.34",
"@angular/forms": "~12.0.1",
"@angular/material": "^12.0.1",
"@angular/platform-browser": "~12.0.1",
"@angular/platform-browser-dynamic": "~12.0.1",
"@angular/router": "~12.0.1",
"@fortawesome/angular-fontawesome": "^0.8.1",
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"@fortawesome/free-regular-svg-icons": "^5.15.1",
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@ngrx/effects": "^10.1.0",
"@ngrx/store": "^10.1.0",
"@ngrx/effects": "^12.0.0",
"@ngrx/store": "^12.0.0",
"@swimlane/ngx-charts": "^16.0.0",
"angular-user-idle": "^2.2.4",
"angularx-qrcode": "^10.0.11",
"angular-user-idle": "^2.2.5",
"angularx-qrcode": "^11.0.0",
"atob": "^2.1.2",
"cookie-parser": "^1.4.5",
"csurf": "^1.11.0",
"express": "^4.17.1",
"hammerjs": "^2.0.8",
"hocon-parser": "^1.0.1",
"ini": "^2.0.0",
"jsonwebtoken": "^8.5.1",
@ -50,30 +51,38 @@
"request": "^2.88.2",
"request-promise": "^4.2.6",
"roboto-fontface": "^0.10.0",
"rxjs": "~6.6.0",
"rxjs": "^7.1.0",
"sha256": "^0.2.0",
"tslib": "^2.0.0",
"typescript": "~4.0.2",
"zone.js": "~0.10.2"
"typescript": "~4.2.4",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.4",
"@angular/cli": "^11.2.9",
"@ngrx/store-devtools": "^10.1.0",
"@angular-devkit/build-angular": "~12.0.1",
"@angular-eslint/builder": "12.0.0",
"@angular-eslint/eslint-plugin": "12.0.0",
"@angular-eslint/eslint-plugin-template": "12.0.0",
"@angular-eslint/schematics": "12.0.0",
"@angular-eslint/template-parser": "12.0.0",
"@angular/cli": "^12.0.1",
"@ngrx/store-devtools": "^12.0.0",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.19.9",
"codelyzer": "^6.0.0",
"@typescript-eslint/eslint-plugin": "4.23.0",
"@typescript-eslint/parser": "4.23.0",
"crypto-browserify": "^3.12.0",
"dotenv": "^8.2.0",
"eslint": "^7.26.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.1.0",
"karma": "~6.3.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"nodemon": "^2.0.6",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0"
"stream-browserify": "^3.0.0",
"ts-node": "~8.3.0"
}
}

View File

@ -1,28 +0,0 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};

View File

@ -2,8 +2,8 @@ const path = require("path");
const express = require("express");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const csurf = require("csurf");
const common = require("./common");
const app = express();
const baseHref = "/rtl/";
const apiRoot = baseHref + "api/";
@ -11,56 +11,57 @@ const apiLNDRoot = baseHref + "api/lnd/";
const apiCLRoot = baseHref + "api/cl/";
const apiECLRoot = baseHref + "api/ecl/";
const authenticateRoutes = require("./routes/shared/authenticate");
const RTLConfRoutes = require("./routes/shared/RTLConf");
const loopRoutes = require('./routes/shared/loop');
const boltzRoutes = require('./routes/shared/boltz');
const authenticateRoutes = require("./shared/authenticate");
const RTLConfRoutes = require("./shared/RTLConf");
const loopRoutes = require('./shared/loop');
const boltzRoutes = require('./shared/boltz');
const infoRoutes = require("./routes/lnd/getInfo");
const channelsRoutes = require("./routes/lnd/channels");
const channelsBackupRoutes = require("./routes/lnd/channelsBackup");
const peersRoutes = require("./routes/lnd/peers");
const feesRoutes = require("./routes/lnd/fees");
const balanceRoutes = require("./routes/lnd/balance");
const walletRoutes = require("./routes/lnd/wallet");
const graphRoutes = require("./routes/lnd/graph");
const newAddressRoutes = require("./routes/lnd/newAddress");
const transactionsRoutes = require("./routes/lnd/transactions");
const payReqRoutes = require("./routes/lnd/payReq");
const paymentsRoutes = require("./routes/lnd/payments");
const invoiceRoutes = require("./routes/lnd/invoices");
const switchRoutes = require("./routes/lnd/switch");
const messageRoutes = require("./routes/lnd/message");
const infoRoutes = require("./lnd/getInfo");
const channelsRoutes = require("./lnd/channels");
const channelsBackupRoutes = require("./lnd/channelsBackup");
const peersRoutes = require("./lnd/peers");
const feesRoutes = require("./lnd/fees");
const balanceRoutes = require("./lnd/balance");
const walletRoutes = require("./lnd/wallet");
const graphRoutes = require("./lnd/graph");
const newAddressRoutes = require("./lnd/newAddress");
const transactionsRoutes = require("./lnd/transactions");
const payReqRoutes = require("./lnd/payReq");
const paymentsRoutes = require("./lnd/payments");
const invoiceRoutes = require("./lnd/invoices");
const switchRoutes = require("./lnd/switch");
const messageRoutes = require("./lnd/message");
const infoCLRoutes = require("./routes/c-lightning/getInfo");
const feesCLRoutes = require("./routes/c-lightning/fees");
const balanceCLRoutes = require("./routes/c-lightning/balance");
const channelsCLRoutes = require("./routes/c-lightning/channels");
const invoicesCLRoutes = require("./routes/c-lightning/invoices");
const onChainCLRoutes = require("./routes/c-lightning/onchain");
const paymentsCLRoutes = require("./routes/c-lightning/payments");
const peersCLRoutes = require("./routes/c-lightning/peers");
const networkCLRoutes = require("./routes/c-lightning/network");
const messageCLRoutes = require("./routes/c-lightning/message");
const infoCLRoutes = require("./c-lightning/getInfo");
const feesCLRoutes = require("./c-lightning/fees");
const balanceCLRoutes = require("./c-lightning/balance");
const channelsCLRoutes = require("./c-lightning/channels");
const invoicesCLRoutes = require("./c-lightning/invoices");
const onChainCLRoutes = require("./c-lightning/onchain");
const paymentsCLRoutes = require("./c-lightning/payments");
const peersCLRoutes = require("./c-lightning/peers");
const networkCLRoutes = require("./c-lightning/network");
const messageCLRoutes = require("./c-lightning/message");
const infoECLRoutes = require("./routes/eclair/getInfo");
const feesECLRoutes = require("./routes/eclair/fees");
const channelsECLRoutes = require("./routes/eclair/channels");
const onChainECLRoutes = require("./routes/eclair/onchain");
const peersECLRoutes = require("./routes/eclair/peers");
const invoicesECLRoutes = require("./routes/eclair/invoices");
const paymentsECLRoutes = require("./routes/eclair/payments");
const networkECLRoutes = require("./routes/eclair/network");
const infoECLRoutes = require("./eclair/getInfo");
const feesECLRoutes = require("./eclair/fees");
const channelsECLRoutes = require("./eclair/channels");
const onChainECLRoutes = require("./eclair/onchain");
const peersECLRoutes = require("./eclair/peers");
const invoicesECLRoutes = require("./eclair/invoices");
const paymentsECLRoutes = require("./eclair/payments");
const networkECLRoutes = require("./eclair/network");
const app = express();
const csrfProtection = csurf({cookie: true});
app.set('trust proxy', true);
app.use(cookieParser(common.secret_key));
app.use(bodyParser.json({limit: '25mb'}));
app.use(bodyParser.urlencoded({extended: false, limit: '25mb'}));
app.use(baseHref, express.static(path.join(__dirname, "angular")));
app.use(baseHref, express.static(path.join(__dirname, "..", "angular")));
// CORS fix, Only required for developement due to separate backend and frontend servers
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization, filePath"
@ -69,9 +70,12 @@ app.use((req, res, next) => {
"Access-Control-Allow-Methods",
"GET, POST, PATCH, PUT, DELETE, OPTIONS"
);
next();
if (process.env.NODE_ENV == 'development') {
res.setHeader("Access-Control-Allow-Origin", req.headers.origin ? req.headers.origin : '');
return next();
}
csrfProtection(req, res, next);
});
// CORS fix, Only required for developement due to separate backend and frontend servers
app.use(apiRoot + "authenticate", authenticateRoutes);
app.use(apiRoot + "conf", RTLConfRoutes);
@ -115,7 +119,8 @@ app.use(apiECLRoot + "payments", paymentsECLRoutes);
app.use(apiECLRoot + "network", networkECLRoutes);
app.use((req, res, next) => {
res.sendFile(path.join(__dirname, "angular", "index.html"));
res.cookie('XSRF-TOKEN', req.csrfToken ? req.csrfToken() : '');
res.sendFile(path.join(__dirname, "..", "angular", "index.html"));
});
module.exports = app;

View File

@ -2,7 +2,7 @@ var fs = require('fs');
var crypto = require('crypto');
var path = require('path');
var common = {};
const MONTH_NAMES = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
const MONTHS = [{name: 'JAN', days: 31}, {name: 'FEB', days: 28}, {name: 'MAR', days: 31}, {name: 'APR', days: 30}, {name: 'MAY', days: 31}, {name: 'JUN', days: 30}, {name: 'JUL', days: 31}, {name: 'AUG', days: 31}, {name: 'SEP', days: 30}, {name: 'OCT', days: 31}, {name: 'NOV', days: 30}, {name: 'DEC', days: 31}];
var dummy_data_array_from_file = [];
common.rtl_conf_file_path = '';
@ -161,18 +161,7 @@ common.convertToBTC = (num) => {
return (num / 100000000).toFixed(6);
};
common.convertTimestampToDate = (num) => {
let myDate = new Date(+num * 1000);
let days = myDate.getDate().toString();
days = +days < 10 ? '0' + days : days;
let hours = myDate.getHours().toString();
hours = +hours < 10 ? '0' + hours : hours;
let minutes = myDate.getMinutes().toString();
minutes = +minutes < 10 ? '0' + minutes : minutes;
return days + "/" + MONTH_NAMES[myDate.getMonth()] + "/" + myDate.getFullYear() + " " + hours + ":" + minutes;
};
common.convertTimestampToLocalDate = (num) => {
common.convertTimestampToTime = (num) => {
let myDate = new Date(+num * 1000);
let days = myDate.getDate().toString();
days = +days < 10 ? '0' + days : days;
@ -182,7 +171,7 @@ common.convertTimestampToLocalDate = (num) => {
minutes = +minutes < 10 ? '0' + minutes : minutes;
let seconds = myDate.getSeconds().toString();
seconds = +seconds < 10 ? '0' + seconds : seconds;
return days + "/" + (MONTH_NAMES[myDate.getMonth()]) + "/" + myDate.getFullYear() + " " + hours + ":" + minutes + ":" + seconds;
return days + "/" + MONTHS[myDate.getMonth()].name + "/" + myDate.getFullYear() + " " + hours + ":" + minutes + ":" + seconds;
};
common.sortAscByKey = (array, key) => {
@ -254,6 +243,10 @@ common.getDummyData = (data_key) => {
});
}
common.getMonthDays = (selMonth, selYear) => {
return (selMonth === 1 && selYear%4 === 0) ? (MONTHS[selMonth].days+1) : MONTHS[selMonth].days;
}
filterData = (data_key) => {
let search_string = '';
switch (data_key) {
@ -269,6 +262,10 @@ filterData = (data_key) => {
search_string = 'INFO: Fees => Payments Response: ';
break;
case 'Invoices':
search_string = 'INFO: Invoice => Invoices List Received: ';
break;
case 'OnChainBalance':
search_string = 'INFO: Onchain => Balance Received: ';
break;

View File

@ -5,10 +5,10 @@ var crypto = require('crypto');
var hash = crypto.createHash('sha256');
var common = require('./common');
var path = require('path');
var logger = require('./controllers/shared/logger');
var logger = require('../controllers/shared/logger');
var connect = {};
var errMsg = '';
var request = require('request');
var request = require('request-promise');
var ini = require('ini');
var parseHocon = require('hocon-parser');
common.path_separator = (platform === 'win32') ? '\\' : '/';
@ -84,7 +84,7 @@ connect.normalizePort = val => {
};
connect.replacePasswordWithHash = (multiPassHashed) => {
common.rtl_conf_file_path = process.env.RTL_CONFIG_PATH ? process.env.RTL_CONFIG_PATH : path.normalize(__dirname);
common.rtl_conf_file_path = process.env.RTL_CONFIG_PATH ? process.env.RTL_CONFIG_PATH : path.join(__dirname, '..');
try {
RTLConfFile = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
var config = JSON.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
@ -336,17 +336,17 @@ connect.logEnvVariables = () => {
if (common.nodes && common.nodes.length > 0) {
common.nodes.forEach((node, idx) => {
if (!node.enable_logging) { return; }
logger.info({fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port, node});
logger.info({fileName: 'Config Setup Variable', msg: 'HOST: ' + common.host, node});
logger.info({fileName: 'Config Setup Variable', msg: 'DEFAULT NODE INDEX: ' + common.selectedNode.index});
logger.info({fileName: 'Config Setup Variable', msg: 'SSO: ' + common.rtl_sso, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LOGOUT REDIRECT LINK: ' + common.logout_redirect_link + '\r\n', node});
logger.info({fileName: 'Config Setup Variable', msg: 'INDEX: ' + node.index, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN NODE: ' + node.ln_node, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + node.ln_implementation, node});
logger.info({fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + node.fiat_conversion, node});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + node.currency_unit, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + node.ln_server_url, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'PORT: ' + common.port, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'HOST: ' + common.host, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'DEFAULT NODE INDEX: ' + common.selectedNode.index});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'SSO: ' + common.rtl_sso, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'LOGOUT REDIRECT LINK: ' + common.logout_redirect_link + '\r\n', node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'INDEX: ' + node.index, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'LN NODE: ' + node.ln_node, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + node.ln_implementation, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + node.fiat_conversion, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + node.currency_unit, node});
logger.log({level: 'DEBUG', fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + node.ln_server_url, node});
});
}
}
@ -359,26 +359,24 @@ connect.getAllNodeAllChannelBackup = (node) => {
json: true,
headers: {'Grpc-Metadata-macaroon': fs.readFileSync(node.macaroon_path + '/admin.macaroon').toString('hex')}
};
request(options, function (err, res, body) {
if (err) {
logger.error({fileName: 'Connect', lineNum: 443, msg: 'Channel Backup Response Failed: ' + JSON.stringify(err)});
} else {
request(options).then(function(body) {
fs.writeFile(channel_backup_file, JSON.stringify(body), function(err) {
if (err) {
if (node.ln_node) {
logger.error({fileName: 'Connect', lineNum: 448, msg: 'Channel Backup Failed for Node ' + node.ln_node + ' with error response: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Connect', msg: 'Channel Backup Failed for Node ' + node.ln_node, error: err});
} else {
logger.error({fileName: 'Connect', lineNum: 450, msg: 'Channel Backup Failed: ' + JSON.stringify(err)});
logger.log({level: 'ERROR', fileName: 'Connect', msg: 'Channel Backup Error', error: err});
}
} else {
if (node.ln_node) {
logger.info({fileName: 'Connect', msg: 'Channel Backup Successful for Node: ' + node.ln_node});
logger.log({level: 'DEBUG', fileName: 'Connect', msg: 'Channel Backup Successful for Node', data: node.ln_node});
} else {
logger.info({fileName: 'Connect', msg: 'Channel Backup Successful'});
logger.log({level: 'DEBUG', fileName: 'Connect', msg: 'Channel Backup Successful'});
}
}
});
}
}, (err) => {
logger.log({level: 'ERROR', fileName: 'Connect', msg: 'Channel Backup Response Error', error: err});
})
};
@ -553,7 +551,7 @@ connect.upgradeConfig = (confFileFullPath) => {
connect.setServerConfiguration = () => {
try {
common.rtl_conf_file_path = (process.env.RTL_CONFIG_PATH) ? process.env.RTL_CONFIG_PATH : path.normalize(__dirname);
common.rtl_conf_file_path = (process.env.RTL_CONFIG_PATH) ? process.env.RTL_CONFIG_PATH : path.join(__dirname, '/..');
confFileFullPath = common.rtl_conf_file_path + common.path_separator + 'RTL-Config.json';
if(!fs.existsSync(confFileFullPath)) {
connect.upgradeConfig(confFileFullPath);

View File

@ -1,7 +0,0 @@
const graphInfoController = require("../../controllers/graphInfo");
const express = require("express");
const router = express.Router();
router.get("/", graphInfoController.getGraphInfo);
module.exports = router;

View File

@ -1,7 +0,0 @@
const LNDSettingsController = require("../../controllers/lndConfSettings");
const express = require("express");
const router = express.Router();
router.get("/", LNDSettingsController.getLNDSettings);
module.exports = router;

View File

@ -4,5 +4,6 @@ const router = express.Router();
const authCheck = require("../shared/authCheck");
router.get("/", authCheck, PaymentsController.getPayments);
router.get("/alltransactions", authCheck, PaymentsController.getAllLightningTransactions);
module.exports = router;

View File

@ -1,5 +1,5 @@
const jwt = require("jsonwebtoken");
var common = require('../../common');
var common = require('../../routes/common');
module.exports = (req, res, next) => {
try {

12
rtl.js
View File

@ -1,9 +1,9 @@
#!/usr/bin/env node
const app = require("./app");
const common = require("./common");
const app = require("./routes/app");
const common = require("./routes/common");
const http = require("http");
var connect = require('./connect').setServerConfiguration(); //Do NOT Remove
var connect = require("./routes/connect").setServerConfiguration(); //Do NOT Remove
const onError = error => {
if (error.syscall !== "listen") {
@ -13,13 +13,15 @@ const onError = error => {
case "EACCES":
console.error("http://" + (common.host ? common.host : 'localhost') + ":" + common.port + " requires elevated privileges");
process.exit(1);
break;
case "EADDRINUSE":
console.error("http://" + (common.host ? common.host : 'localhost') + ":" + common.port + " is already in use");
process.exit(1);
break;
case "ECONNREFUSED":
console.error("Server is down/locked");
process.exit(1);
case "EBADCSRFTOKEN":
console.error("Form tempered");
process.exit(1);
default:
console.error("DEFUALT ERROR");
console.error(error.code);

View File

@ -89,6 +89,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.userIdle.startWatching();
}
});
if (this.sessionService.getItem('defaultPassword') === 'true') {
this.flgSideNavOpened = false;
}
this.actions$.pipe(takeUntil(this.unSubs[2]),
filter((action) => action.type === RTLActions.SET_RTL_CONFIG || action.type === RTLActions.LOGOUT))
.subscribe((action: (RTLActions.SetRTLConfig | RTLActions.Logout)) => {
@ -126,6 +129,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.store.dispatch(new RTLActions.Logout());
}
});
if (this.sessionService.getItem('defaultPassword') === 'true') {
this.flgSideNavOpened = false;
}
}
private readAccessKey() {

View File

@ -54,4 +54,5 @@ export const routes: Routes = [
{ path: '**', component: NotFoundComponent }
];
// export const routing: ModuleWithProviders<RouterModule> = RouterModule.forRoot(routes, { enableTracing: true });
export const routing: ModuleWithProviders<RouterModule> = RouterModule.forRoot(routes);

View File

@ -1,4 +1,4 @@
import { Component, OnChanges, Input } from '@angular/core';
import { Component, Input } from '@angular/core';
import { ChannelsStatus } from '../../../shared/models/clModels';
@Component({
@ -6,11 +6,9 @@ import { ChannelsStatus } from '../../../shared/models/clModels';
templateUrl: './channel-status-info.component.html',
styleUrls: ['./channel-status-info.component.scss']
})
export class CLChannelStatusInfoComponent implements OnChanges {
export class CLChannelStatusInfoComponent {
@Input() channelsStatus: ChannelsStatus = {};
constructor() {}
ngOnChanges() {}
}

View File

@ -220,7 +220,7 @@ export class CLHomeComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -19,7 +19,7 @@
<mat-divider [inset]="true"></mat-divider>
<div fxLayout="column" fxFlex="10" class="my-1">
<h4 class="font-bold-500">Last Update</h4>
<span class="foreground-secondary-text">{{lookupResult[0].last_update_str}}</span>
<span class="foreground-secondary-text">{{lookupResult[0].last_update }}</span>
</div>
<mat-divider [inset]="true"></mat-divider>
<div fxLayout="column" fxFlex="10" class="my-1">
@ -100,7 +100,7 @@
<mat-divider [inset]="true"></mat-divider>
<div fxLayout="column" fxFlex="10" class="my-1">
<h4 class="font-bold-500">Last Update</h4>
<span class="foreground-secondary-text">{{lookupResult[1].last_update_str}}</span>
<span class="foreground-secondary-text">{{(lookupResult[1].last_update * 1000) | date:'dd/MMM/YYYY HH:mm'}}</span>
</div>
<mat-divider [inset]="true"></mat-divider>
<div fxLayout="column" fxFlex="10" class="my-1">

View File

@ -108,7 +108,7 @@ export class CLLookupsComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -15,7 +15,7 @@
<div fxLayout="row">
<div fxLayout="column" fxFlex="50" fxLayoutAlign="end start" class="my-1">
<h4 fxLayoutAlign="start" class="font-bold-500">Last Update</h4>
<span class="foreground-secondary-text">{{lookupResult.last_timestamp_str}}</span>
<span class="foreground-secondary-text">{{(lookupResult.last_timestamp * 1000) | date:'dd/MMM/YYYY HH:mm'}}</span>
</div>
<div fxLayout="column" fxFlex="50" fxLayoutAlign="end start" class="my-1">
<h4 fxLayoutAlign="start" class="font-bold-500">Features</h4>

View File

@ -15,8 +15,6 @@ export class CLFeeRatesComponent implements AfterContentChecked {
constructor() { }
ngOnInit() {}
ngAfterContentChecked() {
if (this.feeRateStyle === feeRateStyle.KB) {
this.perkbw = this.feeRates.perkb;

View File

@ -112,7 +112,7 @@ export class CLNetworkInfoComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { take } from 'rxjs/operators';
import { Store } from '@ngrx/store';
@ -15,15 +15,13 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
templateUrl: './on-chain-receive.component.html',
styleUrls: ['./on-chain-receive.component.scss']
})
export class CLOnChainReceiveComponent implements OnInit {
export class CLOnChainReceiveComponent {
public addressTypes = ADDRESS_TYPES;
public selectedAddressType = ADDRESS_TYPES[0];
public newAddress = '';
constructor(private store: Store<fromRTLReducer.RTLState>, private clEffects: CLEffects) {}
ngOnInit() {}
onGenerateAddress() {
this.store.dispatch(new RTLActions.OpenSpinner('Getting New Address...'));
this.store.dispatch(new CLActions.GetNewAddress(this.selectedAddressType));

View File

@ -287,7 +287,7 @@ export class CLOnChainSendModalComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -33,7 +33,7 @@ export class CLOnChainSendComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -60,7 +60,7 @@ export class CLOnChainComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -60,7 +60,7 @@ export class CLUTXOTablesComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -137,7 +137,7 @@ export class CLChannelOpenTableComponent implements OnInit, AfterViewInit, OnDes
flgShowInput: true,
getInputs: [
{placeholder: 'Base Fee (mSats)', inputType: 'number', inputValue: 1000, width: 48},
{placeholder: 'Fee Rate (mili mSats)', inputType: 'number', inputValue: 1, min: 1, width: 48}
{placeholder: 'Fee Rate (mili mSats)', inputType: 'number', inputValue: 1, min: 1, width: 48, hintFunction: this.percentHintFunction}
]
}}));
this.rtlEffects.closeConfirm
@ -178,7 +178,7 @@ export class CLChannelOpenTableComponent implements OnInit, AfterViewInit, OnDes
flgShowInput: true,
getInputs: [
{placeholder: 'Base Fee (mSats)', inputType: 'number', inputValue: (this.myChanPolicy.fee_base_msat === '') ? 0 : this.myChanPolicy.fee_base_msat, width: 48},
{placeholder: 'Fee Rate (mili mSats)', inputType: 'number', inputValue: this.myChanPolicy.fee_rate_milli_msat, min: 1, width: 48}
{placeholder: 'Fee Rate (mili mSats)', inputType: 'number', inputValue: this.myChanPolicy.fee_rate_milli_msat, min: 1, width: 48, hintFunction: this.percentHintFunction}
]
}}));
});
@ -196,6 +196,10 @@ export class CLChannelOpenTableComponent implements OnInit, AfterViewInit, OnDes
this.applyFilter();
}
percentHintFunction(fee_rate_milli_msat) {
return (fee_rate_milli_msat / 10000).toString() + '%';
}
onChannelClose(channelToClose: Channel) {
this.store.dispatch(new RTLActions.OpenConfirmation({ data: {
type: AlertTypeEnum.CONFIRM,
@ -254,7 +258,7 @@ export class CLChannelOpenTableComponent implements OnInit, AfterViewInit, OnDes
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -154,7 +154,7 @@ export class CLChannelPendingTableComponent implements OnInit, AfterViewInit, On
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -86,7 +86,7 @@ export class CLChannelsTablesComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

View File

@ -172,7 +172,7 @@ export class CLOpenChannelComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.unSubs.forEach(completeSub => {
completeSub.next();
completeSub.next(null);
completeSub.complete();
});
}

Some files were not shown because too many files have changed in this diff Show More