mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-05-31 02:01:59 +02:00
update to nostrsdk0.11.1 (for testing)
This commit is contained in:
parent
cd077db044
commit
19c554d7bf
@ -4,7 +4,7 @@ from pathlib import Path
|
||||
from threading import Thread
|
||||
|
||||
import dotenv
|
||||
from nostr_sdk import Keys, Client, ClientSigner, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt
|
||||
from nostr_sdk import Keys, Client, NostrSigner, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt
|
||||
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nostr_utils import send_event, check_and_set_private_key
|
||||
@ -12,7 +12,7 @@ from nostr_dvm.utils.definitions import EventDefinitions
|
||||
|
||||
|
||||
def nostr_client_test_llm(prompt):
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
|
||||
iTag = Tag.parse(["i", prompt, "text"])
|
||||
relaysTag = Tag.parse(['relays', "wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
|
||||
@ -24,7 +24,7 @@ def nostr_client_test_llm(prompt):
|
||||
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
|
||||
"wss://nostr-pub.wellorder.net"]
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
|
||||
for relay in relay_list:
|
||||
@ -35,7 +35,7 @@ def nostr_client_test_llm(prompt):
|
||||
return event.as_json()
|
||||
|
||||
def nostr_client():
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
sk = keys.secret_key()
|
||||
pk = keys.public_key()
|
||||
print(f"Nostr Test Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
|
||||
|
@ -5,7 +5,7 @@ from threading import Thread
|
||||
|
||||
import dotenv
|
||||
from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \
|
||||
ClientSigner
|
||||
NostrSigner
|
||||
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nostr_utils import send_event, check_and_set_private_key
|
||||
@ -13,7 +13,7 @@ from nostr_dvm.utils.definitions import EventDefinitions
|
||||
|
||||
|
||||
def nostr_client_test_tts(prompt):
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
|
||||
iTag = Tag.parse(["i", prompt, "text"])
|
||||
paramTag1 = Tag.parse(["param", "language", "en"])
|
||||
@ -30,7 +30,7 @@ def nostr_client_test_tts(prompt):
|
||||
"wss://nostr-pub.wellorder.net"]
|
||||
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
for relay in relay_list:
|
||||
client.add_relay(relay)
|
||||
@ -40,11 +40,11 @@ def nostr_client_test_tts(prompt):
|
||||
return event.as_json()
|
||||
|
||||
def nostr_client():
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
sk = keys.secret_key()
|
||||
pk = keys.public_key()
|
||||
print(f"Nostr Test Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
|
||||
dvmconfig = DVMConfig()
|
||||
|
2
main.py
2
main.py
@ -25,7 +25,7 @@ def playground():
|
||||
# Note this is very basic for now and still under development
|
||||
bot_config = DVMConfig()
|
||||
bot_config.PRIVATE_KEY = check_and_set_private_key("bot")
|
||||
npub = Keys.from_sk_str(bot_config.PRIVATE_KEY).public_key().to_bech32()
|
||||
npub = Keys.parse(bot_config.PRIVATE_KEY).public_key().to_bech32()
|
||||
invoice_key, admin_key, wallet_id, user_id, lnaddress = check_and_set_ln_bits_keys("bot", npub)
|
||||
bot_config.LNBITS_INVOICE_KEY = invoice_key
|
||||
bot_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
|
||||
|
@ -5,7 +5,7 @@ import time
|
||||
from datetime import timedelta
|
||||
|
||||
from nostr_sdk import (Keys, Client, Timestamp, Filter, nip04_decrypt, HandleNotification, EventBuilder, PublicKey,
|
||||
Options, Tag, Event, nip04_encrypt, ClientSigner, EventId, Nip19Event)
|
||||
Options, Tag, Event, nip04_encrypt, NostrSigner, EventId, Nip19Event)
|
||||
|
||||
from nostr_dvm.utils.admin_utils import admin_make_database_updates
|
||||
from nostr_dvm.utils.database_utils import get_or_add_user, update_user_balance, create_sql_table, update_sql_table
|
||||
@ -30,12 +30,12 @@ class Bot:
|
||||
nip89config.NAME = self.NAME
|
||||
self.dvm_config.NIP89 = nip89config
|
||||
self.admin_config = admin_config
|
||||
self.keys = Keys.from_sk_str(dvm_config.PRIVATE_KEY)
|
||||
self.keys = Keys.parse(dvm_config.PRIVATE_KEY)
|
||||
wait_for_send = True
|
||||
skip_disconnected_relays = True
|
||||
opts = (Options().wait_for_send(wait_for_send).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT))
|
||||
.skip_disconnected_relays(skip_disconnected_relays))
|
||||
signer = ClientSigner.keys(self.keys)
|
||||
signer = NostrSigner.keys(self.keys)
|
||||
self.client = Client.with_opts(signer, opts)
|
||||
|
||||
pk = self.keys.public_key()
|
||||
@ -211,7 +211,7 @@ class Bot:
|
||||
|
||||
if is_encrypted:
|
||||
if ptag == self.keys.public_key().to_hex():
|
||||
tags_str = nip04_decrypt(Keys.from_sk_str(dvm_config.PRIVATE_KEY).secret_key(),
|
||||
tags_str = nip04_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(),
|
||||
nostr_event.author(), nostr_event.content())
|
||||
params = json.loads(tags_str)
|
||||
params.append(Tag.parse(["p", ptag]).as_vec())
|
||||
|
@ -5,7 +5,7 @@ from datetime import timedelta
|
||||
from sys import platform
|
||||
|
||||
from nostr_sdk import PublicKey, Keys, Client, Tag, Event, EventBuilder, Filter, HandleNotification, Timestamp, \
|
||||
init_logger, LogLevel, Options, nip04_encrypt, ClientSigner
|
||||
init_logger, LogLevel, Options, nip04_encrypt, NostrSigner
|
||||
|
||||
import time
|
||||
|
||||
@ -21,9 +21,6 @@ from nostr_dvm.utils.zap_utils import check_bolt11_ln_bits_is_paid, create_bolt1
|
||||
parse_amount_from_bolt11_invoice, zaprequest, pay_bolt11_ln_bits, create_bolt11_lud16
|
||||
from nostr_dvm.utils.cashu_utils import redeem_cashu
|
||||
|
||||
use_logger = False
|
||||
if use_logger:
|
||||
init_logger(LogLevel.DEBUG)
|
||||
|
||||
|
||||
class DVM:
|
||||
@ -37,15 +34,17 @@ class DVM:
|
||||
def __init__(self, dvm_config, admin_config=None):
|
||||
self.dvm_config = dvm_config
|
||||
self.admin_config = admin_config
|
||||
self.keys = Keys.from_sk_str(dvm_config.PRIVATE_KEY)
|
||||
self.keys = Keys.parse(dvm_config.PRIVATE_KEY)
|
||||
wait_for_send = True
|
||||
skip_disconnected_relays = True
|
||||
opts = (Options().wait_for_send(wait_for_send).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT))
|
||||
.skip_disconnected_relays(skip_disconnected_relays))
|
||||
|
||||
signer = ClientSigner.keys(self.keys)
|
||||
signer = NostrSigner.keys(self.keys)
|
||||
self.client = Client.with_opts(signer,opts)
|
||||
|
||||
if dvm_config.SHOWLOG:
|
||||
init_logger(LogLevel.DEBUG)
|
||||
|
||||
self.job_list = []
|
||||
self.jobs_on_hold_list = []
|
||||
@ -472,7 +471,7 @@ class DVM:
|
||||
else:
|
||||
content = reaction
|
||||
|
||||
keys = Keys.from_sk_str(dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(dvm_config.PRIVATE_KEY)
|
||||
reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content), reply_tags).to_event(keys)
|
||||
send_event(reaction_event, client=self.client, dvm_config=self.dvm_config)
|
||||
print("[" + self.dvm_config.NIP89.NAME + "]" + ": Sent Kind " + str(
|
||||
|
@ -40,7 +40,7 @@ class DVMTaskInterface:
|
||||
self.NAME = name
|
||||
self.PRIVATE_KEY = dvm_config.PRIVATE_KEY
|
||||
if dvm_config.PUBLIC_KEY == "" or dvm_config.PUBLIC_KEY is None:
|
||||
dvm_config.PUBLIC_KEY = Keys.from_sk_str(dvm_config.PRIVATE_KEY).public_key().to_hex()
|
||||
dvm_config.PUBLIC_KEY = Keys.parse(dvm_config.PRIVATE_KEY).public_key().to_hex()
|
||||
self.PUBLIC_KEY = dvm_config.PUBLIC_KEY
|
||||
if dvm_config.FIX_COST is not None:
|
||||
self.FIX_COST = dvm_config.FIX_COST
|
||||
|
@ -1,7 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
from datetime import timedelta
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, ClientSigner
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
@ -90,8 +90,8 @@ class AdvancedSearch(DVMTaskInterface):
|
||||
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
|
||||
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.from_sk_str(sk.to_hex())
|
||||
signer = ClientSigner.keys(keys)
|
||||
keys = Keys.parse(sk.to_hex())
|
||||
signer = NostrSigner.keys(keys)
|
||||
cli = Client.with_opts(signer, opts)
|
||||
|
||||
cli.add_relay(options["relay"])
|
||||
|
@ -3,7 +3,7 @@ import os
|
||||
from datetime import timedelta
|
||||
|
||||
import requests
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, ClientSigner, Event
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Event
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
|
@ -3,7 +3,7 @@ import os
|
||||
from datetime import timedelta
|
||||
from threading import Thread
|
||||
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, ClientSigner
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
@ -68,8 +68,8 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
||||
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
|
||||
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.from_sk_str(sk.to_hex())
|
||||
signer = ClientSigner.keys(keys)
|
||||
keys = Keys.parse(sk.to_hex())
|
||||
signer = NostrSigner.keys(keys)
|
||||
cli = Client.with_opts(signer, opts)
|
||||
for relay in self.dvm_config.RELAY_LIST:
|
||||
cli.add_relay(relay)
|
||||
@ -107,10 +107,10 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
||||
def scanList(users, instance, i, st, notactivesince):
|
||||
from nostr_sdk import Filter
|
||||
|
||||
keys = Keys.from_sk_str(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(self.dvm_config.PRIVATE_KEY)
|
||||
opts = Options().wait_for_send(True).send_timeout(
|
||||
timedelta(seconds=5)).skip_disconnected_relays(True)
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
cli = Client.with_opts(signer, opts)
|
||||
for relay in self.dvm_config.RELAY_LIST:
|
||||
cli.add_relay(relay)
|
||||
|
@ -3,7 +3,7 @@ import os
|
||||
from datetime import timedelta
|
||||
from threading import Thread
|
||||
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, ClientSigner
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
@ -63,8 +63,8 @@ class DiscoverNonFollowers(DVMTaskInterface):
|
||||
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
|
||||
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.from_sk_str(sk.to_hex())
|
||||
signer = ClientSigner.keys(keys)
|
||||
keys = Keys.parse(sk.to_hex())
|
||||
signer = NostrSigner.keys(keys)
|
||||
cli = Client.with_opts(signer, opts)
|
||||
#cli.add_relay("wss://relay.nostr.band")
|
||||
for relay in self.dvm_config.RELAY_LIST:
|
||||
@ -100,10 +100,10 @@ class DiscoverNonFollowers(DVMTaskInterface):
|
||||
def scanList(users, instance, i, st):
|
||||
from nostr_sdk import Filter
|
||||
|
||||
keys = Keys.from_sk_str(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(self.dvm_config.PRIVATE_KEY)
|
||||
opts = Options().wait_for_send(True).send_timeout(
|
||||
timedelta(seconds=5)).skip_disconnected_relays(True)
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
cli = Client.with_opts(signer, opts)
|
||||
for relay in self.dvm_config.RELAY_LIST:
|
||||
cli.add_relay(relay)
|
||||
|
@ -81,7 +81,7 @@ def admin_make_database_updates(adminconfig: AdminConfig = None, dvmconfig: DVMC
|
||||
|
||||
if adminconfig.DELETE_NIP89:
|
||||
event_id = adminconfig.EVENTID
|
||||
keys = Keys.from_sk_str(
|
||||
keys = Keys.parse(
|
||||
adminconfig.PRIVKEY) # Private key from sender of Event (e.g. the key of an nip89 announcement you want to delete)
|
||||
fetch_nip89_paramters_for_deletion(keys, event_id, client, dvmconfig)
|
||||
|
||||
|
@ -174,7 +174,7 @@ def update_user_balance(db, npub, additional_sats, client, config):
|
||||
" Zap amount: " + str(additional_sats) + " Sats. New balance: " + str(new_balance) +" Sats")
|
||||
|
||||
if config is not None:
|
||||
keys = Keys.from_sk_str(config.PRIVATE_KEY)
|
||||
keys = Keys.parse(config.PRIVATE_KEY)
|
||||
#time.sleep(1.0)
|
||||
|
||||
message = ("Added " + str(additional_sats) + " Sats to balance. New balance is " + str(new_balance) + " Sats.")
|
||||
|
@ -23,15 +23,17 @@ class EventDefinitions:
|
||||
KIND_NIP90_CONVERT_VIDEO = 5200
|
||||
KIND_NIP90_RESULT_CONVERT_VIDEO = KIND_NIP90_CONVERT_VIDEO + 1000
|
||||
KIND_NIP90_GENERATE_VIDEO = 5202
|
||||
KIND_NIP90_RESULT_GENERATE_VIDEO = KIND_NIP90_GENERATE_VIDEO + 1000
|
||||
KIND_NIP90_TEXT_TO_SPEECH = 5250
|
||||
KIND_NIP90_RESULT_TEXT_TO_SPEECH = KIND_NIP90_TEXT_TO_SPEECH + 1000
|
||||
KIND_NIP90_RESULT_GENERATE_VIDEO = KIND_NIP90_GENERATE_VIDEO + 1000
|
||||
KIND_NIP90_CONTENT_DISCOVERY = 5300
|
||||
KIND_NIP90_RESULT_CONTENT_DISCOVERY = KIND_NIP90_CONTENT_DISCOVERY + 1000
|
||||
KIND_NIP90_PEOPLE_DISCOVERY = 5301
|
||||
KIND_NIP90_RESULT_PEOPLE_DISCOVERY = KIND_NIP90_PEOPLE_DISCOVERY + 1000
|
||||
KIND_NIP90_CONTENT_SEARCH = 5302
|
||||
KIND_NIP90_RESULTS_CONTENT_SEARCH = KIND_NIP90_CONTENT_SEARCH + 1000
|
||||
KIND_NIP90_USER_SEARCH = 5303
|
||||
KIND_NIP90_RESULTS_USER_SEARCH = KIND_NIP90_USER_SEARCH + 1000
|
||||
KIND_NIP90_GENERIC = 5999
|
||||
KIND_NIP90_RESULT_GENERIC = KIND_NIP90_GENERIC + 1000
|
||||
ANY_RESULT = [KIND_NIP90_RESULT_EXTRACT_TEXT,
|
||||
|
@ -14,6 +14,7 @@ class DVMConfig:
|
||||
PUBLIC_KEY: str = ""
|
||||
FIX_COST: float = None
|
||||
PER_UNIT_COST: float = None
|
||||
SHOWLOG: bool = False # Shows Nostr logs from Rust-Library, default off, turn on in config if needed.
|
||||
|
||||
RELAY_LIST = ["wss://relay.damus.io", "wss://nos.lol", "wss://nostr.wine",
|
||||
"wss://nostr.mom", "wss://nostr.oxtr.dev", "wss://relay.nostr.bg",
|
||||
@ -40,7 +41,7 @@ def build_default_config(identifier):
|
||||
dvm_config = DVMConfig()
|
||||
dvm_config.PRIVATE_KEY = check_and_set_private_key(identifier)
|
||||
dvm_config.IDENTIFIER = identifier
|
||||
npub = Keys.from_sk_str(dvm_config.PRIVATE_KEY).public_key().to_bech32()
|
||||
npub = Keys.parse(dvm_config.PRIVATE_KEY).public_key().to_bech32()
|
||||
invoice_key, admin_key, wallet_id, user_id, lnaddress = check_and_set_ln_bits_keys(identifier, npub)
|
||||
dvm_config.LNBITS_INVOICE_KEY = invoice_key
|
||||
dvm_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
|
||||
|
@ -1,7 +1,7 @@
|
||||
import json
|
||||
from datetime import timedelta
|
||||
|
||||
from nostr_sdk import PublicKey, Options, Keys, Client, ClientSigner
|
||||
from nostr_sdk import PublicKey, Options, Keys, Client, NostrSigner
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
@ -19,8 +19,8 @@ def build_external_dvm(pubkey, task, kind, fix_cost, per_unit_cost, config,
|
||||
|
||||
opts = (Options().wait_for_send(True).send_timeout(timedelta(seconds=config.RELAY_TIMEOUT))
|
||||
.skip_disconnected_relays(True))
|
||||
keys = Keys.from_sk_str(config.PRIVATE_KEY)
|
||||
signer = ClientSigner.keys(keys)
|
||||
keys = Keys.parse(config.PRIVATE_KEY)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client.with_opts(signer, opts)
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ def nip89_create_d_tag(name, pubkey, image):
|
||||
def nip89_announce_tasks(dvm_config, client):
|
||||
k_tag = Tag.parse(["k", str(dvm_config.NIP89.KIND)])
|
||||
d_tag = Tag.parse(["d", dvm_config.NIP89.DTAG])
|
||||
keys = Keys.from_sk_str(dvm_config.NIP89.PK)
|
||||
keys = Keys.parse(dvm_config.NIP89.PK)
|
||||
content = dvm_config.NIP89.CONTENT
|
||||
event = EventBuilder(EventDefinitions.KIND_ANNOUNCEMENT, content, [k_tag, d_tag]).to_event(keys)
|
||||
send_event(event, client=client, dvm_config=dvm_config)
|
||||
@ -98,7 +98,7 @@ def nip89_fetch_events_pubkey(client, pubkey, kind):
|
||||
|
||||
def check_and_set_d_tag(identifier, name, pk, imageurl):
|
||||
if not os.getenv("NIP89_DTAG_" + identifier.upper()):
|
||||
new_dtag = nip89_create_d_tag(name, Keys.from_sk_str(pk).public_key().to_hex(),
|
||||
new_dtag = nip89_create_d_tag(name, Keys.parse(pk).public_key().to_hex(),
|
||||
imageurl)
|
||||
nip89_add_dtag_to_env_file("NIP89_DTAG_" + identifier.upper(), new_dtag)
|
||||
print("Some new dtag:" + new_dtag)
|
||||
|
@ -116,7 +116,7 @@ def check_and_decrypt_tags(event, dvm_config):
|
||||
return None
|
||||
|
||||
elif p == dvm_config.PUBLIC_KEY:
|
||||
tags_str = nip04_decrypt(Keys.from_sk_str(dvm_config.PRIVATE_KEY).secret_key(),
|
||||
tags_str = nip04_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(),
|
||||
event.author(), event.content())
|
||||
params = json.loads(tags_str)
|
||||
params.append(Tag.parse(["p", p]).as_vec())
|
||||
@ -148,7 +148,7 @@ def check_and_decrypt_own_tags(event, dvm_config):
|
||||
return None
|
||||
|
||||
elif event.author().to_hex() == dvm_config.PUBLIC_KEY:
|
||||
tags_str = nip04_decrypt(Keys.from_sk_str(dvm_config.PRIVATE_KEY).secret_key(),
|
||||
tags_str = nip04_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(),
|
||||
PublicKey.from_hex(p), event.content())
|
||||
params = json.loads(tags_str)
|
||||
params.append(Tag.parse(["p", p]).as_vec())
|
||||
@ -164,7 +164,7 @@ def check_and_decrypt_own_tags(event, dvm_config):
|
||||
|
||||
|
||||
def update_profile(dvm_config, client, lud16=""):
|
||||
keys = Keys.from_sk_str(dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(dvm_config.PRIVATE_KEY)
|
||||
nip89content = json.loads(dvm_config.NIP89.CONTENT)
|
||||
if nip89content.get("name"):
|
||||
name = nip89content.get("name")
|
||||
|
@ -2,7 +2,7 @@ import json
|
||||
import os
|
||||
|
||||
import requests
|
||||
from nostr_sdk import Keys, PublicKey, Client, nip04_encrypt, EventBuilder, Tag, ClientSigner
|
||||
from nostr_sdk import Keys, PublicKey, Client, nip04_encrypt, EventBuilder, Tag, NostrSigner
|
||||
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nostr_utils import check_and_set_private_key
|
||||
@ -11,7 +11,7 @@ from nostr_dvm.utils.zap_utils import zaprequest
|
||||
|
||||
def nwc_zap(connectionstr, bolt11, keys):
|
||||
target_pubkey, relay, secret = parse_connection_str(connectionstr)
|
||||
SecretSK = Keys.from_sk_str(secret)
|
||||
SecretSK = Keys.parse(secret)
|
||||
|
||||
content = {
|
||||
"method": "pay_invoice",
|
||||
@ -20,7 +20,7 @@ def nwc_zap(connectionstr, bolt11, keys):
|
||||
}
|
||||
}
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
client.add_relay(relay)
|
||||
client.connect()
|
||||
@ -47,7 +47,7 @@ def parse_connection_str(connectionstring):
|
||||
|
||||
|
||||
def make_nwc_account(identifier, nwcdomain):
|
||||
pubkey = Keys.from_sk_str(os.getenv("DVM_PRIVATE_KEY_" + identifier.upper())).public_key().to_hex()
|
||||
pubkey = Keys.parse(os.getenv("DVM_PRIVATE_KEY_" + identifier.upper())).public_key().to_hex()
|
||||
data = {
|
||||
'name': identifier,
|
||||
'host': os.getenv("LNBITS_HOST"),
|
||||
@ -77,7 +77,7 @@ def nwc_test(nwc_server):
|
||||
# connectionstring = "nostr+walletconnect:..."
|
||||
if connectionstring != "":
|
||||
# we use the keys from a test user
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test"))
|
||||
keys = Keys.parse(check_and_set_private_key("test"))
|
||||
|
||||
# we zap npub1nxa4tywfz9nqp7z9zp7nr7d4nchhclsf58lcqt5y782rmf2hefjquaa6q8's profile 21 sats and say Cool stuff
|
||||
pubkey = PublicKey.from_bech32("npub1nxa4tywfz9nqp7z9zp7nr7d4nchhclsf58lcqt5y782rmf2hefjquaa6q8")
|
||||
|
@ -269,7 +269,7 @@ def zaprequest(lud16: str, amount: int, content, zapped_event, zapped_user, keys
|
||||
|
||||
zap_request = EventBuilder(9733, content,
|
||||
[p_tag, e_tag]).to_event(keys).as_json()
|
||||
keys = Keys.from_sk_str(encryption_key)
|
||||
keys = Keys.parse(encryption_key)
|
||||
encrypted_content = enrypt_private_zap_message(zap_request, keys.secret_key(), zapped_event.author())
|
||||
anon_tag = Tag.parse(['anon', encrypted_content])
|
||||
tags.append(anon_tag)
|
||||
|
4
setup.py
4
setup.py
@ -1,6 +1,6 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
VERSION = '0.2.2'
|
||||
VERSION = '0.2.3'
|
||||
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
|
||||
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. '
|
||||
'This is an early stage release. Interfaces might change/brick')
|
||||
@ -15,7 +15,7 @@ setup(
|
||||
long_description=LONG_DESCRIPTION,
|
||||
packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']),
|
||||
|
||||
install_requires=["nostr-sdk==0.8.0",
|
||||
install_requires=["nostr-sdk==0.9.1",
|
||||
"bech32",
|
||||
"pycryptodome==3.20.0",
|
||||
"python-dotenv==1.0.0",
|
||||
|
@ -3,7 +3,7 @@ import time
|
||||
from datetime import timedelta
|
||||
from nicegui import run, ui
|
||||
from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, \
|
||||
Options, Timestamp, ClientSigner, EventId, Nip19Event, PublicKey
|
||||
Options, Timestamp, NostrSigner, EventId, Nip19Event, PublicKey
|
||||
|
||||
from nostr_dvm.utils import dvmconfig
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
@ -13,11 +13,11 @@ from nostr_dvm.utils.definitions import EventDefinitions
|
||||
|
||||
@ui.page('/', dark=True)
|
||||
def init():
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=2))
|
||||
.skip_disconnected_relays(True))
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client.with_opts(signer, opts)
|
||||
relay_list = dvmconfig.DVMConfig.RELAY_LIST
|
||||
|
||||
|
@ -5,7 +5,7 @@ from threading import Thread
|
||||
|
||||
import dotenv
|
||||
from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \
|
||||
nip04_encrypt, ClientSigner
|
||||
nip04_encrypt, NostrSigner
|
||||
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nostr_utils import send_event, check_and_set_private_key
|
||||
@ -14,7 +14,7 @@ from nostr_dvm.utils.definitions import EventDefinitions
|
||||
|
||||
# TODO HINT: Best use this path with a previously whitelisted privkey, as zapping events is not implemented in the lib/code
|
||||
def nostr_client_test_translation(input, kind, lang, sats, satsmax):
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
if kind == "text":
|
||||
iTag = Tag.parse(["i", input, "text"])
|
||||
elif kind == "event":
|
||||
@ -31,7 +31,7 @@ def nostr_client_test_translation(input, kind, lang, sats, satsmax):
|
||||
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
|
||||
"wss://nostr-pub.wellorder.net"]
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
|
||||
for relay in relay_list:
|
||||
@ -43,7 +43,7 @@ def nostr_client_test_translation(input, kind, lang, sats, satsmax):
|
||||
|
||||
|
||||
def nostr_client_test_image(prompt):
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
|
||||
iTag = Tag.parse(["i", prompt, "text"])
|
||||
outTag = Tag.parse(["output", "image/png;format=url"])
|
||||
@ -60,7 +60,7 @@ def nostr_client_test_image(prompt):
|
||||
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
|
||||
"wss://nostr-pub.wellorder.net"]
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
for relay in relay_list:
|
||||
client.add_relay(relay)
|
||||
@ -71,7 +71,7 @@ def nostr_client_test_image(prompt):
|
||||
|
||||
|
||||
def nostr_client_test_tts(prompt):
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
|
||||
iTag = Tag.parse(["i", prompt, "text"])
|
||||
paramTag1 = Tag.parse(["param", "language", "en"])
|
||||
@ -86,7 +86,7 @@ def nostr_client_test_tts(prompt):
|
||||
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
|
||||
"wss://nostr-pub.wellorder.net"]
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
for relay in relay_list:
|
||||
client.add_relay(relay)
|
||||
@ -97,8 +97,8 @@ def nostr_client_test_tts(prompt):
|
||||
|
||||
|
||||
def nostr_client_test_image_private(prompt, cashutoken):
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
receiver_keys = Keys.from_sk_str(check_and_set_private_key("replicate_sdxl"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
receiver_keys = Keys.parse(check_and_set_private_key("replicate_sdxl"))
|
||||
|
||||
# TODO more advanced logic, more parsing, params etc, just very basic test functions for now
|
||||
|
||||
@ -125,7 +125,7 @@ def nostr_client_test_image_private(prompt, cashutoken):
|
||||
nip90request = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_IMAGE, encrypted_params,
|
||||
[pTag, encrypted_tag]).to_event(keys)
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
for relay in relay_list:
|
||||
client.add_relay(relay)
|
||||
@ -136,11 +136,11 @@ def nostr_client_test_image_private(prompt, cashutoken):
|
||||
|
||||
|
||||
def nostr_client():
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
sk = keys.secret_key()
|
||||
pk = keys.public_key()
|
||||
print(f"Nostr Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client(signer)
|
||||
|
||||
dvmconfig = DVMConfig()
|
||||
|
@ -4,20 +4,20 @@ from pathlib import Path
|
||||
import dotenv
|
||||
import nostr_sdk
|
||||
from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \
|
||||
nip04_encrypt, EventId, Options, PublicKey, Event, ClientSigner, Nip19Event
|
||||
nip04_encrypt, EventId, Options, PublicKey, Event, NostrSigner, Nip19Event
|
||||
|
||||
from nostr_dvm.utils import definitions, dvmconfig
|
||||
from nostr_dvm.utils.nostr_utils import check_and_set_private_key
|
||||
|
||||
|
||||
relay_list = dvmconfig.DVMConfig.RELAY_LIST
|
||||
keys = Keys.from_sk_str(check_and_set_private_key("test_client"))
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
wait_for_send = False
|
||||
skip_disconnected_relays = True
|
||||
opts = (Options().wait_for_send(wait_for_send).send_timeout(timedelta(seconds=5))
|
||||
.skip_disconnected_relays(skip_disconnected_relays))
|
||||
|
||||
signer = ClientSigner.keys(keys)
|
||||
signer = NostrSigner.keys(keys)
|
||||
client = Client.with_opts(signer, opts)
|
||||
|
||||
for relay in relay_list:
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
import '../app.css'
|
||||
import store from "@/store.js";
|
||||
import {Alphabet, ClientBuilder, ClientSigner, Filter, Keys, NostrDatabase, Tag} from "@rust-nostr/nostr-sdk";
|
||||
import {Alphabet, ClientBuilder, NostrSigner, Filter, Keys, NostrDatabase, Tag} from "@rust-nostr/nostr-sdk";
|
||||
import miniToastr from "mini-toastr";
|
||||
import VueNotifications from "vue-notifications";
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {createStore} from "vuex";
|
||||
import {Client, ClientSigner, PublicKey} from "@rust-nostr/nostr-sdk";
|
||||
import {Client, NostrSigner, PublicKey} from "@rust-nostr/nostr-sdk";
|
||||
|
||||
const store = createStore({
|
||||
state () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user