remove the need for nostrclient

This commit is contained in:
callebtc 2023-04-04 12:52:10 +02:00
commit bf6659bbbd
6 changed files with 29 additions and 45 deletions

View file

@ -23,6 +23,7 @@ LNURL is a range of lightning-network standards that allow us to use lightning-n
2. Use the shareable link or view the LNURLp you just created\ 2. Use the shareable link or view the LNURLp you just created\
![LNURLp](https://i.imgur.com/C8s1P0Q.jpg) ![LNURLp](https://i.imgur.com/C8s1P0Q.jpg)
- you can now open your LNURLp and copy the LNURL, get the shareable link or print it\ - you can now open your LNURLp and copy the LNURL, get the shareable link or print it\
![view lnurlp](https://i.imgur.com/4n41S7T.jpg) ![view lnurlp](https://i.imgur.com/4n41S7T.jpg)

View file

@ -9,16 +9,13 @@ from lnbits.helpers import template_renderer
from lnbits.tasks import catch_everything_and_restart from lnbits.tasks import catch_everything_and_restart
from loguru import logger from loguru import logger
try:
from ..nostrclient.nostr.event import Event
from ..nostrclient.nostr.key import PrivateKey, PublicKey
nostrclient_present = True from .nostr.event import Event
from .nostr.key import PrivateKey, PublicKey
nostr_privatekey = PrivateKey() nostr_privatekey = PrivateKey()
nostr_publickey: PublicKey = nostr_privatekey.public_key nostr_publickey: PublicKey = nostr_privatekey.public_key
logger.debug(f"LNURLP Zaps Nostr pubkey: {nostr_publickey.hex()}") logger.debug(f"LNURLP Zaps Nostr pubkey: {nostr_publickey.hex()}")
except ImportError:
nostrclient_present = False
db = Database("ext_lnurlp") db = Database("ext_lnurlp")

View file

@ -2,9 +2,5 @@
"name": "LNURLp", "name": "LNURLp",
"short_description": "Make reusable LNURL pay links", "short_description": "Make reusable LNURL pay links",
"tile": "/lnurlp/static/image/lnurl-pay.png", "tile": "/lnurlp/static/image/lnurl-pay.png",
"contributors": [ "contributors": ["arcbtc", "eillarra", "fiatjaf", "callebtc"]
"arcbtc",
"eillarra",
"fiatjaf"
]
} }

View file

@ -12,13 +12,9 @@ from .crud import increment_pay_link, get_pay_link, get_address_data
from loguru import logger from loguru import logger
from urllib.parse import urlparse from urllib.parse import urlparse
import json import json
from . import nostrclient_present, nostr_publickey from . import nostr_publickey
if nostrclient_present:
try:
from ..nostrclient.nostr.key import PrivateKey, PublicKey from ..nostrclient.nostr.key import PrivateKey, PublicKey
except ImportError:
nostrclient_present = False
@lnurlp_ext.get( @lnurlp_ext.get(
@ -151,7 +147,6 @@ async def api_lnurl_response(request: Request, link_id, lnaddress=False):
if link.comment_chars > 0: if link.comment_chars > 0:
params["commentAllowed"] = link.comment_chars params["commentAllowed"] = link.comment_chars
if nostrclient_present:
params["allowsNostr"] = True params["allowsNostr"] = True
params["nostrPubkey"] = nostr_publickey.hex() params["nostrPubkey"] = nostr_publickey.hex()
return params return params

View file

@ -1,4 +1,3 @@
{ {
"repos": [ "repos": [
{ {

View file

@ -12,16 +12,12 @@ from websocket import WebSocketApp
from lnbits.settings import settings from lnbits.settings import settings
from .crud import get_pay_link from .crud import get_pay_link
from threading import Thread from threading import Thread
from . import nostrclient_present, nostr_privatekey from . import nostr_privatekey
from typing import List from typing import List
import time import time
if nostrclient_present: from .nostr.event import Event
try: from .nostr.key import PrivateKey, PublicKey
from ..nostrclient.nostr.event import Event
from ..nostrclient.nostr.key import PrivateKey, PublicKey
except ImportError:
nostrclient_present = False
async def wait_for_paid_invoices(): async def wait_for_paid_invoices():
@ -77,7 +73,7 @@ async def on_invoice_paid(payment: Payment):
# NIP-57 # NIP-57
nostr = payment.extra.get("nostr") nostr = payment.extra.get("nostr")
if nostrclient_present and nostr: if nostr:
event_json = json.loads(nostr) event_json = json.loads(nostr)
@ -117,10 +113,10 @@ async def on_invoice_paid(payment: Payment):
# list of all threads for these websockets # list of all threads for these websockets
wsts: List[Thread] = [] wsts: List[Thread] = []
# send zap via nostrclient # # send zap via nostrclient
ws, wst = send_zap(f"ws://localhost:{settings.port}/nostrclient/api/v1/relay") # ws, wst = send_zap(f"ws://localhost:{settings.port}/nostrclient/api/v1/relay")
wss += [ws] # wss += [ws]
wsts += [wst] # wsts += [wst]
# send zap receipt to relays in zap request # send zap receipt to relays in zap request
relays = get_tag(event_json, "relays") relays = get_tag(event_json, "relays")