more cleanup

This commit is contained in:
Believethehype
2024-10-17 16:12:18 +02:00
parent a3ad0bebc7
commit db7fb286e0
11 changed files with 76 additions and 94 deletions

View File

@@ -5,9 +5,6 @@ from nostr_dvm.utils.nostr_utils import send_event
from nostr_dvm.utils.print_utils import bcolors from nostr_dvm.utils.print_utils import bcolors
async def announce_dm_relays(dvm_config, client): async def announce_dm_relays(dvm_config, client):
tags = [] tags = []
@@ -51,4 +48,3 @@ async def nip65_announce_relays(dvm_config, client):
else: else:
print( print(
bcolors.RED + "[" + dvm_config.NIP89.NAME + "] Could not announce NIP 65 for " + dvm_config.NIP89.NAME + bcolors.ENDC) bcolors.RED + "[" + dvm_config.NIP89.NAME + "] Could not announce NIP 65 for " + dvm_config.NIP89.NAME + bcolors.ENDC)

View File

@@ -1,10 +1,9 @@
import os import os
from datetime import timedelta
from hashlib import sha256 from hashlib import sha256
from pathlib import Path from pathlib import Path
import dotenv import dotenv
from nostr_sdk import Filter, Tag, Keys, EventBuilder, Client, EventId, PublicKey, Event, Timestamp, SingleLetterTag, \ from nostr_sdk import Filter, Tag, Keys, EventBuilder, Client, EventId, PublicKey, Timestamp, SingleLetterTag, \
Alphabet, Kind Alphabet, Kind
from nostr_dvm.utils import definitions from nostr_dvm.utils import definitions
@@ -88,7 +87,8 @@ async def nip88_delete_announcement(eid: str, keys: Keys, dtag: str, client: Cli
await send_event(event, client, config) await send_event(event, client, config)
async def nip88_has_active_subscription(user: PublicKey, tiereventdtag, client: Client, receiver_public_key_hex, checkCanceled = True): async def nip88_has_active_subscription(user: PublicKey, tiereventdtag, client: Client, receiver_public_key_hex,
checkCanceled=True):
subscription_status = { subscription_status = {
"isActive": False, "isActive": False,
"validUntil": 0, "validUntil": 0,
@@ -140,8 +140,10 @@ async def nip88_announce_tier(dvm_config, client):
# 5% go to NostrSDK developers # 5% go to NostrSDK developers
# 10% optionally go to clients that support this subscription DVM # 10% optionally go to clients that support this subscription DVM
zaptag1 = Tag.parse(["zap", dvm_config.PUBLIC_KEY, "wss://damus.io", "16"]) zaptag1 = Tag.parse(["zap", dvm_config.PUBLIC_KEY, "wss://damus.io", "16"])
zaptag2 = Tag.parse(["zap", "npub1nxa4tywfz9nqp7z9zp7nr7d4nchhclsf58lcqt5y782rmf2hefjquaa6q8", "wss://damus.io", "1"]) # NostrDVM zaptag2 = Tag.parse(
zaptag3 = Tag.parse(["zap", "npub1drvpzev3syqt0kjrls50050uzf25gehpz9vgdw08hvex7e0vgfeq0eseet", "wss://damus.io", "1"]) # NostrSDK ["zap", "npub1nxa4tywfz9nqp7z9zp7nr7d4nchhclsf58lcqt5y782rmf2hefjquaa6q8", "wss://damus.io", "1"]) # NostrDVM
zaptag3 = Tag.parse(
["zap", "npub1drvpzev3syqt0kjrls50050uzf25gehpz9vgdw08hvex7e0vgfeq0eseet", "wss://damus.io", "1"]) # NostrSDK
zaptag4 = Tag.parse(["zap", "", "wss://damus.io", "2"]) # Client might use this for splits zaptag4 = Tag.parse(["zap", "", "wss://damus.io", "2"]) # Client might use this for splits
p_tag = Tag.parse(["p", dvm_config.NIP88.PAYMENT_VERIFIER_PUBKEY]) p_tag = Tag.parse(["p", dvm_config.NIP88.PAYMENT_VERIFIER_PUBKEY])
@@ -182,7 +184,6 @@ async def nip88_announce_tier(dvm_config, client):
else: else:
print("[" + dvm_config.identifier + "] Announced NIP 88 Tier") print("[" + dvm_config.identifier + "] Announced NIP 88 Tier")
return annotier_id return annotier_id
# Relay and payment-verification # Relay and payment-verification

View File

@@ -1,5 +1,4 @@
import os import os
from datetime import timedelta
from hashlib import sha256 from hashlib import sha256
from pathlib import Path from pathlib import Path
@@ -33,8 +32,8 @@ async def nip89_announce_tasks(dvm_config, client):
event = EventBuilder(EventDefinitions.KIND_ANNOUNCEMENT, content, [k_tag, d_tag]).to_event(keys) event = EventBuilder(EventDefinitions.KIND_ANNOUNCEMENT, content, [k_tag, d_tag]).to_event(keys)
eventid = await send_event(event, client=client, dvm_config=dvm_config) eventid = await send_event(event, client=client, dvm_config=dvm_config)
print(bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced NIP 89 for " + dvm_config.NIP89.NAME +" (" + eventid.id.to_hex() +")" + bcolors.ENDC) print(
bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced NIP 89 for " + dvm_config.NIP89.NAME + " (" + eventid.id.to_hex() + ")" + bcolors.ENDC)
async def fetch_nip89_parameters_for_deletion(keys, eventid, client, dvmconfig, pow=False): async def fetch_nip89_parameters_for_deletion(keys, eventid, client, dvmconfig, pow=False):
@@ -70,6 +69,7 @@ async def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Cli
print(f"POW event: {event.as_json()}") print(f"POW event: {event.as_json()}")
await send_event(event, client, config) await send_event(event, client, config)
async def nip89_delete_announcement_pow(eid: str, keys: Keys, dtag: str, client: Client, config): async def nip89_delete_announcement_pow(eid: str, keys: Keys, dtag: str, client: Client, config):
e_tag = Tag.parse(["e", eid]) e_tag = Tag.parse(["e", eid])
a_tag = Tag.parse( a_tag = Tag.parse(

View File

@@ -1,5 +1,6 @@
import base64 import base64
import hashlib import hashlib
from nostr_sdk import EventBuilder, Tag, Kind, Keys from nostr_sdk import EventBuilder, Tag, Kind, Keys
@@ -7,6 +8,7 @@ def sha256sum(filename):
with open(filename, 'rb', buffering=0) as f: with open(filename, 'rb', buffering=0) as f:
return hashlib.file_digest(f, 'sha256').hexdigest() return hashlib.file_digest(f, 'sha256').hexdigest()
async def generate_nip98_header(pkeys_hex, url="", kind="POST", filepath=""): async def generate_nip98_header(pkeys_hex, url="", kind="POST", filepath=""):
keys = Keys.parse(pkeys_hex) keys = Keys.parse(pkeys_hex)
utag = Tag.parse(["u", url]) utag = Tag.parse(["u", url])
@@ -20,4 +22,3 @@ async def generate_nip98_header(pkeys_hex, url="", kind="POST", filepath=""):
encoded_nip98_event = base64.b64encode(event.as_json().encode('utf-8')).decode('utf-8') encoded_nip98_event = base64.b64encode(event.as_json().encode('utf-8')).decode('utf-8')
return "Nostr " + encoded_nip98_event return "Nostr " + encoded_nip98_event

View File

@@ -6,10 +6,10 @@ from typing import List
import dotenv import dotenv
from nostr_sdk import Filter, Client, Alphabet, EventId, Event, PublicKey, Tag, Keys, nip04_decrypt, Metadata, Options, \ from nostr_sdk import Filter, Client, Alphabet, EventId, Event, PublicKey, Tag, Keys, nip04_decrypt, Metadata, Options, \
Nip19Event, SingleLetterTag, RelayOptions, RelayLimits, SecretKey, NostrSigner, Connection, ConnectionTarget, \ Nip19Event, SingleLetterTag, RelayLimits, SecretKey, NostrSigner, Connection, ConnectionTarget, \
EventSource, EventBuilder, Kind, nip04_encrypt EventSource, EventBuilder, Kind
from nostr_dvm.utils.definitions import EventDefinitions, relay_timeout, relay_timeout_long from nostr_dvm.utils.definitions import EventDefinitions, relay_timeout
async def get_event_by_id(event_id_str: str, client: Client, config=None) -> Event | None: async def get_event_by_id(event_id_str: str, client: Client, config=None) -> Event | None:
@@ -25,13 +25,13 @@ async def get_event_by_id(event_id_str: str, client: Client, config=None) -> Eve
events = await client.get_events_of([id_filter], relay_timeout) events = await client.get_events_of([id_filter], relay_timeout)
if len(events) > 0: if len(events) > 0:
return events[0] return events[0]
else: else:
print("Event not found") print("Event not found")
return None return None
async def get_events_async(client, filter, timeout): async def get_events_async(client, filter, timeout):
source_l = EventSource.relays(timedelta(seconds=timeout)) source_l = EventSource.relays(timedelta(seconds=timeout))
events = await client.get_events_of([filter], source_l) events = await client.get_events_of([filter], source_l)
@@ -100,7 +100,6 @@ async def get_referenced_event_by_id(event_id, client, dvm_config, kinds) -> Eve
job_id_filter = Filter().event(event_id).limit(1) job_id_filter = Filter().event(event_id).limit(1)
events = await client.get_events_of([job_id_filter], relay_timeout) events = await client.get_events_of([job_id_filter], relay_timeout)
if len(events) > 0: if len(events) > 0:
return events[0] return events[0]
else: else:
@@ -154,6 +153,7 @@ async def get_dm_relays(event_to_send: Event, client: Client, dvm_config):
relays.append(rtag) relays.append(rtag)
return relays return relays
async def get_main_relays(event_to_send: Event, client: Client, dvm_config): async def get_main_relays(event_to_send: Event, client: Client, dvm_config):
ptags = [] ptags = []
for tag in event_to_send.tags(): for tag in event_to_send.tags():
@@ -182,10 +182,7 @@ async def get_main_relays(event_to_send: Event, client: Client, dvm_config):
return [] return []
async def send_event_outbox(event: Event, client, dvm_config) -> EventId: async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
# 1. OK, Let's overcomplicate things. # 1. OK, Let's overcomplicate things.
# 2. If our event has a relays tag, we just send the event to these relay in the classical way. # 2. If our event has a relays tag, we just send the event to these relay in the classical way.
relays = [] relays = []
@@ -197,10 +194,10 @@ async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
try: try:
relays.append(tag.as_vec()[index]) relays.append(tag.as_vec()[index])
except: except:
print("[" + dvm_config.NIP89.NAME + "] " + tag.as_vec()[index] + " couldn't be added to outbox relays") print("[" + dvm_config.NIP89.NAME + "] " + tag.as_vec()[
index] + " couldn't be added to outbox relays")
break break
# 3. If we couldn't find relays, we look in the receivers inbox # 3. If we couldn't find relays, we look in the receivers inbox
if len(relays) == 0: if len(relays) == 0:
relays = await get_inbox_relays(event, client, dvm_config) relays = await get_inbox_relays(event, client, dvm_config)
@@ -221,8 +218,6 @@ async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
Options().wait_for_send(False).send_timeout(timedelta(seconds=5)).relay_limits( Options().wait_for_send(False).send_timeout(timedelta(seconds=5)).relay_limits(
relaylimits)).connection(connection).connection_timeout(timedelta(seconds=30))) relaylimits)).connection(connection).connection_timeout(timedelta(seconds=30)))
sk = SecretKey.from_hex(dvm_config.PRIVATE_KEY) sk = SecretKey.from_hex(dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex()) keys = Keys.parse(sk.to_hex())
signer = NostrSigner.keys(keys) signer = NostrSigner.keys(keys)
@@ -252,7 +247,6 @@ async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
except: except:
print("Error removing relay: " + relay) print("Error removing relay: " + relay)
relays = await get_main_relays(event, client, dvm_config) relays = await get_main_relays(event, client, dvm_config)
for relay in relays: for relay in relays:
await outboxclient.add_relay(relay) await outboxclient.add_relay(relay)
@@ -264,13 +258,10 @@ async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
event_id = None event_id = None
print(e) print(e)
await outboxclient.shutdown() await outboxclient.shutdown()
return event_id return event_id
async def send_event(event: Event, client: Client, dvm_config): async def send_event(event: Event, client: Client, dvm_config):
try: try:
relays = [] relays = []
@@ -418,16 +409,12 @@ async def update_profile(dvm_config, client, lud16=""):
async def send_nip04_dm(client: Client, msg, receiver: PublicKey, dvm_config): async def send_nip04_dm(client: Client, msg, receiver: PublicKey, dvm_config):
signer = NostrSigner.keys(Keys.parse(dvm_config.PRIVATE_KEY)) signer = NostrSigner.keys(Keys.parse(dvm_config.PRIVATE_KEY))
content = await signer.nip04_encrypt(receiver, msg) content = await signer.nip04_encrypt(receiver, msg)
ptag = Tag.parse(["p", receiver.to_hex()]) ptag = Tag.parse(["p", receiver.to_hex()])
event = EventBuilder(Kind(4), content, [ptag]).to_event(Keys.parse(dvm_config.PRIVATE_KEY)) event = EventBuilder(Kind(4), content, [ptag]).to_event(Keys.parse(dvm_config.PRIVATE_KEY))
await client.send_event(event) await client.send_event(event)
# relays = await get_dm_relays(event, client, dvm_config) # relays = await get_dm_relays(event, client, dvm_config)
# #
# outboxclient = Client(signer) # outboxclient = Client(signer)
@@ -448,7 +435,6 @@ async def send_nip04_dm(client: Client, msg, receiver: PublicKey, dvm_config ):
# print(e) # print(e)
def check_and_set_private_key(identifier): def check_and_set_private_key(identifier):
if not os.getenv("DVM_PRIVATE_KEY_" + identifier.upper()): if not os.getenv("DVM_PRIVATE_KEY_" + identifier.upper()):
pk = Keys.generate().secret_key().to_hex() pk = Keys.generate().secret_key().to_hex()

View File

@@ -1,10 +1,8 @@
import json import json
import os import os
from datetime import timedelta
import requests import requests
from nostr_sdk import Keys, PublicKey, Client, nip04_encrypt, EventBuilder, Tag, NostrSigner, Filter, Timestamp, \ from nostr_sdk import Keys, PublicKey, NostrWalletConnectUri, Nwc
NostrWalletConnectUri, Nwc
from nostr_dvm.utils.dvmconfig import DVMConfig from nostr_dvm.utils.dvmconfig import DVMConfig
from nostr_dvm.utils.nostr_utils import check_and_set_private_key from nostr_dvm.utils.nostr_utils import check_and_set_private_key

View File

@@ -1,19 +1,19 @@
import json
import datetime as datetime import datetime as datetime
import json
import os import os
import random import random
from types import NoneType from types import NoneType
import emoji import emoji
import pandas
import requests import requests
from nostr_sdk import Tag, PublicKey, EventId, Keys, nip04_encrypt, EventBuilder, LogLevel from nostr_sdk import Tag, PublicKey, EventId, Keys, EventBuilder, LogLevel
from pyupload.uploader import CatboxUploader from pyupload.uploader import CatboxUploader
import pandas
from nostr_dvm.utils.print_utils import bcolors
from nostr_dvm.utils.definitions import EventDefinitions from nostr_dvm.utils.definitions import EventDefinitions
from nostr_dvm.utils.nip98_utils import generate_nip98_header from nostr_dvm.utils.nip98_utils import generate_nip98_header
from nostr_dvm.utils.nostr_utils import send_event_outbox from nostr_dvm.utils.nostr_utils import send_event_outbox
from nostr_dvm.utils.print_utils import bcolors
''' '''
Post process results to either given output format or a Nostr readable plain text. Post process results to either given output format or a Nostr readable plain text.
@@ -293,11 +293,9 @@ def build_status_reaction(status, task, amount, content, dvm_config):
return alt_description, reaction return alt_description, reaction
async def send_job_status_reaction(original_event_id_hex, original_event_author_hex, client, dvm_config, async def send_job_status_reaction(original_event_id_hex, original_event_author_hex, client, dvm_config,
content=None, content=None,
status="processing", user=None): status="processing", user=None):
alt_description, reaction = build_status_reaction(status, "generic", 0, content, dvm_config) alt_description, reaction = build_status_reaction(status, "generic", 0, content, dvm_config)
e_tag = Tag.parse(["e", original_event_id_hex]) e_tag = Tag.parse(["e", original_event_id_hex])

View File

@@ -1,22 +1,18 @@
import json
import os
import re
import sys
from typing import Any from typing import Any
from urllib.request import urlopen, Request from urllib.request import urlopen, Request
import requests
import json
import yt_dlp
import sys
import os
import re
import requests
import bs4 import bs4
import requests
import yt_dlp
from tqdm import tqdm from tqdm import tqdm
from pathlib import Path
browser = "chrome" # "firefox" browser = "chrome" # "firefox"
def download_xvideo(url, target_location) -> None: def download_xvideo(url, target_location) -> None:
response = requests.get(url, stream=True) response = requests.get(url, stream=True)
total_size = int(response.headers.get("content-length", 0)) total_size = int(response.headers.get("content-length", 0))
@@ -119,7 +115,6 @@ def TiktokDownloadAll(linkList, path) -> str:
def YTDownload(link, path, audio_only=True): def YTDownload(link, path, audio_only=True):
if audio_only: if audio_only:
return get_audio([link]) return get_audio([link])
else: else:
@@ -140,6 +135,7 @@ def get_media_duration(url):
except: except:
return None return None
def get_media_info(url): def get_media_info(url):
try: try:
# See help(yt_dlp.YoutubeDL) for a list of available options and public functions # See help(yt_dlp.YoutubeDL) for a list of available options and public functions
@@ -186,7 +182,6 @@ def get_video(URLS):
"outtmpl": 'outputs/video.mp4', "outtmpl": 'outputs/video.mp4',
} }
with yt_dlp.YoutubeDL(ydl_opts) as ydl: with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download(URLS) ydl.download(URLS)
return "outputs/video.mp4" return "outputs/video.mp4"

