From e2f720becce3ace0d55bde869cbbd218ed29659e Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Fri, 22 Nov 2024 19:18:44 +0100 Subject: [PATCH] clean up nip89 with suggested params in the nip, replace nip04 with nip44 for encryption --- examples/ollama_dvm/main.py | 4 +- examples/tts_dvm/main.py | 4 +- examples/unleashed_dvm/main.py | 4 +- main.py | 4 +- nostr_dvm/bot.py | 63 ++++++++++--------- nostr_dvm/dvm.py | 58 ++++++++++++----- nostr_dvm/subscription.py | 13 ++-- nostr_dvm/tasks/advanced_search.py | 4 +- nostr_dvm/tasks/advanced_search_wine.py | 4 +- nostr_dvm/tasks/audiogeneration_suno_ai.py | 4 +- ...ent_discovery_currently_latest_longform.py | 8 +-- ...content_discovery_currently_latest_wiki.py | 8 +-- .../content_discovery_currently_popular.py | 8 +-- ...discovery_currently_popular_by_top_zaps.py | 8 +-- ...t_discovery_currently_popular_followers.py | 8 +-- ...ent_discovery_currently_popular_gallery.py | 8 +-- ...ntent_discovery_currently_popular_mostr.py | 8 +-- ...iscovery_currently_popular_nonfollowers.py | 8 +-- ...ntent_discovery_currently_popular_topic.py | 8 +-- ...ntent_discovery_latest_one_per_follower.py | 4 +- .../tasks/content_discovery_update_db_only.py | 8 +-- nostr_dvm/tasks/convert_media.py | 4 +- nostr_dvm/tasks/discovery_bot_farms.py | 4 +- nostr_dvm/tasks/discovery_censor_wot.py | 4 +- nostr_dvm/tasks/discovery_inactive_follows.py | 4 +- nostr_dvm/tasks/discovery_nonfollowers.py | 4 +- .../discovery_trending_notes_gleasonator.py | 4 +- .../discovery_trending_notes_nostrband.py | 4 +- nostr_dvm/tasks/generic_dvm.py | 4 +- .../tasks/imagegeneration_openai_dalle.py | 4 +- nostr_dvm/tasks/imagegeneration_replicate.py | 4 +- .../imagegeneration_replicate_fluxpro.py | 4 +- .../imagegeneration_replicate_recraft.py | 4 +- .../tasks/imagegeneration_replicate_sdxl.py | 4 +- nostr_dvm/tasks/imagegeneration_sd21_mlx.py | 4 +- nostr_dvm/tasks/imagegeneration_sd35_api.py | 6 +- nostr_dvm/tasks/imagegeneration_sdxl.py | 4 +- .../tasks/imagegeneration_sdxlimg2img.py | 4 +- nostr_dvm/tasks/imageinterrogator.py | 4 +- nostr_dvm/tasks/imageupscale.py | 4 +- nostr_dvm/tasks/people_discovery_mywot.py | 8 +-- nostr_dvm/tasks/people_discovery_wot.py | 8 +-- nostr_dvm/tasks/search_users.py | 4 +- nostr_dvm/tasks/summarization_duckduck_ai.py | 4 +- nostr_dvm/tasks/summarization_huggingchat.py | 4 +- .../tasks/summarization_unleashed_chat.py | 4 +- nostr_dvm/tasks/textextraction_google.py | 4 +- nostr_dvm/tasks/textextraction_pdf.py | 4 +- nostr_dvm/tasks/textextraction_whisperx.py | 4 +- nostr_dvm/tasks/textgeneration_huggingchat.py | 4 +- nostr_dvm/tasks/textgeneration_llmlite.py | 4 +- .../tasks/textgeneration_unleashed_chat.py | 4 +- nostr_dvm/tasks/texttospeech.py | 4 +- nostr_dvm/tasks/translation_google.py | 4 +- nostr_dvm/tasks/translation_libretranslate.py | 4 +- .../tasks/videogeneration_replicate_svd.py | 4 +- nostr_dvm/tasks/videogeneration_svd.py | 4 +- nostr_dvm/utils/database_utils.py | 5 +- nostr_dvm/utils/external_dvm_utils.py | 12 ++-- nostr_dvm/utils/nostr_utils.py | 33 +++++++--- nostr_dvm/utils/outbox_utils.py | 5 +- tests/chat_bot.py | 4 +- tests/dalle.py | 4 +- tests/discovery.py | 48 +++++++------- tests/discovery_custom_feed.py | 4 +- tests/discovery_gallery.py | 4 +- tests/discovery_mostr.py | 4 +- tests/discovery_one_per_follow.py | 4 +- tests/discovery_people.py | 4 +- tests/discovery_test.py | 48 +++++++------- tests/generic_dvm.py | 4 +- tests/generic_dvm_autotopic_feed.py | 4 +- tests/generic_dvm_duck_chat.py | 4 +- tests/generic_dvm_flux_hf.py | 4 +- tests/otherstuff.py | 38 +++++------ tests/sd35_api.py | 4 +- tests/search.py | 17 ++--- tests/simplebot.py | 2 +- tests/summarization_duck.py | 4 +- tests/test_dvm_client.py | 6 +- tests/tts.py | 4 +- tutorials/05_announce_dvm.py | 2 +- tutorials/06_dvm_config.py | 2 +- tutorials/07_admin_config.py | 2 +- ui/noogle/src/components/ChatGeneration.vue | 2 +- ui/noogle/src/components/FilterGeneration.vue | 41 ++++++------ ui/noogle/src/components/ImageGeneration.vue | 2 +- ui/noogle/src/components/Login.vue | 4 +- ui/noogle/src/components/Search.vue | 31 ++++++--- .../components/SummarizationGeneration.vue | 2 +- 90 files changed, 412 insertions(+), 346 deletions(-) diff --git a/examples/ollama_dvm/main.py b/examples/ollama_dvm/main.py index 0695eb3..a2da1d9 100644 --- a/examples/ollama_dvm/main.py +++ b/examples/ollama_dvm/main.py @@ -24,8 +24,8 @@ def main(): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use a LLM connected via OLLAMA", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } diff --git a/examples/tts_dvm/main.py b/examples/tts_dvm/main.py index 7154cab..75c639f 100644 --- a/examples/tts_dvm/main.py +++ b/examples/tts_dvm/main.py @@ -24,8 +24,8 @@ def main(): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I Generate Speech from Text", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "language": { "required": False, diff --git a/examples/unleashed_dvm/main.py b/examples/unleashed_dvm/main.py index babf537..5cb4a1a 100644 --- a/examples/unleashed_dvm/main.py +++ b/examples/unleashed_dvm/main.py @@ -24,8 +24,8 @@ def main(): "name": name, "picture": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg", "about": "I generate Text with Unleashed.chat", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } diff --git a/main.py b/main.py index f7d5b77..4294046 100644 --- a/main.py +++ b/main.py @@ -26,8 +26,8 @@ def playground(announce=False): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm just a demo DVM, not doing much.'", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } } diff --git a/nostr_dvm/bot.py b/nostr_dvm/bot.py index 2179f06..c1a4917 100644 --- a/nostr_dvm/bot.py +++ b/nostr_dvm/bot.py @@ -4,8 +4,8 @@ import os import signal from multiprocessing.connection import Connection -from nostr_sdk import (Keys, Timestamp, Filter, nip04_decrypt, HandleNotification, EventBuilder, PublicKey, - Options, Tag, Event, nip04_encrypt, EventId, Nip19Event, Kind, KindEnum, NostrSigner, +from nostr_sdk import (Keys, Timestamp, Filter, nip04_decrypt, nip44_decrypt, HandleNotification, EventBuilder, PublicKey, + Options, Tag, Event, EventId, Nip19Event, Kind, KindEnum, NostrSigner, nip44_encrypt, UnsignedEvent, UnwrappedGift, uniffi_set_event_loop, ClientBuilder, make_private_msg) from nostr_dvm.utils.admin_utils import admin_make_database_updates @@ -28,9 +28,11 @@ class Bot: # This is a simple list just to keep track which events we created and manage, so we don't pay for other requests def __init__(self, dvm_config, admin_config=None): + self.signer = None self.dvm_config = None self.keys = None self.admin_config = None + self.client = None asyncio.run(self.run_bot(dvm_config, admin_config)) uniffi_set_event_loop(asyncio.get_running_loop()) @@ -46,6 +48,7 @@ class Bot: self.dvm_config.NIP89 = nip89config self.admin_config = admin_config self.keys = Keys.parse(dvm_config.PRIVATE_KEY) + self.signer = NostrSigner.keys(self.keys) self.CHATBOT = False opts = Options().gossip(True) @@ -125,7 +128,7 @@ class Bot: if giftwrap: try: # Extract rumor - unwrapped_gift = await UnwrappedGift.from_gift_wrap(self.keys, nostr_event) + unwrapped_gift = await UnwrappedGift.from_gift_wrap(NostrSigner.keys(self.keys), nostr_event) sender = unwrapped_gift.sender().to_hex() rumor: UnsignedEvent = unwrapped_gift.rumor() @@ -185,7 +188,7 @@ class Bot: params_as_str = json.dumps(tags_str) print(params_as_str) # and encrypt them - encrypted_params = nip04_encrypt(self.keys.secret_key(), + encrypted_params = nip44_encrypt(self.keys.secret_key(), PublicKey.from_hex( self.dvm_config.SUPPORTED_DVMS[ index].PUBLIC_KEY), @@ -240,7 +243,7 @@ class Bot: else: message = invoice if giftwrap: - event = await make_private_msg(self.keys, PublicKey.parse(sender), message, + event = await make_private_msg(self.signer, PublicKey.parse(sender), message, None) await self.client.send_event(event) @@ -262,8 +265,7 @@ class Bot: "100 sats (or any other amount) " "to top up your balance") if giftwrap: - event = await make_private_msg(self.keys, PublicKey.parse(sender), message, - None) + event = await make_private_msg(NostrSigner.keys(self.keys), PublicKey.parse(sender), message) await self.client.send_event(event) else: await send_nip04_dm(self.client, message, PublicKey.parse(sender), self.dvm_config) @@ -281,8 +283,7 @@ class Bot: message = "Error: " + cashu_message + ". Token has not been redeemed." if giftwrap: - event = await make_private_msg(self.keys, PublicKey.parse(sender), message, - None) + event = await make_private_msg(self.signer, PublicKey.parse(sender), message) await self.client.send_event(event) else: await send_nip04_dm(self.client, message, PublicKey.parse(sender), self.dvm_config) @@ -290,8 +291,7 @@ class Bot: await asyncio.sleep(2.0) message = "No, there is no second best.\n\nhttps://cdn.nostr.build/p/mYLv.mp4" if giftwrap: - event = await make_private_msg(self.keys, PublicKey.parse(sender), message, - None) + event = await make_private_msg(self.signer, PublicKey.parse(sender), message) await self.client.send_event(event) else: await send_nip04_dm(self.client, message, PublicKey.parse(sender), self.dvm_config) @@ -356,8 +356,13 @@ class Bot: if is_encrypted: if ptag == self.keys.public_key().to_hex(): - tags_str = nip04_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(), - nostr_event.author(), nostr_event.content()) + try: + tags_str = nip44_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(), + nostr_event.author(), nostr_event.content()) + except: + 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()) params.append(Tag.parse(["encrypted"]).as_vec()) @@ -386,8 +391,7 @@ class Bot: client=self.client, config=self.dvm_config) await asyncio.sleep(2.0) if entry["giftwrap"]: - event = await make_private_msg(self.keys, PublicKey.parse(PublicKey.parse(entry["npub"])), content, - None) + event = await make_private_msg(self.signer, PublicKey.parse(PublicKey.parse(entry["npub"])), content) await self.client.send_event(event) else: await send_nip04_dm(self.client, content, PublicKey.parse(entry['npub']), self.dvm_config) @@ -417,8 +421,7 @@ class Bot: amount) + " Sats from balance to DVM. New balance is " + str( balance) + " Sats.\n" if entry["giftwrap"]: - event = await make_private_msg(self.keys, PublicKey.parse(PublicKey.parse(entry["npub"])), message, - None) + event = await make_private_msg(self.signer, PublicKey.parse(PublicKey.parse(entry["npub"])), message) await self.client.send_event(event) else: await send_nip04_dm(self.client, content, PublicKey.parse(entry['npub']), @@ -434,8 +437,7 @@ class Bot: int(amount - user.balance)) + " Sats, then try again." if entry["giftwrap"]: - event = await make_private_msg(self.keys, PublicKey.parse(PublicKey.parse((entry["npub"]))), message, - None) + event = await make_private_msg(self.signer, PublicKey.parse(PublicKey.parse((entry["npub"]))), message) await self.client.send_event(event) else: await send_nip04_dm(self.client, message, PublicKey.parse(entry['npub']), @@ -496,7 +498,10 @@ class Bot: content = nostr_event.content() if is_encrypted: if ptag == self.keys.public_key().to_hex(): - content = nip04_decrypt(self.keys.secret_key(), nostr_event.author(), content) + try: + content = nip44_decrypt(self.keys.secret_key(), nostr_event.author(), content) + except: + content = nip04_decrypt(self.keys.secret_key(), nostr_event.author(), content) else: return @@ -513,8 +518,8 @@ class Bot: print("[" + self.NAME + "] Received results, message to orignal sender " + user.name) await asyncio.sleep(2.0) if entry["giftwrap"]: - event = await make_private_msg(self.keys, PublicKey.parse(user.npub), content, - None) + event = await make_private_msg(self.signer, PublicKey.parse(user.npub), content) + await self.client.send_event(event) else: await send_nip04_dm(self.client, content, PublicKey.parse(user.npub), self.dvm_config) @@ -581,7 +586,7 @@ class Bot: text = message + "\nSelect an Index and provide an input (e.g. \"2 A purple ostrich\")\nType \"index info\" to learn more about each DVM. (e.g. \"2 info\")\n\n Type \"balance\" to see your current balance" if giftwrap: - event = await make_private_msg(self.keys, PublicKey.parse(sender), text) + event = await make_private_msg(self.signer, PublicKey.parse(sender), text) await self.client.send_event(event) else: await send_nip04_dm(self.client, text, PublicKey.parse(sender), self.dvm_config) @@ -589,7 +594,7 @@ class Bot: async def answer_blacklisted(nostr_event, giftwrap, sender): message = "Your are currently blocked from this service." if giftwrap: - event = await make_private_msg(self.keys, PublicKey.parse(sender), message) + event = await make_private_msg(self.signer, PublicKey.parse(sender), message) await self.client.send_event(event) else: await send_nip04_dm(self.client, message, PublicKey.parse(sender), self.dvm_config) @@ -601,7 +606,7 @@ class Bot: await asyncio.sleep(2.0) if giftwrap: - event = await make_private_msg(self.keys, PublicKey.parse(sender), info) + event = await make_private_msg(self.signer, PublicKey.parse(sender), info) await self.client.send_event(event) else: await send_nip04_dm(self.client, info, PublicKey.parse(sender), self.dvm_config) @@ -747,10 +752,10 @@ class Bot: info += nip89content.get("image") + "\n" if nip89content.get("about"): info += "About:\n" + nip89content.get("about") + "\n\n" - if nip89content.get("cashuAccepted"): - cashu_accepted = str(nip89content.get("cashuAccepted")) - if nip89content.get("encryptionSupported"): - encryption_supported = str(nip89content.get("encryptionSupported")) + if nip89content.get("acceptsNutZaps"): + cashu_accepted = str(nip89content.get("acceptsNutZaps")) + if nip89content.get("supportsEncryption"): + encryption_supported = str(nip89content.get("supportsEncryption")) info += "Encryption supported: " + str(encryption_supported) + "\n" info += "Cashu accepted: " + str(cashu_accepted) + "\n\n" diff --git a/nostr_dvm/dvm.py b/nostr_dvm/dvm.py index a61144c..1ec639b 100644 --- a/nostr_dvm/dvm.py +++ b/nostr_dvm/dvm.py @@ -4,7 +4,8 @@ import os from sys import platform from nostr_sdk import PublicKey, Keys, Client, Tag, Event, EventBuilder, Filter, HandleNotification, Timestamp, \ - LogLevel, Options, nip04_encrypt, Kind, RelayLimits, uniffi_set_event_loop, ClientBuilder, NostrSigner + LogLevel, Options, nip04_encrypt, nip44_encrypt, Nip44Version, Kind, RelayLimits, uniffi_set_event_loop, ClientBuilder, NostrSigner + from nostr_dvm.utils.admin_utils import admin_make_database_updates, AdminConfig from nostr_dvm.utils.backend_utils import get_amount_per_task, check_task_is_supported, get_task @@ -107,7 +108,7 @@ class DVM: async def handle_nip90_job_event(nip90_event): # decrypted encrypted events - nip90_event = check_and_decrypt_tags(nip90_event, self.dvm_config) + nip90_event, use_legacy_encryption = check_and_decrypt_tags(nip90_event, self.dvm_config) # if event is encrypted, but we can't decrypt it (e.g. because its directed to someone else), return if nip90_event is None: return @@ -235,7 +236,7 @@ class DVM: if dvm_config.SEND_FEEDBACK_EVENTS: await send_job_status_reaction(nip90_event, "processing", True, 0, content=self.dvm_config.CUSTOM_PROCESSING_MESSAGE, - client=self.client, dvm_config=self.dvm_config, user=user) + client=self.client, dvm_config=self.dvm_config) # when we reimburse users on error make sure to not send anything if it was free if user.iswhitelisted or task_is_free: @@ -337,7 +338,7 @@ class DVM: job_event = await get_event_by_id(tag.as_vec()[1], client=self.client, config=self.dvm_config) if job_event is not None: - job_event = check_and_decrypt_tags(job_event, self.dvm_config) + job_event, use_legacy_encryption = check_and_decrypt_tags(job_event, self.dvm_config) if job_event is None: return else: @@ -357,7 +358,7 @@ class DVM: print("[" + self.dvm_config.NIP89.NAME + "] Payment-request fulfilled...") await send_job_status_reaction(job_event, "processing", client=self.client, content=self.dvm_config.CUSTOM_PROCESSING_MESSAGE, - dvm_config=self.dvm_config, user=user) + dvm_config=self.dvm_config) indices = [i for i, x in enumerate(self.job_list) if x.event == job_event] index = -1 @@ -419,7 +420,7 @@ class DVM: job_event = await get_event_by_id(tag.as_vec()[1], client=self.client, config=self.dvm_config) if job_event is not None: - job_event = check_and_decrypt_tags(job_event, self.dvm_config) + job_event, use_legacy_encryption = check_and_decrypt_tags(job_event, self.dvm_config) if job_event is None: return else: @@ -531,11 +532,11 @@ class DVM: if self.dvm_config.SHOW_RESULT_BEFORE_PAYMENT and not is_paid: await send_nostr_reply_event(data, original_event.as_json()) await send_job_status_reaction(original_event, "success", amount, - dvm_config=self.dvm_config, + dvm_config=self.dvm_config ) # or payment-required, or both? elif not self.dvm_config.SHOW_RESULT_BEFORE_PAYMENT and not is_paid: await send_job_status_reaction(original_event, "success", amount, - dvm_config=self.dvm_config, + dvm_config=self.dvm_config ) # or payment-required, or both? if self.dvm_config.SHOW_RESULT_BEFORE_PAYMENT and is_paid: @@ -595,11 +596,15 @@ class DVM: reply_tags.append(relay_tag) encrypted = False + is_legacy_encryption = False + encryption_tags = [] for tag in original_event.tags().to_vec(): if tag.as_vec()[0] == "encrypted": encrypted = True encrypted_tag = Tag.parse(["encrypted"]) - reply_tags.append(encrypted_tag) + encryption_tags.append(encrypted_tag) + #_, is_legacy_encryption = check_and_decrypt_tags(original_event, dvm_config) + for tag in original_event.tags().to_vec(): if tag.as_vec()[0] == "i": @@ -607,14 +612,30 @@ class DVM: if not encrypted: reply_tags.append(i_tag) + if encrypted: + encryption_tags.append(p_tag) + encryption_tags.append(e_tag) + + else: + reply_tags.append(p_tag) + if encrypted: print(content) - content = nip04_encrypt(self.keys.secret_key(), PublicKey.from_hex(original_event.author().to_hex()), - content) + if is_legacy_encryption: + content = nip04_encrypt(self.keys.secret_key(), PublicKey.from_hex(original_event.author().to_hex()), + content) + else: + + content = nip44_encrypt(self.keys.secret_key(), + PublicKey.from_hex(original_event.author().to_hex()), + content, Nip44Version.V2) + + reply_tags = encryption_tags + reply_event = EventBuilder(Kind(original_event.kind().as_u16() + 1000), str(content)).tags(reply_tags).sign_with_keys( self.keys) - + print(reply_event) # send_event(reply_event, client=self.client, dvm_config=self.dvm_config) await send_event_outbox(reply_event, client=self.client, dvm_config=self.dvm_config) if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value: @@ -626,7 +647,7 @@ class DVM: async def send_job_status_reaction(original_event, status, is_paid=True, amount=0, client=None, content=None, - dvm_config=None, user=None): + dvm_config=None): task = await get_task(original_event, client=client, dvm_config=dvm_config) alt_description, reaction = build_status_reaction(status, task, amount, content, dvm_config) @@ -649,11 +670,13 @@ class DVM: encryption_tags = [] encrypted = False + is_legacy_encryption = False for tag in original_event.tags().to_vec(): if tag.as_vec()[0] == "encrypted": encrypted = True encrypted_tag = Tag.parse(["encrypted"]) encryption_tags.append(encrypted_tag) + #_, is_legacy_encryption = check_and_decrypt_tags(original_event, dvm_config) if encrypted: encryption_tags.append(p_tag) @@ -720,8 +743,13 @@ class DVM: str_tags.append(element.as_vec()) content = json.dumps(str_tags) - content = nip04_encrypt(self.keys.secret_key(), PublicKey.from_hex(original_event.author().to_hex()), - content) + if is_legacy_encryption: + content = nip04_encrypt(self.keys.secret_key(), PublicKey.from_hex(original_event.author().to_hex()), + content) + else: + content = nip44_encrypt(self.keys.secret_key(), + PublicKey.from_hex(original_event.author().to_hex()), + content, version=Nip44Version.V2) reply_tags = encryption_tags else: diff --git a/nostr_dvm/subscription.py b/nostr_dvm/subscription.py index 8b45af8..3cc8ed8 100644 --- a/nostr_dvm/subscription.py +++ b/nostr_dvm/subscription.py @@ -5,8 +5,8 @@ import os import signal from datetime import timedelta -from nostr_sdk import (Keys, Client, Timestamp, Filter, nip04_decrypt, HandleNotification, EventBuilder, PublicKey, - Options, Tag, Event, nip04_encrypt, NostrSigner, EventId, uniffi_set_event_loop, make_private_msg) +from nostr_sdk import (Keys, Client, Timestamp, Filter, nip04_decrypt, nip44_decrypt, HandleNotification, EventBuilder, PublicKey, + Options, Tag, Event, nip44_encrypt, NostrSigner, EventId, uniffi_set_event_loop, make_private_msg) from nostr_dvm.utils.database_utils import fetch_user_metadata from nostr_dvm.utils.definitions import EventDefinitions, relay_timeout @@ -146,7 +146,7 @@ class Subscription: str_tags.append(element.as_vec()) content = json.dumps(str_tags) - content = nip04_encrypt(self.keys.secret_key(), PublicKey.from_hex(original_event.author().to_hex()), + content = nip44_encrypt(self.keys.secret_key(), PublicKey.from_hex(original_event.author().to_hex()), content) reply_tags = encryption_tags @@ -229,7 +229,12 @@ class Subscription: return try: - decrypted_text = nip04_decrypt(self.keys.secret_key(), nostr_event.author(), nostr_event.content()) + + try: + decrypted_text = nip44_decrypt(self.keys.secret_key(), nostr_event.author(), nostr_event.content()) + except: + decrypted_text = nip04_decrypt(self.keys.secret_key(), nostr_event.author(), nostr_event.content()) + subscriber = "" nwc = "" try: diff --git a/nostr_dvm/tasks/advanced_search.py b/nostr_dvm/tasks/advanced_search.py index 542148b..257418a 100644 --- a/nostr_dvm/tasks/advanced_search.py +++ b/nostr_dvm/tasks/advanced_search.py @@ -164,8 +164,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://nostr.band/android-chrome-192x192.png", "about": "I search notes on Nostr.band.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "users": { "required": False, diff --git a/nostr_dvm/tasks/advanced_search_wine.py b/nostr_dvm/tasks/advanced_search_wine.py index 8f6f559..57e8fec 100644 --- a/nostr_dvm/tasks/advanced_search_wine.py +++ b/nostr_dvm/tasks/advanced_search_wine.py @@ -149,8 +149,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/d844d6a963724b9f9deb6b3326984fd95352343336718812424d5e99d93a6f2d.jpg", "about": "I search notes on nostr.wine using the nostr-wine API", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "users": { "required": False, diff --git a/nostr_dvm/tasks/audiogeneration_suno_ai.py b/nostr_dvm/tasks/audiogeneration_suno_ai.py index de2c585..1ebc7a4 100644 --- a/nostr_dvm/tasks/audiogeneration_suno_ai.py +++ b/nostr_dvm/tasks/audiogeneration_suno_ai.py @@ -158,8 +158,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I create songs based on prompts with suno.ai", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": {} } diff --git a/nostr_dvm/tasks/content_discovery_currently_latest_longform.py b/nostr_dvm/tasks/content_discovery_currently_latest_longform.py index e1a3f6e..79e5bff 100644 --- a/nostr_dvm/tasks/content_discovery_currently_latest_longform.py +++ b/nostr_dvm/tasks/content_discovery_currently_latest_longform.py @@ -230,8 +230,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show the latest longform notes.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -275,8 +275,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show the latest longform notes", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py b/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py index dc0c78e..e972574 100644 --- a/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py +++ b/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py @@ -229,8 +229,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show the latest longform notes.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -274,8 +274,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show the latest longform notes", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_popular.py b/nostr_dvm/tasks/content_discovery_currently_popular.py index ce0799f..d939c90 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular.py @@ -228,8 +228,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show notes that are currently popular", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -272,8 +272,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show notes that are currently popular all over Nostr. I'm also used for testing subscriptions.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_by_top_zaps.py b/nostr_dvm/tasks/content_discovery_currently_popular_by_top_zaps.py index 1398258..e0f8c7f 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_by_top_zaps.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_by_top_zaps.py @@ -272,8 +272,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show notes that are currently zapped the most.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -316,8 +316,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show notes that are currently popular all over Nostr. I'm also used for testing subscriptions.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py index 657d0d4..507a904 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py @@ -246,8 +246,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=3 "picture": image, "about": "I show notes that are currently popular from people you follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { @@ -289,8 +289,8 @@ def build_example_subscription(name, identifier, admin_config, options, processi "picture": image, "about": "I show notes that are currently popular, just like the free DVM, I'm also used for testing subscriptions. (beta)", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "subscription": True, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py index 431b451..4cdf990 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py @@ -296,8 +296,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show notes that are currently popular", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -340,8 +340,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show notes that are currently popular all over Nostr. I'm also used for testing subscriptions.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py b/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py index 6e55033..eea4646 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py @@ -250,8 +250,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show notes that are currently popular", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -295,8 +295,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show notes that are currently popular all over Nostr. I'm also used for testing subscriptions.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py b/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py index 99b3860..765fa04 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py @@ -282,8 +282,8 @@ def build_example(name, identifier, admin_config, options, image, description, u "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -321,8 +321,8 @@ def build_example_subscription(name, identifier, admin_config, options, image, d "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py index 83e806c..d002d10 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py @@ -259,8 +259,8 @@ def build_example(name, identifier, admin_config, options, image, description, u "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -298,8 +298,8 @@ def build_example_subscription(name, identifier, admin_config, options, image, d "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/content_discovery_latest_one_per_follower.py b/nostr_dvm/tasks/content_discovery_latest_one_per_follower.py index 101d407..ca02e43 100644 --- a/nostr_dvm/tasks/content_discovery_latest_one_per_follower.py +++ b/nostr_dvm/tasks/content_discovery_latest_one_per_follower.py @@ -208,8 +208,8 @@ def build_example(name, identifier, admin_config): "picture": "https://i.nostr.build/H6SMmCl7eRDvkbAn.jpg", "about": "I discover users you follow, but that have been inactive on Nostr", "action": "unfollow", # follow, mute, unmute - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "user": { "required": False, diff --git a/nostr_dvm/tasks/content_discovery_update_db_only.py b/nostr_dvm/tasks/content_discovery_update_db_only.py index e26ee48..f2f8f86 100644 --- a/nostr_dvm/tasks/content_discovery_update_db_only.py +++ b/nostr_dvm/tasks/content_discovery_update_db_only.py @@ -220,8 +220,8 @@ def build_example(name, identifier, admin_config, options, image, description, u "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -259,8 +259,8 @@ def build_example_subscription(name, identifier, admin_config, options, image, d "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/convert_media.py b/nostr_dvm/tasks/convert_media.py index b1f9a72..4de4ced 100644 --- a/nostr_dvm/tasks/convert_media.py +++ b/nostr_dvm/tasks/convert_media.py @@ -89,8 +89,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I convert videos from urls to given output format.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "format": { "required": False, diff --git a/nostr_dvm/tasks/discovery_bot_farms.py b/nostr_dvm/tasks/discovery_bot_farms.py index 8e1a18a..dee05d6 100644 --- a/nostr_dvm/tasks/discovery_bot_farms.py +++ b/nostr_dvm/tasks/discovery_bot_farms.py @@ -165,8 +165,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/981b560820bc283c58de7989b7abc6664996b487a531d852e4ef7322586a2122.jpg", "about": "I hunt down bot farms.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "action": "mute", # follow, unfollow, mute, unmute "nip90Params": { "max_results": { diff --git a/nostr_dvm/tasks/discovery_censor_wot.py b/nostr_dvm/tasks/discovery_censor_wot.py index 6c8b69d..9a72fee 100644 --- a/nostr_dvm/tasks/discovery_censor_wot.py +++ b/nostr_dvm/tasks/discovery_censor_wot.py @@ -173,8 +173,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/19872a2edd866258fa9eab137631efda89310d52b2c6ea8f99ef057325aa1c7b.jpg", "about": "I show users that have been reported by either your followers or your Web of Trust. Note: Anyone can report, so you might double check and decide for yourself who to mute. Considers spam, illegal and impersonation reports. Notice: This works with NIP51 mute lists. Not all clients support the new mute list format.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "action": "mute", # follow, unfollow, mute, unmute "nip90Params": { "since_days": { diff --git a/nostr_dvm/tasks/discovery_inactive_follows.py b/nostr_dvm/tasks/discovery_inactive_follows.py index d39aaa4..5a34fb5 100644 --- a/nostr_dvm/tasks/discovery_inactive_follows.py +++ b/nostr_dvm/tasks/discovery_inactive_follows.py @@ -194,8 +194,8 @@ def build_example(name, identifier, admin_config): "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I discover users you follow, but that have been inactive on Nostr", "action": "unfollow", # follow, mute, unmute - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "user": { "required": False, diff --git a/nostr_dvm/tasks/discovery_nonfollowers.py b/nostr_dvm/tasks/discovery_nonfollowers.py index 5b4a80e..c18673c 100644 --- a/nostr_dvm/tasks/discovery_nonfollowers.py +++ b/nostr_dvm/tasks/discovery_nonfollowers.py @@ -197,8 +197,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I discover users you follow, but that don't follow you back.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "user": { "required": False, diff --git a/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py b/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py index 1127a60..ada5bfc 100644 --- a/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py +++ b/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py @@ -128,8 +128,8 @@ def build_example(name, identifier, admin_config, custom_processing_msg): "picture": "https://image.nostr.build/0c760b3ecdbc993ba47b785d0adecf00c760b3ecdbc993ba47b785d0adecf0ec71fd9c59808e27d0665b9f77a32d8de.png", "about": "I show trending notes from Soapbox Ditto", "amount": "Free", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } nip89config = NIP89Config() diff --git a/nostr_dvm/tasks/discovery_trending_notes_nostrband.py b/nostr_dvm/tasks/discovery_trending_notes_nostrband.py index a767d0f..b0d33dd 100644 --- a/nostr_dvm/tasks/discovery_trending_notes_nostrband.py +++ b/nostr_dvm/tasks/discovery_trending_notes_nostrband.py @@ -120,8 +120,8 @@ def build_example(name, identifier, admin_config, custom_processing_msg): "picture": "https://nostr.band/android-chrome-192x192.png", "about": "I show trending notes from nostr.band", "amount": "Free", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } nip89config = NIP89Config() diff --git a/nostr_dvm/tasks/generic_dvm.py b/nostr_dvm/tasks/generic_dvm.py index 3e272de..be668e4 100644 --- a/nostr_dvm/tasks/generic_dvm.py +++ b/nostr_dvm/tasks/generic_dvm.py @@ -85,8 +85,8 @@ def build_example(name, identifier, admin_config, announce=False): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm an all purpose DVM'", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } } diff --git a/nostr_dvm/tasks/imagegeneration_openai_dalle.py b/nostr_dvm/tasks/imagegeneration_openai_dalle.py index 6c2cef0..ae1c8f1 100644 --- a/nostr_dvm/tasks/imagegeneration_openai_dalle.py +++ b/nostr_dvm/tasks/imagegeneration_openai_dalle.py @@ -135,8 +135,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use OpenAI's DALL·E 3", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "size": { "required": False, diff --git a/nostr_dvm/tasks/imagegeneration_replicate.py b/nostr_dvm/tasks/imagegeneration_replicate.py index b94bf52..032e27d 100644 --- a/nostr_dvm/tasks/imagegeneration_replicate.py +++ b/nostr_dvm/tasks/imagegeneration_replicate.py @@ -150,8 +150,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run StableDiffusion 3", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "ratio": { "required": False, diff --git a/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py b/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py index 4159a0f..6813b58 100644 --- a/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py +++ b/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py @@ -145,8 +145,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run FluxPro", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "ratio": { "required": False, diff --git a/nostr_dvm/tasks/imagegeneration_replicate_recraft.py b/nostr_dvm/tasks/imagegeneration_replicate_recraft.py index dfd46db..8ae8b6d 100644 --- a/nostr_dvm/tasks/imagegeneration_replicate_recraft.py +++ b/nostr_dvm/tasks/imagegeneration_replicate_recraft.py @@ -143,8 +143,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run Recraft", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "ratio": { "required": False, diff --git a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py index 7e8848e..e5936c7 100644 --- a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py +++ b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py @@ -129,8 +129,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run StableDiffusion XL", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "size": { "required": False, diff --git a/nostr_dvm/tasks/imagegeneration_sd21_mlx.py b/nostr_dvm/tasks/imagegeneration_sd21_mlx.py index 449813e..6a2b03a 100644 --- a/nostr_dvm/tasks/imagegeneration_sd21_mlx.py +++ b/nostr_dvm/tasks/imagegeneration_sd21_mlx.py @@ -158,8 +158,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run StableDiffusion XL", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "size": { "required": False, diff --git a/nostr_dvm/tasks/imagegeneration_sd35_api.py b/nostr_dvm/tasks/imagegeneration_sd35_api.py index 0352bb7..80d87bd 100644 --- a/nostr_dvm/tasks/imagegeneration_sd35_api.py +++ b/nostr_dvm/tasks/imagegeneration_sd35_api.py @@ -266,9 +266,9 @@ def build_example(name, identifier, admin_config, server_address, default_model= "name": name, "picture": "https://i.nostr.build/NOXcCIPmOZrDTK35.jpg", "about": "I draw images using Stable diffusion ultra", - "encryptionSupported": True, - "cashuAccepted": True, - "nip90Params": { + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, + "nip90Params":{ "negative_prompt": { "required": False, "values": [] diff --git a/nostr_dvm/tasks/imagegeneration_sdxl.py b/nostr_dvm/tasks/imagegeneration_sdxl.py index c51da2e..0cdfc31 100644 --- a/nostr_dvm/tasks/imagegeneration_sdxl.py +++ b/nostr_dvm/tasks/imagegeneration_sdxl.py @@ -177,8 +177,8 @@ def build_example(name, identifier, admin_config, server_address, default_model= "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I draw images based on a prompt with a Model called unstable diffusion", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "negative_prompt": { "required": False, diff --git a/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py b/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py index 30d3aef..976b022 100644 --- a/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py +++ b/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py @@ -199,8 +199,8 @@ def build_example(name, identifier, admin_config, server_address, default_lora=" "name": name, "picture": "https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg", "about": "I convert an image to another image, kinda random for now. ", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "negative_prompt": { "required": False, diff --git a/nostr_dvm/tasks/imageinterrogator.py b/nostr_dvm/tasks/imageinterrogator.py index 314595e..8809de3 100644 --- a/nostr_dvm/tasks/imageinterrogator.py +++ b/nostr_dvm/tasks/imageinterrogator.py @@ -116,8 +116,8 @@ def build_example(name, identifier, admin_config, server_address): "name": name, "picture": "https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg", "about": "I analyse Images an return a prompt or a prompt analysis", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "method": { "required": False, diff --git a/nostr_dvm/tasks/imageupscale.py b/nostr_dvm/tasks/imageupscale.py index 2676ec2..928c74a 100644 --- a/nostr_dvm/tasks/imageupscale.py +++ b/nostr_dvm/tasks/imageupscale.py @@ -121,8 +121,8 @@ def build_example(name, identifier, admin_config, server_address): "name": name, "picture": "https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg", "about": "I upscale an image using realESRGan up to factor 4 (default is factor 4)", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "upscale": { "required": False, diff --git a/nostr_dvm/tasks/people_discovery_mywot.py b/nostr_dvm/tasks/people_discovery_mywot.py index c411881..3f759c4 100644 --- a/nostr_dvm/tasks/people_discovery_mywot.py +++ b/nostr_dvm/tasks/people_discovery_mywot.py @@ -310,8 +310,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show notes that are currently popular", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -354,8 +354,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show notes that are currently popular all over Nostr. I'm also used for testing subscriptions.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/people_discovery_wot.py b/nostr_dvm/tasks/people_discovery_wot.py index 64654f1..6db6baf 100644 --- a/nostr_dvm/tasks/people_discovery_wot.py +++ b/nostr_dvm/tasks/people_discovery_wot.py @@ -314,8 +314,8 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1 "picture": image, "about": "I show notes that are currently popular", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -358,8 +358,8 @@ def build_example_subscription(name, identifier, admin_config, options, update_r "picture": image, "about": "I show notes that are currently popular all over Nostr. I'm also used for testing subscriptions.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "subscription": True, "personalized": False, "nip90Params": { diff --git a/nostr_dvm/tasks/search_users.py b/nostr_dvm/tasks/search_users.py index 11ddd1a..254113c 100644 --- a/nostr_dvm/tasks/search_users.py +++ b/nostr_dvm/tasks/search_users.py @@ -206,8 +206,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/a99ab925084029d9468fef8330ff3d9be2cf67da473b024f2a6d48b5cd77197f.jpg", "about": "I search users.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "users": { "required": False, diff --git a/nostr_dvm/tasks/summarization_duckduck_ai.py b/nostr_dvm/tasks/summarization_duckduck_ai.py index b252b04..71b4524 100644 --- a/nostr_dvm/tasks/summarization_duckduck_ai.py +++ b/nostr_dvm/tasks/summarization_duckduck_ai.py @@ -122,8 +122,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I summarize Text", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } diff --git a/nostr_dvm/tasks/summarization_huggingchat.py b/nostr_dvm/tasks/summarization_huggingchat.py index bd975ce..0230b20 100644 --- a/nostr_dvm/tasks/summarization_huggingchat.py +++ b/nostr_dvm/tasks/summarization_huggingchat.py @@ -127,8 +127,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/720eadc9af89084bb09de659af43ad17fec1f4b0887084e83ac0ae708dfa83a6.png", "about": "I use a LLM connected via Huggingchat to summarize Inputs", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } diff --git a/nostr_dvm/tasks/summarization_unleashed_chat.py b/nostr_dvm/tasks/summarization_unleashed_chat.py index 2d683b5..8f91518 100644 --- a/nostr_dvm/tasks/summarization_unleashed_chat.py +++ b/nostr_dvm/tasks/summarization_unleashed_chat.py @@ -151,8 +151,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg", "about": "I summarize Text with https://unleashed.chat", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": {} } diff --git a/nostr_dvm/tasks/textextraction_google.py b/nostr_dvm/tasks/textextraction_google.py index 9e42a07..88fe666 100644 --- a/nostr_dvm/tasks/textextraction_google.py +++ b/nostr_dvm/tasks/textextraction_google.py @@ -139,8 +139,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I extract text from media files with the Google API. I understand English by default", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "language": { "required": False, diff --git a/nostr_dvm/tasks/textextraction_pdf.py b/nostr_dvm/tasks/textextraction_pdf.py index 94bb0db..24ed3b6 100644 --- a/nostr_dvm/tasks/textextraction_pdf.py +++ b/nostr_dvm/tasks/textextraction_pdf.py @@ -102,8 +102,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I extract text from pdf documents. I only support Latin letters", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": {} } diff --git a/nostr_dvm/tasks/textextraction_whisperx.py b/nostr_dvm/tasks/textextraction_whisperx.py index 570edac..6c58abb 100644 --- a/nostr_dvm/tasks/textextraction_whisperx.py +++ b/nostr_dvm/tasks/textextraction_whisperx.py @@ -163,8 +163,8 @@ def build_example(name, identifier, admin_config, server_address): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I extract text from media files with WhisperX", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "model": { "required": False, diff --git a/nostr_dvm/tasks/textgeneration_huggingchat.py b/nostr_dvm/tasks/textgeneration_huggingchat.py index 01ae75c..bdf2239 100644 --- a/nostr_dvm/tasks/textgeneration_huggingchat.py +++ b/nostr_dvm/tasks/textgeneration_huggingchat.py @@ -92,8 +92,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/720eadc9af89084bb09de659af43ad17fec1f4b0887084e83ac0ae708dfa83a6.png", "about": "I use a LLM connected via Huggingchat", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } diff --git a/nostr_dvm/tasks/textgeneration_llmlite.py b/nostr_dvm/tasks/textgeneration_llmlite.py index decf908..0cb3bb0 100644 --- a/nostr_dvm/tasks/textgeneration_llmlite.py +++ b/nostr_dvm/tasks/textgeneration_llmlite.py @@ -107,8 +107,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use a LLM connected via OLLAMA", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } diff --git a/nostr_dvm/tasks/textgeneration_unleashed_chat.py b/nostr_dvm/tasks/textgeneration_unleashed_chat.py index 14ece25..b139d8f 100644 --- a/nostr_dvm/tasks/textgeneration_unleashed_chat.py +++ b/nostr_dvm/tasks/textgeneration_unleashed_chat.py @@ -115,8 +115,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg", "about": "I generate Text with Unleashed.chat", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": {} } diff --git a/nostr_dvm/tasks/texttospeech.py b/nostr_dvm/tasks/texttospeech.py index 0d9c6e5..29c838f 100644 --- a/nostr_dvm/tasks/texttospeech.py +++ b/nostr_dvm/tasks/texttospeech.py @@ -177,8 +177,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I Generate Speech from Text", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "language": { "required": False, diff --git a/nostr_dvm/tasks/translation_google.py b/nostr_dvm/tasks/translation_google.py index 91398bc..63c016b 100644 --- a/nostr_dvm/tasks/translation_google.py +++ b/nostr_dvm/tasks/translation_google.py @@ -121,8 +121,8 @@ def build_example(name, identifier, admin_config): "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I translate text from given text/event/job. Currently using Google TranslationGoogle Services to translate " "input into the language defined in params.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "language": { "required": False, diff --git a/nostr_dvm/tasks/translation_libretranslate.py b/nostr_dvm/tasks/translation_libretranslate.py index fad1a98..ace5b74 100644 --- a/nostr_dvm/tasks/translation_libretranslate.py +++ b/nostr_dvm/tasks/translation_libretranslate.py @@ -119,8 +119,8 @@ def build_example(name, identifier, admin_config): "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I translate text from given text/event/job using LibreTranslate Services to translate " "input into the language defined in params.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "language": { "required": False, diff --git a/nostr_dvm/tasks/videogeneration_replicate_svd.py b/nostr_dvm/tasks/videogeneration_replicate_svd.py index 2a4162f..f4a7ef2 100644 --- a/nostr_dvm/tasks/videogeneration_replicate_svd.py +++ b/nostr_dvm/tasks/videogeneration_replicate_svd.py @@ -122,8 +122,8 @@ def build_example(name, identifier, admin_config): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Replicate to run StableDiffusion XL", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": {} } diff --git a/nostr_dvm/tasks/videogeneration_svd.py b/nostr_dvm/tasks/videogeneration_svd.py index c8d68af..ba40f9d 100644 --- a/nostr_dvm/tasks/videogeneration_svd.py +++ b/nostr_dvm/tasks/videogeneration_svd.py @@ -110,8 +110,8 @@ def build_example(name, identifier, admin_config, server_address): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I create a short video based on an image", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } nip89config = NIP89Config() diff --git a/nostr_dvm/utils/database_utils.py b/nostr_dvm/utils/database_utils.py index ae96b79..9ef2c6b 100644 --- a/nostr_dvm/utils/database_utils.py +++ b/nostr_dvm/utils/database_utils.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from logging import Filter from sqlite3 import Error -from nostr_sdk import Timestamp, Keys, PublicKey, Filter, Kind, make_private_msg +from nostr_sdk import Timestamp, Keys, PublicKey, Filter, Kind, make_private_msg, NostrSigner from nostr_dvm.utils.definitions import relay_timeout from nostr_dvm.utils.nostr_utils import send_nip04_dm @@ -192,8 +192,7 @@ async def update_user_balance(db, npub, additional_sats, client, config, giftwra # always send giftwrapped. sorry not sorry. #if giftwrap: - event = await make_private_msg(keys, PublicKey.parse(npub), message, - None) + event = await make_private_msg(NostrSigner.keys(keys), PublicKey.parse(npub), message) await client.send_event(event) #else: # await send_nip04_dm(client, message, PublicKey.parse(npub), config) diff --git a/nostr_dvm/utils/external_dvm_utils.py b/nostr_dvm/utils/external_dvm_utils.py index 60e6a73..0f8c106 100644 --- a/nostr_dvm/utils/external_dvm_utils.py +++ b/nostr_dvm/utils/external_dvm_utils.py @@ -52,18 +52,18 @@ def build_external_dvm(pubkey, task, kind, fix_cost, per_unit_cost, config, about = nip89content.get("about") if nip89content.get("nip90Params"): nip90params = nip89content["nip90Params"] - if nip89content.get("encryptionSupported"): - encryption_supported = nip89content["encryptionSupported"] - if nip89content.get("cashuAccepted"): - cashu_accepted = nip89content["cashuAccepted"] + if nip89content.get("supportsEncryption"): + encryption_supported = nip89content["supportsEncryption"] + if nip89content.get("acceptsNutZaps"): + cashu_accepted = nip89content["acceptsNutZaps"] else: print("No NIP89 set for " + name) nip89info = { "name": name, "picture": image, "about": about, - "encryptionSupported": encryption_supported, - "cashuAccepted": cashu_accepted, + "supportsEncryption": encryption_supported, + "acceptsNutZaps": cashu_accepted, "nip90Params": nip90params } nip89config = NIP89Config() diff --git a/nostr_dvm/utils/nostr_utils.py b/nostr_dvm/utils/nostr_utils.py index 9010d75..72f52d8 100644 --- a/nostr_dvm/utils/nostr_utils.py +++ b/nostr_dvm/utils/nostr_utils.py @@ -5,7 +5,7 @@ from pathlib import Path from typing import List 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, nip44_decrypt, Metadata, Options, \ Nip19Event, SingleLetterTag, RelayLimits, SecretKey, Connection, ConnectionTarget, \ EventBuilder, Kind, ClientBuilder, SendEventOutput, NostrSigner @@ -295,9 +295,10 @@ async def send_event(event: Event, client: Client, dvm_config): def check_and_decrypt_tags(event, dvm_config): - try: + is_encrypted = False + use_legacy_encryption = False - is_encrypted = False + try: p = "" for tag in event.tags().to_vec(): if tag.as_vec()[0] == 'encrypted': @@ -309,11 +310,21 @@ def check_and_decrypt_tags(event, dvm_config): if p != dvm_config.PUBLIC_KEY: print("[" + dvm_config.NIP89.NAME + "] Task encrypted and not addressed to this DVM, " "skipping..") - return None + return None, False elif p == dvm_config.PUBLIC_KEY: - tags_str = nip04_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(), - event.author(), event.content()) + try: + tags_str = nip04_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(), + event.author(), event.content()) + except: + try: + tags_str = nip44_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(), + event.author(), event.content()) + except: + print("Wrong Nip44 Format") + return None, False + use_legacy_encryption = True + params = json.loads(tags_str) params.append(Tag.parse(["p", p]).as_vec()) params.append(Tag.parse(["encrypted"]).as_vec()) @@ -324,7 +335,7 @@ def check_and_decrypt_tags(event, dvm_config): except Exception as e: print(e) - return event + return event, use_legacy_encryption def check_and_decrypt_own_tags(event, dvm_config): @@ -344,8 +355,12 @@ 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.parse(dvm_config.PRIVATE_KEY).secret_key(), - PublicKey.from_hex(p), event.content()) + try: + tags_str = nip44_decrypt(Keys.parse(dvm_config.PRIVATE_KEY).secret_key(), + PublicKey.from_hex(p), event.content()) + except: + 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()) params.append(Tag.parse(["encrypted"]).as_vec()) diff --git a/nostr_dvm/utils/outbox_utils.py b/nostr_dvm/utils/outbox_utils.py index 44e15d0..7ba0497 100644 --- a/nostr_dvm/utils/outbox_utils.py +++ b/nostr_dvm/utils/outbox_utils.py @@ -82,7 +82,10 @@ AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://nostr.fmt.wiz.biz", "wss://no "wss://onchain.pub", "wss://relay.nostr.info", "wss://relay.chicagoplebs.com", "wss://relay.current.fyi", "wss://relay.stemstr.app", "wss://nostr.zenon.info", "ws://localhost:7777", "wss://nostr.fmt.wiz.biz", "wss://nostrich.friendship.tw", - "wss://public.relaying.io", "wss://relay.me3d.app", + "wss://public.relaying.io", "wss://relay.me3d.app", "wss://dreamofthe90s.nostr1.com", + "wss://lnbits.eldamar.icu/nostrrelay/relay", "wss://nostr.olwe.link", + "wss://nostr.cheeserobot.org", + diff --git a/tests/chat_bot.py b/tests/chat_bot.py index f7c2b22..2f2d812 100644 --- a/tests/chat_bot.py +++ b/tests/chat_bot.py @@ -49,8 +49,8 @@ def playground(announce = False): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm briding DuckDuckAI'", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } } diff --git a/tests/dalle.py b/tests/dalle.py index a29869c..6ff8901 100644 --- a/tests/dalle.py +++ b/tests/dalle.py @@ -37,8 +37,8 @@ def build_dalle(name, identifier): "name": name, "picture": "https://image.nostr.build/22f2267ca9d4ee9d5e8a0c7818a9fa325bbbcdac5573a60a2d163e699bb69923.jpg", "about": "I create Images bridging OpenAI's DALL·E 3", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "size": { "required": False, diff --git a/tests/discovery.py b/tests/discovery.py index 6bb3c80..f9670e4 100644 --- a/tests/discovery.py +++ b/tests/discovery.py @@ -78,8 +78,8 @@ def build_db_scheduler(name, identifier, admin_config, options, image, descripti "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -120,8 +120,8 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0 "picture": image, "about": "I show popular gallery entries", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { @@ -157,8 +157,8 @@ def build_example_nostrband(name, identifier, admin_config, image, about, custom "picture": image, "about": about, "amount": "Free", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } nip89config = NIP89Config() @@ -196,8 +196,8 @@ def build_longform(name, identifier, admin_config, options, cost=0, update_rate= "picture": image, "about": "I show the latest longform notes.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -248,8 +248,8 @@ def build_wiki(name, identifier, admin_config, options, cost=0, update_rate=180, "picture": image, "about": "I show the latest wikifreedia entries.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -296,8 +296,8 @@ def build_example_topic(name, identifier, admin_config, options, image, descript "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -338,8 +338,8 @@ def build_example_popular(name, identifier, admin_config, options, image, cost=0 "picture": image, "about": "I show notes that are currently popular", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -381,8 +381,8 @@ def build_example_popular_followers(name, identifier, admin_config, options, ima "picture": image, "about": "I show notes that are currently popular from people you follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { @@ -430,8 +430,8 @@ def build_example_popular_non_followers(name, identifier, admin_config, options, "picture": image, "about": "I show notes that are currently popular from people you do not follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": False, "personalized": True, "amount": create_amount_tag(cost), @@ -496,8 +496,8 @@ def build_example_top_zapped(name, identifier, admin_config, options, image, cos "picture": image, "about": "I show notes that are currently zapped the most.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -544,8 +544,8 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0, "picture": image, "about": "I show notes from Mostr.pub and Momostr.pink that are currently popular on Nostr", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -586,8 +586,8 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c "picture": image, "about": "I show the single latest note of people you follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { diff --git a/tests/discovery_custom_feed.py b/tests/discovery_custom_feed.py index ec1864d..bb3dda6 100644 --- a/tests/discovery_custom_feed.py +++ b/tests/discovery_custom_feed.py @@ -49,8 +49,8 @@ def build_example_topic(name, identifier, admin_config, options, image, descript "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { diff --git a/tests/discovery_gallery.py b/tests/discovery_gallery.py index 49119c5..9396909 100644 --- a/tests/discovery_gallery.py +++ b/tests/discovery_gallery.py @@ -40,8 +40,8 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0 "picture": image, "about": "I show popular gallery entries", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { diff --git a/tests/discovery_mostr.py b/tests/discovery_mostr.py index af93f9c..3057395 100644 --- a/tests/discovery_mostr.py +++ b/tests/discovery_mostr.py @@ -54,8 +54,8 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0, "picture": image, "about": "I show popular notes from Mostr.pub and Momostr.pink", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { diff --git a/tests/discovery_one_per_follow.py b/tests/discovery_one_per_follow.py index 5b2dece..6b0c312 100644 --- a/tests/discovery_one_per_follow.py +++ b/tests/discovery_one_per_follow.py @@ -43,8 +43,8 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c "picture": image, "about": "I show the single latest note of people you follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { diff --git a/tests/discovery_people.py b/tests/discovery_people.py index f94db9f..e3adf27 100644 --- a/tests/discovery_people.py +++ b/tests/discovery_people.py @@ -48,8 +48,8 @@ def build_example_wot(name, identifier, admin_config, options, image, cost=0, up "picture": image, "about": "I show people to follow from your WOT", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { diff --git a/tests/discovery_test.py b/tests/discovery_test.py index cadd7f5..7aea172 100644 --- a/tests/discovery_test.py +++ b/tests/discovery_test.py @@ -75,8 +75,8 @@ def build_db_scheduler(name, identifier, admin_config, options, image, descripti "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -117,8 +117,8 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0 "picture": image, "about": "I show popular gallery entries", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { @@ -153,8 +153,8 @@ def build_example_nostrband(name, identifier, admin_config, image, about, custom "picture": image, "about": about, "amount": "Free", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } nip89config = NIP89Config() @@ -191,8 +191,8 @@ def build_longform(name, identifier, admin_config, options, cost=0, update_rate= "picture": image, "about": "I show the latest longform notes.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -242,8 +242,8 @@ def build_wiki(name, identifier, admin_config, options, cost=0, update_rate=180, "picture": image, "about": "I show the latest wikifreedia entries.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -287,8 +287,8 @@ def build_example_topic(name, identifier, admin_config, options, image, descript "picture": image, "about": description, "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -328,8 +328,8 @@ def build_example_popular(name, identifier, admin_config, options, image, cost=0 "picture": image, "about": "I show notes that are currently popular", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -368,8 +368,8 @@ def build_example_popular_followers(name, identifier, admin_config, options, ima "picture": image, "about": "I show notes that are currently popular from people you follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": True, "amount": create_amount_tag(cost), "nip90Params": { @@ -416,8 +416,8 @@ def build_example_popular_non_followers(name, identifier, admin_config, options, "picture": image, "about": "I show notes that are currently popular from people you do not follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "subscription": True, "personalized": False, "nip90Params": { @@ -478,8 +478,8 @@ def build_example_top_zapped(name, identifier, admin_config, options, image, cos "picture": image, "about": "I show notes that are currently zapped the most.", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -525,8 +525,8 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0, "picture": image, "about": "I show notes from Mostr.pub and Momostr.pink that are currently popular on Nostr", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { @@ -565,8 +565,8 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c "picture": image, "about": "I show the single latest note of people you follow", "lud16": dvm_config.LN_ADDRESS, - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "personalized": False, "amount": create_amount_tag(cost), "nip90Params": { diff --git a/tests/generic_dvm.py b/tests/generic_dvm.py index 5ef2d93..1b8d481 100644 --- a/tests/generic_dvm.py +++ b/tests/generic_dvm.py @@ -26,8 +26,8 @@ def playground(announce=False): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm an all purpose DVM'", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } } diff --git a/tests/generic_dvm_autotopic_feed.py b/tests/generic_dvm_autotopic_feed.py index ed00723..ee8d6fd 100644 --- a/tests/generic_dvm_autotopic_feed.py +++ b/tests/generic_dvm_autotopic_feed.py @@ -81,8 +81,8 @@ def playground(announce=False): "name": name, "picture": "https://i.nostr.build/I8fJo0n355cbNEbS.png", # "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I create a personalized feed based on topics you were writing about recently", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } } diff --git a/tests/generic_dvm_duck_chat.py b/tests/generic_dvm_duck_chat.py index 491c92e..dbb4c13 100644 --- a/tests/generic_dvm_duck_chat.py +++ b/tests/generic_dvm_duck_chat.py @@ -46,8 +46,8 @@ def playground(announce=False): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm briding DuckDuckAI'", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } } diff --git a/tests/generic_dvm_flux_hf.py b/tests/generic_dvm_flux_hf.py index 9b71e4f..8fed4d9 100644 --- a/tests/generic_dvm_flux_hf.py +++ b/tests/generic_dvm_flux_hf.py @@ -51,8 +51,8 @@ def playground(announce=False): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I produce images with Flux-Schnell'", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { } } diff --git a/tests/otherstuff.py b/tests/otherstuff.py index 3cb9bfb..ae140b2 100644 --- a/tests/otherstuff.py +++ b/tests/otherstuff.py @@ -60,8 +60,8 @@ def build_sd35(name, identifier, announce): "name": name, "picture": "https://i.nostr.build/NOXcCIPmOZrDTK35.jpg", "about": "I draw images using Stable diffusion ultra", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "negative_prompt": { "required": False, @@ -109,8 +109,8 @@ def build_dalle(name, identifier, announce): "name": name, "picture": "https://image.nostr.build/22f2267ca9d4ee9d5e8a0c7818a9fa325bbbcdac5573a60a2d163e699bb69923.jpg", "about": "I create Images bridging OpenAI's DALL·E 3", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "size": { "required": False, @@ -145,8 +145,8 @@ def build_svd(name, identifier, announce): "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I use Stable Video Diffusion to create short videos", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": {} } @@ -172,8 +172,8 @@ def build_media_converter(name, identifier, announce): "name": name, "picture": "https://cdn.nostr.build/i/a177be1159da5aad8396a1188f686728d55647d3a7371549584daf2b5e50eec9.jpg", "about": "I convert videos from urls to given output format.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "media_format": { "required": False, @@ -207,7 +207,7 @@ def build_inactive_follows_finder(name, identifier, announce): "picture": "https://image.nostr.build/50621bbf8082c478bc06a06684e1c443b5d37f1362ad56d679cab7328e0481db.jpg", "about": "I discover npubs you follow, but that have been inactive on Nostr for the last 90 days", "action": "unfollow", - "cashuAccepted": True, + "acceptsNutZaps": False, "nip90Params": { "user": { "required": False, @@ -246,8 +246,8 @@ def build_1984(name, identifier, announce): "name": name, "picture": "https://image.nostr.build/19872a2edd866258fa9eab137631efda89310d52b2c6ea8f99ef057325aa1c7b.jpg", "about": "I show users that have been reported by either your followers or your Web of Trust. Note: Anyone can report, so you might double check and decide for yourself who to mute. Considers spam, illegal and impersonation reports. Notice: This works with NIP51 mute lists. Not all clients support the new mute list format.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "action": "mute", # follow, unfollow, mute, unmute "nip90Params": { "since_days": { @@ -281,8 +281,8 @@ def build_botfarms(name, identifier, announce): "name": name, "picture": "https://image.nostr.build/981b560820bc283c58de7989b7abc6664996b487a531d852e4ef7322586a2122.jpg", "about": "I hunt down bot farms.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "action": "mute", # follow, unfollow, mute, unmute "nip90Params": { "max_results": { @@ -319,8 +319,8 @@ def build_replicate(name, identifier, model, announce): "name": name, "picture": "https://i.nostr.build/qnoBIN4jSkfF8IHk.png", "about": "I use Replicate to run StableDiffusion XL", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "size": { "required": False, @@ -356,8 +356,8 @@ def build_replicate_recraft(name, identifier, announce): "name": name, "picture": "https://i.nostr.build/jSbrXvYglXCzSeAc.jpg", "about": "I use Replicate to run Recraft v3", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "size": { "required": False, @@ -391,8 +391,8 @@ def build_replicate_fluxpro(name, identifier, announce): "name": name, "picture": "https://i.nostr.build/AQTujqzVmLxLmG16.jpg", "about": "I use Replicate to FluxPro 1.1.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": False, "nip90Params": { "size": { "required": False, diff --git a/tests/sd35_api.py b/tests/sd35_api.py index 5d69151..257afb1 100644 --- a/tests/sd35_api.py +++ b/tests/sd35_api.py @@ -35,8 +35,8 @@ def build_sd35(name, identifier): "name": name, "picture": "https://i.nostr.build/NOXcCIPmOZrDTK35.jpg", "about": "I draw images using Stable diffusion ultra", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "negative_prompt": { "required": False, diff --git a/tests/search.py b/tests/search.py index 4868967..2cb264f 100644 --- a/tests/search.py +++ b/tests/search.py @@ -52,6 +52,7 @@ def build_advanced_search(name, identifier): dvm_config.SYNC_DB_RELAY_LIST = SYNC_DB_RELAY_LIST + admin_config = AdminConfig() admin_config.REBROADCAST_NIP89 = rebroadcast_NIP89 admin_config.REBROADCAST_NIP65_RELAY_LIST = rebroadcast_NIP65_Relay_List @@ -63,8 +64,8 @@ def build_advanced_search(name, identifier): "name": name, "picture": "https://nostr.band/android-chrome-192x192.png", "about": "I search notes on nostr.band", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "users": { "required": False, @@ -119,8 +120,8 @@ def build_advanced_search_wine(name, identifier): "name": name, "picture": "https://image.nostr.build/d844d6a963724b9f9deb6b3326984fd95352343336718812424d5e99d93a6f2d.jpg", "about": "I search notes on nostr.wine using the nostr-wine API", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "users": { "required": False, @@ -175,8 +176,8 @@ def build_user_search(name, identifier): "name": name, "picture": "https://image.nostr.build/bd0181a3089181f1d92a5da1ef85cffbe37ba80fbcc695b9d85648dc2fa92583.jpg", "about": "I search users based on their profile info.", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "max_results": { "required": False, @@ -206,8 +207,8 @@ def playground(): advanced_search_wine = build_advanced_search_wine("Nostr.wine Search", "discovery_content_searchwine") advanced_search_wine.run() - profile_search = build_user_search("Profile Searcher", "profile_search") - profile_search.run() + #profile_search = build_user_search("Profile Searcher", "profile_search") + #profile_search.run() diff --git a/tests/simplebot.py b/tests/simplebot.py index edcd7ab..3e020d1 100644 --- a/tests/simplebot.py +++ b/tests/simplebot.py @@ -50,7 +50,7 @@ async def test(): print("Decrypting NIP59 event") try: # Extract rumor - unwrapped_gift = UnwrappedGift.from_gift_wrap(keys, event) + unwrapped_gift = UnwrappedGift.from_gift_wrap(NostrSigner(keys), event) sender = unwrapped_gift.sender() rumor: UnsignedEvent = unwrapped_gift.rumor() diff --git a/tests/summarization_duck.py b/tests/summarization_duck.py index 674ce79..7f74233 100644 --- a/tests/summarization_duck.py +++ b/tests/summarization_duck.py @@ -24,8 +24,8 @@ def playground(announce=False): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I summarize Text", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": {} } diff --git a/tests/test_dvm_client.py b/tests/test_dvm_client.py index 3b707ee..c6c09e0 100644 --- a/tests/test_dvm_client.py +++ b/tests/test_dvm_client.py @@ -7,7 +7,7 @@ from nostr_dvm.utils.print_utils import bcolors import dotenv from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \ - nip04_encrypt, NostrSigner, Event, Kind, RelayOptions + nip44_encrypt, Nip44Version, NostrSigner, Event, Kind, RelayOptions from nostr_dvm.utils.dvmconfig import DVMConfig from nostr_dvm.utils.nostr_utils import send_event, check_and_set_private_key @@ -377,8 +377,8 @@ async def nostr_client_test_image_private(prompt, cashutoken): encrypted_params_string = json.dumps([i_tag.as_vec(), outTag.as_vec(), paramTag1.as_vec(), bid_tag.as_vec(), relays_tag.as_vec(), alt_tag.as_vec(), cashu_tag.as_vec()]) - encrypted_params = nip04_encrypt(keys.secret_key(), receiver_keys.public_key(), - encrypted_params_string) + encrypted_params = nip44_encrypt(keys.secret_key(), receiver_keys.public_key(), + encrypted_params_string, Nip44Version.V2) encrypted_tag = Tag.parse(['encrypted']) nip90request = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_IMAGE, encrypted_params).tags( diff --git a/tests/tts.py b/tests/tts.py index 59c5259..83bb929 100644 --- a/tests/tts.py +++ b/tests/tts.py @@ -34,8 +34,8 @@ if __name__ == '__main__': "name": name, "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I Generate Speech from Text", - "encryptionSupported": True, - "cashuAccepted": True, + "supportsEncryption": True, + "acceptsNutZaps": dvm_config.ENABLE_NUTZAP, "nip90Params": { "language": { "required": False, diff --git a/tutorials/05_announce_dvm.py b/tutorials/05_announce_dvm.py index 18eebf0..d647956 100644 --- a/tutorials/05_announce_dvm.py +++ b/tutorials/05_announce_dvm.py @@ -55,7 +55,7 @@ def run_dvm(identifier, announce): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm a very simply DVM that always responds with the same message.", - "encryptionSupported": True, + "supportsEncryption": True, "nip90Params": { "some_option": { "required": False, diff --git a/tutorials/06_dvm_config.py b/tutorials/06_dvm_config.py index cf61845..21549ba 100644 --- a/tutorials/06_dvm_config.py +++ b/tutorials/06_dvm_config.py @@ -119,7 +119,7 @@ def run_dvm(identifier, announce): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm a very simply DVM that always responds with the same message.", - "encryptionSupported": True, + "supportsEncryption": True, "nip90Params": { "some_option": { "required": False, diff --git a/tutorials/07_admin_config.py b/tutorials/07_admin_config.py index eff01ba..fb6571a 100644 --- a/tutorials/07_admin_config.py +++ b/tutorials/07_admin_config.py @@ -94,7 +94,7 @@ def run_dvm(identifier, announce): "name": name, "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png", "about": "I'm a very simply DVM that always responds with the same message.", - "encryptionSupported": True, + "supportsEncryption": True, "nip90Params": { "some_option": { "required": False, diff --git a/ui/noogle/src/components/ChatGeneration.vue b/ui/noogle/src/components/ChatGeneration.vue index 73e5643..82da529 100644 --- a/ui/noogle/src/components/ChatGeneration.vue +++ b/ui/noogle/src/components/ChatGeneration.vue @@ -181,7 +181,7 @@ async function listen() { if (JSON.parse(el.event).pubkey === event.author.toHex().toString() && el.kind === "5050") { jsonentry.name = el.name jsonentry.about = el.about - jsonentry.image = el.image + jsonentry.picture = el.picture jsonentry.nip90Params = el.nip90Params //jsonentry.reactions = await dvmreactions(PublicKey.parse(el.id), store.state.followings) //jsonentry.reactions.negativeUser = false diff --git a/ui/noogle/src/components/FilterGeneration.vue b/ui/noogle/src/components/FilterGeneration.vue index 3cb520b..a53c364 100644 --- a/ui/noogle/src/components/FilterGeneration.vue +++ b/ui/noogle/src/components/FilterGeneration.vue @@ -67,7 +67,6 @@ async function generate_feed(id) { try { let client = store.state.client - //console.log(dvms.find(i => i.id === id).encryptionSupported) let current_dvm = dvms.find(i => i.id === id) @@ -85,7 +84,7 @@ async function generate_feed(id) { let requestid; // for now we only want to use encrypted events for subscribed dvms (might change later, also we dont encrypt on amber because decryption and update doesnt work) - if (current_dvm.encryptionSupported && current_dvm.nip88 && current_dvm.nip88.hasActiveSubscription && localStorage.getItem('nostr-key-method') !== 'android-signer' && localStorage.getItem('nostr-key-method') !== 'nostr-login') { + if (current_dvm.supportsEncryption && current_dvm.nip88 && current_dvm.nip88.hasActiveSubscription && localStorage.getItem('nostr-key-method') !== 'android-signer' && localStorage.getItem('nostr-key-method') !== 'nostr-login') { let tags_str = [] for (let tag of tags) { @@ -101,7 +100,7 @@ async function generate_feed(id) { let pk = PublicKey.parse(id) - let content = await signer.nip04Encrypt(pk, params_as_str) + let content = await signer.nip44Encrypt(pk, params_as_str) let tags_t = [] tags_t.push(Tag.parse(["p", id])) @@ -150,7 +149,7 @@ async function listen() { let client = store.state.client let pubkey = store.state.pubkey - const filter = new Filter().kinds([7000, 6301]).pubkey(pubkey).since(Timestamp.now()); + const filter = new Filter().kinds([Kind(7000), Kind(6301)]).pubkey(pubkey).since(Timestamp.now()); await client.subscribe([filter]); const handle = { @@ -197,7 +196,7 @@ async function listen() { return // tags_str = await amberSignerService.nip04Decrypt(event.author.toHex(), event.content) } else { - tags_str = await signer.nip04Decrypt(event.author, event.content) + tags_str = await signer.nip44Decrypt(event.author, event.content) } @@ -301,7 +300,7 @@ async function listen() { if (is_encrypted) { if (ptag === store.state.pubkey.toHex()) { let signer = store.state.signer - content = await signer.nip04Decrypt(event.author, event.content) + content = await signer.nip44Decrypt(event.author, event.content) } else { console.log("not addressed to us") @@ -465,7 +464,7 @@ async function addAllContentDVMs() { console.log(active_dvms) - const filtera = new Filter().authors(relevant_dvms).kinds([6301, 7000]) + const filtera = new Filter().authors(relevant_dvms).kinds([Kind(6301), Kind(7000)]) let client = store.state.client let activities = await client.getEventsOf([filtera], Duration.fromSecs(1)) @@ -503,8 +502,8 @@ async function addAllContentDVMs() { about: el.about, image: el.image, amount: el.amount, - encryptionSupported: el.encryptionSupported, - cashuAccepted: el.cashuAccepted, + supportsEncryption: el.supportsEncryption, + acceptsNutZaps: el.acceptsNutZaps, bolt11: "", lud16: el.lud16, subscription: "", @@ -538,8 +537,8 @@ async function addDVM(event) { bolt11: "", lud16: "", subscription: "", - encryptionSupported: false, - cashuAccepted: false + supportsEncryption: false, + acceptsNutZaps: false } for (const tag in event.tags) { @@ -584,8 +583,8 @@ async function addDVM(event) { jsonentry.about = el.about jsonentry.image = el.image jsonentry.lud16 = el.lud16 - jsonentry.encryptionSupported = el.encryptionSupported - jsonentry.cashuAccepted = el.cashuAccepted + jsonentry.supportsEncryption = el.supportsEncryption + jsonentry.acceptsNutZaps = el.acceptsNutZaps jsonentry.action = el.action console.log(jsonentry) @@ -713,7 +712,7 @@ async function subscribe_to_dvm() { try { - let msg = await (await nclient.signer()).nip04Encrypt(nwcdvm, tags_as_str) + let msg = await (await nclient.signer()).nip44Encrypt(nwcdvm, tags_as_str) let tags_t = [] tags_t.push(Tag.parse(["p", store.state.subscription_verifier_pubkey])) tags_t.push(Tag.parse(["encrypted"])) @@ -789,7 +788,7 @@ async function mute_all(results) { try { let eventasjson = JSON.parse(list.asJson()) - let content = await (await signer).nip04Decrypt(store.state.pubkey, list.content) + let content = await (await signer).nip44Decrypt(store.state.pubkey, list.content) let jsonObject = JSON.parse(content) console.log(content) @@ -817,7 +816,7 @@ async function mute_all(results) { let newcontent = JSON.stringify(jsonObject) console.log(newcontent) let lol = "[]" - eventasjson.content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent) + eventasjson.content = await (await signer).nip44Encrypt(store.state.pubkey, newcontent) let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey) try { @@ -841,7 +840,7 @@ async function mute_all(results) { let newcontent = JSON.stringify(jsonObject) - let content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent) + let content = await (await signer).nip44Encrypt(store.state.pubkey, newcontent) let tags = [] let newList = new EventBuilder(10000, content, tags).toUnsignedEvent(store.state.pubkey) try { @@ -873,7 +872,7 @@ async function mute(result) { try { // console.log(list.content) let signer = await store.state.signer - content = await signer.nip04Decrypt(store.state.pubkey, list.content) + content = await signer.nip44Decrypt(store.state.pubkey, list.content) // console.log(content) } catch (error) { @@ -895,7 +894,7 @@ async function mute(result) { store.state.mutes.push(result.authorid) let newcontent = JSON.stringify(jsonObject) console.log(newcontent) - eventasjson.content = await store.state.signer.nip04Encrypt(store.state.pubkey, newcontent) + eventasjson.content = await store.state.signer.nip44Encrypt(store.state.pubkey, newcontent) let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey) //console.log(signedMuteList.asJson()) try { @@ -924,7 +923,7 @@ async function mute(result) { let newcontent = JSON.stringify(jsonObject) - let content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent) + let content = await (await signer).nip44Encrypt(store.state.pubkey, newcontent) let tags = [] let newList = new EventBuilder(10000, content, tags).toUnsignedEvent(store.state.pubkey) try { @@ -1301,7 +1300,7 @@ const submitHandler = async () => {