diff --git a/lnbits/extensions/hivemind/README.md b/lnbits/extensions/hivemind/README.md new file mode 100644 index 000000000..1e9667ec9 --- /dev/null +++ b/lnbits/extensions/hivemind/README.md @@ -0,0 +1,3 @@ +

Hivemind

+ +Placeholder for a future Bitcoin Hivemind extension. diff --git a/lnbits/extensions/hivemind/__init__.py b/lnbits/extensions/hivemind/__init__.py new file mode 100644 index 000000000..4e416e30b --- /dev/null +++ b/lnbits/extensions/hivemind/__init__.py @@ -0,0 +1,17 @@ +from fastapi import APIRouter + +from lnbits.db import Database +from lnbits.helpers import template_renderer + +db = Database("ext_hivemind") + +hivemind_ext: APIRouter = APIRouter( + prefix="/hivemind", + tags=["hivemind"] +) + +def hivemind_renderer(): + return template_renderer(["lnbits/extensions/hivemind/templates"]) + + +from .views import * # noqa diff --git a/lnbits/extensions/hivemind/config.json b/lnbits/extensions/hivemind/config.json new file mode 100644 index 000000000..a5469b15f --- /dev/null +++ b/lnbits/extensions/hivemind/config.json @@ -0,0 +1,6 @@ +{ + "name": "Hivemind", + "short_description": "Make cheap talk expensive!", + "icon": "batch_prediction", + "contributors": ["fiatjaf"] +} diff --git a/lnbits/extensions/hivemind/migrations.py b/lnbits/extensions/hivemind/migrations.py new file mode 100644 index 000000000..775a94548 --- /dev/null +++ b/lnbits/extensions/hivemind/migrations.py @@ -0,0 +1,10 @@ +# async def m001_initial(db): +# await db.execute( +# f""" +# CREATE TABLE hivemind.hivemind ( +# id TEXT PRIMARY KEY, +# wallet TEXT NOT NULL, +# time TIMESTAMP NOT NULL DEFAULT {db.timestamp_now} +# ); +# """ +# ) diff --git a/lnbits/extensions/hivemind/models.py b/lnbits/extensions/hivemind/models.py new file mode 100644 index 000000000..be5232339 --- /dev/null +++ b/lnbits/extensions/hivemind/models.py @@ -0,0 +1,11 @@ +# from sqlite3 import Row +# from typing import NamedTuple + + +# class Example(NamedTuple): +# id: str +# wallet: str +# +# @classmethod +# def from_row(cls, row: Row) -> "Example": +# return cls(**dict(row)) diff --git a/lnbits/extensions/hivemind/templates/hivemind/index.html b/lnbits/extensions/hivemind/templates/hivemind/index.html new file mode 100644 index 000000000..40a320f0b --- /dev/null +++ b/lnbits/extensions/hivemind/templates/hivemind/index.html @@ -0,0 +1,35 @@ +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} + + +
+ This extension is just a placeholder for now. +
+

+ Hivemind is a Bitcoin sidechain + project for a peer-to-peer oracle protocol that absorbs accurate data into + a blockchain so that Bitcoin users can speculate in prediction markets. +

+

+ These markets have the potential to revolutionize the emergence of + diffusion of knowledge in society and fix all sorts of problems in the + world. +

+

+ This extension will become fully operative when the + BIP300 soft-fork gets activated and + Bitcoin Hivemind is launched. +

+
+
+{% endblock %} {% block scripts %} {{ window_vars(user) }} + +{% endblock %} diff --git a/lnbits/extensions/hivemind/views.py b/lnbits/extensions/hivemind/views.py new file mode 100644 index 000000000..51122dfdf --- /dev/null +++ b/lnbits/extensions/hivemind/views.py @@ -0,0 +1,13 @@ +from fastapi.param_functions import Depends +from starlette.requests import Request +from starlette.responses import HTMLResponse + +from lnbits.core.models import User +from lnbits.decorators import check_user_exists + +from . import hivemind_ext, hivemind_renderer + + +@hivemind_ext.get("/", response_class=HTMLResponse) +async def index(request: Request, user: User = Depends(check_user_exists)): + return hivemind_renderer().TemplateResponse("hivemind/index.html", {"request": request, "user": user.dict()})