it's zappening.

This commit is contained in:
Believethehype
2023-11-26 21:47:33 +01:00
parent fe054c76db
commit 15284f5944
5 changed files with 116 additions and 95 deletions

View File

@@ -45,6 +45,7 @@ def parse_zap_event_tags(zap_event, keys, name, client, config):
zapped_event = None
invoice_amount = 0
anon = False
message = ""
sender = zap_event.pubkey()
for tag in zap_event.tags():
@@ -59,7 +60,7 @@ def parse_zap_event_tags(zap_event, keys, name, client, config):
for z_tag in zap_request_event.tags():
if z_tag.as_vec()[0] == 'anon':
if len(z_tag.as_vec()) > 1:
print("[" + name + "] Private Zap received.")
#print("[" + name + "] Private Zap received.")
decrypted_content = decrypt_private_zap_message(z_tag.as_vec()[1],
keys.secret_key(),
zap_request_event.pubkey())
@@ -67,14 +68,14 @@ def parse_zap_event_tags(zap_event, keys, name, client, config):
if decrypted_private_event.kind() == 9733:
sender = decrypted_private_event.pubkey().to_hex()
message = decrypted_private_event.content()
if message != "":
print("Zap Message: " + message)
#if message != "":
# print("Zap Message: " + message)
else:
anon = True
print(
"[" + name + "] Anonymous Zap received. Unlucky, I don't know from whom, and never will")
return invoice_amount, zapped_event, sender, anon
return invoice_amount, zapped_event, sender, message, anon
def create_bolt11_ln_bits(sats: int, config: DVMConfig) -> (str, str):
@@ -142,10 +143,6 @@ def enrypt_private_zap_message(message, privatekey, publickey):
encrypted_msg_bech32 = bech32_encode("pzap", convertbits(encrypted_msg, 8, 5, True))
iv_bech32 = bech32_encode("iv", convertbits(iv, 8, 5, True))
print("Encrypted Message:", encrypted_msg_bech32)
print("IV:", iv_bech32)
return encrypted_msg_bech32 + "_" + iv_bech32