Skip to content

Commit

Permalink
Variable cleanup (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
UTXOnly authored Mar 26, 2024
1 parent ae9ba59 commit 1d51736
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
Empty file removed src/lnurl.py
Empty file.
17 changes: 7 additions & 10 deletions src/nostr.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def parse_tags(self, logger):

def create_event(self, kind_number, logger):
kind_9735_tags = self.parse_tags(logger)
content = ""
#content = ""
event_id = self.calc_event_id(
self.pubkey, self.created_at, kind_number, kind_9735_tags, content
self.pubkey, self.created_at, kind_number, kind_9735_tags, content=""
)
signature_hex = self.sign_event_id(event_id, self.privkey)
event_data = {
Expand All @@ -60,10 +60,9 @@ def create_event(self, kind_number, logger):
"kind": kind_number,
"created_at": self.created_at,
"tags": kind_9735_tags,
"content": content,
"content": '',#content,
"sig": signature_hex,
}

return event_data

def verify_signature(self, event_id: str, pubkey: str, sig: str, logger) -> bool:
Expand All @@ -86,13 +85,11 @@ def send_event(self, ws_relay, logger):
ws = create_connection(ws_relay)
logger.info(f"WebSocket connection created with {ws_relay}")
event_data = self.create_event(9735, logger)
sig = event_data["sig"]
id = event_data["id"]
signature_valid = self.verify_signature(id, self.pubkey, sig, logger)
signature_valid = self.verify_signature(event_data["id"], self.pubkey, event_data["sig"], logger)
if signature_valid:
event_json = json.dumps(("EVENT", event_data))
ws.send(event_json)
logger.debug(f"Event sent to {ws_relay}: {event_json}")
json_event = json.dumps(("EVENT", event_data))
ws.send(json_event)
logger.debug(f"Event sent to {ws_relay}: {json_event}")
else:
logger.error("Invalid signature, event not sent.")
ws.close()
Expand Down
4 changes: 1 addition & 3 deletions src/zap_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
import os
import socket
import time
import urllib.parse
import threading
import asyncio

import requests
import socks
from dotenv import load_dotenv
from ddtrace import tracer, patch_all
from nostr import NostpyClient
from flask import Flask, jsonify, request, after_this_request
from flask import Flask, jsonify, request


app = Flask(__name__)
Expand Down

0 comments on commit 1d51736

Please sign in to comment.