From 43a974af838944ae2e77b576ac6b848dfabdd5fa Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Tue, 29 Nov 2022 23:18:24 +0100 Subject: [PATCH 01/25] initializing the deezy extension --- lnbits/extensions/deezy/README.md | 11 ++++ lnbits/extensions/deezy/__init__.py | 16 +++++ lnbits/extensions/deezy/config.json | 6 ++ lnbits/extensions/deezy/migrations.py | 10 ++++ lnbits/extensions/deezy/models.py | 5 ++ .../deezy/templates/example/index.html | 59 +++++++++++++++++++ lnbits/extensions/deezy/views.py | 21 +++++++ lnbits/extensions/deezy/views_api.py | 35 +++++++++++ 8 files changed, 163 insertions(+) create mode 100644 lnbits/extensions/deezy/README.md create mode 100644 lnbits/extensions/deezy/__init__.py create mode 100644 lnbits/extensions/deezy/config.json create mode 100644 lnbits/extensions/deezy/migrations.py create mode 100644 lnbits/extensions/deezy/models.py create mode 100644 lnbits/extensions/deezy/templates/example/index.html create mode 100644 lnbits/extensions/deezy/views.py create mode 100644 lnbits/extensions/deezy/views_api.py diff --git a/lnbits/extensions/deezy/README.md b/lnbits/extensions/deezy/README.md new file mode 100644 index 00000000..27729459 --- /dev/null +++ b/lnbits/extensions/deezy/README.md @@ -0,0 +1,11 @@ +

Example Extension

+

*tagline*

+This is an example extension to help you organise and build you own. + +Try to include an image + + + +

If your extension has API endpoints, include useful ones here

+ +curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"example"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY" diff --git a/lnbits/extensions/deezy/__init__.py b/lnbits/extensions/deezy/__init__.py new file mode 100644 index 00000000..663920cd --- /dev/null +++ b/lnbits/extensions/deezy/__init__.py @@ -0,0 +1,16 @@ +from fastapi import APIRouter + +from lnbits.db import Database +from lnbits.helpers import template_renderer + +db = Database("ext_deezy") + +deezy_ext: APIRouter = APIRouter(prefix="/deezy", tags=["deezy"]) + + +def deezy_renderer(): + return template_renderer(["lnbits/extensions/deezy/templates"]) + + +from .views import * # noqa +from .views_api import * # noqa diff --git a/lnbits/extensions/deezy/config.json b/lnbits/extensions/deezy/config.json new file mode 100644 index 00000000..200d1220 --- /dev/null +++ b/lnbits/extensions/deezy/config.json @@ -0,0 +1,6 @@ +{ + "name": "Deezy", + "short_description": "Join us, make an extension", + "icon": "info", + "contributors": ["Uthpala"] +} diff --git a/lnbits/extensions/deezy/migrations.py b/lnbits/extensions/deezy/migrations.py new file mode 100644 index 00000000..99d7c362 --- /dev/null +++ b/lnbits/extensions/deezy/migrations.py @@ -0,0 +1,10 @@ +# async def m001_initial(db): +# await db.execute( +# f""" +# CREATE TABLE example.example ( +# id TEXT PRIMARY KEY, +# wallet TEXT NOT NULL, +# time TIMESTAMP NOT NULL DEFAULT {db.timestamp_now} +# ); +# """ +# ) diff --git a/lnbits/extensions/deezy/models.py b/lnbits/extensions/deezy/models.py new file mode 100644 index 00000000..bfeb7517 --- /dev/null +++ b/lnbits/extensions/deezy/models.py @@ -0,0 +1,5 @@ +# from pydantic import BaseModel + +# class Example(BaseModel): +# id: str +# wallet: str diff --git a/lnbits/extensions/deezy/templates/example/index.html b/lnbits/extensions/deezy/templates/example/index.html new file mode 100644 index 00000000..d732ef37 --- /dev/null +++ b/lnbits/extensions/deezy/templates/example/index.html @@ -0,0 +1,59 @@ +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} + + +
+ Frameworks used by {{SITE_TITLE}} +
+ + + {% raw %} + + + {{ tool.name }} + {{ tool.language }} + + {% endraw %} + + + +

+ A magical "g" is always available, with info about the user, wallets and + extensions: +

