commit
d1944e919c
4 changed files with 36 additions and 35 deletions
|
|
@ -16,12 +16,10 @@ python3 -m venv venv
|
||||||
./venv/bin/pip install -r requirements.txt
|
./venv/bin/pip install -r requirements.txt
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
mkdir data
|
mkdir data
|
||||||
./venv/bin/quart assets
|
./venv/bin/uvicorn lnbits.__main__:app --port 5000
|
||||||
./venv/bin/quart migrate
|
|
||||||
./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 'lnbits.app:create_app()'
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can visit your LNbits at http://localhost:5000/.
|
Now you can visit your LNbits at http://localhost:5000/.
|
||||||
|
|
||||||
Now modify the `.env` file with any settings you prefer and add a proper [funding source](./wallets.md) by modifying the value of `LNBITS_BACKEND_WALLET_CLASS` and providing the extra information and credentials related to the chosen funding source.
|
Now modify the `.env` file with any settings you prefer and add a proper [funding source](./wallets.md) by modifying the value of `LNBITS_BACKEND_WALLET_CLASS` and providing the extra information and credentials related to the chosen funding source.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
import json
|
import json
|
||||||
from lnurl import Lnurl, LnurlWithdrawResponse, encode as lnurl_encode # type: ignore
|
|
||||||
from urllib.parse import urlparse, urlunparse, parse_qs, urlencode, ParseResult
|
|
||||||
from lnurl.types import LnurlPayMetadata # type: ignore
|
|
||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import NamedTuple, Optional, Dict
|
from typing import Dict, NamedTuple, Optional
|
||||||
|
from urllib.parse import ParseResult, parse_qs, urlencode, urlparse, urlunparse
|
||||||
|
|
||||||
import shortuuid # type: ignore
|
import shortuuid # type: ignore
|
||||||
from fastapi.param_functions import Query
|
|
||||||
from pydantic.main import BaseModel
|
|
||||||
from pydantic import BaseModel
|
|
||||||
from typing import Optional
|
|
||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
|
from fastapi.param_functions import Query
|
||||||
|
from lnurl import Lnurl, LnurlWithdrawResponse
|
||||||
|
from lnurl import encode as lnurl_encode # type: ignore
|
||||||
|
from lnurl.types import LnurlPayMetadata # type: ignore
|
||||||
|
from pydantic import BaseModel
|
||||||
|
from pydantic.main import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class satsdiceLink(BaseModel):
|
class satsdiceLink(BaseModel):
|
||||||
|
|
@ -105,7 +106,7 @@ class HashCheck(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class CreateSatsDiceLink(BaseModel):
|
class CreateSatsDiceLink(BaseModel):
|
||||||
wallet_id: str = Query(None)
|
wallet: str = Query(None)
|
||||||
title: str = Query(None)
|
title: str = Query(None)
|
||||||
base_url: str = Query(None)
|
base_url: str = Query(None)
|
||||||
min_bet: str = Query(None)
|
min_bet: str = Query(None)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ from .crud import (
|
||||||
update_satsdice_pay,
|
update_satsdice_pay,
|
||||||
update_satsdice_withdraw,
|
update_satsdice_withdraw,
|
||||||
)
|
)
|
||||||
from .models import CreateSatsDiceLink, CreateSatsDiceWithdraws
|
from .models import CreateSatsDiceLink, CreateSatsDiceWithdraws, satsdiceLink
|
||||||
|
|
||||||
################LNURL pay
|
################LNURL pay
|
||||||
|
|
||||||
|
|
@ -92,7 +92,8 @@ async def api_link_create_or_update(
|
||||||
detail="Come on, seriously, this isn't your satsdice!",
|
detail="Come on, seriously, this isn't your satsdice!",
|
||||||
)
|
)
|
||||||
|
|
||||||
data.wallet_id = wallet.wallet.id
|
|
||||||
|
data.wallet = wallet.wallet.id
|
||||||
link = await update_satsdice_pay(link_id, **data.dict())
|
link = await update_satsdice_pay(link_id, **data.dict())
|
||||||
else:
|
else:
|
||||||
link = await create_satsdice_pay(wallet_id=wallet.wallet.id, data=data)
|
link = await create_satsdice_pay(wallet_id=wallet.wallet.id, data=data)
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,35 @@ except ImportError: # pragma: nocover
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import random
|
import random
|
||||||
import json
|
from functools import partial, wraps
|
||||||
|
|
||||||
from os import getenv
|
from os import getenv
|
||||||
from typing import Optional, AsyncGenerator
|
from typing import AsyncGenerator, Optional
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
StatusResponse,
|
|
||||||
InvoiceResponse,
|
InvoiceResponse,
|
||||||
PaymentResponse,
|
PaymentResponse,
|
||||||
PaymentStatus,
|
PaymentStatus,
|
||||||
Wallet,
|
StatusResponse,
|
||||||
Unsupported,
|
Unsupported,
|
||||||
|
Wallet,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def async_wrap(func):
|
||||||
|
@wraps(func)
|
||||||
|
async def run(*args, loop=None, executor=None, **kwargs):
|
||||||
|
if loop is None:
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
partial_func = partial(func, *args, **kwargs)
|
||||||
|
return await loop.run_in_executor(executor, partial_func)
|
||||||
|
|
||||||
|
return run
|
||||||
|
|
||||||
|
|
||||||
|
def _paid_invoices_stream(ln, last_pay_index):
|
||||||
|
return ln.waitanyinvoice(last_pay_index)
|
||||||
|
|
||||||
|
|
||||||
class CLightningWallet(Wallet):
|
class CLightningWallet(Wallet):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if LightningRpc is None: # pragma: nocover
|
if LightningRpc is None: # pragma: nocover
|
||||||
|
|
@ -115,21 +129,8 @@ class CLightningWallet(Wallet):
|
||||||
raise KeyError("supplied an invalid checking_id")
|
raise KeyError("supplied an invalid checking_id")
|
||||||
|
|
||||||
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
||||||
reader, writer = await asyncio.open_unix_connection(self.rpc)
|
|
||||||
|
|
||||||
i = 0
|
|
||||||
while True:
|
while True:
|
||||||
call = json.dumps(
|
wrapped = async_wrap(_paid_invoices_stream)
|
||||||
{"method": "waitanyinvoice", "id": 0, "params": [self.last_pay_index]}
|
paid = await wrapped(self.ln, self.last_pay_index)
|
||||||
)
|
|
||||||
writer.write(call.encode())
|
|
||||||
await writer.drain()
|
|
||||||
|
|
||||||
data = await reader.read()
|
|
||||||
paid = json.loads(data.decode("ascii"))
|
|
||||||
|
|
||||||
paid = self.ln.waitanyinvoice(self.last_pay_index)
|
|
||||||
self.last_pay_index = paid["pay_index"]
|
self.last_pay_index = paid["pay_index"]
|
||||||
yield paid["label"]
|
yield paid["label"]
|
||||||
|
|
||||||
i += 1
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue