From c3281399d2aad776ce62027b7fae347a2875d136 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Fri, 12 Jun 2020 20:58:37 +0200 Subject: [PATCH] Improve setup instructions and README - README cleanups and link to documentation - Improve dev setup instructions - Fix js linting errors - Move local setup instructions to installation docs - Project link fix, closes #42 - Notes about frontend - Clarify different LND backends --- .env.example | 2 +- README.md | 63 +++++---------- docs/devs/installation.md | 33 ++++++-- lnbits/core/templates/core/index.html | 2 +- .../events/templates/events/_api_docs.html | 38 +++++---- .../events/templates/events/index.html | 23 +++--- .../templates/lnticket/_api_docs.html | 37 +++++---- .../paywall/templates/paywall/_api_docs.html | 78 +++++++++++-------- .../paywall/templates/paywall/display.html | 17 +++- .../paywall/templates/paywall/index.html | 15 ++-- .../tpos/templates/tpos/_api_docs.html | 11 +-- .../templates/withdraw/_api_docs.html | 9 +-- lnbits/templates/base.html | 2 +- package-lock.json | 12 +++ package.json | 3 + 15 files changed, 189 insertions(+), 156 deletions(-) create mode 100644 package-lock.json diff --git a/.env.example b/.env.example index 993b6cd84..2596be303 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,7 @@ LNBITS_DISABLED_EXTENSIONS="amilk,events" LNBITS_FORCE_HTTPS=1 LNBITS_SERVICE_FEE="0.0" -# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, LndWallet, CLightningWallet, LnbitsWallet +# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, LndWallet (gRPC), LndRestWallet, CLightningWallet, LnbitsWallet LNBITS_BACKEND_WALLET_CLASS=LntxbotWallet CLIGHTNING_RPC="/home/bob/.lightning/bitcoin/lightning-rpc" diff --git a/README.md b/README.md index f642d1be6..67a06fff7 100644 --- a/README.md +++ b/README.md @@ -7,80 +7,59 @@ LNbits ![Lightning network wallet](https://i.imgur.com/EHvK6Lq.png) -# LNbits v0.1 BETA, free and open-source lightning-network wallet/accounts system -https://lnbits.com, or run your own LNbits server! +# LNbits v0.1 BETA, free and open-source lightning-network wallet/accounts system + +Use [lnbits.com](https://lnbits.com), or run your own LNbits server! + +LNbits is a very simple Python server that sits on top of any funding source, and can be used as: -LNbits is a very simple Python server that sits on top of any funding source, and can be used as: * Accounts system to mitigate the risk of exposing applications to your full balance, via unique API keys for each wallet -* Extendable platform for exploring lightning-network functionality via LNbits extension framework +* Extendable platform for exploring lightning-network functionality via LNbits extension framework * Part of a development stack via LNbits API * Fallback wallet for the LNURL scheme -* Instant wallet for LN demonstrations +* Instant wallet for LN demonstrations -The wallet can run on top of any lightning-network funding source, currently there is support for LND, CLightning, Lntxbot, LNpay, OpenNode, with more being added regularily. +The wallet can run on top of any lightning-network funding source, currently there is support for LND, CLightning, Lntxbot, LNpay, OpenNode, with more being added regularily. + +See [lnbits.org](https://lnbits.org) for more detailed documentation. ## LNbits as an account system -LNbits is packaged with tools to help manage funds, such as a table of transactions, line chart of spending, export to csv + more to come.. +LNbits is packaged with tools to help manage funds, such as a table of transactions, line chart of spending, export to csv + more to come.. ![Lightning network wallet](https://i.imgur.com/w8jdGpF.png) -Each wallet also comes with its own API keys, to help partition the exposure of your funding source. +Each wallet also comes with its own API keys, to help partition the exposure of your funding source. -(LNbits M5StackSats available here https://github.com/arcbtc/M5StackSats) +(LNbits M5StackSats available here https://github.com/arcbtc/M5StackSats) ![lnurl ATM](https://i.imgur.com/WfCg8wY.png) ## LNbits as an LNURL-withdraw fallback -LNURL has a fallback scheme, so if scanned by a regular QR code reader it can default to a URL. LNbits exploits this to generate an instant wallet using the LNURL-withdraw. + +LNURL has a fallback scheme, so if scanned by a regular QR code reader it can default to a URL. LNbits exploits this to generate an instant wallet using the [LNURL-withdraw](https://github.com/btcontract/lnurl-rfc/blob/master/lnurl-withdraw.md). ![lnurl fallback](https://i.imgur.com/CPBKHIv.png) -https://github.com/btcontract/lnurl-rfc/blob/master/spec.md -Using **lnbits.com/?lightning="LNURL-withdraw"** will trigger a withdraw that builds an LNbits wallet. +Using **lnbits.com/?lightning="LNURL-withdraw"** will trigger a withdraw that builds an LNbits wallet. Example use would be an ATM, which utilises LNURL, if the user scans the QR with a regular QR code scanner app, they will stilll be able to access the funds. ![lnurl ATM](https://i.imgur.com/Gi6bn3L.jpg) ## LNbits as an insta-wallet + Wallets can be easily generated and given out to people at events (one click multi-wallet generation to be added soon). "Go to this website", has a lot less friction than "Download this app". ![lnurl ATM](https://i.imgur.com/xFWDnwy.png) -# Running LNbits locally -Download this repo +## Running LNbits locally -LNbits uses [Flask](http://flask.pocoo.org/). -Feel free to contribute to the project. +See the [development docs](docs/devs/installation.md) for details on installation and setup. -Application dependencies ------------------------- -The application uses [Pipenv][pipenv] to manage Python packages. -While in development, you will need to install all dependencies: - - $ pipenv shell - $ pipenv install --dev - -You will need to set the variables in .env.example, and rename the file to .env - -![lnurl ATM](https://i.imgur.com/ri2zOe8.png) - -Running the server ------------------- - - $ flask migrate - $ flask run - -There is an environment variable called `FLASK_ENV` that has to be set to `development` -if you want to run Flask in debug mode with autoreload - -[pipenv]: https://docs.pipenv.org/#install-pipenv-today - -# Tip me -If you like this project and might even use or extend it, why not send some tip love! -https://lnbits.com/paywall/GAqKguK5S8f6w5VNjS9DfK +## Tip me +If you like this project and might even use or extend it, why not [send some tip love](https://lnbits.com/paywall/GAqKguK5S8f6w5VNjS9DfK)! [github-actions]: https://github.com/lnbits/lnbits/actions [github-actions-badge]: https://github.com/lnbits/lnbits/workflows/test%20suite/badge.svg diff --git a/docs/devs/installation.md b/docs/devs/installation.md index c3865de92..3502df325 100644 --- a/docs/devs/installation.md +++ b/docs/devs/installation.md @@ -5,30 +5,47 @@ title: Installation nav_order: 1 --- - Installation ============ -LNbits uses [Flask](http://flask.pocoo.org/). - +Download this repo and install the dependencies. Application dependencies ------------------------ The application uses [Pipenv][pipenv] to manage Python packages. -While in development, you will need to install all dependencies (includes packages like `black` and `flake8`): +While in development, you will need to install all dependencies: - $ pipenv shell - $ pipenv install --dev +```sh +$ pipenv shell +$ pipenv install --dev +``` +You will need to set the variables in `.env.example`, and rename the file to `.env`. + +![Files](https://i.imgur.com/ri2zOe8.png) + +You might also need to install additional packages, depending on the [backend wallets](../guide/wallets.md) you configured. +E.g. when you want to use LND you have to `pipenv install lnd-grpc`. + +Take a look at [Polar](https://lightningpolar.com/) for an excellent way of spinning up a Lightning Network dev environment. Running the server ------------------ - $ flask run +LNbits uses [Flask](http://flask.pocoo.org/) as an application server. + +```sh +$ pipenv run flask migrate +$ pipenv run flask run +``` There is an environment variable called `FLASK_ENV` that has to be set to `development` if you want to run Flask in debug mode with autoreload +[pipenv]: https://pipenv.pypa.io/ -[pipenv]: https://docs.pipenv.org/#install-pipenv-today +Frontend +-------- + +The views are build using [Vue.js and Quasar](https://quasar.dev/start/how-to-use-vue). diff --git a/lnbits/core/templates/core/index.html b/lnbits/core/templates/core/index.html index 7db8490a9..8b4d8cd87 100644 --- a/lnbits/core/templates/core/index.html +++ b/lnbits/core/templates/core/index.html @@ -47,7 +47,7 @@
View project in GitHub + type="a" href="https://github.com/lnbits/lnbits" target="_blank" rel="noopener">View project in GitHub Donate diff --git a/lnbits/extensions/events/templates/events/_api_docs.html b/lnbits/extensions/events/templates/events/_api_docs.html index 0caedae58..a5c821747 100644 --- a/lnbits/extensions/events/templates/events/_api_docs.html +++ b/lnbits/extensions/events/templates/events/_api_docs.html @@ -1,17 +1,23 @@ - - - - -
Events: Sell and register ticket waves for an event
-

