This commit is contained in:
Arc 2024-11-19 23:03:41 +00:00
commit b24224a7e5
3 changed files with 11 additions and 7 deletions

View file

@ -1,8 +1,6 @@
import secp256k1 import secp256k1
async def m001_initial(db): async def m001_initial(db):
""" """
Initial tables Initial tables
@ -70,13 +68,15 @@ async def m003_default_config(db):
""" """
await db.execute( await db.execute(
""" """
INSERT OR REPLACE INTO nwcprovider.config (key, value) VALUES ('relay', 'nostrclient'); INSERT OR REPLACE INTO nwcprovider.config
(key, value) VALUES ('relay', 'nostrclient');
""" """
) )
new_private_key = bytes.hex(secp256k1._gen_private_key()) new_private_key = bytes.hex(secp256k1._gen_private_key())
await db.execute( await db.execute(
""" """
INSERT OR REPLACE INTO nwcprovider.config (key, value) VALUES ('provider_key', :provider_key); INSERT OR REPLACE INTO nwcprovider.config
(key, value) VALUES ('provider_key', :provider_key);
""", """,
{"provider_key": new_private_key}, {"provider_key": new_private_key},
) )
@ -89,7 +89,8 @@ async def m004_default_config2(db):
await db.execute( await db.execute(
""" """
INSERT OR REPLACE INTO nwcprovider.config (key, value) VALUES ('relay_alias', :value); INSERT OR REPLACE INTO nwcprovider.config
(key, value) VALUES ('relay_alias', :value);
""", """,
{"value": ""}, {"value": ""},
) )

View file

@ -64,6 +64,7 @@ class DeleteNWC(BaseModel):
class OnInvoicePaid(BaseModel): class OnInvoicePaid(BaseModel):
class Config: class Config:
arbitrary_types_allowed = True arbitrary_types_allowed = True
sp: NWCServiceProvider sp: NWCServiceProvider
pubkey: str pubkey: str
payload: Dict payload: Dict

View file

@ -5,7 +5,6 @@ import json
import random import random
import time import time
from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union
from pydantic import BaseModel
import secp256k1 import secp256k1
import websockets.client as websockets import websockets.client as websockets
@ -15,6 +14,8 @@ from Cryptodome.Util.Padding import pad, unpad
from lnbits.helpers import encrypt_internal_message from lnbits.helpers import encrypt_internal_message
from lnbits.settings import settings from lnbits.settings import settings
from loguru import logger from loguru import logger
from pydantic import BaseModel
class MainSubscription(BaseModel): class MainSubscription(BaseModel):
class Config: class Config:
@ -49,6 +50,7 @@ class MainSubscription(BaseModel):
class NWCServiceProvider(BaseModel): class NWCServiceProvider(BaseModel):
class Config: class Config:
arbitrary_types_allowed = True arbitrary_types_allowed = True
def __init__(self, private_key: Optional[str] = None, relay: Optional[str] = None): def __init__(self, private_key: Optional[str] = None, relay: Optional[str] = None):
if not relay: # Connect to nostrclient if not relay: # Connect to nostrclient
relay = "nostrclient" relay = "nostrclient"