+ {% raw %}{{ g }}{% endraw %} +
+
+{% endblock %} {% block scripts %} {{ window_vars(user) }} + +{% endblock %} diff --git a/lnbits/extensions/deezy/views.py b/lnbits/extensions/deezy/views.py new file mode 100644 index 00000000..b8efeae8 --- /dev/null +++ b/lnbits/extensions/deezy/views.py @@ -0,0 +1,21 @@ +from fastapi import FastAPI, Request +from fastapi.params import Depends +from fastapi.templating import Jinja2Templates +from starlette.responses import HTMLResponse + +from lnbits.core.models import User +from lnbits.decorators import check_user_exists + +from . import deezy_ext, deezy_renderer + +templates = Jinja2Templates(directory="templates") + + +@deezy_ext.get("/", response_class=HTMLResponse) +async def index( + request: Request, + user: User = Depends(check_user_exists), # type: ignore +): + return deezy_renderer().TemplateResponse( + "example/index.html", {"request": request, "user": user.dict()} + ) diff --git a/lnbits/extensions/deezy/views_api.py b/lnbits/extensions/deezy/views_api.py new file mode 100644 index 00000000..e8d270a9 --- /dev/null +++ b/lnbits/extensions/deezy/views_api.py @@ -0,0 +1,35 @@ +# views_api.py is for you API endpoints that could be hit by another service + +# add your dependencies here + +# import httpx +# (use httpx just like requests, except instead of response.ok there's only the +# response.is_error that is its inverse) + +from . import deezy_ext + +# add your endpoints here + + +@deezy_ext.get("/api/v1/tools") +async def api_example(): + """Try to add descriptions for others.""" + tools = [ + { + "name": "fastAPI", + "url": "https://fastapi.tiangolo.com/", + "language": "Python", + }, + { + "name": "Vue.js", + "url": "https://vuejs.org/", + "language": "JavaScript", + }, + { + "name": "Quasar Framework", + "url": "https://quasar.dev/", + "language": "JavaScript", + }, + ] + + return tools From 4645b8338b1719abde50fdf6f6f8ff15b971343d Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Sun, 4 Dec 2022 23:29:57 +0100 Subject: [PATCH 02/25] added the reverse swap as well --- lnbits/extensions/deezy/config.json | 2 +- .../deezy/templates/deezy/index.html | 255 ++++++++++++++++++ .../deezy/templates/example/index.html | 59 ---- lnbits/extensions/deezy/views.py | 2 +- 4 files changed, 257 insertions(+), 61 deletions(-) create mode 100644 lnbits/extensions/deezy/templates/deezy/index.html delete mode 100644 lnbits/extensions/deezy/templates/example/index.html diff --git a/lnbits/extensions/deezy/config.json b/lnbits/extensions/deezy/config.json index 200d1220..27c4df2d 100644 --- a/lnbits/extensions/deezy/config.json +++ b/lnbits/extensions/deezy/config.json @@ -1,6 +1,6 @@ { "name": "Deezy", "short_description": "Join us, make an extension", - "icon": "info", + "icon": "swap_horiz", "contributors": ["Uthpala"] } diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html new file mode 100644 index 00000000..007144f0 --- /dev/null +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -0,0 +1,255 @@ +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} + + +
+ Deezy +
+ + + + + + Send onchain funds offchain (BTC -> LN) + + + + + Send offchain funds to onchain address (LN -> BTC) + + + + +
+
Lightning Btc -> Btc
+ + + + + + Cancel + + + + +
+
Pay invoice to complete swap
+ + + +
+
+ + + + + + + +
+
+
+
+
Btc -> Lightning Btc
+ + + + + + Cancel + + + + +
+
Response - Important
+ + + +
+
+ {% raw %} + + Address - {{ swapBtcToLn.response.address }} + + + Commitment - {{ swapBtcToLn.response.commitment }} + + + Secret Access Key - {{ swapBtcToLn.response.secret_access_key }} + + + Signature - {{ swapBtcToLn.response.signature }} + + + Webhook Url - {{ swapBtcToLn.response.webhook_url }} + + {% endraw %} +
+
+
+
+{% endblock %} {% block scripts %} {{ window_vars(user) }} + +{% endblock %} diff --git a/lnbits/extensions/deezy/templates/example/index.html b/lnbits/extensions/deezy/templates/example/index.html deleted file mode 100644 index d732ef37..00000000 --- a/lnbits/extensions/deezy/templates/example/index.html +++ /dev/null @@ -1,59 +0,0 @@ -{% extends "base.html" %} {% from "macros.jinja" import window_vars with context -%} {% block page %} - - -
- Frameworks used by {{SITE_TITLE}} -
- - - {% raw %} - - - {{ tool.name }} - {{ tool.language }} - - {% endraw %} - - - -

- A magical "g" is always available, with info about the user, wallets and - extensions: -

- {% raw %}{{ g }}{% endraw %} -
-
-{% endblock %} {% block scripts %} {{ window_vars(user) }} - -{% endblock %} diff --git a/lnbits/extensions/deezy/views.py b/lnbits/extensions/deezy/views.py index b8efeae8..131c03b2 100644 --- a/lnbits/extensions/deezy/views.py +++ b/lnbits/extensions/deezy/views.py @@ -17,5 +17,5 @@ async def index( user: User = Depends(check_user_exists), # type: ignore ): return deezy_renderer().TemplateResponse( - "example/index.html", {"request": request, "user": user.dict()} + "deezy/index.html", {"request": request, "user": user.dict()} ) From 6ec5b9abf6771071daab96f446619f74c3f3a650 Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Mon, 5 Dec 2022 21:07:38 +0100 Subject: [PATCH 03/25] convert string to ints --- lnbits/extensions/deezy/templates/deezy/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index 007144f0..0d68f0a9 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -53,7 +53,7 @@ filled dense emit-value - v-model.trim="swapLnToBtc.data.onChainFees" + v-model.trim="swapLnToBtc.data.on_chain_sats_per_vbyte" label="On chain fees" min="1" type="number" @@ -204,9 +204,9 @@ sendLnToBtc() { var self = this axios.post('https://api-testnet.deezy.io/v1/swap', { - amount_sats: self.swapLnToBtc.data.amount, + amount_sats: parseInt(self.swapLnToBtc.data.amount), on_chain_address: self.swapLnToBtc.data.on_chain_address, - on_chain_sats_per_vbyte: self.swapLnToBtc.data.on_chain_sats_per_vbyte + on_chain_sats_per_vbyte: parseInt(self.swapLnToBtc.data.on_chain_sats_per_vbyte) }) .then(function (response) { self.swapLnToBtc = { From 209750386edcafec949a60fe0ce2881c67da8ff4 Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Mon, 5 Dec 2022 21:12:17 +0100 Subject: [PATCH 04/25] forgot to update this one --- lnbits/extensions/deezy/templates/deezy/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index 0d68f0a9..95bdc14b 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -45,7 +45,7 @@ filled dense emit-value - v-model.trim="swapLnToBtc.data.refund_address" + v-model.trim="swapLnToBtc.data.on_chain_address" type="string" label="Onchain address to receive funds" > From 1b2e8d218d00babcd2058f8724d84dc4ecbab921 Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Tue, 6 Dec 2022 22:39:45 +0100 Subject: [PATCH 05/25] add api docs and update according to requirements --- .../deezy/templates/deezy/_api_docs.html | 221 ++++++++++++ .../deezy/templates/deezy/index.html | 332 +++++++++--------- 2 files changed, 384 insertions(+), 169 deletions(-) create mode 100644 lnbits/extensions/deezy/templates/deezy/_api_docs.html diff --git a/lnbits/extensions/deezy/templates/deezy/_api_docs.html b/lnbits/extensions/deezy/templates/deezy/_api_docs.html new file mode 100644 index 00000000..88e64e1f --- /dev/null +++ b/lnbits/extensions/deezy/templates/deezy/_api_docs.html @@ -0,0 +1,221 @@ + + + + +
+ Deezy.io: Do onchain to offchain and vice-versa swaps +
+

+ Link : + + https://deezy.io/ + +

+

+ API DOCS +

+

+ Created by, + Uthpala +

+
+
+
+ + + + + +
+ Get the current info about the swap service for converting LN btc to on-chain BTC. +
+ + GET (mainnet) + https://api.deezy.io/v1/swap/info + +
+ + GET (testnet) + https://api-testnet.deezy.io/v1/swap/info + +
Response
+
+            {
+              "liquidity_fee_ppm": 2000,
+              "on_chain_bytes_estimate": 300,
+              "max_swap_amount_sats": 100000000,
+              "min_swap_amount_sats": 100000,
+              "available": true
+            }
+          
+
+
+
+ + + +
+ Initiate a new swap to send lightning btc in exchange for on-chain btc +
+ + POST (mainnet) + https://api.deezy.io/v1/swap + +
+ + POST (testnet) + https://api-testnet.deezy.io/v1/swap + +
Payload
+
+            {
+              "amount_sats": 500000,
+              "on_chain_address": "tb1qrcdhlm0m...",
+              "on_chain_sats_per_vbyte": 2
+            }
+          
+
Response
+
+            {
+              "bolt11_invoice": "lntb603u1p3vmxj7p...",
+              "fee_sats": 600
+            }
+          
+
+
+
+ + + +
+ Lookup the on-chain transaction information for an existing swap +
+ + GET (mainnet) + https://api.deezy.io/v1/swap/lookup + +
+ + GET (testnet) + https://api-testnet.deezy.io/v1/swap/lookup + +
Query Parameter
+
+            "bolt11_invoice": "lntb603u1p3vmxj7pp54...",
+          
+
Response
+
+            {
+              "on_chain_txid": "string",
+              "tx_hex": "string"
+            }
+          
+
+
+
+
+ + + + +
+ Generate an on-chain deposit address for your lnurl or lightning address. +
+ + POST (mainnet) + https://api.deezy.io/v1/source + +
+ + POST (testnet) + https://api-testnet.deezy.io/v1/source + +
Payload
+
+            {
+              "lnurl_or_lnaddress": "LNURL1DP68GURN8GHJ...",
+              "secret_access_key": "b3c6056d2845867fa7..",
+              "webhook_url": "https://your.website.com/dee.."
+            }
+          
+
Response
+
+            {
+              "address": "bc1qkceyc5...",
+              "secret_access_key": "b3c6056d28458...",
+              "commitment": "for any satoshis sent to bc1..",
+              "signature": "d69j6aj1ssz5egmsr..",
+              "webhook_url": "https://your.website.com/deez.."
+            }
+          
+
+
+
+ + + +
+ Lookup (BTC to LN) swaps +
+ + GET (mainnet) + https://api.deezy.io/v1/source/lookup + +
+ + GET (testnet) + https://api-testnet.deezy.io/v1/source/lookup + +
Response
+
+            {
+              "swaps": [
+                {
+                  "lnurl_or_lnaddress": "string",
+                  "deposit_address": "string",
+                  "utxo_key": "string",
+                  "deposit_amount_sats": 0,
+                  "target_payout_amount_sats": 0,
+                  "paid_amount_sats": 0,
+                  "deezy_fee_sats": 0,
+                  "status": "string"
+                }
+              ],
+              "total_sent_sats": 0,
+              "total_received_sats": 0,
+              "total_pending_payout_sats": 0,
+              "total_deezy_fees_sats": 0
+            }
+          
+
+
+
+
+
diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index 95bdc14b..233fce34 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -1,176 +1,172 @@ {% extends "base.html" %} {% from "macros.jinja" import window_vars with context %} {% block page %} - - -
- Deezy -
- +
+
- - - Send onchain funds offchain (BTC -> LN) - - - - - Send offchain funds to onchain address (LN -> BTC) - - +
+ Deezy +
+ + + + + + Send onchain funds offchain (BTC -> LN) + + + + + Send offchain funds to onchain address (LN -> BTC) + + + + +
+
LIGHTNING BTC -> BTC
+ + + + + + Cancel + + + + +
+
Pay invoice to complete swap
+ + + +
+
+ + + + + + + +
+
+
+
+
BTC -> LIGHTNING BTC
+ + + + Cancel + + + + +
+
Response - Important
+ + + +
+
+ {% raw %} + + Address - {{ swapBtcToLn.response.address }} + + + Commitment - {{ swapBtcToLn.response.commitment }} + + + Secret Access Key - {{ swapBtcToLn.response.secret_access_key }} + + + Signature - {{ swapBtcToLn.response.signature }} + + {% endraw %} +
+
+
+
+
+
+ + +
{{SITE_TITLE}} Boltz extension
+
+ + + {% include "deezy/_api_docs.html" %}
-
-
Lightning Btc -> Btc
- - - - - - Cancel - - - - -
-
Pay invoice to complete swap
- - - -
-
- - - - - - - -
-
-
-
-
Btc -> Lightning Btc
- - - - - - Cancel - - - - -
-
Response - Important
- - - -
-
- {% raw %} - - Address - {{ swapBtcToLn.response.address }} - - - Commitment - {{ swapBtcToLn.response.commitment }} - - - Secret Access Key - {{ swapBtcToLn.response.secret_access_key }} - - - Signature - {{ swapBtcToLn.response.signature }} - - - Webhook Url - {{ swapBtcToLn.response.webhook_url }} - - {% endraw %} -
-
-
- +
+
{% endblock %} {% block scripts %} {{ window_vars(user) }} From d338e3889a74602854057a4084060aa78c39cee9 Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Thu, 8 Dec 2022 16:42:33 +0100 Subject: [PATCH 12/25] Add on chain fee suggestions --- .../deezy/templates/deezy/index.html | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index 537ed887..60b31a09 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -12,7 +12,7 @@ label="SWAP (LIGHTNING -> BTC)" unelevated color="primary" - @click="swapLnToBtc.show = true; swapBtcToLn.show = false" + @click="showLnToBtcForm" > Send lightning btc and receive on-chain btc @@ -60,7 +60,9 @@ label="On chain fee rate (sats/vbyte)" min="1" type="number" - > + :hint="swapLnToBtc.suggested_fees && `Economy Fee - ${swapLnToBtc.suggested_fees?.economyFee} | Half an hour fee - ${swapLnToBtc.suggested_fees?.halfHourFee} | Fastest fee - ${swapLnToBtc.suggested_fees?.fastestFee}`" + > + { + console.log(result.data) + this.swapLnToBtc.suggested_fees = result.data + }) + }, checkIfInvoiceIsPaid() { if (this.swapLnToBtc.response && !this.swapLnToBtc.invoicePaid) { var self = this From c2423605ccff3604640d765e5304ea424c280782 Mon Sep 17 00:00:00 2001 From: Danny Diekroeger Date: Sat, 10 Dec 2022 11:00:36 -0800 Subject: [PATCH 13/25] add migrations --- lnbits/extensions/deezy/migrations.py | 39 ++++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/lnbits/extensions/deezy/migrations.py b/lnbits/extensions/deezy/migrations.py index 99d7c362..86edcf09 100644 --- a/lnbits/extensions/deezy/migrations.py +++ b/lnbits/extensions/deezy/migrations.py @@ -1,10 +1,29 @@ -# async def m001_initial(db): -# await db.execute( -# f""" -# CREATE TABLE example.example ( -# id TEXT PRIMARY KEY, -# wallet TEXT NOT NULL, -# time TIMESTAMP NOT NULL DEFAULT {db.timestamp_now} -# ); -# """ -# ) +async def m001_initial(db): + await db.execute( + f""" + CREATE TABLE deezy.ln_to_btc_swap ( + id TEXT PRIMARY KEY, + amount_sats {db.big_int} NOT NULL, + on_chain_address TEXT NOT NULL, + on_chain_sats_per_vbyte INT NOT NULL, + bolt11_invoice TEXT NOT NULL, + fee_sats {db.big_int} NOT NULL, + txid TEXT NULL, + tx_hex TEXT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); + """ + ) + await db.execute( + f""" + CREATE TABLE deezy.btc_to_ln_swap ( + id TEXT PRIMARY KEY, + ln_address TEXT NOT NULL, + on_chain_address TEXT NOT NULL, + secret_access_key TEXT NOT NULL, + commitment TEXT NOT NULL, + signature TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); + """ + ) From 663cee8fbe1b5836d9421c854d7f075b9c081fa5 Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Sun, 11 Dec 2022 17:42:47 +0100 Subject: [PATCH 14/25] fix ui bug --- lnbits/extensions/deezy/templates/deezy/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index 60b31a09..98067fd7 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -223,12 +223,12 @@ showLnToBtcForm() { this.getSuggestedOnChainFees() this.swapLnToBtc.show = true + this.swapBtcToLn.show = false }, getSuggestedOnChainFees() { axios .get('https://mempool.space/api/v1/fees/recommended') .then(result => { - console.log(result.data) this.swapLnToBtc.suggested_fees = result.data }) }, From cd05eba183bc7b8bfdbd1c98d52bd07fae90a256 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 5 Jan 2023 00:52:08 +0000 Subject: [PATCH 15/25] Added tile and tweaked description for size limitation --- lnbits/extensions/deezy/__init__.py | 9 +++++++++ lnbits/extensions/deezy/config.json | 4 ++-- lnbits/extensions/deezy/static/deezy.png | Bin 0 -> 5196 bytes 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 lnbits/extensions/deezy/static/deezy.png diff --git a/lnbits/extensions/deezy/__init__.py b/lnbits/extensions/deezy/__init__.py index 120124e7..97f6d9ef 100644 --- a/lnbits/extensions/deezy/__init__.py +++ b/lnbits/extensions/deezy/__init__.py @@ -1,4 +1,5 @@ from fastapi import APIRouter +from starlette.staticfiles import StaticFiles from lnbits.db import Database from lnbits.helpers import template_renderer @@ -7,6 +8,14 @@ db = Database("ext_deezy") deezy_ext: APIRouter = APIRouter(prefix="/deezy", tags=["deezy"]) +deezy_static_files = [ + { + "path": "/deezy/static", + "app": StaticFiles(directory="lnbits/extensions/deezy/static"), + "name": "deezy_static", + } +] + def deezy_renderer(): return template_renderer(["lnbits/extensions/deezy/templates"]) diff --git a/lnbits/extensions/deezy/config.json b/lnbits/extensions/deezy/config.json index e3c1a3d7..4f945a79 100644 --- a/lnbits/extensions/deezy/config.json +++ b/lnbits/extensions/deezy/config.json @@ -1,6 +1,6 @@ { "name": "Deezy", - "short_description": "Swap lightning to on-chain, or receive on-chain to lightning addresses.", - "icon": "swap_horiz", + "short_description": "LN to onchain, onchain to LN swaps", + "tile": "/deezy/static/deezy.png", "contributors": ["Uthpala"] } diff --git a/lnbits/extensions/deezy/static/deezy.png b/lnbits/extensions/deezy/static/deezy.png new file mode 100644 index 0000000000000000000000000000000000000000..cb526705c4f83e165699236de8bdf4d69b61e1b7 GIT binary patch literal 5196 zcmb_g_cPqz`+Zq$)oiqg8lr_nCn8v##cI(-U%mIvszD-HLUhp+y+rRsFRQnx5hQvG zR{MJY^8E`wbLY8t=KOHyx#!He^UR4>S5+V(q#*M$9ZCoXQzR<;h70KkzDm>{m$txgf4_U1h^CI0Iu5kxVmxs;Y{MlGRSF~lxH zhhD`PgAb=cQ9M%U{Jy$6W5)KopiKC}yyeh`acjxl=RiWT zI3?A}^8;3zQ~Fogx5EhCAEUZB5D;(Z<5d0L3>MZkLzD9I&o<=)DTFt zb*kAy4{gtz^tw*pY>}>*YNY^GF}n%eXvW5JpX=Vn)#?s`r&gjuYIICgM2@Akd|YWX zM=Y*d(;kD5_!&wv>P75-bJ{N_w)198>Lxd;+CvDQn-h@9aunx=^E>p|%)+YTb59!L zf;-NXH#GaTK~MWYoaiUbL5I)_aYHUB-#%-^FUjp6t`d>RQKK9U_lyIJKHChS(|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B*)&A};|m!SO#0R{lSo$pYU%k1l%6qb37*?qenZCZ{S}E^Qk6e_71X At^fc4 literal 0 HcmV?d00001 From 93d6d1279e8092f4b9c769a736ce4dede402f3c5 Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Thu, 5 Jan 2023 11:46:01 +0100 Subject: [PATCH 16/25] adding deezy token --- lnbits/extensions/deezy/__init__.py | 1 + lnbits/extensions/deezy/crud.py | 38 +++++ lnbits/extensions/deezy/migrations.py | 8 + lnbits/extensions/deezy/models.py | 9 +- .../deezy/templates/deezy/index.html | 151 +++++++++++++++++- lnbits/extensions/deezy/views_api.py | 31 ++++ 6 files changed, 233 insertions(+), 5 deletions(-) create mode 100644 lnbits/extensions/deezy/crud.py create mode 100644 lnbits/extensions/deezy/views_api.py diff --git a/lnbits/extensions/deezy/__init__.py b/lnbits/extensions/deezy/__init__.py index 97f6d9ef..05d1c9a7 100644 --- a/lnbits/extensions/deezy/__init__.py +++ b/lnbits/extensions/deezy/__init__.py @@ -22,3 +22,4 @@ def deezy_renderer(): from .views import * # noqa +from .views_api import * # noqa diff --git a/lnbits/extensions/deezy/crud.py b/lnbits/extensions/deezy/crud.py new file mode 100644 index 00000000..69630610 --- /dev/null +++ b/lnbits/extensions/deezy/crud.py @@ -0,0 +1,38 @@ +from http import HTTPStatus +from typing import List + +from . import db +from .models import ( + Token, +) + +""" +Get Deezy Token +""" + + +async def get_token() -> Token: + + row = await db.fetchone( + f"SELECT * FROM deezy.token ORDER BY created_at DESC", + ) + + return Token(**row) if row else None + + +async def save_token( + data: Token, +) -> Token: + + await db.execute( + """ + INSERT INTO deezy.token ( + deezy_token + ) + VALUES (?) + """, + ( + data.deezy_token, + ), + ) + return data diff --git a/lnbits/extensions/deezy/migrations.py b/lnbits/extensions/deezy/migrations.py index 86edcf09..67455d6b 100644 --- a/lnbits/extensions/deezy/migrations.py +++ b/lnbits/extensions/deezy/migrations.py @@ -27,3 +27,11 @@ async def m001_initial(db): ); """ ) + await db.execute( + f""" + CREATE TABLE deezy.token ( + deezy_token TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); + """ + ) diff --git a/lnbits/extensions/deezy/models.py b/lnbits/extensions/deezy/models.py index bfeb7517..751191f0 100644 --- a/lnbits/extensions/deezy/models.py +++ b/lnbits/extensions/deezy/models.py @@ -1,5 +1,6 @@ -# from pydantic import BaseModel +from pydantic.main import BaseModel +from sqlalchemy.engine import base # type: ignore -# class Example(BaseModel): -# id: str -# wallet: str + +class Token(BaseModel): + deezy_token: str diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index 98067fd7..5c2f9ae4 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -5,6 +5,30 @@
Deezy
+

Due to regulatory reasons you need to get a access token from deezy. Contact - support@deezy.io or @dannydeezy on telegram

+
+
+ Deezy token + Add or Update token +
+

+
+ + + + @@ -189,6 +213,14 @@ +
+ +
{% endblock %} {% block scripts %} {{ window_vars(user) }} -{% endblock %} +{% endblock %} \ No newline at end of file From af472ba8330ef28ff2174a25ed648b156c949e7c Mon Sep 17 00:00:00 2001 From: Uthpala Heenatigala Date: Fri, 6 Jan 2023 20:34:31 +0100 Subject: [PATCH 21/25] fix formatting --- .../deezy/templates/deezy/index.html | 182 ++++++++++++++---- 1 file changed, 145 insertions(+), 37 deletions(-) diff --git a/lnbits/extensions/deezy/templates/deezy/index.html b/lnbits/extensions/deezy/templates/deezy/index.html index b1e06362..858d3255 100644 --- a/lnbits/extensions/deezy/templates/deezy/index.html +++ b/lnbits/extensions/deezy/templates/deezy/index.html @@ -6,50 +6,105 @@
Deezy

- An access token is required to use the swap service. - Email support@deezy.io or contact @dannydeezy on telegram to get one. + An access token is required to use the swap service. Email + support@deezy.io or contact @dannydeezy on telegram to get one.

Deezy token - Add or Update token + Add or Update token

- - + + - + Send lightning btc and receive on-chain btc - + Send on-chain btc and receive via lightning -
+
LIGHTNING BTC -> BTC
- - - + + + - - Cancel + + Cancel @@ -62,22 +117,52 @@
- + - - + +
-
+
BTC -> LIGHTNING BTC
- - - Cancel + + + Cancel @@ -90,15 +175,28 @@
- + - + - + @@ -135,10 +233,20 @@
- +
- +
{% endblock %} {% block scripts %} {{ window_vars(user) }} @@ -176,8 +284,8 @@ align: 'left', field: 'fee_sats' }, - { name: 'txid', label: 'Tx Id', align: 'left', field: 'txid' }, - { name: 'tx_hex', label: 'Tx Hex', align: 'left', field: 'tx_hex' }, + {name: 'txid', label: 'Tx Id', align: 'left', field: 'txid'}, + {name: 'tx_hex', label: 'Tx Hex', align: 'left', field: 'tx_hex'}, { name: 'created_at', label: 'Created at', @@ -477,4 +585,4 @@ } }) -{% endblock %} \ No newline at end of file +{% endblock %} From ef456c66d7deba6d9659306b0232997566cd348f Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 7 Jan 2023 21:59:10 +0000 Subject: [PATCH 22/25] Format --- lnbits/extensions/deezy/crud.py | 11 ++--------- lnbits/extensions/deezy/models.py | 1 + lnbits/extensions/deezy/views_api.py | 16 +++++----------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lnbits/extensions/deezy/crud.py b/lnbits/extensions/deezy/crud.py index d3b3f935..8df50eb6 100644 --- a/lnbits/extensions/deezy/crud.py +++ b/lnbits/extensions/deezy/crud.py @@ -2,12 +2,7 @@ from http import HTTPStatus from typing import List from . import db -from .models import ( - Token, - LnToBtcSwap, - BtcToLnSwap, - UpdateLnToBtcSwap -) +from .models import BtcToLnSwap, LnToBtcSwap, Token, UpdateLnToBtcSwap async def get_ln_to_btc() -> List[LnToBtcSwap]: @@ -48,9 +43,7 @@ async def save_token( ) VALUES (?) """, - ( - data.deezy_token, - ), + (data.deezy_token,), ) return data diff --git a/lnbits/extensions/deezy/models.py b/lnbits/extensions/deezy/models.py index 0fcc3ce8..e69db355 100644 --- a/lnbits/extensions/deezy/models.py +++ b/lnbits/extensions/deezy/models.py @@ -1,4 +1,5 @@ from typing import Optional + from pydantic.main import BaseModel from sqlalchemy.engine import base # type: ignore diff --git a/lnbits/extensions/deezy/views_api.py b/lnbits/extensions/deezy/views_api.py index 85741b43..6af3bd72 100644 --- a/lnbits/extensions/deezy/views_api.py +++ b/lnbits/extensions/deezy/views_api.py @@ -7,22 +7,16 @@ # response.is_error that is its inverse) from . import deezy_ext -from .models import ( - Token, - LnToBtcSwap, - BtcToLnSwap, - UpdateLnToBtcSwap, -) - from .crud import ( - get_token, - get_ln_to_btc, get_btc_to_ln, - save_token, + get_ln_to_btc, + get_token, save_btc_to_ln, save_ln_to_btc, - update_ln_to_btc + save_token, + update_ln_to_btc, ) +from .models import BtcToLnSwap, LnToBtcSwap, Token, UpdateLnToBtcSwap @deezy_ext.get("/api/v1/token") From 7f1a08e16ac0d75aa03e7cfaa9b9c2349e2acb6f Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 7 Jan 2023 22:06:35 +0000 Subject: [PATCH 23/25] mypy --- lnbits/extensions/deezy/crud.py | 4 +++- lnbits/extensions/deezy/views_api.py | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lnbits/extensions/deezy/crud.py b/lnbits/extensions/deezy/crud.py index 8df50eb6..23eca774 100644 --- a/lnbits/extensions/deezy/crud.py +++ b/lnbits/extensions/deezy/crud.py @@ -23,7 +23,7 @@ async def get_btc_to_ln() -> List[BtcToLnSwap]: return [BtcToLnSwap(**row) for row in rows] -async def get_token() -> Token: +async def get_token() -> Optional[Token]: row = await db.fetchone( f"SELECT * FROM deezy.token ORDER BY created_at DESC", @@ -75,6 +75,7 @@ async def save_ln_to_btc( data.tx_hex, ), ) + return async def update_ln_to_btc(data: UpdateLnToBtcSwap) -> str: @@ -113,3 +114,4 @@ async def save_btc_to_ln( data.signature, ), ) + return diff --git a/lnbits/extensions/deezy/views_api.py b/lnbits/extensions/deezy/views_api.py index 6af3bd72..1006edeb 100644 --- a/lnbits/extensions/deezy/views_api.py +++ b/lnbits/extensions/deezy/views_api.py @@ -20,46 +20,46 @@ from .models import BtcToLnSwap, LnToBtcSwap, Token, UpdateLnToBtcSwap @deezy_ext.get("/api/v1/token") -async def api_deezy(): +async def api_deezy_get_token(): rows = await get_token() return rows @deezy_ext.get("/api/v1/ln-to-btc") -async def api_deezy(): +async def api_deezy_get_ln_to_btc(): rows = await get_ln_to_btc() return rows @deezy_ext.get("/api/v1/btc-to-ln") -async def api_deezy(): +async def api_deezy_get_btc_to_ln(): rows = await get_btc_to_ln() return rows @deezy_ext.post("/api/v1/store-token") -async def api_deezy(data: Token): +async def api_deezy_save_toke(data: Token): await save_token(data) return data.deezy_token @deezy_ext.post("/api/v1/store-ln-to-btc") -async def api_deezy(data: LnToBtcSwap): +async def api_deezy_save_ln_to_btc(data: LnToBtcSwap): response = await save_ln_to_btc(data) return response @deezy_ext.post("/api/v1/update-ln-to-btc") -async def api_deezy(data: UpdateLnToBtcSwap): +async def api_deezy_update_ln_to_btc(data: UpdateLnToBtcSwap): response = await update_ln_to_btc(data) return response @deezy_ext.post("/api/v1/store-btc-to-ln") -async def api_deezy(data: BtcToLnSwap): +async def api_deezy_save_btc_to_ln(data: BtcToLnSwap): response = await save_btc_to_ln(data) return response From ccdb6d76bdf12e53dd55f29ee3ede44a373c1741 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 7 Jan 2023 22:11:17 +0000 Subject: [PATCH 24/25] added Optional --- lnbits/extensions/deezy/crud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/deezy/crud.py b/lnbits/extensions/deezy/crud.py index 23eca774..c2768e25 100644 --- a/lnbits/extensions/deezy/crud.py +++ b/lnbits/extensions/deezy/crud.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import List +from typing import List, Optional from . import db from .models import BtcToLnSwap, LnToBtcSwap, Token, UpdateLnToBtcSwap From dfd86ed2e05703b553b5cbd6291849bec6a89864 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 7 Jan 2023 22:16:36 +0000 Subject: [PATCH 25/25] mypy --- lnbits/extensions/deezy/crud.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lnbits/extensions/deezy/crud.py b/lnbits/extensions/deezy/crud.py index c2768e25..75549349 100644 --- a/lnbits/extensions/deezy/crud.py +++ b/lnbits/extensions/deezy/crud.py @@ -52,7 +52,7 @@ async def save_ln_to_btc( data: LnToBtcSwap, ) -> LnToBtcSwap: - await db.execute( + return await db.execute( """ INSERT INTO deezy.ln_to_btc_swap ( amount_sats, @@ -75,7 +75,6 @@ async def save_ln_to_btc( data.tx_hex, ), ) - return async def update_ln_to_btc(data: UpdateLnToBtcSwap) -> str: @@ -95,7 +94,7 @@ async def save_btc_to_ln( data: BtcToLnSwap, ) -> BtcToLnSwap: - await db.execute( + return await db.execute( """ INSERT INTO deezy.btc_to_ln_swap ( ln_address, @@ -114,4 +113,3 @@ async def save_btc_to_ln( data.signature, ), ) - return