Events alows you to make a wave of tickets for an event, each ticket is in the form of a unqiue QRcode, which the user presents at registration. Events comes with a shareable ticket scanner, which can be used to register attendees.
- Created by, Ben Arc

-
- - - + + + +
+ Events: Sell and register ticket waves for an event +
+

+ Events alows you to make a wave of tickets for an event, each ticket is + in the form of a unqiue QRcode, which the user presents at registration. + Events comes with a shareable ticket scanner, which can be used to + register attendees.
+ + Created by, Ben Arc + +

+
+
diff --git a/lnbits/extensions/events/templates/events/index.html b/lnbits/extensions/events/templates/events/index.html index 74304a0e1..0d60d97e7 100644 --- a/lnbits/extensions/events/templates/events/index.html +++ b/lnbits/extensions/events/templates/events/index.html @@ -55,19 +55,16 @@ :href="props.row.displayUrl" target="_blank" > - - - - + {{ col.value }} diff --git a/lnbits/extensions/lnticket/templates/lnticket/_api_docs.html b/lnbits/extensions/lnticket/templates/lnticket/_api_docs.html index 8cf813594..69328f384 100644 --- a/lnbits/extensions/lnticket/templates/lnticket/_api_docs.html +++ b/lnbits/extensions/lnticket/templates/lnticket/_api_docs.html @@ -1,17 +1,22 @@ - - - - -
Support Tickets: Get paid sats to answer questions
-