View File

@@ -57,12 +57,15 @@ def create_subscription_sql_table(db):
print(e) print(e)
def add_to_subscription_sql_table(db, id, recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag, zaps, def add_to_subscription_sql_table(db, id, recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag,
zaps,
recipe, active, lastupdate, tier): recipe, active, lastupdate, tier):
try: try:
con = sqlite3.connect(db) con = sqlite3.connect(db)
cur = con.cursor() cur = con.cursor()
data = (id, recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag, zaps, recipe, active, lastupdate, tier) data = (
id, recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag, zaps, recipe, active, lastupdate,
tier)
print(id) print(id)
print(recipient) print(recipient)
print(subscriber) print(subscriber)
@@ -118,7 +121,9 @@ def get_all_subscriptions_from_sql_table(db):
records = cursor.fetchall() records = cursor.fetchall()
subscriptions = [] subscriptions = []
for row in records: for row in records:
subscriptions.append(Subscription(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14])) subscriptions.append(
Subscription(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10],
row[11], row[12], row[13], row[14]))
cursor.close() cursor.close()
return subscriptions return subscriptions
@@ -129,6 +134,7 @@ def get_all_subscriptions_from_sql_table(db):
con.close() con.close()
# print("The SQLite connection is closed") # print("The SQLite connection is closed")
def delete_from_subscription_sql_table(db, id): def delete_from_subscription_sql_table(db, id):
try: try:
con = sqlite3.connect(db) con = sqlite3.connect(db)
@@ -139,12 +145,16 @@ def delete_from_subscription_sql_table(db, id):
except Error as e: except Error as e:
print(e) print(e)
def update_subscription_sql_table(db, id, recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag, zaps,
def update_subscription_sql_table(db, id, recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag,
zaps,
recipe, active, lastupdate, tier): recipe, active, lastupdate, tier):
try: try:
con = sqlite3.connect(db) con = sqlite3.connect(db)
cur = con.cursor() cur = con.cursor()
data = (recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag, zaps, recipe, active, lastupdate, tier, id) data = (
recipient, subscriber, nwc, cadence, amount, unit, begin, end, tier_dtag, zaps, recipe, active, lastupdate,
tier, id)
cur.execute(""" UPDATE subscriptions cur.execute(""" UPDATE subscriptions
SET recipient = ? , SET recipient = ? ,
@@ -167,7 +177,3 @@ def update_subscription_sql_table(db, id, recipient, subscriber, nwc, cadence, a
con.close() con.close()
except Error as e: except Error as e:
print("Error Updating DB: " + str(e)) print("Error Updating DB: " + str(e))

View File

@@ -4,9 +4,11 @@ import os
import random import random
import string import string
import urllib.parse import urllib.parse
from hashlib import sha256
from pathlib import Path from pathlib import Path
import bech32 import bech32
import dotenv
import requests import requests
from Crypto.Cipher import AES from Crypto.Cipher import AES
from Crypto.Util.Padding import pad from Crypto.Util.Padding import pad
@@ -14,10 +16,7 @@ from bech32 import bech32_decode, convertbits, bech32_encode
from nostr_sdk import PublicKey, SecretKey, Event, EventBuilder, Tag, Keys, generate_shared_key, Kind, \ from nostr_sdk import PublicKey, SecretKey, Event, EventBuilder, Tag, Keys, generate_shared_key, Kind, \
Timestamp Timestamp
from nostr_dvm.utils.nostr_utils import get_event_by_id, check_and_decrypt_own_tags, update_profile, \ from nostr_dvm.utils.nostr_utils import get_event_by_id, check_and_decrypt_own_tags, update_profile_lnaddress
update_profile_lnaddress
from hashlib import sha256
import dotenv
# TODO tor connection to lnbits # TODO tor connection to lnbits
# proxies = { # proxies = {
@@ -277,7 +276,6 @@ def zaprequest(lud16: str, amount: int, content, zapped_event, zapped_user, keys
callback = ob["callback"] callback = ob["callback"]
print(ob["callback"]) print(ob["callback"])
# encoded_lnurl = lnurl.encode(url) # encoded_lnurl = lnurl.encode(url)
url_bytes = url.encode() url_bytes = url.encode()
@@ -351,12 +349,13 @@ def get_price_per_sat(currency):
return price_currency_per_sat return price_currency_per_sat
def randomword(length): def randomword(length):
letters = string.ascii_lowercase letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(length)) return ''.join(random.choice(letters) for i in range(length))
def make_ln_address_nostdress(identifier, npub, pin, nostdressdomain, newname = " ", currentname=" "):
def make_ln_address_nostdress(identifier, npub, pin, nostdressdomain, newname=" ", currentname=" "):
if newname == " ": if newname == " ":
newname = identifier newname = identifier
@@ -423,7 +422,8 @@ async def change_ln_address(identifier, new_identifier, dvm_config, updateprofil
previous_identifier = os.getenv("LNADDRESS_" + identifier.upper()).split("@")[0] previous_identifier = os.getenv("LNADDRESS_" + identifier.upper()).split("@")[0]
pin = os.getenv("LNADDRESS_PIN_" + identifier.upper()) pin = os.getenv("LNADDRESS_PIN_" + identifier.upper())
npub = Keys.parse(os.getenv("DVM_PRIVATE_KEY_" + identifier.upper())).public_key().to_hex() npub = Keys.parse(os.getenv("DVM_PRIVATE_KEY_" + identifier.upper())).public_key().to_hex()
lnaddress, pin = make_ln_address_nostdress(identifier, npub, pin, os.getenv("NOSTDRESS_DOMAIN"), new_identifier, currentname=previous_identifier) lnaddress, pin = make_ln_address_nostdress(identifier, npub, pin, os.getenv("NOSTDRESS_DOMAIN"), new_identifier,
currentname=previous_identifier)
add_key_to_env_file("LNADDRESS_" + identifier.upper(), lnaddress) add_key_to_env_file("LNADDRESS_" + identifier.upper(), lnaddress)
add_key_to_env_file("LNADDRESS_PIN_" + identifier.upper(), pin) add_key_to_env_file("LNADDRESS_PIN_" + identifier.upper(), pin)
print("changed lnaddress") print("changed lnaddress")
@@ -431,6 +431,7 @@ async def change_ln_address(identifier, new_identifier, dvm_config, updateprofil
private_key = os.getenv("DVM_PRIVATE_KEY_" + identifier.upper()) private_key = os.getenv("DVM_PRIVATE_KEY_" + identifier.upper())
await update_profile_lnaddress(private_key, dvm_config, lud16=lnaddress) await update_profile_lnaddress(private_key, dvm_config, lud16=lnaddress)
def add_key_to_env_file(value, oskey): def add_key_to_env_file(value, oskey):
env_path = Path('.env') env_path = Path('.env')
if env_path.is_file(): if env_path.is_file():