diff --git a/lnbits/extensions/subdomains/README.md b/lnbits/extensions/subdomains/README.md new file mode 100644 index 000000000..ca3fce5ae --- /dev/null +++ b/lnbits/extensions/subdomains/README.md @@ -0,0 +1,65 @@ +
curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"subdomains"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY"
+
+## cloudflare
+
+- Cloudflare offers programmatic subdomain registration... (create new A record)
+- you can keep your existing domain's registrar, you just have to transfer dns records to the cloudflare (free service)
+- more information:
+ - https://api.cloudflare.com/#getting-started-requests
+ - API endpoints needed for our project:
+ - https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records
+ - https://api.cloudflare.com/#dns-records-for-a-zone-create-dns-record
+ - https://api.cloudflare.com/#dns-records-for-a-zone-delete-dns-record
+ - https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record
+- api can be used by providing authorization token OR authorization key
+ - check API Tokens and API Keys : https://api.cloudflare.com/#getting-started-requests
+
+
+
+example curls:
+List dns records
+```bash
+curl --location --request GET 'https://api.cloudflare.com/client/v4/zones/bf3c1e516b35878c9f6532db2f2705ee/dns_records?type=A' \
+--header 'Content-Type: application/json' \
+--header 'Authorization: Bearer mS3gGFC3ySLqBe2ERtRTlh7H2YiGbFp2KLDK62uu'
+```
+
+```bash
+curl --location --request POST 'https://api.cloudflare.com/client/v4/zones/bf3c1e516b35878c9f6532db2f2705ee/dns_records' \
+--header 'Content-Type: application/json' \
+--header 'Authorization: Bearer mS3gGFC3ySLqBe2ERtRTlh7H2YiGbFp2KLDK62uu' \
+--data-raw '{
+ "type":"A",
+ "name":"subdomain1.grmkris.com",
+ "content":"31.15.150.237",
+ "ttl":0,
+ "proxied":true
+}'
+```
\ No newline at end of file
diff --git a/lnbits/extensions/subdomains/__init__.py b/lnbits/extensions/subdomains/__init__.py
new file mode 100644
index 000000000..51a821174
--- /dev/null
+++ b/lnbits/extensions/subdomains/__init__.py
@@ -0,0 +1,10 @@
+from quart import Blueprint
+from lnbits.db import Database
+
+db = Database("ext_subdomains")
+
+subdomains_ext: Blueprint = Blueprint("subdomains", __name__, static_folder="static", template_folder="templates")
+
+
+from .views_api import * # noqa
+from .views import * # noqa
diff --git a/lnbits/extensions/subdomains/config.json b/lnbits/extensions/subdomains/config.json
new file mode 100644
index 000000000..4a34be565
--- /dev/null
+++ b/lnbits/extensions/subdomains/config.json
@@ -0,0 +1,6 @@
+{
+ "name": "Subdomains",
+ "short_description": "Sell subdomains of your domain",
+ "icon": "domain",
+ "contributors": ["grmkris"]
+}
diff --git a/lnbits/extensions/subdomains/migrations.py b/lnbits/extensions/subdomains/migrations.py
new file mode 100644
index 000000000..00010f60f
--- /dev/null
+++ b/lnbits/extensions/subdomains/migrations.py
@@ -0,0 +1,34 @@
+async def m001_initial(db):
+
+ await db.execute(
+ """
+ CREATE TABLE IF NOT EXISTS domain (
+ id TEXT PRIMARY KEY,
+ wallet TEXT NOT NULL,
+ domain_name TEXT NOT NULL,
+ webhook TEXT,
+ cf_token TEXT NOT NULL,
+ cf_zone_id TEXT NOT NULL,
+ description TEXT NOT NULL,
+ cost INTEGER NOT NULL,
+ amountmade INTEGER NOT NULL,
+ time TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now'))
+ );
+ """
+ )
+
+ await db.execute(
+ """
+ CREATE TABLE IF NOT EXISTS subdomain (
+ id TEXT PRIMARY KEY,
+ domain_name TEXT NOT NULL,
+ email TEXT NOT NULL,
+ subdomain TEXT NOT NULL,
+ ip TEXT NOT NULL,
+ wallet TEXT NOT NULL,
+ sats INTEGER NOT NULL,
+ paid BOOLEAN NOT NULL,
+ time TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now'))
+ );
+ """
+ )
\ No newline at end of file
diff --git a/lnbits/extensions/subdomains/models.py b/lnbits/extensions/subdomains/models.py
new file mode 100644
index 000000000..9b330b858
--- /dev/null
+++ b/lnbits/extensions/subdomains/models.py
@@ -0,0 +1,26 @@
+from typing import NamedTuple
+
+
+class Domains(NamedTuple):
+ id: str
+ wallet: str
+ domainName: str
+ cfToken: str
+ cfZoneId: str
+ webhook: str
+ description: str
+ cost: int
+ amountmade: int
+ time: int
+
+
+class Subdomains(NamedTuple):
+ id: str
+ domainName: str
+ email: str
+ subdomain: str
+ ip: str
+ wallet: str
+ sats: int
+ paid: bool
+ time: int
diff --git a/lnbits/extensions/subdomains/templates/subdomains/index.html b/lnbits/extensions/subdomains/templates/subdomains/index.html
new file mode 100644
index 000000000..cc6a37362
--- /dev/null
+++ b/lnbits/extensions/subdomains/templates/subdomains/index.html
@@ -0,0 +1,296 @@
+{% extends "base.html" %} {% from "macros.jinja" import window_vars with context
+%} {% block page %}
+
+