Charge people per word for contacting you. Possible applications incude, paid support ticketing, PAYG language services, contact spam protection.
- Created by, Ben Arc

-
- - - + + + +
+ Support Tickets: Get paid sats to answer questions +
+

+ Charge people per word for contacting you. Possible applications incude, + paid support ticketing, PAYG language services, contact spam + protection.
+ + Created by, Ben Arc +

+
+
diff --git a/lnbits/extensions/paywall/templates/paywall/_api_docs.html b/lnbits/extensions/paywall/templates/paywall/_api_docs.html index eda9ba182..60e610817 100644 --- a/lnbits/extensions/paywall/templates/paywall/_api_docs.html +++ b/lnbits/extensions/paywall/templates/paywall/_api_docs.html @@ -7,9 +7,7 @@ - GET /paywall/api/v1/paywalls + GET /paywall/api/v1/paywalls
Headers
{"X-Api-Key": <invoice_key>}
Body (application/json)
@@ -29,37 +27,42 @@ POST - /paywall/api/v1/paywallsPOST /paywall/api/v1/paywalls
Headers
{"X-Api-Key": <admin_key>}
Body (application/json)
{"amount": <integer>, "description": <string>, - "memo": <string>, "remembers": <boolean>, - "url": <string>}{"amount": <integer>, "description": <string>, "memo": + <string>, "remembers": <boolean>, "url": + <string>}
Returns 201 CREATED (application/json)
- {"amount": <integer>, "description": <string>, - "id": <string>, "memo": <string>, - "remembers": <boolean>, "time": <int>, - "url": <string>, "wallet": <string>} + {"amount": <integer>, "description": <string>, "id": + <string>, "memo": <string>, "remembers": <boolean>, + "time": <int>, "url": <string>, "wallet": + <string>}
Curl example
curl -X POST {{ request.url_root }}paywall/api/v1/paywalls -d - '{"url": <string>, "memo": <string>, - "description": <string>, "amount": <integer>, - "remembers": <boolean>}' -H - "Content-type: application/json" -H "X-Api-Key: {{ - g.user.wallets[0].adminkey }}" + '{"url": <string>, "memo": <string>, "description": + <string>, "amount": <integer>, "remembers": + <boolean>}' -H "Content-type: application/json" -H "X-Api-Key: + {{ g.user.wallets[0].adminkey }}"
- +
Body (application/json)
- {"amount": <integer>} + {"amount": <integer>}
Returns 201 CREATED (application/json)
- {"checking_id": <string>, "payment_request": <string>} + {"checking_id": <string>, "payment_request": + <string>}
Curl example
curl -X POST {{ request.url_root }}paywall/api/v1/paywalls/<paywall_id>/invoice -d - '{"amount": <integer>}' -H - "Content-type: application/json" + >curl -X POST {{ request.url_root + }}paywall/api/v1/paywalls/<paywall_id>/invoice -d '{"amount": + <integer>}' -H "Content-type: application/json"
- +
Body (application/json)
- {"checking_id": <string>} + {"checking_id": <string>}
Returns 200 OK (application/json)
- {"paid": false}
- {"paid": true, "url": <string>, "remembers": <boolean>} + {"paid": false}
+ {"paid": true, "url": <string>, "remembers": + <boolean>}
Curl example
curl -X POST {{ request.url_root }}paywall/api/v1/paywalls/<paywall_id>/check_invoice -d - '{"checking_id": <string>}' -H - "Content-type: application/json" + >curl -X POST {{ request.url_root + }}paywall/api/v1/paywalls/<paywall_id>/check_invoice -d + '{"checking_id": <string>}' -H "Content-type: application/json"
diff --git a/lnbits/extensions/paywall/templates/paywall/display.html b/lnbits/extensions/paywall/templates/paywall/display.html index c11b19d2a..f3b7c6ff4 100644 --- a/lnbits/extensions/paywall/templates/paywall/display.html +++ b/lnbits/extensions/paywall/templates/paywall/display.html @@ -5,7 +5,7 @@
{{ paywall.memo }}
{% if paywall.description %} -

