diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index 817b2e9..79fa4ec 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -9,7 +9,7 @@
$ProjectFileDir$
- sqlite.xerial
+ 038acd88-11f0-4c07-ae7d-36e6f74bad7c
true
org.sqlite.JDBC
jdbc:sqlite:$PROJECT_DIR$/db/bot.db
@@ -21,7 +21,7 @@
- sqlite.xerial
+ 038acd88-11f0-4c07-ae7d-36e6f74bad7c
true
org.sqlite.JDBC
jdbc:sqlite:$PROJECT_DIR$/db/subscriptions.db
@@ -33,7 +33,7 @@
- sqlite.xerial
+ 038acd88-11f0-4c07-ae7d-36e6f74bad7c
true
org.sqlite.JDBC
jdbc:sqlite:$PROJECT_DIR$/db/Translator.db
@@ -45,7 +45,7 @@
- sqlite.xerial
+ 038acd88-11f0-4c07-ae7d-36e6f74bad7c
true
org.sqlite.JDBC
jdbc:sqlite:$PROJECT_DIR$/db/Unstable Diffusion.db
@@ -57,7 +57,7 @@
- sqlite.xerial
+ 038acd88-11f0-4c07-ae7d-36e6f74bad7c
true
org.sqlite.JDBC
jdbc:sqlite:$PROJECT_DIR$/db/nostr_mostr.db
@@ -69,7 +69,7 @@
- sqlite.xerial
+ 038acd88-11f0-4c07-ae7d-36e6f74bad7c
true
org.sqlite.JDBC
jdbc:sqlite:$PROJECT_DIR$/db/nostr_profiles.db
@@ -102,7 +102,7 @@
$ProjectFileDir$
- sqlite.xerial
+ 038acd88-11f0-4c07-ae7d-36e6f74bad7c
true
org.sqlite.JDBC
jdbc:sqlite:$PROJECT_DIR$/db/subscriptions
diff --git a/.idea/dvm.iml b/.idea/dvm.iml
index 3c35999..f3dc204 100644
--- a/.idea/dvm.iml
+++ b/.idea/dvm.iml
@@ -14,7 +14,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 83b7974..80b51eb 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/examples/ollama_dvm/main.py b/examples/ollama_dvm/main.py
index 6e0fb91..a2da1d9 100644
--- a/examples/ollama_dvm/main.py
+++ b/examples/ollama_dvm/main.py
@@ -22,17 +22,17 @@ def main():
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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": {
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
ollama = TextGenerationLLMLite(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config,
diff --git a/examples/ollama_dvm/test_client.py b/examples/ollama_dvm/test_client.py
index d591103..b4f3470 100644
--- a/examples/ollama_dvm/test_client.py
+++ b/examples/ollama_dvm/test_client.py
@@ -20,13 +20,13 @@ async def nostr_client_test_llm(prompt):
relaysTag = Tag.parse(['relays', "wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"])
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to generate TTSt"])
- event = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_TEXT, str("Generate an Audio File."),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_TEXT, str("Generate an Audio File.")).tags(
[iTag, relaysTag, alttag]).sign_with_keys(keys)
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"]
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
@@ -40,7 +40,7 @@ async def nostr_client():
sk = keys.secret_key()
pk = keys.public_key()
print(f"Nostr Test Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
dvmconfig = DVMConfig()
for relay in dvmconfig.RELAY_LIST:
await client.add_relay(relay)
diff --git a/examples/tts_dvm/main.py b/examples/tts_dvm/main.py
index 2ce8d46..75c639f 100644
--- a/examples/tts_dvm/main.py
+++ b/examples/tts_dvm/main.py
@@ -22,10 +22,10 @@ def main():
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -35,7 +35,7 @@ def main():
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
tts = TextToSpeech(name=name,
diff --git a/examples/tts_dvm/test_client.py b/examples/tts_dvm/test_client.py
index c62e001..e504dd9 100644
--- a/examples/tts_dvm/test_client.py
+++ b/examples/tts_dvm/test_client.py
@@ -24,14 +24,14 @@ async def nostr_client_test_tts(prompt):
relaysTag = Tag.parse(['relays', "wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"])
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to generate TTS"])
- event = EventBuilder(EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH, str("Generate an Audio File."),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH, str("Generate an Audio File.")).tags(
[iTag, paramTag1, bidTag, relaysTag, alttag]).sign_with_keys(keys)
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"]
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -44,7 +44,7 @@ async def nostr_client():
sk = keys.secret_key()
pk = keys.public_key()
print(f"Nostr Test Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
dvmconfig = DVMConfig()
for relay in dvmconfig.RELAY_LIST:
diff --git a/examples/unleashed_dvm/main.py b/examples/unleashed_dvm/main.py
index d32c250..5cb4a1a 100644
--- a/examples/unleashed_dvm/main.py
+++ b/examples/unleashed_dvm/main.py
@@ -22,15 +22,15 @@ def main():
nip89info = {
"name": name,
- "image": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
diff --git a/examples/unleashed_dvm/test_client.py b/examples/unleashed_dvm/test_client.py
index 3202d9c..736950b 100644
--- a/examples/unleashed_dvm/test_client.py
+++ b/examples/unleashed_dvm/test_client.py
@@ -23,13 +23,13 @@ async def nostr_client_test(prompt):
relaysTag = Tag.parse(['relays', "wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"])
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to generate TTS"])
- event = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_TEXT, str("Answer to prompt"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_TEXT, str("Answer to prompt")).tags(
[iTag, relaysTag, alttag]).sign_with_keys(keys)
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"]
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -42,7 +42,7 @@ async def nostr_client():
sk = keys.secret_key()
pk = keys.public_key()
print(f"Nostr Test Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
dvmconfig = DVMConfig()
for relay in dvmconfig.RELAY_LIST:
diff --git a/main.py b/main.py
index e5cd934..4294046 100644
--- a/main.py
+++ b/main.py
@@ -24,16 +24,16 @@ def playground(announce=False):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "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": {
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {
diff --git a/nostr_dvm/bot.py b/nostr_dvm/bot.py
index 0c79be8..518da3f 100644
--- a/nostr_dvm/bot.py
+++ b/nostr_dvm/bot.py
@@ -2,11 +2,11 @@ import asyncio
import json
import os
import signal
-from datetime import timedelta
+from multiprocessing.connection import Connection
-from nostr_sdk import (Keys, Client, Timestamp, Filter, nip04_decrypt, HandleNotification, EventBuilder, PublicKey,
- Options, Tag, Event, nip04_encrypt, NostrSigner, EventId, Nip19Event, Kind, KindEnum,
- UnsignedEvent, UnwrappedGift, uniffi_set_event_loop)
+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
from nostr_dvm.utils.cashu_utils import redeem_cashu
@@ -28,6 +28,12 @@ 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())
@@ -42,10 +48,11 @@ 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))
- self.client = Client.with_opts(self.keys, opts)
+ opts = Options().gossip(True)
+ self.client = ClientBuilder().signer(NostrSigner.keys(self.keys)).opts(opts).build()
self.invoice_list = []
pk = self.keys.public_key()
@@ -63,9 +70,6 @@ class Bot:
for relay in self.dvm_config.RELAY_LIST:
await self.client.add_relay(relay)
- await self.client.add_read_relay("wss://relay.nostr.band")
- await self.client.add_read_relay("wss://relay.damus.io")
-
await self.client.connect()
zap_filter = Filter().pubkey(pk).kinds([EventDefinitions.KIND_ZAP]).since(Timestamp.now())
@@ -124,8 +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),
@@ -194,13 +197,13 @@ class Bot:
encrypted_tag = Tag.parse(['encrypted'])
# add the encrypted params to the content
nip90request = (EventBuilder(self.dvm_config.SUPPORTED_DVMS[index].KIND,
- encrypted_params, [p_tag, encrypted_tag]).
+ encrypted_params).tags([p_tag, encrypted_tag]).
sign_with_keys(self.keys))
else:
tags.append(p_tag)
nip90request = (EventBuilder(self.dvm_config.SUPPORTED_DVMS[index].KIND,
- "", tags).
+ "").tags(tags).
sign_with_keys(self.keys))
# remember in the job_list that we have made an event, if anybody asks for payment,
@@ -240,7 +243,10 @@ class Bot:
else:
message = invoice
if giftwrap:
- await self.client.send_private_msg(PublicKey.parse(sender), message, None)
+ event = await make_private_msg(self.signer, PublicKey.parse(sender), message,
+ None)
+ await self.client.send_event(event)
+
else:
await send_nip04_dm(self.client, message, PublicKey.parse(sender), self.dvm_config)
@@ -259,11 +265,10 @@ class Bot:
"100 sats (or any other amount) "
"to top up your balance")
if giftwrap:
- await self.client.send_private_msg(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)
- # await self.client.send_direct_msg(PublicKey.parse(sender), message, None)
- # await self.client.send_private_msg(PublicKey.parse(sender), message, None)
elif decrypted_text.startswith("cashuA"):
print("Received Cashu token:" + decrypted_text)
cashu_redeemed, cashu_message, total_amount, fees = await redeem_cashu(decrypted_text,
@@ -278,14 +283,16 @@ class Bot:
message = "Error: " + cashu_message + ". Token has not been redeemed."
if giftwrap:
- await self.client.send_private_msg(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)
elif decrypted_text.lower().startswith("what's the second best"):
await asyncio.sleep(2.0)
message = "No, there is no second best.\n\nhttps://cdn.nostr.build/p/mYLv.mp4"
if giftwrap:
- await self.client.send_private_msg(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)
else:
@@ -313,7 +320,7 @@ class Bot:
tags.append(p_tag)
nip90request = (EventBuilder(Kind(kind),
- "", tags).
+ "").tags(tags).
sign_with_keys(self.keys))
entry = {"npub": user.npub, "event_id": nip90request.id().to_hex(),
@@ -349,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())
@@ -379,7 +391,8 @@ class Bot:
client=self.client, config=self.dvm_config)
await asyncio.sleep(2.0)
if entry["giftwrap"]:
- await self.client.send_private_msg(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)
print(status + ": " + content)
@@ -408,8 +421,8 @@ class Bot:
amount) + " Sats from balance to DVM. New balance is " + str(
balance) + " Sats.\n"
if entry["giftwrap"]:
- await self.client.send_private_msg(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']),
self.dvm_config)
@@ -424,8 +437,8 @@ class Bot:
int(amount - user.balance)) + " Sats, then try again."
if entry["giftwrap"]:
- await self.client.send_private_msg(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']),
self.dvm_config)
@@ -485,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
@@ -502,7 +518,9 @@ class Bot:
print("[" + self.NAME + "] Received results, message to orignal sender " + user.name)
await asyncio.sleep(2.0)
if entry["giftwrap"]:
- await self.client.send_private_msg(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)
@@ -568,14 +586,16 @@ 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:
- await self.client.send_private_msg(PublicKey.parse(sender), text, nostr_event.id())
+ 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)
async def answer_blacklisted(nostr_event, giftwrap, sender):
message = "Your are currently blocked from this service."
if giftwrap:
- await self.client.send_private_msg(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)
@@ -586,7 +606,8 @@ class Bot:
await asyncio.sleep(2.0)
if giftwrap:
- await self.client.send_private_msg(PublicKey.parse(sender), info, None)
+ 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)
@@ -725,14 +746,16 @@ class Bot:
if nip89content.get("name"):
info += "Name: " + nip89content.get("name") + "\n"
- if nip89content.get("image"):
+ if nip89content.get("picture"):
+ info += nip89content.get("picture") + "\n"
+ elif nip89content.get("image"):
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 27b3bfb..d239c78 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
+ 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
@@ -47,7 +48,8 @@ class DVM:
opts = (
Options().relay_limits(relaylimits)) #.difficulty(28)
- self.client = Client.with_opts(self.keys, opts)
+ #self.client = Client(self.keys)
+ self.client = ClientBuilder().signer(NostrSigner.keys(self.keys)).opts(opts).build()
self.job_list = []
self.jobs_on_hold_list = []
pk = self.keys.public_key()
@@ -106,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
@@ -234,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:
@@ -336,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:
@@ -356,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
@@ -418,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:
@@ -530,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:
@@ -594,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":
@@ -606,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:
- reply_event = EventBuilder(Kind(original_event.kind().as_u16() + 1000), str(content), reply_tags).sign_with_keys(
+ 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:
@@ -625,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)
@@ -648,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)
@@ -719,15 +743,20 @@ 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:
content = reaction
keys = Keys.parse(dvm_config.PRIVATE_KEY)
- reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content), reply_tags).sign_with_keys(keys)
+ reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content)).tags(reply_tags).sign_with_keys(keys)
# send_event(reaction_event, client=self.client, dvm_config=self.dvm_config)
await send_event_outbox(reaction_event, client=self.client, dvm_config=self.dvm_config)
diff --git a/nostr_dvm/subscription.py b/nostr_dvm/subscription.py
index 7dd7e15..01b7707 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)
+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
@@ -39,7 +39,7 @@ class Subscription:
self.dvm_config.NIP89 = nip89config
self.admin_config = admin_config
self.keys = Keys.parse(dvm_config.PRIVATE_KEY)
- self.client = Client(self.keys)
+ self.client = Client(NostrSigner.keys(self.keys))
pk = self.keys.public_key()
@@ -146,12 +146,12 @@ 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
keys = Keys.parse(dvm_config.PRIVATE_KEY)
- reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content), reply_tags).sign_with_keys(keys)
+ reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content)).tags(reply_tags).sign_with_keys(keys)
await send_event(reaction_event, client=self.client, dvm_config=self.dvm_config)
print("[" + self.dvm_config.NIP89.NAME + "]" + ": Sent Kind " + str(
EventDefinitions.KIND_FEEDBACK.as_u16()) + " Reaction: " + "success" + " " + reaction_event.as_json())
@@ -209,7 +209,7 @@ class Subscription:
tags = [pTag, PTag, eTag, validTag, tierTag, alttag]
event = EventBuilder(EventDefinitions.KIND_NIP88_PAYMENT_RECIPE,
- message, tags).sign_with_keys(self.keys)
+ message).tags(tags).sign_with_keys(self.keys)
dvmconfig = DVMConfig()
client = Client(self.keys)
@@ -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:
@@ -348,7 +353,8 @@ class Subscription:
Timestamp.from_secs(end).to_human_datetime().replace("Z", " ").replace("T",
" ") + " GMT"))
- self.client.send_private_msg(PublicKey.parse(subscriber), message, None)
+ event = await make_private_msg(NostrSigner.keys(self.keys), PublicKey.parse(subscriber), message)
+ await self.client.send_event(event)
@@ -407,7 +413,8 @@ class Subscription:
Timestamp.from_secs(end).to_human_datetime().replace("Z", " ").replace("T",
" ")))
# await self.client.send_direct_msg(PublicKey.parse(subscription.subscriber), message, None)
- await self.client.send_private_msg(PublicKey.parse(subscription.subscriber), message, None)
+ event = await make_private_msg(NostrSigner.keys(self.keys), PublicKey.parse(subscription.subscriber), message)
+ await self.client.send_event(event)
async def check_subscriptions():
try:
diff --git a/nostr_dvm/tasks/advanced_search.py b/nostr_dvm/tasks/advanced_search.py
index 8545265..257418a 100644
--- a/nostr_dvm/tasks/advanced_search.py
+++ b/nostr_dvm/tasks/advanced_search.py
@@ -89,7 +89,7 @@ class AdvancedSearch(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
- cli = Client(keys)
+ cli = Client(NostrSigner.keys(keys))
await cli.add_relay(options["relay"])
@@ -162,10 +162,10 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://nostr.band/android-chrome-192x192.png",
+ "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,
@@ -191,7 +191,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {"relay": "wss://relay.nostr.band"}
diff --git a/nostr_dvm/tasks/advanced_search_wine.py b/nostr_dvm/tasks/advanced_search_wine.py
index 68a5715..57e8fec 100644
--- a/nostr_dvm/tasks/advanced_search_wine.py
+++ b/nostr_dvm/tasks/advanced_search_wine.py
@@ -147,10 +147,10 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/d844d6a963724b9f9deb6b3326984fd95352343336718812424d5e99d93a6f2d.jpg",
+ "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,
@@ -176,7 +176,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return AdvancedSearchWine(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/audiogeneration_suno_ai.py b/nostr_dvm/tasks/audiogeneration_suno_ai.py
index a0af881..1ebc7a4 100644
--- a/nostr_dvm/tasks/audiogeneration_suno_ai.py
+++ b/nostr_dvm/tasks/audiogeneration_suno_ai.py
@@ -156,15 +156,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return AudioGenerationSonoAI(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/content_discovery_currently_latest_longform.py b/nostr_dvm/tasks/content_discovery_currently_latest_longform.py
index a1207a1..79e5bff 100644
--- a/nostr_dvm/tasks/content_discovery_currently_latest_longform.py
+++ b/nostr_dvm/tasks/content_discovery_currently_latest_longform.py
@@ -112,7 +112,7 @@ class DicoverContentLatestLongForm(DVMTaskInterface):
database = NostrDatabase.lmdb(self.db_name)
# print(self.db_name)
- cli = ClientBuilder().database(database).signer(keys).build()
+ cli = ClientBuilder().database(database).signer(NostrSigner.keys(keys)).build()
await cli.connect()
# Negentropy reconciliation
@@ -123,10 +123,10 @@ class DicoverContentLatestLongForm(DVMTaskInterface):
filter1 = Filter().kind(definitions.EventDefinitions.KIND_LONGFORM).since(since)
events = await cli.database().query([filter1])
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
index = options["max_results"]
- for event in events:
+ for event in events.to_vec():
if event.created_at().as_secs() > timestamp_hour_ago:
ns.finallist[event.id().to_hex()] = index
index = index - 1
@@ -175,7 +175,7 @@ class DicoverContentLatestLongForm(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).opts(opts).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).opts(opts).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -227,12 +227,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -245,7 +244,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -273,12 +272,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -291,14 +289,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py b/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py
index 68ed059..e972574 100644
--- a/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py
+++ b/nostr_dvm/tasks/content_discovery_currently_latest_wiki.py
@@ -112,7 +112,7 @@ class DicoverContentLatestWiki(DVMTaskInterface):
database = NostrDatabase.lmdb(self.db_name)
# print(self.db_name)
- cli = ClientBuilder().database(database).signer(keys).build()
+ cli = ClientBuilder().database(database).signer(NostrSigner.keys(keys)).build()
await cli.connect()
# Negentropy reconciliation
@@ -123,10 +123,10 @@ class DicoverContentLatestWiki(DVMTaskInterface):
filter1 = Filter().kind(definitions.EventDefinitions.KIND_WIKI).since(since)
events = await cli.database().query([filter1])
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
index = options["max_results"]
- for event in events:
+ for event in events.to_vec():
if event.created_at().as_secs() > timestamp_hour_ago:
ns.finallist[event.id().to_hex()] = index
index = index - 1
@@ -175,7 +175,7 @@ class DicoverContentLatestWiki(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).opts(opts).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).opts(opts).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -226,12 +226,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -244,7 +243,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -272,12 +271,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -290,14 +288,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/content_discovery_currently_popular.py b/nostr_dvm/tasks/content_discovery_currently_popular.py
index ac09e91..c69bd37 100644
--- a/nostr_dvm/tasks/content_discovery_currently_popular.py
+++ b/nostr_dvm/tasks/content_discovery_currently_popular.py
@@ -9,6 +9,7 @@ from nostr_sdk import Timestamp, Tag, Keys, Options, SecretKey, NostrSigner, Nos
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils import definitions
from nostr_dvm.utils.admin_utils import AdminConfig
+from nostr_dvm.utils.database_utils import init_db
from nostr_dvm.utils.definitions import EventDefinitions
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
from nostr_dvm.utils.nip88_utils import NIP88Config, check_and_set_d_tag_nip88, check_and_set_tiereventid_nip88
@@ -117,17 +118,17 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
events = await database.query([filter1])
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
- for event in events:
+ for event in events.to_vec():
if event.created_at().as_secs() > timestamp_since:
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await database.query([filt])
- if len(reactions) >= self.min_reactions:
- ns.finallist[event.id().to_hex()] = len(reactions)
+ if len(reactions.to_vec()) >= self.min_reactions:
+ ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
if len(ns.finallist) == 0:
return self.result
@@ -171,8 +172,9 @@ class DicoverContentCurrentlyPopular(DVMTaskInterface):
try:
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
+
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -225,12 +227,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -243,7 +244,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -270,12 +271,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -288,14 +288,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
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 1b0a56c..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
@@ -115,20 +115,20 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).since(since)
events = await database.query([filter1])
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
- for event in events:
+ for event in events.to_vec():
if event.created_at().as_secs() > timestamp_hour_ago:
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP]).event(event.id()).since(since)
zaps = await database.query([filt])
invoice_amount = 0
event_author = event.author().to_hex()
- if len(zaps) >= self.min_reactions:
+ if len(zaps.to_vec()) >= self.min_reactions:
has_preimage = False
has_amount = False
overall_amount = 0
- for zap in zaps:
+ for zap in zaps.to_vec():
if event_author == zap.author().to_hex():
continue # Skip self zaps..
invoice_amount = 0
@@ -216,7 +216,7 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -269,12 +269,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -287,7 +286,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -314,12 +313,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -332,14 +330,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py
index afa7f8b..507a904 100644
--- a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py
+++ b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py
@@ -98,7 +98,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().database(database).signer(keys).opts(opts).build()
+ cli = ClientBuilder().database(database).signer(NostrSigner.keys(keys)).opts(opts).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -137,18 +137,18 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
filter1 = Filter().kind(definitions.EventDefinitions.KIND_NOTE).authors(followings).since(since)
events = await cli.database().query([filter1])
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
- for event in events:
+ for event in events.to_vec():
# if event.created_at().as_secs() > timestamp_since:
filt = Filter().kinds(
[definitions.EventDefinitions.KIND_ZAP, definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await cli.database().query([filt])
- if len(reactions) >= self.min_reactions:
- ns.finallist[event.id().to_hex()] = len(reactions)
+ if len(reactions.to_vec()) >= self.min_reactions:
+ ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[
:int(options["max_results"])]
@@ -192,7 +192,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -243,12 +243,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=3
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -261,7 +260,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=3
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -287,12 +286,11 @@ def build_example_subscription(name, identifier, admin_config, options, processi
image = "https://image.nostr.build/d92652a6a07677e051d647dcf9f0f59e265299b3335a939d008183a911513f4a.jpg"
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -305,14 +303,14 @@ def build_example_subscription(name, identifier, admin_config, options, processi
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py
index 3bc1857..4cdf990 100644
--- a/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py
+++ b/nostr_dvm/tasks/content_discovery_currently_popular_gallery.py
@@ -121,16 +121,16 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface):
ge_events = await databasegallery.query([filter1])
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(ge_events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(ge_events.to_vec())) + " Events")
ns.finallist = {}
ids = []
relays = []
- if len(ge_events) == 0:
+ if len(ge_events.to_vec()) == 0:
return []
- for ge_event in ge_events:
+ for ge_event in ge_events.to_vec():
id = None
for tag in ge_event.tags().to_vec():
@@ -150,7 +150,7 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
- cli = ClientBuilder().database(databasegallery).signer(keys).opts(opts).build()
+ cli = ClientBuilder().database(databasegallery).signer(NostrSigner.keys(keys)).opts(opts).build()
for relay in relays:
await cli.add_relay(relay)
@@ -176,7 +176,7 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface):
if event.created_at().as_secs() > timestamp_since:
filt1 = Filter().kinds([definitions.EventDefinitions.KIND_DELETION]).event(event.id()).limit(1)
deletions = await databasegallery.query([filt1])
- if len(deletions) > 0:
+ if len(deletions.to_vec()) > 0:
print("Deleted event, skipping")
continue
@@ -185,13 +185,13 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface):
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await databasegallery.query([filt])
- if len(reactions) >= self.min_reactions:
+ if len(reactions.to_vec()) >= self.min_reactions:
found = False
- for ge_event in ge_events:
+ for ge_event in ge_events.to_vec():
for tag in ge_event.tags().to_vec():
if tag.as_vec()[0] == "e":
if event.id().to_hex() == tag.as_vec()[1]:
- ns.finallist[ge_event.id().to_hex()] = len(reactions)
+ ns.finallist[ge_event.id().to_hex()] = len(reactions.to_vec())
found = True
break
if found:
@@ -241,7 +241,7 @@ class DicoverContentCurrentlyPopularGallery(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -293,12 +293,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -311,7 +310,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -338,12 +337,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -356,14 +354,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py b/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py
index 5de007e..eea4646 100644
--- a/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py
+++ b/nostr_dvm/tasks/content_discovery_currently_popular_mostr.py
@@ -121,10 +121,10 @@ class DicoverContentCurrentlyPopularMostr(DVMTaskInterface):
events = await database.query([filter1])
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
- for event in events:
+ for event in events.to_vec():
if event.created_at().as_secs() > timestamp_since:
filt = Filter().kinds(
@@ -133,8 +133,8 @@ class DicoverContentCurrentlyPopularMostr(DVMTaskInterface):
EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await database.query([filt])
- if len(reactions) >= self.min_reactions:
- ns.finallist[event.id().to_hex()] = len(reactions)
+ if len(reactions.to_vec()) >= self.min_reactions:
+ ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
if len(ns.finallist) == 0:
return self.result
@@ -179,7 +179,7 @@ class DicoverContentCurrentlyPopularMostr(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -247,12 +247,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -265,7 +264,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -293,12 +292,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -311,14 +309,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py b/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py
index 829c77e..765fa04 100644
--- a/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py
+++ b/nostr_dvm/tasks/content_discovery_currently_popular_nonfollowers.py
@@ -147,7 +147,7 @@ class DicoverContentCurrentlyPopularNonFollowers(DVMTaskInterface):
if self.database is None:
self.database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().database(self.database).signer(keys).opts(opts).build()
+ cli = ClientBuilder().database(self.database).signer(NostrSigner.keys(keys)).opts(opts).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -185,10 +185,10 @@ class DicoverContentCurrentlyPopularNonFollowers(DVMTaskInterface):
events = await self.database.query([filter1])
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
- for event in events:
+ for event in events.to_vec():
if event.author().to_hex() in followings:
continue
@@ -197,8 +197,8 @@ class DicoverContentCurrentlyPopularNonFollowers(DVMTaskInterface):
definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await self.database.query([filt])
- if len(reactions) >= self.min_reactions:
- ns.finallist[event.id().to_hex()] = len(reactions)
+ if len(reactions.to_vec()) >= self.min_reactions:
+ ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
print(len(ns.finallist))
result_list = []
@@ -228,7 +228,7 @@ class DicoverContentCurrentlyPopularNonFollowers(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -279,12 +279,11 @@ def build_example(name, identifier, admin_config, options, image, description, u
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -297,7 +296,7 @@ def build_example(name, identifier, admin_config, options, image, description, u
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularNonFollowers(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -319,12 +318,11 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"picture": image,
"about": description,
"lud16": dvm_config.LN_ADDRESS,
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": False,
"subscription": True,
"personalized": False,
"nip90Params": {
@@ -337,14 +335,14 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py
index 91c1d73..d002d10 100644
--- a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py
+++ b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py
@@ -161,10 +161,10 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
events = await self.database.query(filters)
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + self.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
- for event in events:
+ for event in events.to_vec():
if all(ele in event.content().lower() for ele in self.must_list):
# if any(ele in event.content().lower() for ele in self.search_list):
if not any(ele in event.content().lower() for ele in self.avoid_list):
@@ -173,8 +173,8 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await self.database.query([filt])
- if len(reactions) >= self.min_reactions:
- ns.finallist[event.id().to_hex()] = len(reactions)
+ if len(reactions.to_vec()) >= self.min_reactions:
+ ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
result_list = []
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(options["max_results"])]
@@ -205,7 +205,7 @@ class DicoverContentCurrentlyPopularbyTopic(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -256,12 +256,11 @@ def build_example(name, identifier, admin_config, options, image, description, u
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -274,7 +273,7 @@ def build_example(name, identifier, admin_config, options, image, description, u
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -296,12 +295,11 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"picture": image,
"about": description,
"lud16": dvm_config.LN_ADDRESS,
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": False,
"subscription": True,
"personalized": False,
"nip90Params": {
@@ -314,14 +312,14 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
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 a43400f..ca02e43 100644
--- a/nostr_dvm/tasks/content_discovery_latest_one_per_follower.py
+++ b/nostr_dvm/tasks/content_discovery_latest_one_per_follower.py
@@ -4,7 +4,7 @@ import os
from datetime import timedelta
from threading import Thread
-from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayLimits
+from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayLimits, ClientBuilder
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils.admin_utils import AdminConfig
@@ -74,9 +74,9 @@ class Discoverlatestperfollower(DVMTaskInterface):
relaylimits = RelayLimits.disable()
- opts = (Options().relay_limits(relaylimits))
+ opts = Options().relay_limits(relaylimits)
- cli = Client.with_opts(keys, opts)
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).opts(opts).build()
for relay in self.dvm_config.RELAY_LIST:
await cli.add_relay(relay)
# ropts = RelayOptions().ping(False)
@@ -123,7 +123,7 @@ class Discoverlatestperfollower(DVMTaskInterface):
from nostr_sdk import Filter
keys = Keys.parse(self.dvm_config.PRIVATE_KEY)
- cli = Client(keys)
+ cli = Client(NostrSigner.keys(keys))
for relay in self.dvm_config.RELAY_LIST:
await cli.add_relay(relay)
await cli.connect()
@@ -205,11 +205,11 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://i.nostr.build/H6SMmCl7eRDvkbAn.jpg",
+ "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,
@@ -224,7 +224,7 @@ def build_example(name, identifier, admin_config):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return Discoverlatestperfollower(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/content_discovery_update_db_only.py b/nostr_dvm/tasks/content_discovery_update_db_only.py
index 7487ace..74ddf4e 100644
--- a/nostr_dvm/tasks/content_discovery_update_db_only.py
+++ b/nostr_dvm/tasks/content_discovery_update_db_only.py
@@ -11,6 +11,7 @@ from nostr_sdk import Timestamp, PublicKey, Keys, Options, SecretKey, NostrSigne
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils import definitions
from nostr_dvm.utils.admin_utils import AdminConfig
+from nostr_dvm.utils.database_utils import init_db
from nostr_dvm.utils.definitions import EventDefinitions
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
from nostr_dvm.utils.nip88_utils import NIP88Config, check_and_set_d_tag_nip88, check_and_set_tiereventid_nip88
@@ -42,6 +43,8 @@ class DicoverContentDBUpdateScheduler(DVMTaskInterface):
personalized = False
result = ""
database = None
+ wot_counter = 0
+ max_db_size = 280
async def init_dvm(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
admin_config: AdminConfig = None, options=None):
@@ -62,6 +65,8 @@ class DicoverContentDBUpdateScheduler(DVMTaskInterface):
self.db_name = self.options.get("db_name")
if self.options.get("db_since"):
self.db_since = int(self.options.get("db_since"))
+ if self.options.get("max_db_size"):
+ self.max_db_size = int(self.options.get("max_db_size"))
use_logger = False
if use_logger:
@@ -135,16 +140,17 @@ class DicoverContentDBUpdateScheduler(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
if self.database is None:
- self.database = NostrDatabase.lmdb(self.db_name)
+ self.database = await init_db(self.db_name, True, self.max_db_size)
+ #self.database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(self.database).opts(opts).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(self.database).opts(opts).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
await cli.connect()
- if self.dvm_config.WOT_FILTERING:
+ if self.dvm_config.WOT_FILTERING and self.wot_counter == 0:
print("Calculating WOT for " + str(self.dvm_config.WOT_BASED_ON_NPUBS))
filtering = cli.filtering()
index_map, G = await build_wot_network(self.dvm_config.WOT_BASED_ON_NPUBS,
@@ -166,7 +172,10 @@ class DicoverContentDBUpdateScheduler(DVMTaskInterface):
# toc = time.time()
# print(f'finished in {toc - tic} seconds')
await filtering.add_public_keys(wot_keys)
-
+ self.wot_counter += 1
+ # only calculate wot every 10th call
+ if self.wot_counter >= 10:
+ self.wot_counter = 0
# Mute public key
# await cli. (self.dvm_config.MUTE)
@@ -177,7 +186,6 @@ class DicoverContentDBUpdateScheduler(DVMTaskInterface):
[definitions.EventDefinitions.KIND_NOTE, definitions.EventDefinitions.KIND_REACTION,
definitions.EventDefinitions.KIND_ZAP]).since(since) # Notes, reactions, zaps
- # filter = Filter().author(keys.public_key())
if self.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
print("[" + self.dvm_config.IDENTIFIER + "] Syncing notes of the last " + str(
self.db_since) + " seconds.. this might take a while..")
@@ -214,12 +222,11 @@ def build_example(name, identifier, admin_config, options, image, description, u
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -232,7 +239,7 @@ def build_example(name, identifier, admin_config, options, image, description, u
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentDBUpdateScheduler(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -254,12 +261,11 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -272,14 +278,14 @@ def build_example_subscription(name, identifier, admin_config, options, image, d
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/convert_media.py b/nostr_dvm/tasks/convert_media.py
index d69c15a..4de4ced 100644
--- a/nostr_dvm/tasks/convert_media.py
+++ b/nostr_dvm/tasks/convert_media.py
@@ -87,10 +87,10 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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 60a199b..dee05d6 100644
--- a/nostr_dvm/tasks/discovery_bot_farms.py
+++ b/nostr_dvm/tasks/discovery_bot_farms.py
@@ -78,7 +78,7 @@ class DiscoveryBotFarms(DVMTaskInterface):
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb("db/nostr_profiles.db")
- cli = ClientBuilder().database(database).signer(keys).build()
+ cli = ClientBuilder().database(database).signer(NostrSigner.keys(keys)).build()
await cli.add_relay("wss://relay.damus.io")
# cli.add_relay("wss://atl.purplerelay.com")
@@ -91,13 +91,13 @@ class DiscoveryBotFarms(DVMTaskInterface):
filter1 = Filter().kind(Kind(0))
events = await cli.database().query([filter1])
result_list = []
- print("Events: " + str(len(events)))
+ print("Events: " + str(len(events.to_vec())))
searchterms = str(options["search"]).split(";")
index = 0
- if len(events) > 0:
+ if len(events.to_vec()) > 0:
- for event in events:
+ for event in events.to_vec():
if index < options["max_results"]:
try:
if any(ext in event.content().lower() for ext in searchterms):
@@ -137,7 +137,7 @@ class DiscoveryBotFarms(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb("db/nostr_profiles.db")
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
await cli.add_relay("wss://relay.damus.io")
await cli.add_relay("wss://nostr21.com")
@@ -163,10 +163,10 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/981b560820bc283c58de7989b7abc6664996b487a531d852e4ef7322586a2122.jpg",
+ "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": {
@@ -178,7 +178,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {"relay": "wss://relay.damus.io"}
diff --git a/nostr_dvm/tasks/discovery_censor_wot.py b/nostr_dvm/tasks/discovery_censor_wot.py
index 2bd81c8..9a72fee 100644
--- a/nostr_dvm/tasks/discovery_censor_wot.py
+++ b/nostr_dvm/tasks/discovery_censor_wot.py
@@ -2,7 +2,7 @@ import json
import os
from datetime import timedelta
-from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayLimits
+from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayLimits, ClientBuilder
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils.admin_utils import AdminConfig
@@ -73,7 +73,7 @@ class DiscoverReports(DVMTaskInterface):
Options().relay_limits(relaylimits))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
- cli = Client.with_opts(keys, opts)
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).opts(opts).build()
# cli.add_relay("wss://relay.nostr.band")
for relay in self.dvm_config.RELAY_LIST:
await cli.add_relay(relay)
@@ -171,10 +171,10 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/19872a2edd866258fa9eab137631efda89310d52b2c6ea8f99ef057325aa1c7b.jpg",
+ "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": {
@@ -185,7 +185,7 @@ def build_example(name, identifier, admin_config):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DiscoverReports(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/discovery_inactive_follows.py b/nostr_dvm/tasks/discovery_inactive_follows.py
index 35e0fc1..5a34fb5 100644
--- a/nostr_dvm/tasks/discovery_inactive_follows.py
+++ b/nostr_dvm/tasks/discovery_inactive_follows.py
@@ -5,7 +5,7 @@ from datetime import timedelta
from threading import Thread
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions, \
- RelayLimits
+ RelayLimits, ClientBuilder
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils.admin_utils import AdminConfig
@@ -76,7 +76,7 @@ class DiscoverInactiveFollows(DVMTaskInterface):
opts = (Options().relay_limits(relaylimits))
- cli = Client.with_opts(keys, opts)
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).opts(opts).build()
for relay in self.dvm_config.RELAY_LIST:
await cli.add_relay(relay)
await cli.add_relay("wss://nostr.band")
@@ -123,7 +123,7 @@ class DiscoverInactiveFollows(DVMTaskInterface):
from nostr_sdk import Filter
keys = Keys.parse(self.dvm_config.PRIVATE_KEY)
- cli = Client(keys)
+ cli = Client(NostrSigner.keys(keys))
for relay in self.dvm_config.RELAY_LIST:
await cli.add_relay(relay)
await cli.connect()
@@ -191,11 +191,11 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -210,7 +210,7 @@ def build_example(name, identifier, admin_config):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DiscoverInactiveFollows(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/discovery_nonfollowers.py b/nostr_dvm/tasks/discovery_nonfollowers.py
index 34e42b3..c18673c 100644
--- a/nostr_dvm/tasks/discovery_nonfollowers.py
+++ b/nostr_dvm/tasks/discovery_nonfollowers.py
@@ -5,7 +5,7 @@ from datetime import timedelta
from threading import Thread
from nostr_sdk import Client, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions, \
- RelayLimits
+ RelayLimits, ClientBuilder
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils.admin_utils import AdminConfig
@@ -68,7 +68,8 @@ class DiscoverNonFollowers(DVMTaskInterface):
relaylimits))
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
- cli = Client.with_opts(keys, opts)
+ cli= ClientBuilder().signer(NostrSigner.keys(keys)).opts(opts).build()
+
# cli.add_relay("wss://relay.nostr.band")
for relay in self.dvm_config.RELAY_LIST:
await cli.add_relay(relay)
@@ -105,7 +106,7 @@ class DiscoverNonFollowers(DVMTaskInterface):
async def scanList(users, instance, i, st):
from nostr_sdk import Filter
keys = Keys.parse(self.dvm_config.PRIVATE_KEY)
- cli = Client(keys)
+ cli = Client(NostrSigner.keys(keys))
for relay in self.dvm_config.RELAY_LIST:
await cli.add_relay(relay)
await cli.connect()
@@ -194,10 +195,10 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -212,7 +213,7 @@ def build_example(name, identifier, admin_config):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DiscoverNonFollowers(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py b/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py
index 75cf909..ada5bfc 100644
--- a/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py
+++ b/nostr_dvm/tasks/discovery_trending_notes_gleasonator.py
@@ -72,7 +72,7 @@ class TrendingNotesGleasonator(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
- cli = Client(keys)
+ cli = Client(NostrSigner.keys(keys))
await cli.add_relay(options["relay"])
await cli.connect()
@@ -125,16 +125,15 @@ def build_example(name, identifier, admin_config, custom_processing_msg):
nip89info = {
"name": name,
- "picture": "0c760b3ecdbc993ba47b785d0adecf00c760b3ecdbc993ba47b785d0adecf0ec71fd9c59808e27d0665b9f77a32d8de.png",
- "image": "0c760b3ecdbc993ba47b785d0adecf00c760b3ecdbc993ba47b785d0adecf0ec71fd9c59808e27d0665b9f77a32d8de.png",
+ "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()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TrendingNotesGleasonator(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/discovery_trending_notes_nostrband.py b/nostr_dvm/tasks/discovery_trending_notes_nostrband.py
index edc91fc..b0d33dd 100644
--- a/nostr_dvm/tasks/discovery_trending_notes_nostrband.py
+++ b/nostr_dvm/tasks/discovery_trending_notes_nostrband.py
@@ -117,16 +117,15 @@ def build_example(name, identifier, admin_config, custom_processing_msg):
nip89info = {
"name": name,
- "image": "https://nostr.band/android-chrome-192x192.png",
"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()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TrendingNotesNostrBand(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/generic_dvm.py b/nostr_dvm/tasks/generic_dvm.py
index f26e989..be668e4 100644
--- a/nostr_dvm/tasks/generic_dvm.py
+++ b/nostr_dvm/tasks/generic_dvm.py
@@ -83,16 +83,16 @@ def build_example(name, identifier, admin_config, announce=False):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "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": {
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {
diff --git a/nostr_dvm/tasks/imagegeneration_openai_dalle.py b/nostr_dvm/tasks/imagegeneration_openai_dalle.py
index bfc6773..ae1c8f1 100644
--- a/nostr_dvm/tasks/imagegeneration_openai_dalle.py
+++ b/nostr_dvm/tasks/imagegeneration_openai_dalle.py
@@ -133,10 +133,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -146,7 +146,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationDALLE(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config)
diff --git a/nostr_dvm/tasks/imagegeneration_replicate.py b/nostr_dvm/tasks/imagegeneration_replicate.py
index 6f6e902..032e27d 100644
--- a/nostr_dvm/tasks/imagegeneration_replicate.py
+++ b/nostr_dvm/tasks/imagegeneration_replicate.py
@@ -148,10 +148,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -161,7 +161,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationReplicate(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py b/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py
index f5a8702..6813b58 100644
--- a/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py
+++ b/nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py
@@ -143,10 +143,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -156,7 +156,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationReplicateFluxPro(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imagegeneration_replicate_recraft.py b/nostr_dvm/tasks/imagegeneration_replicate_recraft.py
index dbb285c..8ae8b6d 100644
--- a/nostr_dvm/tasks/imagegeneration_replicate_recraft.py
+++ b/nostr_dvm/tasks/imagegeneration_replicate_recraft.py
@@ -141,10 +141,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -154,7 +154,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationReplicateRecraft(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py
index 749f463..e5936c7 100644
--- a/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py
+++ b/nostr_dvm/tasks/imagegeneration_replicate_sdxl.py
@@ -127,10 +127,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -140,7 +140,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationReplicateSDXL(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imagegeneration_sd21_mlx.py b/nostr_dvm/tasks/imagegeneration_sd21_mlx.py
index 3c66dbf..6a2b03a 100644
--- a/nostr_dvm/tasks/imagegeneration_sd21_mlx.py
+++ b/nostr_dvm/tasks/imagegeneration_sd21_mlx.py
@@ -156,10 +156,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -169,7 +169,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationMLX(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imagegeneration_sd35_api.py b/nostr_dvm/tasks/imagegeneration_sd35_api.py
index 981e116..80d87bd 100644
--- a/nostr_dvm/tasks/imagegeneration_sd35_api.py
+++ b/nostr_dvm/tasks/imagegeneration_sd35_api.py
@@ -264,11 +264,11 @@ def build_example(name, identifier, admin_config, server_address, default_model=
nip89info = {
"name": name,
- "image": "https://i.nostr.build/NOXcCIPmOZrDTK35.jpg",
+ "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": []
@@ -284,7 +284,7 @@ def build_example(name, identifier, admin_config, server_address, default_model=
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationSD35(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imagegeneration_sdxl.py b/nostr_dvm/tasks/imagegeneration_sdxl.py
index 7c7e743..0cdfc31 100644
--- a/nostr_dvm/tasks/imagegeneration_sdxl.py
+++ b/nostr_dvm/tasks/imagegeneration_sdxl.py
@@ -175,10 +175,10 @@ def build_example(name, identifier, admin_config, server_address, default_model=
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -191,7 +191,7 @@ def build_example(name, identifier, admin_config, server_address, default_model=
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationSDXL(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py b/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py
index 9fa5fea..976b022 100644
--- a/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py
+++ b/nostr_dvm/tasks/imagegeneration_sdxlimg2img.py
@@ -197,10 +197,10 @@ def build_example(name, identifier, admin_config, server_address, default_lora="
nip89info = {
"name": name,
- "image": "https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg",
+ "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,
@@ -221,7 +221,7 @@ def build_example(name, identifier, admin_config, server_address, default_lora="
options = {'default_lora': default_lora, 'strength': strength, 'server': server_address}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageGenerationSDXLIMG2IMG(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imageinterrogator.py b/nostr_dvm/tasks/imageinterrogator.py
index 3dfcf57..8809de3 100644
--- a/nostr_dvm/tasks/imageinterrogator.py
+++ b/nostr_dvm/tasks/imageinterrogator.py
@@ -114,10 +114,10 @@ def build_example(name, identifier, admin_config, server_address):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg",
+ "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,
@@ -134,7 +134,7 @@ def build_example(name, identifier, admin_config, server_address):
options = {'server': server_address}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageInterrogator(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/imageupscale.py b/nostr_dvm/tasks/imageupscale.py
index afdccad..928c74a 100644
--- a/nostr_dvm/tasks/imageupscale.py
+++ b/nostr_dvm/tasks/imageupscale.py
@@ -119,10 +119,10 @@ def build_example(name, identifier, admin_config, server_address):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/229c14e440895da30de77b3ca145d66d4b04efb4027ba3c44ca147eecde891f1.jpg",
+ "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,
@@ -131,7 +131,7 @@ def build_example(name, identifier, admin_config, server_address):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return ImageUpscale(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/people_discovery_mywot.py b/nostr_dvm/tasks/people_discovery_mywot.py
index 0c1d9f5..3f759c4 100644
--- a/nostr_dvm/tasks/people_discovery_mywot.py
+++ b/nostr_dvm/tasks/people_discovery_mywot.py
@@ -8,6 +8,7 @@ from nostr_sdk import Timestamp, PublicKey, Tag, Keys, Options, SecretKey, Nostr
ClientBuilder, Filter, SyncOptions, SyncDirection, init_logger, LogLevel, Kind
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
+from nostr_dvm.tasks.people_discovery_wot import DiscoverPeopleWOT
from nostr_dvm.utils.admin_utils import AdminConfig
from nostr_dvm.utils.definitions import EventDefinitions
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
@@ -205,7 +206,7 @@ class DiscoverPeopleMyWOT(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -248,8 +249,8 @@ async def analyse_users(user_ids=None, dunbar=100000000):
followers_filter = Filter().authors(user_keys).kind(Kind(3))
followers = await database.query([followers_filter])
allfriends = []
- if len(followers) > 0:
- for follower in followers:
+ if len(followers.to_vec()) > 0:
+ for follower in followers.to_vec():
frens = []
if len(follower.tags().to_vec()) < dunbar:
for tag in follower.tags().to_vec():
@@ -306,12 +307,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -324,7 +324,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -351,12 +351,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -369,14 +368,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/people_discovery_wot.py b/nostr_dvm/tasks/people_discovery_wot.py
index 591afdc..6db6baf 100644
--- a/nostr_dvm/tasks/people_discovery_wot.py
+++ b/nostr_dvm/tasks/people_discovery_wot.py
@@ -210,7 +210,7 @@ class DiscoverPeopleWOT(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -253,8 +253,8 @@ async def analyse_users(user_ids=None, dunbar=100000000):
followers_filter = Filter().authors(user_keys).kind(Kind(3))
followers = await database.query([followers_filter])
allfriends = []
- if len(followers) > 0:
- for follower in followers:
+ if len(followers.to_vec()) > 0:
+ for follower in followers.to_vec():
frens = []
if len(follower.tags().to_vec()) < dunbar:
for tag in follower.tags().to_vec():
@@ -311,12 +311,11 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -329,7 +328,7 @@ def build_example(name, identifier, admin_config, options, cost=0, update_rate=1
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -356,12 +355,11 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -374,14 +372,14 @@ def build_example_subscription(name, identifier, admin_config, options, update_r
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
diff --git a/nostr_dvm/tasks/search_users.py b/nostr_dvm/tasks/search_users.py
index 05cac30..254113c 100644
--- a/nostr_dvm/tasks/search_users.py
+++ b/nostr_dvm/tasks/search_users.py
@@ -1,9 +1,10 @@
import json
import os
from datetime import timedelta
+from itertools import islice
from nostr_sdk import Timestamp, Tag, Keys, Options, SecretKey, NostrSigner, NostrDatabase, \
- ClientBuilder, Filter, SyncOptions, SyncDirection, Kind
+ ClientBuilder, Filter, SyncOptions, SyncDirection, Kind, PublicKey, RelayFilteringMode, RelayLimits
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
from nostr_dvm.utils.admin_utils import AdminConfig
@@ -12,6 +13,7 @@ from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
from nostr_dvm.utils.nip88_utils import NIP88Config
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag
from nostr_dvm.utils.output_utils import post_process_list_to_users
+from nostr_dvm.utils.wot_utils import build_wot_network
"""
This File contains a Module to search for notes
@@ -28,13 +30,12 @@ class SearchUser(DVMTaskInterface):
dvm_config: DVMConfig
last_schedule: int = 0
db_name = "db/nostr_profiles.db"
- relay = "wss://profiles.nostr1.com"
+ wot_counter = 0
async def init_dvm(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
admin_config: AdminConfig = None, options=None):
dvm_config.SCRIPT = os.path.abspath(__file__)
- if self.options.get("relay"):
- self.relay = self.options['relay']
+
if self.dvm_config.UPDATE_DATABASE:
await self.sync_db()
@@ -81,9 +82,10 @@ class SearchUser(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().database(database).signer(keys).build()
+ cli = ClientBuilder().database(database).signer(NostrSigner.keys(keys)).build()
- await cli.add_relay(self.relay)
+ for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
+ await cli.add_relay(relay)
# cli.add_relay("wss://atl.purplerelay.com")
await cli.connect()
@@ -95,13 +97,14 @@ class SearchUser(DVMTaskInterface):
events = await cli.database().query([filter1])
result_list = []
- print("Events: " + str(len(events)))
+ print("Events: " + str(len(events.to_vec())))
index = 0
- if len(events) > 0:
+ if len(events.to_vec()) > 0:
- for event in events:
+ for event in events.to_vec():
if index < options["max_results"]:
try:
+ searchterm = " " + options["search"].lower() + " "
if options["search"].lower() in event.content().lower():
p_tag = Tag.parse(["p", event.author().to_hex()])
#print(event.as_json())
@@ -140,10 +143,42 @@ class SearchUser(DVMTaskInterface):
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
database = NostrDatabase.lmdb(self.db_name)
- cli = ClientBuilder().signer(keys).database(database).build()
+ relaylimits = RelayLimits.disable()
+ opts = (Options().relay_limits(relaylimits))
+ if self.dvm_config.WOT_FILTERING:
+ opts = opts.filtering_mode(RelayFilteringMode.WHITELIST)
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).opts(opts).build()
- await cli.add_relay(self.relay)
+ for relay in self.dvm_config.SYNC_DB_RELAY_LIST:
+ await cli.add_relay(relay)
await cli.connect()
+ if self.dvm_config.WOT_FILTERING and self.wot_counter == 0:
+ print("Calculating WOT for " + str(self.dvm_config.WOT_BASED_ON_NPUBS))
+ filtering = cli.filtering()
+ index_map, G = await build_wot_network(self.dvm_config.WOT_BASED_ON_NPUBS,
+ depth=self.dvm_config.WOT_DEPTH, max_batch=500,
+ max_time_request=10, dvm_config=self.dvm_config)
+
+ # Do we actually need pagerank here?
+ # print('computing global pagerank...')
+ # tic = time.time()
+ # p_G = nx.pagerank(G, tol=1e-12)
+ # print("network after pagerank: " + str(len(p_G)))
+
+ wot_keys = []
+ for item in islice(G, len(G)):
+ key = next((PublicKey.parse(pubkey) for pubkey, id in index_map.items() if id == item),
+ None)
+ wot_keys.append(key)
+
+ # toc = time.time()
+ # print(f'finished in {toc - tic} seconds')
+ await filtering.add_public_keys(wot_keys)
+
+ self.wot_counter += 1
+ # only calculate wot every 10th call
+ if self.wot_counter >= 10:
+ self.wot_counter = 0
filter1 = Filter().kind(Kind(0))
@@ -169,10 +204,10 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/a99ab925084029d9468fef8330ff3d9be2cf67da473b024f2a6d48b5cd77197f.jpg",
+ "picture": "https://image.nostr.build/a99ab925084029d9468fef8330ff3d9be2cf67da473b024f2a6d48b5cd77197f.jpg",
"about": "I search users.",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": False,
"nip90Params": {
"users": {
"required": False,
@@ -198,13 +233,11 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
- options = {"relay": "wss://profiles.nostr1.com"}
-
return SearchUser(name=name, dvm_config=dvm_config, nip89config=nip89config,
- admin_config=admin_config, options=options)
+ admin_config=admin_config)
if __name__ == '__main__':
diff --git a/nostr_dvm/tasks/summarization_duckduck_ai.py b/nostr_dvm/tasks/summarization_duckduck_ai.py
index 74b6b1b..71b4524 100644
--- a/nostr_dvm/tasks/summarization_duckduck_ai.py
+++ b/nostr_dvm/tasks/summarization_duckduck_ai.py
@@ -120,15 +120,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
"about": "I summarize Text",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
"nip90Params": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
admin_config2 = AdminConfig()
admin_config2.REBROADCAST_NIP89 = False
diff --git a/nostr_dvm/tasks/summarization_huggingchat.py b/nostr_dvm/tasks/summarization_huggingchat.py
index 8aea328..0230b20 100644
--- a/nostr_dvm/tasks/summarization_huggingchat.py
+++ b/nostr_dvm/tasks/summarization_huggingchat.py
@@ -125,15 +125,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/720eadc9af89084bb09de659af43ad17fec1f4b0887084e83ac0ae708dfa83a6.png",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TextSummarizationHuggingChat(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/summarization_unleashed_chat.py b/nostr_dvm/tasks/summarization_unleashed_chat.py
index fffb175..8f91518 100644
--- a/nostr_dvm/tasks/summarization_unleashed_chat.py
+++ b/nostr_dvm/tasks/summarization_unleashed_chat.py
@@ -149,15 +149,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
admin_config2 = AdminConfig()
admin_config2.REBROADCAST_NIP89 = False
diff --git a/nostr_dvm/tasks/textextraction_google.py b/nostr_dvm/tasks/textextraction_google.py
index 04be3cb..88fe666 100644
--- a/nostr_dvm/tasks/textextraction_google.py
+++ b/nostr_dvm/tasks/textextraction_google.py
@@ -137,10 +137,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -149,7 +149,7 @@ def build_example(name, identifier, admin_config):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return SpeechToTextGoogle(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/textextraction_pdf.py b/nostr_dvm/tasks/textextraction_pdf.py
index 2f15b54..24ed3b6 100644
--- a/nostr_dvm/tasks/textextraction_pdf.py
+++ b/nostr_dvm/tasks/textextraction_pdf.py
@@ -100,15 +100,15 @@ def build_example(name, identifier, admin_config):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TextExtractionPDF(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config)
diff --git a/nostr_dvm/tasks/textextraction_whisperx.py b/nostr_dvm/tasks/textextraction_whisperx.py
index 910bd37..6c58abb 100644
--- a/nostr_dvm/tasks/textextraction_whisperx.py
+++ b/nostr_dvm/tasks/textextraction_whisperx.py
@@ -161,10 +161,10 @@ def build_example(name, identifier, admin_config, server_address):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -178,7 +178,7 @@ def build_example(name, identifier, admin_config, server_address):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return SpeechToTextWhisperX(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/textgeneration_huggingchat.py b/nostr_dvm/tasks/textgeneration_huggingchat.py
index 163a944..bdf2239 100644
--- a/nostr_dvm/tasks/textgeneration_huggingchat.py
+++ b/nostr_dvm/tasks/textgeneration_huggingchat.py
@@ -90,15 +90,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/720eadc9af89084bb09de659af43ad17fec1f4b0887084e83ac0ae708dfa83a6.png",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TextGenerationHuggingChat(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/textgeneration_llmlite.py b/nostr_dvm/tasks/textgeneration_llmlite.py
index ce33766..0cb3bb0 100644
--- a/nostr_dvm/tasks/textgeneration_llmlite.py
+++ b/nostr_dvm/tasks/textgeneration_llmlite.py
@@ -105,15 +105,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TextGenerationLLMLite(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config,
diff --git a/nostr_dvm/tasks/textgeneration_unleashed_chat.py b/nostr_dvm/tasks/textgeneration_unleashed_chat.py
index bb27229..b139d8f 100644
--- a/nostr_dvm/tasks/textgeneration_unleashed_chat.py
+++ b/nostr_dvm/tasks/textgeneration_unleashed_chat.py
@@ -113,15 +113,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg",
+ "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": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TextGenerationUnleashedChat(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/texttospeech.py b/nostr_dvm/tasks/texttospeech.py
index b90393a..29c838f 100644
--- a/nostr_dvm/tasks/texttospeech.py
+++ b/nostr_dvm/tasks/texttospeech.py
@@ -175,10 +175,10 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -188,7 +188,7 @@ def build_example(name, identifier, admin_config):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TextToSpeech(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config,
diff --git a/nostr_dvm/tasks/translation_google.py b/nostr_dvm/tasks/translation_google.py
index da112f0..63c016b 100644
--- a/nostr_dvm/tasks/translation_google.py
+++ b/nostr_dvm/tasks/translation_google.py
@@ -118,11 +118,11 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -143,7 +143,7 @@ def build_example(name, identifier, admin_config):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TranslationGoogle(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config)
diff --git a/nostr_dvm/tasks/translation_libretranslate.py b/nostr_dvm/tasks/translation_libretranslate.py
index e2fc33a..ace5b74 100644
--- a/nostr_dvm/tasks/translation_libretranslate.py
+++ b/nostr_dvm/tasks/translation_libretranslate.py
@@ -116,11 +116,11 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -141,7 +141,7 @@ def build_example(name, identifier, admin_config):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TranslationLibre(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/videogeneration_replicate_svd.py b/nostr_dvm/tasks/videogeneration_replicate_svd.py
index 92cb235..f4a7ef2 100644
--- a/nostr_dvm/tasks/videogeneration_replicate_svd.py
+++ b/nostr_dvm/tasks/videogeneration_replicate_svd.py
@@ -120,15 +120,15 @@ def build_example(name, identifier, admin_config):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "picture": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
"about": "I use Replicate to run StableDiffusion XL",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": False,
"nip90Params": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return VideoGenerationReplicateSVD(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/tasks/videogeneration_svd.py b/nostr_dvm/tasks/videogeneration_svd.py
index ce60455..ba40f9d 100644
--- a/nostr_dvm/tasks/videogeneration_svd.py
+++ b/nostr_dvm/tasks/videogeneration_svd.py
@@ -108,14 +108,14 @@ def build_example(name, identifier, admin_config, server_address):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return VideoGenerationSVD(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/nostr_dvm/utils/database_utils.py b/nostr_dvm/utils/database_utils.py
index a9abad0..6ce7ba9 100644
--- a/nostr_dvm/utils/database_utils.py
+++ b/nostr_dvm/utils/database_utils.py
@@ -1,11 +1,15 @@
# DATABASE LOGIC
import json
+import os
+import pathlib
+import shutil
import sqlite3
from dataclasses import dataclass
from logging import Filter
from sqlite3 import Error
+from tkinter.filedialog import Directory
-from nostr_sdk import Timestamp, Keys, PublicKey, Filter, Kind
+from nostr_sdk import Timestamp, Keys, PublicKey, Filter, Kind, make_private_msg, NostrSigner, NostrDatabase
from nostr_dvm.utils.definitions import relay_timeout
from nostr_dvm.utils.nostr_utils import send_nip04_dm
@@ -192,7 +196,8 @@ async def update_user_balance(db, npub, additional_sats, client, config, giftwra
# always send giftwrapped. sorry not sorry.
#if giftwrap:
- await client.send_private_msg(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)
@@ -245,6 +250,30 @@ async def get_or_add_user(db, npub, client, config, update=False, skip_meta=Fals
return user
+async def init_db(database, wipe=False, limit=1000, print_filesize=True):
+ # LMDB can't grow smaller, so by using this function we can wipe the database on init to avoid
+ # it growing too big. If wipe is set to true, the database will be deleted once the size is above the limit param.
+ database_content = database + "/data.mdb"
+ if os.path.isfile(database_content):
+ file_stats = os.stat(database_content)
+ sizeinmb = file_stats.st_size / (1024 * 1024)
+ if print_filesize:
+ print("Filesize of database \"" + database + "\": " + str(sizeinmb) + " Mb.")
+
+ if wipe and sizeinmb > limit:
+ try:
+ shutil.rmtree(database)
+ print("Removed database due to large file size. Waiting for resync")
+ except OSError as e:
+ print("Error: %s - %s." % (e.filename, e.strerror))
+ else:
+ print("Creating database: " + database)
+
+
+ return NostrDatabase.lmdb(database)
+
+
+
async def fetch_user_metadata(npub, client):
name = ""
nip05 = ""
diff --git a/nostr_dvm/utils/external_dvm_utils.py b/nostr_dvm/utils/external_dvm_utils.py
index 6cdc961..0f8c106 100644
--- a/nostr_dvm/utils/external_dvm_utils.py
+++ b/nostr_dvm/utils/external_dvm_utils.py
@@ -12,7 +12,7 @@ from nostr_dvm.utils.output_utils import PostProcessFunctionType
async def build_client(config):
keys = Keys.parse(config.PRIVATE_KEY)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in config.RELAY_LIST:
await client.add_relay(relay)
@@ -44,24 +44,26 @@ def build_external_dvm(pubkey, task, kind, fix_cost, per_unit_cost, config,
nip89content = json.loads(nip89content_str)
if nip89content.get("name"):
name = nip89content.get("name")
- if nip89content.get("image"):
+ if nip89content.get("picture"):
+ image = nip89content.get("picture")
+ elif nip89content.get("image"):
image = nip89content.get("image")
if nip89content.get("about"):
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,
- "image": image,
+ "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/gallery_utils.py b/nostr_dvm/utils/gallery_utils.py
index 8147431..6bb25eb 100644
--- a/nostr_dvm/utils/gallery_utils.py
+++ b/nostr_dvm/utils/gallery_utils.py
@@ -7,7 +7,7 @@ from nostr_dvm.utils.print_utils import bcolors
async def gallery_announce_list(tags, dvm_config, client):
keys = Keys.parse(dvm_config.NIP89.PK)
content = ""
- event = EventBuilder(Kind(10011), content, tags).sign_with_keys(keys)
+ event = EventBuilder(Kind(10011), content).tags(tags).sign_with_keys(keys)
eventid = await send_event(event, client=client, dvm_config=dvm_config)
print(
diff --git a/nostr_dvm/utils/nip65_utils.py b/nostr_dvm/utils/nip65_utils.py
index 8797651..55c4791 100644
--- a/nostr_dvm/utils/nip65_utils.py
+++ b/nostr_dvm/utils/nip65_utils.py
@@ -15,9 +15,9 @@ async def announce_dm_relays(dvm_config, client):
keys = Keys.parse(dvm_config.NIP89.PK)
content = ""
- event = EventBuilder(Kind(10050), content, tags).sign_with_keys(keys)
+ event = EventBuilder(Kind(10050), content).tags(tags).sign_with_keys(keys)
eventid = await send_event(event, client=client, dvm_config=dvm_config)
- if (eventid is not None):
+ if eventid is not None:
print(
bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced DM relays for " + dvm_config.NIP89.NAME + " (EventID: " + str(
eventid.id.to_hex()) + ")" + bcolors.ENDC)
@@ -39,9 +39,9 @@ async def nip65_announce_relays(dvm_config, client):
keys = Keys.parse(dvm_config.NIP89.PK)
content = ""
- event = EventBuilder(EventDefinitions.KIND_RELAY_ANNOUNCEMENT, content, tags).sign_with_keys(keys)
+ event = EventBuilder(EventDefinitions.KIND_RELAY_ANNOUNCEMENT, content).tags(tags).sign_with_keys(keys)
eventid = await send_event(event, client=client, dvm_config=dvm_config)
- if (eventid is not None):
+ if eventid is not None:
print(
bcolors.BLUE + "[" + dvm_config.NIP89.NAME + "] Announced NIP 65 for " + dvm_config.NIP89.NAME + " (EventID: " + str(
eventid.id.to_hex()) + ")" + bcolors.ENDC)
diff --git a/nostr_dvm/utils/nip88_utils.py b/nostr_dvm/utils/nip88_utils.py
index 199dda2..6760dbd 100644
--- a/nostr_dvm/utils/nip88_utils.py
+++ b/nostr_dvm/utils/nip88_utils.py
@@ -83,7 +83,7 @@ async def nip88_delete_announcement(eid: str, keys: Keys, dtag: str, client: Cli
e_tag = Tag.parse(["e", eid])
a_tag = Tag.parse(
["a", str(EventDefinitions.KIND_NIP88_TIER_EVENT) + ":" + keys.public_key().to_hex() + ":" + dtag])
- event = EventBuilder(Kind(5), "", [e_tag, a_tag]).sign_with_keys(keys)
+ event = EventBuilder(Kind(5), "").tags([e_tag, a_tag]).sign_with_keys(keys)
await send_event(event, client, config)
@@ -130,7 +130,7 @@ async def nip88_has_active_subscription(user: PublicKey, tiereventdtag, client:
async def nip88_announce_tier(dvm_config, client):
title_tag = Tag.parse(["title", str(dvm_config.NIP88.TITLE)])
- image_tag = Tag.parse(["image", str(dvm_config.NIP88.IMAGE)])
+ image_tag = Tag.parse(["picture", str(dvm_config.NIP88.IMAGE)])
d_tag = Tag.parse(["d", dvm_config.NIP88.DTAG])
# zap splits. Feel free to change this for your DVM
@@ -176,7 +176,7 @@ async def nip88_announce_tier(dvm_config, client):
keys = Keys.parse(dvm_config.NIP89.PK)
content = dvm_config.NIP88.CONTENT
- event = EventBuilder(EventDefinitions.KIND_NIP88_TIER_EVENT, content, tags).sign_with_keys(keys)
+ event = EventBuilder(EventDefinitions.KIND_NIP88_TIER_EVENT, content).tags(tags).sign_with_keys(keys)
annotier_id = await send_event(event, client=client, dvm_config=dvm_config)
if dvm_config.NIP89 is not None:
diff --git a/nostr_dvm/utils/nip89_utils.py b/nostr_dvm/utils/nip89_utils.py
index 3234c47..9dd92da 100644
--- a/nostr_dvm/utils/nip89_utils.py
+++ b/nostr_dvm/utils/nip89_utils.py
@@ -29,7 +29,7 @@ async def nip89_announce_tasks(dvm_config, client):
d_tag = Tag.parse(["d", dvm_config.NIP89.DTAG])
keys = Keys.parse(dvm_config.NIP89.PK)
content = dvm_config.NIP89.CONTENT
- event = EventBuilder(EventDefinitions.KIND_ANNOUNCEMENT, content, [k_tag, d_tag]).sign_with_keys(keys)
+ event = EventBuilder(EventDefinitions.KIND_ANNOUNCEMENT, content).tags([k_tag, d_tag]).sign_with_keys(keys)
eventid = await send_event(event, client=client, dvm_config=dvm_config)
print(
@@ -65,7 +65,7 @@ async def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Cli
e_tag = Tag.parse(["e", eid])
a_tag = Tag.parse(
["a", str(EventDefinitions.KIND_ANNOUNCEMENT.as_u16()) + ":" + keys.public_key().to_hex() + ":" + dtag])
- event = EventBuilder(Kind(5), "", [e_tag, a_tag]).sign_with_keys(keys)
+ event = EventBuilder(Kind(5), "").tags([e_tag, a_tag]).sign_with_keys(keys)
print(f"POW event: {event.as_json()}")
await send_event(event, client, config)
@@ -74,7 +74,7 @@ async def nip89_delete_announcement_pow(eid: str, keys: Keys, dtag: str, client:
e_tag = Tag.parse(["e", eid])
a_tag = Tag.parse(
["a", str(EventDefinitions.KIND_ANNOUNCEMENT.as_u16()) + ":" + keys.public_key().to_hex() + ":" + dtag])
- event = EventBuilder(Kind(5), "", [e_tag, a_tag]).pow(28).sign_with_keys(keys)
+ event = EventBuilder(Kind(5), "").tags([e_tag, a_tag]).pow(28).sign_with_keys(keys)
print(f"POW event: {event.as_json()}")
await send_event(event, client, config)
diff --git a/nostr_dvm/utils/nip98_utils.py b/nostr_dvm/utils/nip98_utils.py
index d1f3cf3..ed0c7eb 100644
--- a/nostr_dvm/utils/nip98_utils.py
+++ b/nostr_dvm/utils/nip98_utils.py
@@ -17,7 +17,7 @@ async def generate_nip98_header(pkeys_hex, url="", kind="POST", filepath=""):
if kind == "POST":
payloadtag = Tag.parse(["payload", sha256sum(filepath)])
tags.append(payloadtag)
- eb = EventBuilder(Kind(27235), "", tags)
+ eb = EventBuilder(Kind(27235), "").tags(tags)
event = eb.sign_with_keys(keys)
encoded_nip98_event = base64.b64encode(event.as_json().encode('utf-8')).decode('utf-8')
diff --git a/nostr_dvm/utils/nostr_utils.py b/nostr_dvm/utils/nostr_utils.py
index 9b432de..72f52d8 100644
--- a/nostr_dvm/utils/nostr_utils.py
+++ b/nostr_dvm/utils/nostr_utils.py
@@ -5,9 +5,9 @@ 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, \
- Nip19Event, SingleLetterTag, RelayLimits, SecretKey, NostrSigner, Connection, ConnectionTarget, \
- EventSource, EventBuilder, Kind
+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
from nostr_dvm.utils.definitions import EventDefinitions, relay_timeout
@@ -33,8 +33,7 @@ async def get_event_by_id(event_id_str: str, client: Client, config=None) -> Eve
async def get_events_async(client, filter, timeout):
- source_l = EventSource.relays(timedelta(seconds=timeout))
- events = await client.fetch_events([filter], source_l)
+ events = await client.fetch_events([filter], timedelta(seconds=timeout))
return events.to_vec()
@@ -176,14 +175,14 @@ async def get_main_relays(event_to_send: Event, client: Client, dvm_config):
content = json.loads(followlist.content())
relays = []
for relay in content:
- if relay not in dvm_config.AVOID_OUTBOX_RELAY_LIST:
+ if relay.rstrip("/") not in dvm_config.AVOID_OUTBOX_RELAY_LIST:
relays.append(relay)
return relays
except:
return []
-async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
+async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput | None:
# 1. OK, Let's overcomplicate things.
# 2. If our event has a relays tag, we just send the event to these relay in the classical way.
relays = []
@@ -208,6 +207,9 @@ async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
print("[" + dvm_config.NIP89.NAME + "] No Inbox found, replying to generic relays")
relays = await get_main_relays(event, client, dvm_config)
+
+ if len(relays) == 0:
+ return
# eventid = await send_event(event, client, dvm_config)
# return eventid
@@ -215,10 +217,10 @@ async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
relaylimits = RelayLimits.disable()
connection = Connection().embedded_tor().target(ConnectionTarget.ONION)
# connection = Connection().addr("127.0.0.1:9050").target(ConnectionTarget.ONION)
- opts = Options().relay_limits(relaylimits).connection(connection).connection_timeout(timedelta(seconds=30))
+ opts = Options().relay_limits(relaylimits).connection(connection).timeout(timedelta(seconds=5))
sk = SecretKey.from_hex(dvm_config.PRIVATE_KEY)
keys = Keys.parse(sk.to_hex())
- outboxclient = Client.with_opts(keys, opts)
+ outboxclient = ClientBuilder().signer(NostrSigner.keys(keys)).opts(opts).build()
print("[" + dvm_config.NIP89.NAME + "] Receiver Inbox relays: " + str(relays))
for relay in relays[:5]:
@@ -236,32 +238,23 @@ async def send_event_outbox(event: Event, client, dvm_config) -> EventId:
event_id = None
print(e)
- for relay in relays[:5]:
- try:
- await outboxclient.force_remove_relay(relay)
- except:
- print("Error removing relay: " + relay)
-
# 5. Fallback, if we couldn't send the event to any relay, we try to send to generic relays instead.
if event_id is None:
relays = await get_main_relays(event, client, dvm_config)
+ if len(relays) == 0:
+ return None
for relay in relays:
await outboxclient.add_relay(relay)
try:
await outboxclient.connect()
event_id = await outboxclient.send_event(event)
- for relay in relays:
- try:
- await outboxclient.force_remove_relay(relay)
- except:
- print("Error removing relay: " + relay)
except Exception as e:
# Love yourself then.
event_id = None
print(e)
- await outboxclient.remove_all_relays()
- await outboxclient.disconnect()
+
await outboxclient.shutdown()
+
return event_id
@@ -302,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':
@@ -316,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())
@@ -331,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):
@@ -351,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())
@@ -368,7 +376,7 @@ def check_and_decrypt_own_tags(event, dvm_config):
async def update_profile_lnaddress(private_key, dvm_config, lud16="", ):
keys = Keys.parse(private_key)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in dvm_config.RELAY_LIST:
await client.add_relay(relay)
await client.connect()
@@ -386,7 +394,7 @@ async def update_profile(dvm_config, client, lud16=""):
nip89content = json.loads(dvm_config.NIP89.CONTENT)
name = nip89content.get("name")
about = nip89content.get("about")
- image = nip89content.get("image")
+ image = nip89content.get("picture")
# Set metadata
metadata = Metadata() \
@@ -413,7 +421,7 @@ async def send_nip04_dm(client: Client, msg, receiver: PublicKey, dvm_config):
keys = Keys.parse(dvm_config.PRIVATE_KEY)
content = await keys.nip04_encrypt(receiver, msg)
ptag = Tag.parse(["p", receiver.to_hex()])
- event = EventBuilder(Kind(4), content, [ptag]).sign_with_keys(Keys.parse(dvm_config.PRIVATE_KEY))
+ event = EventBuilder(Kind(4), content).tags([ptag]).sign_with_keys(Keys.parse(dvm_config.PRIVATE_KEY))
await client.send_event(event)
# relays = await get_dm_relays(event, client, dvm_config)
diff --git a/nostr_dvm/utils/nut_wallet_utils.py b/nostr_dvm/utils/nut_wallet_utils.py
index 240a47f..450c42b 100644
--- a/nostr_dvm/utils/nut_wallet_utils.py
+++ b/nostr_dvm/utils/nut_wallet_utils.py
@@ -6,10 +6,10 @@ from datetime import timedelta
import requests
from nostr_sdk import Tag, Keys, nip44_encrypt, nip44_decrypt, Nip44Version, EventBuilder, Client, Filter, Kind, \
- EventId, nip04_decrypt, nip04_encrypt, PublicKey, Metadata
+ EventId, nip04_decrypt, nip04_encrypt, PublicKey, Metadata, NostrSigner
from nostr_dvm.utils.database_utils import fetch_user_metadata
-from nostr_dvm.utils.definitions import EventDefinitions, relay_timeout, relay_timeout_long
+from nostr_dvm.utils.definitions import EventDefinitions
from nostr_dvm.utils.dvmconfig import DVMConfig
from nostr_dvm.utils.nostr_utils import check_and_set_private_key
from nostr_dvm.utils.print_utils import bcolors
@@ -52,7 +52,7 @@ class NutZapWallet:
async def client_connect(self, relay_list, keys):
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -103,7 +103,7 @@ class NutZapWallet:
relay_tag = Tag.parse(["relay", relay])
tags.append(relay_tag)
- event = EventBuilder(EventDefinitions.KIND_NUT_WALLET, content, tags).sign_with_keys(keys)
+ event = EventBuilder(EventDefinitions.KIND_NUT_WALLET, content).tags(tags).sign_with_keys(keys)
send_response = await client.send_event(event)
print(
@@ -327,7 +327,7 @@ class NutZapWallet:
p_tag = Tag.parse(["p", sender_hex])
tags.append(p_tag)
- event = EventBuilder(Kind(7376), content, tags).sign_with_keys(keys)
+ event = EventBuilder(Kind(7376), content).tags(tags).sign_with_keys(keys)
eventid = await client.send_event(event)
async def create_unspent_proof_event(self, nut_wallet: NutWallet, mint_proofs, mint_url, amount, direction, marker,
@@ -373,7 +373,7 @@ class NutZapWallet:
else:
content = nip44_encrypt(keys.secret_key(), keys.public_key(), message, Nip44Version.V2)
- event = EventBuilder(Kind(7375), content, tags).sign_with_keys(keys)
+ event = EventBuilder(Kind(7375), content).tags(tags).sign_with_keys(keys)
eventid = await client.send_event(event)
await self.create_transaction_history_event(nut_wallet, amount, nut_wallet.unit, old_event_id, eventid.id,
direction, marker, sender_hex, event_hex, client, keys)
@@ -436,7 +436,7 @@ class NutZapWallet:
pubkey = Keys.parse(nut_wallet.privkey).public_key().to_hex()
tags.append(Tag.parse(["pubkey", pubkey]))
- event = EventBuilder(Kind(10019), "", tags).sign_with_keys(keys)
+ event = EventBuilder(Kind(10019), "").tags(tags).sign_with_keys(keys)
eventid = await client.send_event(event)
print(
bcolors.CYAN + "[" + nut_wallet.name + "] Announced mint preferences info event (" + eventid.id.to_hex() + ")" + bcolors.ENDC)
@@ -624,7 +624,7 @@ class NutZapWallet:
}
tags.append(Tag.parse(["proof", json.dumps(nut_proof)]))
- event = EventBuilder(Kind(9321), comment, tags).sign_with_keys(keys)
+ event = EventBuilder(Kind(9321), comment).tags(tags).sign_with_keys(keys)
response = await client.send_event(event)
await self.update_spend_mint_proof_event(nut_wallet, proofs, mint_url, "zapped", keys.public_key().to_hex(),
diff --git a/nostr_dvm/utils/outbox_utils.py b/nostr_dvm/utils/outbox_utils.py
index 4627d91..7ba0497 100644
--- a/nostr_dvm/utils/outbox_utils.py
+++ b/nostr_dvm/utils/outbox_utils.py
@@ -2,28 +2,34 @@
# even trying to send to them, avoiding potential errors or delays on the way.
-AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://relay.primal.net",
- "wss://nostrelay.yeghro.site", "wss://nostr.wine", "wss://filter.nostr.wine",
+AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://nostr.fmt.wiz.biz", "wss://nostrelay.yeghro.site", "wss://nostr.wine",
+ "wss://filter.nostr.wine", "wss://relay.lightwork.space", "wss://onchain.pub",
"wss://nostr21.com", "wss://nostr.bitcoiner.social", "wss://nostr.orangepill.dev",
- "wss://brb.io",
+ "wss://brb.io", "wss://relay.nostr.ch", "wss://nostr.rock", "wss://nostr.sandwich.farm",
+ "wss://nostr.onsats.org", "wss://nostr-pub.semisol.dev", "wss://no.str.cr",
+ "wss://nostr.zebedee.cloud", "wss://blg.nostr.sx", "wss://relay.nostr.ai",
+ "wss://nostr.600.wtf", "ws://umbrel.local:4848", "wss://192.168.1.52:5051",
+ "wss://nostrvista.aaroniumii.com", "wss://https//nostr.einundzwanzig.space",
+ "wss://nostr.localhost.re", "wss://shopstr.store", "wss://th1.nostr.earnkrub.xyz",
"wss://relay.lnpay.me", "wss://relay.snort.social", "wss://relay.minds.com/nostr/v1/ws",
- "ws://elitedesk:4848",
+ "ws://elitedesk:4848", "wss://wot.nostr.net", "wss://blg.nostr.sx",
"wss://nostr-pub.semisol.dev", "wss://mostr.mostr.pub", "wss://relay.mostr.pub",
- "wss://minds.com",
+ "wss://minds.com", "wss://nostr.leximaster.com", "wss://th2.nostr.earnkrub.xyz",
+ "wss://relay.zerosatoshi.xyz", "wss://bouncer.minibolt.info",
"wss://yabu.me", "wss://relay.yozora.world", "wss://filter.nostr.wine/?global=all",
- "wss://eden.nostr.land",
+ "wss://eden.nostr.land", "wss://relay.otherstuff.fyi",
"wss://relay.orangepill.ovh", "wss://nostr.jcloud.es", "wss://af.purplerelay.com",
- "wss://za.purplerelay.com", "ws://192.168.18.7:7777",
+ "wss://za.purplerelay.com", "ws://192.168.18.7:7777", "wss://nostr.fediverse.jp",
"wss://relay.nostrich.land", "wss://relay.nostrplebs.com", "wss://relay.nostrich.land",
- "ws://elitedesk.local:4848",
+ "ws://elitedesk.local:4848", "wss://nrelay-jp.c-stellar.net", "wss://blastr.f7z.xyz",
"wss://rss.nos.social", "wss://atlas.nostr.land", "wss://puravida.nostr.land",
- "wss://nostr.inosta.cc",
+ "wss://nostr.inosta.cc", "wss://relay-jp.nostr.wirednet.jp",
"wss://relay.orangepill.dev", "wss://no.str.cr", "wss://nostr.milou.lol",
- "wss://relay.nostr.com.au",
+ "wss://relay.nostr.com.au", "wss://nostrelites.com", "wss://sfr0.nostr1.com",
"wss://puravida.nostr.land", "wss://atlas.nostr.land", "wss://nostr-pub.wellorder.net",
- "wss://relay.current.fyi",
+ "wss://relay.current.fyi", "wss://nfrelay.app",
"wss://nostr.thesamecat.io", "wss://nostr.plebchain.org", "wss://relay.noswhere.com",
- "wss://nostr.uselessshit.co",
+ "wss://nostr.uselessshit.co", "wss://tictac.nostr1.com", "wss://abcdefg20240104205400.xyz/v1",
"wss://bitcoiner.social", "wss://relay.stoner.com", "wss://nostr.l00p.org",
"wss://relay.nostr.ro", "wss://nostr.kollider.xyz",
"wss://relay.valera.co", "wss://relay.austrich.net", "wss://relay.nostrich.de",
@@ -48,14 +54,14 @@ AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://relay.primal.net",
"wss://relay.nostreggs.io", "wss://relay.blackbyte.nl", "ws://localhost:8080",
"wss://127.0.0.1:4869", "wss://sendit.nosflare.io",
"wss://astral.ninja", "wss://nostr.libertasprimordium.com", "wss://relay.shitforce.one",
- "wss://nostr.cro.social",
+ "wss://nostr.cro.social", "wss://datagrave.wild-vibes.ts.net/nostr", "wss://nostr01.sharkshake.net",
"wss://relay.nostreggs.io", "wss://nostr.rocks", "wss://groups.0xchat.com",
"wss://bostr.lecturify.net", "wss://dave.st.germa.in/nostr",
"wss://dvms.f7z.io", "wss://nostr.social", "wss://i.nostr.build",
- "wss://teemie1-relay.duckdns.org",
+ "wss://teemie1-relay.duckdns.org", "wss://newperspectives.duckdns.org",
"wss://nostrs.build", "wss://relay.hllo.live", "wss://relay-pub.deschooling.us",
"wss://nostr.sandwich.farm", "wss://nostr.lol", "wss://nostr.developer.li",
- "wss://paid.spore.ws",
+ "wss://paid.spore.ws", "ws://relay.damus.io",
"ws://ofotwjuiv7t6q4azt2fjx3qo7esglmxdeqmh2qvdsdnxw5eqgza24iyd.onion", "wss://r.kojira.io",
"wss://nostr-relay.h3z.jp", "wss://relay.yozora.world",
"wss://nostr.0xtr.dev", "wss://purplepeg.es", "wss://nostr.mutinywallet.com",
@@ -71,7 +77,17 @@ AVOID_OUTBOX_RELAY_LIST = ["wss://nos.lol", "wss://relay.primal.net",
"wss://nostream-production-5895.up.railway.app",
"ws://127.0.0.1:4869", "wss://sign.siamstr.com", "wss://relay.hash.stream",
"wss://pablof7z.nostr1.com", "wss://nostr.beckmeyer.us", "wss://pow.hzrd149.com",
- "wss://relay.nostrss.re", "wss://relay.nostr.bg", "ws://bugman.mguy.net:4848"
+ "wss://relay.nostrss.re", "wss://relay.nostr.bg", "ws://bugman.mguy.net:4848",
+ "wss://nostr-2.zebedee.cloud", "wss://nostr.lorentz.is", "wss://zap.nostr1.com",
+ "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://dreamofthe90s.nostr1.com",
+ "wss://lnbits.eldamar.icu/nostrrelay/relay", "wss://nostr.olwe.link",
+ "wss://nostr.cheeserobot.org",
+
+
+
]
diff --git a/nostr_dvm/utils/output_utils.py b/nostr_dvm/utils/output_utils.py
index 6a2f9dc..c91b0cb 100644
--- a/nostr_dvm/utils/output_utils.py
+++ b/nostr_dvm/utils/output_utils.py
@@ -318,7 +318,7 @@ async def send_job_status_reaction(original_event_id_hex, original_event_author_
content = reaction
keys = Keys.parse(dvm_config.PRIVATE_KEY)
- reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content), reply_tags).sign_with_keys(keys)
+ reaction_event = EventBuilder(EventDefinitions.KIND_FEEDBACK, str(content)).tags(reply_tags).sign_with_keys(keys)
await send_event_outbox(reaction_event, client=client, dvm_config=dvm_config)
if dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
diff --git a/nostr_dvm/utils/reaction_utils.py b/nostr_dvm/utils/reaction_utils.py
index 94cd038..5d5798f 100644
--- a/nostr_dvm/utils/reaction_utils.py
+++ b/nostr_dvm/utils/reaction_utils.py
@@ -21,9 +21,9 @@ async def create_reaction(keys, title, dtag):
keys = Keys.parse(keys)
content = ""
- event = EventBuilder(Kind(30030), content, [d_tag, title_tag] + emoji_tags).sign_with_keys(keys)
+ event = EventBuilder(Kind(30030), content).tags([d_tag, title_tag] + emoji_tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
# We add the relays we defined above and told our DVM we would want to receive events to.
for relay in DVMConfig().RELAY_LIST:
await client.add_relay(relay)
@@ -42,9 +42,9 @@ async def delete_reaction(keys, eid: str, dtag: str):
e_tag = Tag.parse(["e", eid])
a_tag = Tag.parse(
["a", "30030:" + keys.public_key().to_hex() + ":" + dtag])
- event = EventBuilder(Kind(5), "", [e_tag, a_tag]).sign_with_keys(keys)
+ event = EventBuilder(Kind(5), "").tags([e_tag, a_tag]).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
# We add the relays we defined above and told our DVM we would want to receive events to.
for relay in DVMConfig().RELAY_LIST:
await client.add_relay(relay)
diff --git a/nostr_dvm/utils/wot_utils.py b/nostr_dvm/utils/wot_utils.py
index 25a395d..8e100c2 100644
--- a/nostr_dvm/utils/wot_utils.py
+++ b/nostr_dvm/utils/wot_utils.py
@@ -46,7 +46,7 @@ async def get_following(pks, max_time_request=10, newer_than_time=None, dvm_conf
# fetching events
keys = Keys.parse(check_and_set_private_key("test_client"))
- cli = ClientBuilder().signer(keys).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).build()
for relay in dvm_config.SYNC_DB_RELAY_LIST:
await cli.add_relay(relay)
@@ -586,7 +586,7 @@ async def get_metadata(npub):
except:
return "", "", ""
keys = Keys.parse(check_and_set_private_key("test_client"))
- client = ClientBuilder().signer(keys).build()
+ client = ClientBuilder().signer(NostrSigner.keys(keys)).build()
await client.add_relay("wss://relay.damus.io")
await client.add_relay("wss://purplepag.es")
await client.connect()
diff --git a/nostr_dvm/utils/zap_utils.py b/nostr_dvm/utils/zap_utils.py
index 50dcf94..06b6cd5 100644
--- a/nostr_dvm/utils/zap_utils.py
+++ b/nostr_dvm/utils/zap_utils.py
@@ -304,8 +304,7 @@ def zaprequest(lud16: str, amount: int, content, zapped_event, zapped_user, keys
tags = [p_tag]
if zapped_event is not None:
tags.append(e_tag)
- zap_request = EventBuilder(Kind(9733), content,
- tags).sign_with_keys(keys).as_json()
+ zap_request = EventBuilder(Kind(9733), content).tags(tags).sign_with_keys(keys).as_json()
keys = Keys.parse(encryption_key)
if zapped_event is not None:
encrypted_content = enrypt_private_zap_message(zap_request, keys.secret_key(), zapped_event.author())
@@ -316,8 +315,7 @@ def zaprequest(lud16: str, amount: int, content, zapped_event, zapped_user, keys
tags.append(anon_tag)
content = ""
- zap_request = EventBuilder(Kind(9734), content,
- tags).sign_with_keys(keys).as_json()
+ zap_request = EventBuilder(Kind(9734), content).tags(tags).sign_with_keys(keys).as_json()
response = requests.get(callback + "?amount=" + str(int(amount) * 1000) + "&nostr=" + urllib.parse.quote_plus(
zap_request) + "&lnurl=" + encoded_lnurl)
diff --git a/setup.py b/setup.py
index 54dc80a..d346c06 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
-VERSION = '0.9.11'
+VERSION = '0.9.12'
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')
@@ -14,7 +14,7 @@ setup(
long_description=LONG_DESCRIPTION,
packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']),
- install_requires=["nostr-sdk==0.36.0",
+ install_requires=["nostr-sdk==0.37.0",
"bech32==1.2.0",
"pycryptodome==3.20.0",
"yt-dlp==2024.11.04",
diff --git a/tests/chat_bot.py b/tests/chat_bot.py
index d89194f..2f2d812 100644
--- a/tests/chat_bot.py
+++ b/tests/chat_bot.py
@@ -47,17 +47,17 @@ def playground(announce = False):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
"about": "I'm briding DuckDuckAI'",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
"nip90Params": {
}
}
nip89config = NIP89Config()
nip89config.KIND = kind
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {
diff --git a/tests/dalle.py b/tests/dalle.py
index 9f4c9db..6ff8901 100644
--- a/tests/dalle.py
+++ b/tests/dalle.py
@@ -35,10 +35,10 @@ def build_dalle(name, identifier):
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
nip89info = {
"name": name,
- "image": "https://image.nostr.build/22f2267ca9d4ee9d5e8a0c7818a9fa325bbbcdac5573a60a2d163e699bb69923.jpg",
+ "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,
@@ -48,7 +48,7 @@ def build_dalle(name, identifier):
}
nip89config = NIP89Config()
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
aconfig = AdminConfig()
aconfig.REBROADCAST_NIP89 = False # We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
diff --git a/tests/db.py b/tests/db.py
index 1fea844..93a663e 100644
--- a/tests/db.py
+++ b/tests/db.py
@@ -32,7 +32,7 @@ async def do_some_work():
f = Filter().author(keys.public_key()).limit(10)
events = await database.query([f])
- for event in events:
+ for event in events.to_vec():
print(event.as_json())
nostr_dvm_thread = Thread(target=reconcile_db)
diff --git a/tests/discovery.py b/tests/discovery.py
index 16a5f06..93f8b70 100644
--- a/tests/discovery.py
+++ b/tests/discovery.py
@@ -1,6 +1,7 @@
import asyncio
import json
import os
+import shutil
import threading
from pathlib import Path
@@ -22,6 +23,7 @@ from nostr_dvm.tasks.content_discovery_latest_one_per_follower import Discoverla
from nostr_dvm.tasks.content_discovery_update_db_only import DicoverContentDBUpdateScheduler
from nostr_dvm.tasks.discovery_trending_notes_nostrband import TrendingNotesNostrBand
from nostr_dvm.utils.admin_utils import AdminConfig
+from nostr_dvm.utils.database_utils import init_db
from nostr_dvm.utils.dvmconfig import build_default_config, DVMConfig
from nostr_dvm.utils.nip88_utils import NIP88Config, check_and_set_d_tag_nip88, check_and_set_tiereventid_nip88
from nostr_dvm.utils.nip89_utils import create_amount_tag, NIP89Config, check_and_set_d_tag
@@ -36,7 +38,7 @@ update_profile = False
global_update_rate = 180 # set this high on first sync so db can fully sync before another process trys to.
use_logger = True
log_level = LogLevel.ERROR
-max_sync_duration_in_h = 48
+max_sync_duration_in_h = 24
SYNC_DB_RELAY_LIST = ["wss://relay.damus.io",
#"wss://relay.primal.net",
@@ -75,12 +77,11 @@ def build_db_scheduler(name, identifier, admin_config, options, image, descripti
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -93,7 +94,7 @@ def build_db_scheduler(name, identifier, admin_config, options, image, descripti
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentDBUpdateScheduler(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -118,12 +119,11 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -136,7 +136,7 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularGallery(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
@@ -156,16 +156,15 @@ def build_example_nostrband(name, identifier, admin_config, image, about, custom
nip89info = {
"name": name,
- "image": image,
"picture": image,
"about": about,
"amount": "Free",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
"nip90Params": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TrendingNotesNostrBand(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -196,12 +195,11 @@ def build_longform(name, identifier, admin_config, options, cost=0, update_rate=
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -214,7 +212,7 @@ def build_longform(name, identifier, admin_config, options, cost=0, update_rate=
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -249,12 +247,11 @@ def build_wiki(name, identifier, admin_config, options, cost=0, update_rate=180,
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -267,7 +264,7 @@ def build_wiki(name, identifier, admin_config, options, cost=0, update_rate=180,
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -298,12 +295,11 @@ def build_example_topic(name, identifier, admin_config, options, image, descript
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -316,7 +312,7 @@ def build_example_topic(name, identifier, admin_config, options, image, descript
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -341,12 +337,11 @@ def build_example_popular(name, identifier, admin_config, options, image, cost=0
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -359,7 +354,7 @@ def build_example_popular(name, identifier, admin_config, options, image, cost=0
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopular(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
@@ -385,12 +380,11 @@ def build_example_popular_followers(name, identifier, admin_config, options, ima
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -403,7 +397,7 @@ def build_example_popular_followers(name, identifier, admin_config, options, ima
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularFollowers(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -421,7 +415,7 @@ def build_example_popular_non_followers(name, identifier, admin_config, options,
dvm_config.UPDATE_DATABASE = update_db
dvm_config.DATABASE = database
# Activate these to use a subscription based model instead
- dvm_config.FIX_COST = 10
+ dvm_config.FIX_COST = cost
dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg
dvm_config.AVOID_OUTBOX_RELAY_LIST = AVOID_OUTBOX_RELAY_LIST
dvm_config.SYNC_DB_RELAY_LIST = SYNC_DB_RELAY_LIST
@@ -435,14 +429,14 @@ def build_example_popular_non_followers(name, identifier, admin_config, options,
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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),
"nip90Params": {
"max_results": {
"required": False,
@@ -453,14 +447,14 @@ def build_example_popular_non_followers(name, identifier, admin_config, options,
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
@@ -501,12 +495,11 @@ def build_example_top_zapped(name, identifier, admin_config, options, image, cos
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -519,7 +512,7 @@ def build_example_top_zapped(name, identifier, admin_config, options, image, cos
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -550,12 +543,11 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -568,7 +560,7 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularMostr(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
@@ -593,12 +585,11 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -611,31 +602,30 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return Discoverlatestperfollower(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
-async def init_db(database):
- return NostrDatabase.lmdb(database)
-
-
def playground():
main_db = "db/nostr_recent_notes.db"
- DATABASE = asyncio.run(init_db(main_db))
+ main_db_limit = 1024 # in mb
+
+ DATABASE = asyncio.run(init_db(main_db, wipe=True, limit=main_db_limit, print_filesize=True))
# DB Scheduler, do not announce, just use it to update the DB for the other DVMs.
admin_config_db_scheduler = AdminConfig()
- options_animal = {
+ options_db = {
"db_name": main_db,
"db_since": max_sync_duration_in_h * 60 * 60, # 48h since gmt,
"personalized": False,
+ "max_db_size" : main_db_limit,
"logger": False}
image = ""
about = "I just update the Database based on my schedule"
db_scheduler = build_db_scheduler("DB Scheduler",
"db_scheduler",
- admin_config_db_scheduler, options_animal,
+ admin_config_db_scheduler, options_db,
image=image,
description=about,
update_rate=global_update_rate,
@@ -887,10 +877,10 @@ def playground():
options_animal = {
"search_list": ["catstr", "pawstr", "dogstr", "pugstr", " cat ", " cats ", "doggo", " deer ", " dog ", " dogs ",
" fluffy ",
- "animal",
+ " animal",
" duck", " lion ", " lions ", " fox ", " foxes ", " koala ", " koalas ", "capybara", "squirrel",
- " monkey", "panda", "alpaca", " otter"],
- "avoid_list": ["porn", "smoke", "nsfw", "bitcoin", "bolt12", "bolt11", "github", "currency", "utxo",
+ " monkey", " panda", "alpaca", " otter"],
+ "avoid_list": ["porn", "broth", "smoke", "nsfw", "bitcoin", "bolt12", "bolt11", "github", "currency", "utxo",
"encryption", "government", "airpod", "ipad", "iphone", "android", "warren",
"moderna", "pfizer", " meat ", "pc mouse", "shotgun", "vagina", "rune", "testicle", "victim",
"sexualize", "murder", "tax", "engagement", "hodlers", "hodl", "gdp", "global markets", "crypto",
@@ -909,7 +899,7 @@ def playground():
"must_list": ["http"],
"db_name": "db/nostr_recent_notes.db",
- "db_since": 12 * 60 * 60, # 48h since gmt,
+ "db_since": 24 * 60 * 60, # 48h since gmt,
"personalized": False,
"logger": False}
@@ -1031,7 +1021,7 @@ def playground():
"db_name": "db/nostr_recent_notes.db",
"db_since": 2 * 60 * 60, # 2h since gmt,
}
- cost = 0
+ cost = 10
image = "https://i.nostr.build/l11EczDmpZBaxlRm.jpg"
discovery_non_followers = build_example_popular_non_followers(
diff --git a/tests/discovery_custom_feed.py b/tests/discovery_custom_feed.py
index 679aaac..bb3dda6 100644
--- a/tests/discovery_custom_feed.py
+++ b/tests/discovery_custom_feed.py
@@ -46,12 +46,11 @@ def build_example_topic(name, identifier, admin_config, options, image, descript
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -79,7 +78,7 @@ def build_example_topic(name, identifier, admin_config, options, image, descript
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config,
diff --git a/tests/discovery_gallery.py b/tests/discovery_gallery.py
index 618ca4b..9396909 100644
--- a/tests/discovery_gallery.py
+++ b/tests/discovery_gallery.py
@@ -37,12 +37,11 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -55,7 +54,7 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularGallery(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
diff --git a/tests/discovery_mostr.py b/tests/discovery_mostr.py
index 29e6153..3057395 100644
--- a/tests/discovery_mostr.py
+++ b/tests/discovery_mostr.py
@@ -51,12 +51,11 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -69,7 +68,7 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularMostr(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
diff --git a/tests/discovery_one_per_follow.py b/tests/discovery_one_per_follow.py
index b230ffd..6b0c312 100644
--- a/tests/discovery_one_per_follow.py
+++ b/tests/discovery_one_per_follow.py
@@ -40,12 +40,11 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -58,7 +57,7 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return Discoverlatestperfollower(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
diff --git a/tests/discovery_people.py b/tests/discovery_people.py
index 4d91656..e3adf27 100644
--- a/tests/discovery_people.py
+++ b/tests/discovery_people.py
@@ -45,12 +45,11 @@ def build_example_wot(name, identifier, admin_config, options, image, cost=0, up
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -63,7 +62,7 @@ def build_example_wot(name, identifier, admin_config, options, image, cost=0, up
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DiscoverPeopleMyWOT(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
diff --git a/tests/discovery_test.py b/tests/discovery_test.py
index aee8b64..7aea172 100644
--- a/tests/discovery_test.py
+++ b/tests/discovery_test.py
@@ -72,12 +72,11 @@ def build_db_scheduler(name, identifier, admin_config, options, image, descripti
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -90,7 +89,7 @@ def build_db_scheduler(name, identifier, admin_config, options, image, descripti
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentDBUpdateScheduler(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -115,12 +114,11 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -133,7 +131,7 @@ def build_example_gallery(name, identifier, admin_config, options, image, cost=0
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularGallery(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
@@ -152,16 +150,15 @@ def build_example_nostrband(name, identifier, admin_config, image, about, custom
nip89info = {
"name": name,
- "image": image,
"picture": image,
"about": about,
"amount": "Free",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
"nip90Params": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return TrendingNotesNostrBand(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -191,12 +188,11 @@ def build_longform(name, identifier, admin_config, options, cost=0, update_rate=
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -209,7 +205,7 @@ def build_longform(name, identifier, admin_config, options, cost=0, update_rate=
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -243,12 +239,11 @@ def build_wiki(name, identifier, admin_config, options, cost=0, update_rate=180,
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -261,7 +256,7 @@ def build_wiki(name, identifier, admin_config, options, cost=0, update_rate=180,
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -289,12 +284,11 @@ def build_example_topic(name, identifier, admin_config, options, image, descript
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -307,7 +301,7 @@ def build_example_topic(name, identifier, admin_config, options, image, descript
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularbyTopic(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -331,12 +325,11 @@ def build_example_popular(name, identifier, admin_config, options, image, cost=0
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -349,7 +342,7 @@ def build_example_popular(name, identifier, admin_config, options, image, cost=0
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopular(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
@@ -372,12 +365,11 @@ def build_example_popular_followers(name, identifier, admin_config, options, ima
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -390,7 +382,7 @@ def build_example_popular_followers(name, identifier, admin_config, options, ima
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularFollowers(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -421,12 +413,11 @@ def build_example_popular_non_followers(name, identifier, admin_config, options,
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -439,14 +430,14 @@ def build_example_popular_non_followers(name, identifier, admin_config, options,
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
nip88config = NIP88Config()
- nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip88config.DTAG = check_and_set_d_tag_nip88(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip88config.TIER_EVENT = check_and_set_tiereventid_nip88(identifier, "1")
nip89config.NAME = name
- nip88config.IMAGE = nip89info["image"]
+ nip88config.IMAGE = nip89info["picture"]
nip88config.TITLE = name
nip88config.AMOUNT_DAILY = 100
nip88config.AMOUNT_MONTHLY = 2000
@@ -484,12 +475,11 @@ def build_example_top_zapped(name, identifier, admin_config, options, image, cos
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -502,7 +492,7 @@ def build_example_top_zapped(name, identifier, admin_config, options, image, cos
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# admin_config.UPDATE_PROFILE = False
@@ -532,12 +522,11 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -550,7 +539,7 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DicoverContentCurrentlyPopularMostr(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
@@ -573,12 +562,11 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c
# Add NIP89
nip89info = {
"name": name,
- "image": image,
"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": {
@@ -591,7 +579,7 @@ def build_example_oneperfollow(name, identifier, admin_config, options, image, c
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return Discoverlatestperfollower(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config, options=options)
diff --git a/tests/ditto.py b/tests/ditto.py
index dd80ba2..f9dbc31 100644
--- a/tests/ditto.py
+++ b/tests/ditto.py
@@ -17,7 +17,7 @@ async def main():
}
keys = Keys.parse(check_and_set_private_key("test_client"))
- cli = Client(keys)
+ cli = Client(NostrSigner.keys(keys))
await cli.add_relay(options["relay"])
await cli.connect()
diff --git a/tests/generic_dvm.py b/tests/generic_dvm.py
index 915f470..1b8d481 100644
--- a/tests/generic_dvm.py
+++ b/tests/generic_dvm.py
@@ -24,16 +24,16 @@ def playground(announce=False):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "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": {
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {
diff --git a/tests/generic_dvm_autotopic_feed.py b/tests/generic_dvm_autotopic_feed.py
index 656f2c6..ee8d6fd 100644
--- a/tests/generic_dvm_autotopic_feed.py
+++ b/tests/generic_dvm_autotopic_feed.py
@@ -79,17 +79,17 @@ def playground(announce=False):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://i.nostr.build/I8fJo0n355cbNEbS.png", # "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "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": {
}
}
nip89config = NIP89Config()
nip89config.KIND = Kind(kind)
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {
@@ -183,11 +183,11 @@ def playground(announce=False):
events = await database.query(filters)
if dvm.dvm_config.LOGLEVEL.value >= LogLevel.DEBUG.value:
- print("[" + dvm.dvm_config.NIP89.NAME + "] Considering " + str(len(events)) + " Events")
+ print("[" + dvm.dvm_config.NIP89.NAME + "] Considering " + str(len(events.to_vec())) + " Events")
ns.finallist = {}
#search_list = result.split(',')
- for event in events:
+ for event in events.to_vec():
#if all(ele in event.content().lower() for ele in []):
#if not any(ele in event.content().lower() for ele in []):
filt = Filter().kinds(
@@ -195,8 +195,8 @@ def playground(announce=False):
definitions.EventDefinitions.KIND_REPOST,
definitions.EventDefinitions.KIND_NOTE]).event(event.id()).since(since)
reactions = await database.query([filt])
- if len(reactions) >= 1:
- ns.finallist[event.id().to_hex()] = len(reactions)
+ if len(reactions.to_vec()) >= 1:
+ ns.finallist[event.id().to_hex()] = len(reactions.to_vec())
result_list = []
finallist_sorted = sorted(ns.finallist.items(), key=lambda x: x[1], reverse=True)[:int(200)]
diff --git a/tests/generic_dvm_duck_chat.py b/tests/generic_dvm_duck_chat.py
index 5cbc172..dbb4c13 100644
--- a/tests/generic_dvm_duck_chat.py
+++ b/tests/generic_dvm_duck_chat.py
@@ -44,17 +44,17 @@ def playground(announce=False):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
"about": "I'm briding DuckDuckAI'",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
"nip90Params": {
}
}
nip89config = NIP89Config()
nip89config.KIND = kind
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {
diff --git a/tests/generic_dvm_flux_hf.py b/tests/generic_dvm_flux_hf.py
index e61c5bc..8fed4d9 100644
--- a/tests/generic_dvm_flux_hf.py
+++ b/tests/generic_dvm_flux_hf.py
@@ -49,17 +49,17 @@ def playground(announce=False):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "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": {
}
}
nip89config = NIP89Config()
nip89config.KIND = kind
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {
diff --git a/tests/otherstuff.py b/tests/otherstuff.py
index 1c7780b..ae140b2 100644
--- a/tests/otherstuff.py
+++ b/tests/otherstuff.py
@@ -58,10 +58,10 @@ def build_sd35(name, identifier, announce):
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
nip89info = {
"name": name,
- "image": "https://i.nostr.build/NOXcCIPmOZrDTK35.jpg",
+ "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,
@@ -75,7 +75,7 @@ def build_sd35(name, identifier, announce):
}
nip89config = NIP89Config()
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
aconfig = AdminConfig()
aconfig.REBROADCAST_NIP89 = announce # We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
@@ -107,10 +107,10 @@ def build_dalle(name, identifier, announce):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/22f2267ca9d4ee9d5e8a0c7818a9fa325bbbcdac5573a60a2d163e699bb69923.jpg",
+ "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,
@@ -121,7 +121,7 @@ def build_dalle(name, identifier, announce):
nip89config = NIP89Config()
nip89config.DTAG = nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
@@ -143,16 +143,16 @@ def build_svd(name, identifier, announce):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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": {}
}
nip89config = NIP89Config()
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
# We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
return VideoGenerationReplicateSVD(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -170,10 +170,10 @@ def build_media_converter(name, identifier, announce):
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
nip89info = {
"name": name,
- "image": "https://cdn.nostr.build/i/a177be1159da5aad8396a1188f686728d55647d3a7371549584daf2b5e50eec9.jpg",
+ "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,
@@ -183,7 +183,7 @@ def build_media_converter(name, identifier, announce):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return MediaConverter(name=name, dvm_config=dvm_config, nip89config=nip89config,
admin_config=admin_config)
@@ -204,10 +204,10 @@ def build_inactive_follows_finder(name, identifier, announce):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/50621bbf8082c478bc06a06684e1c443b5d37f1362ad56d679cab7328e0481db.jpg",
+ "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,
@@ -225,7 +225,7 @@ def build_inactive_follows_finder(name, identifier, announce):
nip89config = NIP89Config()
nip89config.DTAG = nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DiscoverInactiveFollows(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -244,10 +244,10 @@ def build_1984(name, identifier, announce):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/19872a2edd866258fa9eab137631efda89310d52b2c6ea8f99ef057325aa1c7b.jpg",
+ "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": {
@@ -258,7 +258,7 @@ def build_1984(name, identifier, announce):
}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return DiscoverReports(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -279,10 +279,10 @@ def build_botfarms(name, identifier, announce):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/981b560820bc283c58de7989b7abc6664996b487a531d852e4ef7322586a2122.jpg",
+ "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": {
@@ -294,7 +294,7 @@ def build_botfarms(name, identifier, announce):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
options = {"relay": "wss://relay.damus.io"}
@@ -317,10 +317,10 @@ def build_replicate(name, identifier, model, announce):
nip89info = {
"name": name,
- "image": "https://i.nostr.build/qnoBIN4jSkfF8IHk.png",
+ "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,
@@ -330,7 +330,7 @@ def build_replicate(name, identifier, model, announce):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
opts = {"model": model}
@@ -354,10 +354,10 @@ def build_replicate_recraft(name, identifier, announce):
nip89info = {
"name": name,
- "image": "https://i.nostr.build/jSbrXvYglXCzSeAc.jpg",
+ "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,
@@ -367,7 +367,7 @@ def build_replicate_recraft(name, identifier, announce):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
@@ -389,10 +389,10 @@ def build_replicate_fluxpro(name, identifier, announce):
nip89info = {
"name": name,
- "image": "https://i.nostr.build/AQTujqzVmLxLmG16.jpg",
+ "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,
@@ -402,7 +402,7 @@ def build_replicate_fluxpro(name, identifier, announce):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
diff --git a/tests/sd35_api.py b/tests/sd35_api.py
index cef26e9..257afb1 100644
--- a/tests/sd35_api.py
+++ b/tests/sd35_api.py
@@ -33,10 +33,10 @@ def build_sd35(name, identifier):
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
nip89info = {
"name": name,
- "image": "https://i.nostr.build/NOXcCIPmOZrDTK35.jpg",
+ "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,
@@ -50,7 +50,7 @@ def build_sd35(name, identifier):
}
nip89config = NIP89Config()
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
aconfig = AdminConfig()
aconfig.REBROADCAST_NIP89 = False # We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
diff --git a/tests/search.py b/tests/search.py
index a3bef47..07e5629 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
@@ -61,10 +62,10 @@ def build_advanced_search(name, identifier):
nip89info = {
"name": name,
- "image": "https://nostr.band/android-chrome-192x192.png",
+ "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,
@@ -90,7 +91,7 @@ def build_advanced_search(name, identifier):
}
nip89config = NIP89Config()
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
return AdvancedSearch(name=name, dvm_config=dvm_config, nip89config=nip89config,
@@ -101,7 +102,7 @@ def build_advanced_search_wine(name, identifier):
dvm_config.PRIVATE_KEY = check_and_set_private_key(identifier)
npub = Keys.parse(dvm_config.PRIVATE_KEY).public_key().to_bech32()
dvm_config.RELAY_LIST = RELAY_LIST
- invoice_key, admin_key, wallet_id, user_id, lnaddress = check_and_set_ln_bits_keys(identifier, npub)
+ invoice_key, admin_key, wallet_id, lnaddress = check_and_set_ln_bits_keys(identifier, npub)
dvm_config.LNBITS_INVOICE_KEY = invoice_key
dvm_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
dvm_config.LNBITS_URL = os.getenv("LNBITS_HOST")
@@ -117,10 +118,10 @@ def build_advanced_search_wine(name, identifier):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/d844d6a963724b9f9deb6b3326984fd95352343336718812424d5e99d93a6f2d.jpg",
+ "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,
@@ -147,7 +148,7 @@ def build_advanced_search_wine(name, identifier):
nip89config = NIP89Config()
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
- nip89info["image"])
+ nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
@@ -158,11 +159,11 @@ def build_advanced_search_wine(name, identifier):
def build_user_search(name, identifier):
dvm_config = build_default_config(identifier)
- dvm_config.SYNC_DB_RELAY_LIST = ["wss://relay.damus.io"]
+ dvm_config.SYNC_DB_RELAY_LIST = SYNC_DB_RELAY_LIST
dvm_config.AVOID_OUTBOX_RELAY_LIST = AVOID_OUTBOX_RELAY_LIST
dvm_config.RELAY_LIST = RELAY_LIST
+ dvm_config.WOT_FILTERING = True
npub = Keys.parse(dvm_config.PRIVATE_KEY).public_key().to_bech32()
- dvm_config.RELAY_LIST = RELAY_LIST
invoice_key, admin_key, wallet_id, lnaddress = check_and_set_ln_bits_keys(identifier, npub)
admin_config = AdminConfig()
admin_config.REBROADCAST_NIP89 = rebroadcast_NIP89
@@ -173,10 +174,10 @@ def build_user_search(name, identifier):
# Add NIP89
nip89info = {
"name": name,
- "image": "https://image.nostr.build/bd0181a3089181f1d92a5da1ef85cffbe37ba80fbcc695b9d85648dc2fa92583.jpg",
+ "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,
@@ -187,13 +188,11 @@ def build_user_search(name, identifier):
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
- options = {"relay": "wss://profiles.nostr1.com"}
-
return SearchUser(name=name, dvm_config=dvm_config, nip89config=nip89config,
- admin_config=admin_config, options=options)
+ admin_config=admin_config)
@@ -208,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 59ffe8d..3e020d1 100644
--- a/tests/simplebot.py
+++ b/tests/simplebot.py
@@ -20,7 +20,7 @@ async def test():
pk = keys.public_key()
print(f"Bot public key: {pk.to_bech32()}")
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
await client.add_relay("wss://relay.damus.io")
await client.add_relay("wss://nostr.mom")
@@ -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 f8a58f9..7f74233 100644
--- a/tests/summarization_duck.py
+++ b/tests/summarization_duck.py
@@ -22,15 +22,15 @@ def playground(announce=False):
nip89info = {
"name": name,
- "image": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
+ "picture": "https://image.nostr.build/28da676a19841dcfa7dcf7124be6816842d14b84f6046462d2a3f1268fe58d03.png",
"about": "I summarize Text",
- "encryptionSupported": True,
- "cashuAccepted": True,
+ "supportsEncryption": True,
+ "acceptsNutZaps": dvm_config.ENABLE_NUTZAP,
"nip90Params": {}
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
diff --git a/tests/test_dvm_client.py b/tests/test_dvm_client.py
index 92acf9e..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
@@ -27,13 +27,13 @@ async def nostr_client_test_translation(input, kind, lang, sats, satsmax):
relaysTag = Tag.parse(['relays', "wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"])
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to translate a given Input"])
- event = EventBuilder(EventDefinitions.KIND_NIP90_TRANSLATE_TEXT, str("Translate the given input."),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_TRANSLATE_TEXT, str("Translate the given input.")).tags(
[iTag, paramTag1, bidTag, relaysTag, alttag]).sign_with_keys(keys)
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"]
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
@@ -48,13 +48,13 @@ async def nostr_client_test_search_profile(input):
iTag = Tag.parse(["i", input, "text"])
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to translate a given Input"])
- event = EventBuilder(EventDefinitions.KIND_NIP90_USER_SEARCH, str("Search for user"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_USER_SEARCH, str("Search for user")).tags(
[iTag, alttag]).sign_with_keys(keys)
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"]
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
@@ -74,10 +74,10 @@ async def nostr_client_test_image(prompt):
bidTag = Tag.parse(['bid', str(1000 * 1000), str(1000 * 1000)])
relaysTag = Tag.parse(['relays', "wss://relay.primal.net", "wss://nostr.oxtr.dev"])
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to generate an Image from a given Input"])
- event = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_IMAGE, str("Generate an Image."),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_IMAGE, str("Generate an Image.")).tags(
[iTag, outTag, paramTag1, bidTag, relaysTag, alttag]).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in DVMConfig().RELAY_LIST:
await client.add_relay(relay)
await client.connect()
@@ -102,10 +102,10 @@ async def nostr_client_test_censor_filter(users):
iTag = Tag.parse(["i", user, "text"])
tags.append(iTag)
- event = EventBuilder(EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY, str("Give me bad actors"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY, str("Give me bad actors")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -127,10 +127,10 @@ async def nostr_client_test_inactive_filter(user):
tags = [relaysTag, alttag, paramTag, paramTag2]
- event = EventBuilder(EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY, str("Give me inactive users"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY, str("Give me inactive users")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.add_relay("wss://nostr.band")
@@ -150,13 +150,13 @@ async def nostr_client_test_tts(prompt):
relaysTag = Tag.parse(['relays', "wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
"wss://nostr-pub.wellorder.net"])
alttag = Tag.parse(["alt", "This is a NIP90 DVM AI task to generate TTSt"])
- event = EventBuilder(EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH, str("Generate an Audio File."),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_TEXT_TO_SPEECH, str("Generate an Audio File.")).tags(
[iTag, paramTag1, bidTag, relaysTag, alttag]).sign_with_keys(keys)
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org" "wss://dvms.f7z.io",
]
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -178,10 +178,10 @@ async def nostr_client_test_discovery(user, ptag):
tags = [relaysTag, alttag, paramTag, pTag]
- event = EventBuilder(EventDefinitions.KIND_NIP90_CONTENT_DISCOVERY, str("Give me content"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_CONTENT_DISCOVERY, str("Give me content")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
@@ -215,10 +215,10 @@ async def nostr_client_custom_discovery(user, ptag):
tags = [relaysTag, alttag, paramTag, pTag]# paramTagSearch, paramTagMust, paramTagAvoid]
- event = EventBuilder(EventDefinitions.KIND_NIP90_CONTENT_DISCOVERY, str("Give me content"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_CONTENT_DISCOVERY, str("Give me content")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
@@ -241,10 +241,10 @@ async def nostr_client_generic_test(ptag):
tags = [relaysTag, alttag, pTag]
- event = EventBuilder(Kind(5050), str("Give me content"),
+ event = EventBuilder(Kind(5050), str("Give me content")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -267,10 +267,10 @@ async def nostr_client_duckduck_test(ptag, query):
tags = [relaysTag, alttag, pTag, iTag]
- event = EventBuilder(Kind(5050), str("Give me content"),
+ event = EventBuilder(Kind(5050), str("Give me content")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -291,10 +291,10 @@ async def nostr_client_flux_schnell(ptag, query):
tags = [relaysTag, alttag, pTag, iTag]
- event = EventBuilder(Kind(5100), str("Give me image"),
+ event = EventBuilder(Kind(5100), str("Give me image")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
ropts = RelayOptions().ping(False)
@@ -319,10 +319,10 @@ async def nostr_client_test_discovery_user(user, ptag):
tags = [relaysTag, alttag, paramTag, pTag]
- event = EventBuilder(EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY, str("Give me people"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY, str("Give me people")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -344,10 +344,10 @@ async def nostr_client_test_discovery_gallery(user, ptag):
tags = [relaysTag, alttag, paramTag, pTag]
- event = EventBuilder(EventDefinitions.KIND_NIP90_VISUAL_DISCOVERY, str("Give me visuals"),
+ event = EventBuilder(EventDefinitions.KIND_NIP90_VISUAL_DISCOVERY, str("Give me visuals")).tags(
tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -377,14 +377,14 @@ 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,
+ nip90request = EventBuilder(EventDefinitions.KIND_NIP90_GENERATE_IMAGE, encrypted_params).tags(
[pTag, encrypted_tag]).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -398,7 +398,7 @@ async def nostr_client():
sk = keys.secret_key()
pk = keys.public_key()
print(f"Nostr Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
dvmconfig = DVMConfig()
for relay in dvmconfig.RELAY_LIST:
diff --git a/tests/test_events.py b/tests/test_events.py
index 77fd4a4..260780e 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -17,7 +17,7 @@ from nostr_dvm.utils.nostr_utils import check_and_set_private_key
async def test():
relay_list = dvmconfig.DVMConfig.RELAY_LIST
keys = Keys.parse(check_and_set_private_key("test_client"))
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
@@ -71,7 +71,7 @@ async def test_gallery():
relay_list = dvmconfig.DVMConfig.RELAY_LIST
keys = Keys.parse(check_and_set_private_key("test_client"))
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
diff --git a/tests/tts.py b/tests/tts.py
index 4c6f7c4..83bb929 100644
--- a/tests/tts.py
+++ b/tests/tts.py
@@ -32,10 +32,10 @@ if __name__ == '__main__':
options = {'input_file': ""}
nip89info = {
"name": name,
- "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
+ "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,
@@ -45,7 +45,7 @@ if __name__ == '__main__':
}
nip89config = NIP89Config()
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
tts = TextToSpeech(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config_tts,
options=options)
diff --git a/tests/wot.py b/tests/wot.py
index 4eba286..d4204ef 100644
--- a/tests/wot.py
+++ b/tests/wot.py
@@ -27,7 +27,7 @@ async def getmetadata(npub):
except:
return "", "", ""
keys = Keys.parse("nsec1zmzllu40a7mr7ztl78uwfwslnp0pn0pww868adl05x52d4la237s6m8qfj")
- client = ClientBuilder().signer(keys).build()
+ client = ClientBuilder().signer(NostrSigner.keys(keys)).build()
await client.add_relay("wss://relay.damus.io")
#await client.add_relay("wss://relay.primal.net")
await client.add_relay("wss://purplepag.es")
@@ -54,7 +54,7 @@ async def getmetadata(npub):
async def sync_db():
keys = Keys.parse("nsec1zmzllu40a7mr7ztl78uwfwslnp0pn0pww868adl05x52d4la237s6m8qfj")
database = NostrDatabase.lmdb("db/nostr_followlists.db")
- cli = ClientBuilder().signer(keys).database(database).build()
+ cli = ClientBuilder().signer(NostrSigner.keys(keys)).database(database).build()
await cli.add_relay("wss://relay.damus.io") # TODO ADD MORE
# await cli.add_relay("wss://relay.primal.net") # TODO ADD MORE
@@ -86,8 +86,8 @@ async def analyse_users(user_ids=None):
followers_filter = Filter().authors(user_keys).kind(Kind(3))
followers = await database.query([followers_filter])
allfriends = []
- if len(followers) > 0:
- for follower in followers:
+ if len(followers.to_vec()) > 0:
+ for follower in followers.to_vec():
frens = []
for tag in follower.tags().to_vec():
if tag.as_vec()[0] == "p":
diff --git a/tutorials/03_client.py b/tutorials/03_client.py
index d8951a5..671da81 100644
--- a/tutorials/03_client.py
+++ b/tutorials/03_client.py
@@ -36,10 +36,10 @@ async def nostr_client_generic_test(ptag):
# We now send a 5050 Request (for Text Generation) with our tags. The content is optional.
event = EventBuilder(Kind(5050), "This is a test",
- tags).sign_with_keys(keys)
+ ).tags(tags).sign_with_keys(keys)
# We create a signer with some random keys
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
# We add the relays we defined above and told our DVM we would want to receive events to.
for relay in relay_list:
await client.add_relay(relay)
@@ -57,7 +57,7 @@ async def nostr_client(target_dvm_npub):
sk = keys.secret_key()
pk = keys.public_key()
print(f"Nostr Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
dvmconfig = DVMConfig()
for relay in dvmconfig.RELAY_LIST:
diff --git a/tutorials/05_announce_dvm.py b/tutorials/05_announce_dvm.py
index 1bbc3ba..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,
@@ -72,7 +72,7 @@ def run_dvm(identifier, announce):
# We set a d tag. We need the dtag so if we want to update or delete the announcement, relays know which event is meant
# You can choose a dtag you like. Here we build a hash from identiier, name, key and image and store it in the .env file.
# So even if you change the name or image, it will now use the dtag from the env file until you delete it.
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
# We dump the nip89info struct from above to the content
nip89config.CONTENT = json.dumps(nip89info)
diff --git a/tutorials/06_dvm_config.py b/tutorials/06_dvm_config.py
index 44229f4..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,
@@ -131,7 +131,7 @@ def run_dvm(identifier, announce):
# We now create or Nip89Config object
nip89config = NIP89Config()
nip89config.KIND = kind
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
diff --git a/tutorials/07_admin_config.py b/tutorials/07_admin_config.py
index 9eee2bd..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,
@@ -106,7 +106,7 @@ def run_dvm(identifier, announce):
# We now create or Nip89Config object
nip89config = NIP89Config()
nip89config.KIND = kind
- nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
+ nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["picture"])
nip89config.CONTENT = json.dumps(nip89info)
diff --git a/tutorials/09_nutzap_client.py b/tutorials/09_nutzap_client.py
index 69ec6f8..0bbbd38 100644
--- a/tutorials/09_nutzap_client.py
+++ b/tutorials/09_nutzap_client.py
@@ -31,9 +31,9 @@ async def nostr_client_generic_test(ptag):
pTag = Tag.parse(["p", PublicKey.parse(ptag).to_hex()])
tags = [relaysTag, alttag, pTag, paramTag]
event = EventBuilder(Kind(5050), "This is a test",
- tags).sign_with_keys(keys)
+ ).tags(tags).sign_with_keys(keys)
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
for relay in relay_list:
await client.add_relay(relay)
await client.connect()
@@ -46,7 +46,7 @@ async def nostr_client(target_dvm_npub):
keys = Keys.parse(check_and_set_private_key("test_client"))
pk = keys.public_key()
print(f"Nostr Client public key: {pk.to_bech32()}, Hex: {pk.to_hex()} ")
- client = Client(keys)
+ client = Client(NostrSigner.keys(keys))
dvmconfig = DVMConfig()
for relay in dvmconfig.RELAY_LIST:
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 () => {