From b24224a7e546ec038e188bcd26a7805752c101e6 Mon Sep 17 00:00:00 2001 From: Arc Date: Tue, 19 Nov 2024 23:03:41 +0000 Subject: [PATCH] make --- migrations.py | 13 +++++++------ models.py | 1 + nwcp.py | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/migrations.py b/migrations.py index 94aa7db..98dd934 100644 --- a/migrations.py +++ b/migrations.py @@ -1,8 +1,6 @@ import secp256k1 - - async def m001_initial(db): """ Initial tables @@ -70,13 +68,15 @@ async def m003_default_config(db): """ 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()) 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}, ) @@ -89,9 +89,10 @@ async def m004_default_config2(db): 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": ""}, ) diff --git a/models.py b/models.py index 07dbe2d..e8c762d 100644 --- a/models.py +++ b/models.py @@ -64,6 +64,7 @@ class DeleteNWC(BaseModel): class OnInvoicePaid(BaseModel): class Config: arbitrary_types_allowed = True + sp: NWCServiceProvider pubkey: str payload: Dict diff --git a/nwcp.py b/nwcp.py index b1c5f9e..02f2a04 100644 --- a/nwcp.py +++ b/nwcp.py @@ -5,7 +5,6 @@ import json import random import time from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union -from pydantic import BaseModel import secp256k1 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.settings import settings from loguru import logger +from pydantic import BaseModel + class MainSubscription(BaseModel): class Config: @@ -49,6 +50,7 @@ class MainSubscription(BaseModel): class NWCServiceProvider(BaseModel): class Config: arbitrary_types_allowed = True + def __init__(self, private_key: Optional[str] = None, relay: Optional[str] = None): if not relay: # Connect to nostrclient relay = "nostrclient"