{{ paywall.description }}

+

{{ paywall.description }}

{% endif %}
@@ -19,7 +19,16 @@ :hint="'Minimum ' + paywallAmount + ' sat'" > @@ -37,7 +46,9 @@ Copy invoice - Cancel + Cancel
diff --git a/lnbits/extensions/paywall/templates/paywall/index.html b/lnbits/extensions/paywall/templates/paywall/index.html index 69f583d39..3ea22e6d1 100644 --- a/lnbits/extensions/paywall/templates/paywall/index.html +++ b/lnbits/extensions/paywall/templates/paywall/index.html @@ -147,11 +147,11 @@ > - Remember payments + Remember payments A succesful payment will be registered in the browser's storage, so the user doesn't need to pay again to access the URL.A succesful payment will be registered in the browser's + storage, so the user doesn't need to pay again to access the + URL. @@ -204,7 +204,12 @@ return rowA.amount - rowB.amount } }, - {name: 'remembers', align: 'left', label: 'Remember', field: 'remembers'}, + { + name: 'remembers', + align: 'left', + label: 'Remember', + field: 'remembers' + }, { name: 'date', align: 'left', diff --git a/lnbits/extensions/tpos/templates/tpos/_api_docs.html b/lnbits/extensions/tpos/templates/tpos/_api_docs.html index d122a9794..aac366a29 100644 --- a/lnbits/extensions/tpos/templates/tpos/_api_docs.html +++ b/lnbits/extensions/tpos/templates/tpos/_api_docs.html @@ -4,12 +4,7 @@ label="API info" :content-inset-level="0.5" > - + GET /tpos/api/v1/tposs @@ -31,9 +26,7 @@ - POST /tpos/api/v1/tposs + POST /tpos/api/v1/tposs
Headers
{"X-Api-Key": <invoice_key>}
Body (application/json)
diff --git a/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html b/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html index 11082e567..b87e3e3bd 100644 --- a/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html +++ b/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html @@ -12,9 +12,7 @@ > - GET /withdraw/api/v1/links + GET /withdraw/api/v1/links
Headers
{"X-Api-Key": <invoice_key>}
Body (application/json)
@@ -66,10 +64,7 @@ > - POST - /withdraw/api/v1/links + POST /withdraw/api/v1/links
Headers
{"X-Api-Key": <admin_key>}
Body (application/json)
diff --git a/lnbits/templates/base.html b/lnbits/templates/base.html index 4d93ae6ce..b7a1b2d2c 100644 --- a/lnbits/templates/base.html +++ b/lnbits/templates/base.html @@ -67,7 +67,7 @@ LNbits, free and open-source lightning wallet/accounts system - + View project in GitHub diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..e08f5cc4c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,12 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "prettier": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", + "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 835ff779f..d2b656031 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,8 @@ { "devDependencies": { "prettier": "^2.0.5" + }, + "scripts": { + "lint": "prettier --write lnbits/static/js/** lnbits/core/static/js/** lnbits/extensions/*/templates/**" } }