diff --git a/Makefile b/Makefile index be5e342..50b7f4c 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,5 @@ -prettier: - ./node_modules/.bin/prettier --write lnbits/static/js/** lnbits/core/static/js/** lnbits/extensions/*/templates/** +prettier: $(shell find lnbits -name "*.js" -name ".html") + ./node_modules/.bin/prettier --write lnbits/static/js/*.js lnbits/core/static/js/*.js lnbits/extensions/*/templates/*/*.html ./lnbits/core/templates/core/*.html lnbits/templates/*.html lnbits/extensions/*/static/js/*.js + +mypy: $(shell find lnbits -name "*.py") + mypy lnbits diff --git a/lnbits/core/templates/core/_api_docs.html b/lnbits/core/templates/core/_api_docs.html index 000be86..38c3568 100644 --- a/lnbits/core/templates/core/_api_docs.html +++ b/lnbits/core/templates/core/_api_docs.html @@ -4,22 +4,43 @@ label="API info" :content-inset-level="0.5" > - + POST /api/v1/payments
Headers
{"X-Api-Key": "{{ wallet.inkey }}"}
Body (application/json)
- {"out": false, "amount": <int>, "memo": <string>} -
Returns 201 CREATED (application/json)
- {"checking_id": <string>, "payment_request": <string>} + {"out": false, "amount": <int>, "memo": <string>} +
+ Returns 201 CREATED (application/json) +
+ {"checking_id": <string>, "payment_request": + <string>}
Curl example
- curl -X POST {{ request.url_root }}api/v1/payments -d '{"out": false, "amount": <int>, "memo": <string>}' -H "X-Api-Key: {{ wallet.inkey }}" -H "Content-type: application/json" + curl -X POST {{ request.url_root }}api/v1/payments -d '{"out": false, + "amount": <int>, "memo": <string>}' -H "X-Api-Key: + {{ wallet.inkey }}" -H "Content-type: application/json"
- + POST /api/v1/payments @@ -27,24 +48,45 @@ {"X-Api-Key": "{{ wallet.adminkey }}"}
Body (application/json)
{"out": true, "bolt11": <string>} -
Returns 201 CREATED (application/json)
+
+ Returns 201 CREATED (application/json) +
{"checking_id": <string>}
Curl example
- curl -X POST {{ request.url_root }}api/v1/payments -d '{"out": true, "bolt11": <string>}' -H "X-Api-Key: {{ wallet.adminkey }}" -H "Content-type: application/json" + curl -X POST {{ request.url_root }}api/v1/payments -d '{"out": true, + "bolt11": <string>}' -H "X-Api-Key: + {{ wallet.adminkey }}" -H "Content-type: + application/json"
- + - GET /api/v1/payments/<checking_id> + GET + /api/v1/payments/<checking_id>
Headers
{"X-Api-Key": "{{ wallet.inkey }}"} -
Returns 200 OK (application/json)
+
+ Returns 200 OK (application/json) +
{"paid": <bool>}
Curl example
- curl -X GET {{ request.url_root }}api/v1/payments/<checking_id> -H "X-Api-Key: {{ wallet.inkey }}" -H "Content-type: application/json" + curl -X GET {{ request.url_root }}api/v1/payments/<checking_id> + -H "X-Api-Key: {{ wallet.inkey }}" -H "Content-type: + application/json"
diff --git a/lnbits/core/templates/core/extensions.html b/lnbits/core/templates/core/extensions.html index 7638beb..8ddb988 100644 --- a/lnbits/core/templates/core/extensions.html +++ b/lnbits/core/templates/core/extensions.html @@ -1,42 +1,55 @@ -{% extends "base.html" %} - -{% from "macros.jinja" import window_vars with context %} - - -{% block scripts %} - {{ window_vars(user) }} - {% assets filters='rjsmin', output='__bundle__/core/extensions.js', - 'core/js/extensions.js' %} - - {% endassets %} -{% endblock %} - -{% block page %} -
-
- - - - {% raw %} -
{{ extension.name }}
- {{ extension.shortDescription }} - {% endraw %} -
- - -
- Open - Disable -
- +{% endassets %} {% endblock %} {% block page %} +
+
+ + + + {% raw %} +
{{ extension.name }}
+ {{ extension.shortDescription }} {% endraw %} +
+ + +
+ Open + - Enable - - -
+ :href="['{{ url_for('core.extensions') }}', '?usr=', g.user.id, '&disable=', extension.code].join('')" + > + Disable +
+ + Enable + +
+
{% endblock %} diff --git a/lnbits/core/templates/core/index.html b/lnbits/core/templates/core/index.html index 8b4d8cd..2b148a3 100644 --- a/lnbits/core/templates/core/index.html +++ b/lnbits/core/templates/core/index.html @@ -1,72 +1,111 @@ -{% extends "public.html" %} +{% extends "public.html" %} {% block scripts %} {% assets filters='rjsmin', +output='__bundle__/core/index.js', 'core/js/index.js' %} + +{% endassets %} {% endblock %} {% block page %} +
+
+ + + {% if lnurl %} + + Press to claim bitcoin + + {% else %} + + + Add a new wallet + + {% endif %} + + - -{% block scripts %} - {% assets filters='rjsmin', output='__bundle__/core/index.js', - 'core/js/index.js' %} - - {% endassets %} -{% endblock %} - -{% block page %} -
-
- - - - {% if lnurl %} - - Press to claim bitcoin - - {% else %} - - - Add a new wallet - - {% endif %} - - - - - -

LNbits

-
Free and open-source lightning wallet
-

Easy to set up and lightweight, LNbits can run on any lightning-network funding source, currently supporting LND, c-lightning, OpenNode, lntxbot, LNPay and even LNbits itself!

-

You can run LNbits for yourself, or easily offer a custodian solution for others.

-

Each wallet has its own API keys and there is no limit to the number of wallets you can make. Being able to partition funds makes LNbits a useful tool for money management and as a development tool.

-

Extensions add extra functionality to LNbits so you can experiment with a range of cutting-edge technologies on the lightning network. We have made developing extensions as easy as possible, and as a free and open-source project, we encourage people to develop and submit their own.

-
- View project in GitHub - Donate -
-
-
- -
- - -
-
-
- - - - + + +

LNbits

+
Free and open-source lightning wallet
+

+ Easy to set up and lightweight, LNbits can run on any + lightning-network funding source, currently supporting LND, + c-lightning, OpenNode, lntxbot, LNPay and even LNbits itself! +

+

+ You can run LNbits for yourself, or easily offer a custodian solution + for others. +

+

+ Each wallet has its own API keys and there is no limit to the number + of wallets you can make. Being able to partition funds makes LNbits a + useful tool for money management and as a development tool. +

+

+ Extensions add extra functionality to LNbits so you can experiment + with a range of cutting-edge technologies on the lightning network. We + have made developing extensions as easy as possible, and as a free and + open-source project, we encourage people to develop and submit their + own. +

+
+ View project in GitHub + Donate
+
+
+
+ + +
+
+
+ + + +
+
{% endblock %} diff --git a/lnbits/core/templates/core/wallet.html b/lnbits/core/templates/core/wallet.html index eac2a13..6d19bca 100644 --- a/lnbits/core/templates/core/wallet.html +++ b/lnbits/core/templates/core/wallet.html @@ -1,259 +1,345 @@ -{% extends "base.html" %} - -{% from "macros.jinja" import window_vars with context %} - - -{% block styles %} - -{% endblock %} - -{% block scripts %} - {{ window_vars(user, wallet) }} - - {% assets filters='rjsmin', output='__bundle__/core/chart.js', - 'vendor/moment@2.25.1/moment.min.js', - 'vendor/chart.js@2.9.3/chart.min.js' %} - - {% endassets %} - {% assets filters='rjsmin', output='__bundle__/core/wallet.js', - 'vendor/bolt11/utils.js', - 'vendor/bolt11/decoder.js', - 'vendor/vue-qrcode-reader@2.2.0/vue-qrcode-reader.min.js', - 'core/js/wallet.js' %} - - {% endassets %} -{% endblock %} +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block styles %} + +{% endblock %} {% block scripts %} {{ window_vars(user, wallet) }} + +{% assets filters='rjsmin', output='__bundle__/core/chart.js', +'vendor/moment@2.25.1/moment.min.js', 'vendor/chart.js@2.9.3/chart.min.js' %} + +{% endassets %} {% assets filters='rjsmin', output='__bundle__/core/wallet.js', +'vendor/bolt11/utils.js', 'vendor/bolt11/decoder.js', +'vendor/vue-qrcode-reader@2.2.0/vue-qrcode-reader.min.js', 'core/js/wallet.js' +%} + +{% endassets %} {% endblock %} {% block page %} +
+
+ + +

+ {% raw %}{{ fbalance }}{% endraw %} sat +

+
+
+
+ Send +
+
+ Receive +
+
+
-{% block page %} -
-
- - -

{% raw %}{{ fbalance }}{% endraw %} sat

-
-
-
- Send -
+ + +
- Receive +
Transactions
-
-
- - - -
-
-
Transactions
-
-
- Export to CSV - - - Show chart - -
+ + Show chart +
- - - - {% raw %} - - - {% endraw %} - -
-
-
+
+ + + + {% raw %} + + + {% endraw %} + + + +
-
- - - Renew keys -
LNbits wallet
- Wallet name: {{ wallet.name }}
- Wallet ID: {{ wallet.id }}
- Admin key: {{ wallet.adminkey }}
- Invoice/read key: {{ wallet.inkey }} -
- +
+ + + Renew keys +
LNbits wallet
+ Wallet name: {{ wallet.name }}
+ Wallet ID: {{ wallet.id }}
+ Admin key: {{ wallet.adminkey }}
+ Invoice/read key: {{ wallet.inkey }} +
+ + + + {% include "core/_api_docs.html" %} - - {% include "core/_api_docs.html" %} - - - - -

This whole wallet will be deleted, the funds will be UNRECOVERABLE.

- Delete wallet -
-
-
-
-
-
-
+ + + +

+ This whole wallet will be deleted, the funds will be + UNRECOVERABLE. +

+ Delete wallet +
+
+
+ +
+
+
- - - - - -
- Create invoice - Cancel -
- -
-
- - -
- Copy invoice - Close + + + + + +
+ Create invoice + Cancel
-
-
+ + + + + +
+ Copy invoice + Close +
+
+ - - -
- - - - -
- Read invoice - Cancel -
-
-
- - - -
- Cancel -
-
-
-
- {% raw %} -
{{ send.invoice.fsat }} sat
- -

- Memo: {{ send.invoice.description }}
- Expire date: {{ send.invoice.expireDate }}
- Hash: {{ send.invoice.hash }} -

- {% endraw %} -
- + +
+ + + + +
+ Send satoshis - Cancel + :disable="send.data.bolt11 == ''" + type="submit" + >Read invoice + Cancel
-
- Not enough funds! - Cancel + +
+ + + +
+ Cancel
- - +
+
+ {% raw %} +
{{ send.invoice.fsat }} sat
+ +

+ Memo: {{ send.invoice.description }}
+ Expire date: {{ send.invoice.expireDate }}
+ Hash: {{ send.invoice.hash }} +

+ {% endraw %} +
+ Send satoshis + Cancel +
+
+ Not enough funds! + Cancel +
+
+ + - - - - - - - + + + + + + + - {% if service_fee > 0 %} -
- - -
Warning
-

Login functionality to be released in v0.2, for now, make sure you bookmark this page for future access to your wallet!

-

This service is in BETA, and we hold no responsibility for people losing access to funds. To encourage you to run your own LNbits installation, any balance on {% raw %}{{ disclaimerDialog.location.host }}{% endraw %} will incur a charge of {{ service_fee }}% service fee per week.

-
- Copy wallet URL - I understand -
-
-
- {% endif %} -{% endblock %} +{% if service_fee > 0 %} +
+ + +
Warning
+

+ Login functionality to be released in v0.2, for now, + make sure you bookmark this page for future access to your + wallet! +

+

+ This service is in BETA, and we hold no responsibility for people losing + access to funds. To encourage you to run your own LNbits installation, any + balance on {% raw %}{{ disclaimerDialog.location.host }}{% endraw %} will + incur a charge of {{ service_fee }}% service fee per + week. +

+
+ Copy wallet URL + I understand +
+
+
+{% endif %} {% endblock %} diff --git a/lnbits/extensions/events/templates/events/register.html b/lnbits/extensions/events/templates/events/register.html index dd4cc54..5dc88c5 100644 --- a/lnbits/extensions/events/templates/events/register.html +++ b/lnbits/extensions/events/templates/events/register.html @@ -157,7 +157,7 @@ message: 'Registered!' }) setTimeout(function () { - window.location.reload() + window.location.reload() }, 2000) }) .catch(function (error) { diff --git a/lnbits/extensions/withdraw/static/js/index.js b/lnbits/extensions/withdraw/static/js/index.js index 6e9371c..70f3992 100644 --- a/lnbits/extensions/withdraw/static/js/index.js +++ b/lnbits/extensions/withdraw/static/js/index.js @@ -59,15 +59,6 @@ new Vue({ is_unique: false } }, - simpleformDialog: { - show: false, - data: { - is_unique: false, - title: 'Vouchers', - min_withdrawable: 0, - wait_time: 1 - } - }, qrCodeDialog: { show: false, data: null @@ -106,17 +97,9 @@ new Vue({ is_unique: false } }, - simplecloseFormDialog: function () { - this.simpleformDialog.data = { - is_unique: false - } - }, openQrCodeDialog: function (linkId) { var link = _.findWhere(this.withdrawLinks, {id: linkId}) - this.qrCodeDialog.data = _.clone(link) - console.log(this.qrCodeDialog.data) - this.qrCodeDialog.data.url = window.location.hostname this.qrCodeDialog.show = true }, openUpdateDialog: function (linkId) { @@ -144,23 +127,6 @@ new Vue({ this.createWithdrawLink(wallet, data) } }, - simplesendFormData: function () { - var wallet = _.findWhere(this.g.user.wallets, { - id: this.simpleformDialog.data.wallet - }) - var data = _.omit(this.simpleformDialog.data, 'wallet') - - data.wait_time = 1 - data.min_withdrawable = data.max_withdrawable - data.title = 'vouchers' - data.is_unique = true - - if (data.id) { - this.updateWithdrawLink(wallet, data) - } else { - this.createWithdrawLink(wallet, data) - } - }, updateWithdrawLink: function (wallet, data) { var self = this @@ -198,7 +164,6 @@ new Vue({ .then(function (response) { self.withdrawLinks.push(mapWithdrawLink(response.data)) self.formDialog.show = false - self.simpleformDialog.show = false }) .catch(function (error) { LNbits.utils.notifyApiError(error) diff --git a/lnbits/extensions/withdraw/templates/withdraw/display.html b/lnbits/extensions/withdraw/templates/withdraw/display.html index 05dce02..d6458d1 100644 --- a/lnbits/extensions/withdraw/templates/withdraw/display.html +++ b/lnbits/extensions/withdraw/templates/withdraw/display.html @@ -18,7 +18,6 @@
- Copy LNURL @@ -57,11 +56,8 @@ data: function () { return { theurl: location.protocol + '//' + location.host - } - }, - - + } }) {% endblock %} diff --git a/lnbits/static/js/components.js b/lnbits/static/js/components.js index 1efb745..1a484d8 100644 --- a/lnbits/static/js/components.js +++ b/lnbits/static/js/components.js @@ -1,3 +1,5 @@ +/* global Vue, LNbits, EventHub */ + Vue.component('lnbits-fsat', { props: { amount: { @@ -28,11 +30,11 @@ Vue.component('lnbits-wallet-list', { Wallets {{ wallet.name }} {{ wallet.live_fsat }} sat - + @@ -60,7 +62,7 @@ Vue.component('lnbits-wallet-list', { @@ -73,7 +75,7 @@ Vue.component('lnbits-wallet-list', { var bal = this.activeBalance return this.user.wallets.map(function (obj) { obj.live_fsat = - bal.length && bal[0] == obj.id + bal.length && bal[0] === obj.id ? LNbits.utils.formatSat(bal[1]) : obj.fsat return obj diff --git a/lnbits/templates/base.html b/lnbits/templates/base.html index b7a1b2d..c9baddf 100644 --- a/lnbits/templates/base.html +++ b/lnbits/templates/base.html @@ -1,107 +1,128 @@ - + - + {% assets 'base_css' %} - - {% endassets %} - {% block styles %}{% endblock %} + + {% endassets %} {% block styles %}{% endblock %} - {% block title %} - {% if SITE_TITLE != 'LNbits' %}{{ SITE_TITLE }}{% else %}LNbits{% endif %} - {% endblock %} + {% block title %} {% if SITE_TITLE != 'LNbits' %}{{ SITE_TITLE }}{% else + %}LNbits{% endif %} {% endblock %} - - + + {% block head_scripts %}{% endblock %} - {% block drawer_toggle %} - + {% endblock %} - {% block toolbar_title %} - {% if SITE_TITLE != 'LNbits' %} - {{ SITE_TITLE }} - {% else %} - LNbits - {% endif %} - {% endblock %} + {% block toolbar_title %} {% if SITE_TITLE != 'LNbits' %} {{ + SITE_TITLE }} {% else %} + LNbits {% endif %} {% endblock %} {% block beta %} - - USE WITH CAUTION - LNbits wallet is still in BETA - + + USE WITH CAUTION - LNbits wallet is still in BETA + {% endblock %} - + Toggle Dark Mode {% block drawer %} - - - - - {% endblock %} - - {% block page_container %} - - - {% block page %}{% endblock %} - - - {% endblock %} - - {% block footer %} - - - - LNbits, free and open-source lightning wallet/accounts system - - - - View project in GitHub - - - + + + + + {% endblock %} {% block page_container %} + + + {% block page %}{% endblock %} + + + {% endblock %} {% block footer %} + + + + LNbits, free and open-source lightning + wallet/accounts system + + + + View project in GitHub + + + {% endblock %} - - {% block vue_templates %}{% endblock %} - - {% if DEBUG %} - - - - - {% else %} - {% assets output='__bundle__/vue.js', - 'vendor/quasar@1.10.4/quasar.ie.polyfills.umd.min.js', - 'vendor/vue@2.6.11/vue.min.js', - 'vendor/vue-router@3.1.6/vue-router.min.js', - 'vendor/vuex@3.1.3/vuex.min.js', - 'vendor/quasar@1.10.4/quasar.umd.min.js' %} - - {% endassets %} - {% endif %} - - {% assets filters='rjsmin', output='__bundle__/base.js', - 'vendor/axios@0.19.2/axios.min.js', - 'vendor/underscore@1.10.2/underscore.min.js', - 'js/base.js', - 'js/components.js' %} - - {% endassets %} - - {% block scripts %}{% endblock %} + {% block vue_templates %}{% endblock %} {% if DEBUG %} + + + + + {% else %} {% assets output='__bundle__/vue.js', + 'vendor/quasar@1.10.4/quasar.ie.polyfills.umd.min.js', + 'vendor/vue@2.6.11/vue.min.js', 'vendor/vue-router@3.1.6/vue-router.min.js', + 'vendor/vuex@3.1.3/vuex.min.js', 'vendor/quasar@1.10.4/quasar.umd.min.js' %} + + {% endassets %} {% endif %} {% assets filters='rjsmin', + output='__bundle__/base.js', 'vendor/axios@0.19.2/axios.min.js', + 'vendor/underscore@1.10.2/underscore.min.js', 'js/base.js', + 'js/components.js' %} + + {% endassets %} {% block scripts %}{% endblock %} diff --git a/lnbits/templates/print.html b/lnbits/templates/print.html index 00931a7..d177a4c 100644 --- a/lnbits/templates/print.html +++ b/lnbits/templates/print.html @@ -1,24 +1,31 @@ - + - + {% block styles %}{% endblock %} - {% block title %} - {% if SITE_TITLE != 'LNbits' %}{{ SITE_TITLE }}{% else %}LNbits{% endif %} - {% endblock %} + {% block title %} {% if SITE_TITLE != 'LNbits' %}{{ SITE_TITLE }}{% else + %}LNbits{% endif %} {% endblock %} - - + + {% block head_scripts %}{% endblock %} @@ -32,17 +39,12 @@ {% if DEBUG %} - - - {% else %} - {% assets output='__bundle__/vue-print.js', - 'vendor/quasar@1.10.4/quasar.ie.polyfills.umd.min.js', - 'vendor/vue@2.6.11/vue.min.js', - 'vendor/quasar@1.10.4/quasar.umd.min.js' %} - - {% endassets %} - {% endif %} - - {% block scripts %}{% endblock %} + + + {% else %} {% assets output='__bundle__/vue-print.js', + 'vendor/quasar@1.10.4/quasar.ie.polyfills.umd.min.js', + 'vendor/vue@2.6.11/vue.min.js', 'vendor/quasar@1.10.4/quasar.umd.min.js' %} + + {% endassets %} {% endif %} {% block scripts %}{% endblock %} diff --git a/lnbits/templates/public.html b/lnbits/templates/public.html index 98e29aa..d2f0e65 100644 --- a/lnbits/templates/public.html +++ b/lnbits/templates/public.html @@ -1,17 +1,7 @@ -{% extends "base.html" %} - - -{% block beta %}{% endblock %} -{% block drawer_toggle %}{% endblock %} -{% block drawer %}{% endblock %} - - -{% block toolbar_title %} - - {% if SITE_TITLE != 'LNbits' %} - {{ SITE_TITLE }} - {% else %} - LNbits - {% endif %} - +{% extends "base.html" %} {% block beta %}{% endblock %} {% block drawer_toggle +%}{% endblock %} {% block drawer %}{% endblock %} {% block toolbar_title %} + + {% if SITE_TITLE != 'LNbits' %} {{ SITE_TITLE }} {% else %} + LNbits {% endif %} + {% endblock %}