Merge pull request #1878 from RoboSats/fix-tests-review

Fix tests review
This commit is contained in:
KoalaSat
2025-04-26 16:50:44 +00:00
committed by GitHub
2 changed files with 4 additions and 17 deletions

View File

@ -4,7 +4,7 @@ import uuid
from secp256k1 import PrivateKey from secp256k1 import PrivateKey
from asgiref.sync import sync_to_async from asgiref.sync import sync_to_async
from nostr_sdk import Keys, Client, EventBuilder, NostrSigner, Kind, Tag, PublicKey from nostr_sdk import Keys, Client, EventBuilder, NostrSigner, Kind, Tag
from api.models import Order from api.models import Order
from decouple import config from decouple import config
@ -115,13 +115,6 @@ class Nostr:
return ["lightning"] return ["lightning"]
return False return False
def is_valid_public_key(public_key_hex):
try:
PublicKey.from_hex(public_key_hex)
return True
except Exception:
return False
def sign_message(text: str) -> str: def sign_message(text: str) -> str:
try: try:
keys = Keys.parse(config("NOSTR_NSEC", cast=str)) keys = Keys.parse(config("NOSTR_NSEC", cast=str))

View File

@ -1066,15 +1066,9 @@ class ReviewView(APIView):
status.HTTP_400_BAD_REQUEST, status.HTTP_400_BAD_REQUEST,
) )
if not request.user.robot.nostr_pubkey: if not request.user.robot.nostr_pubkey:
verified = Nostr.is_valid_public_key(pubkey) request.user.robot.nostr_pubkey = pubkey
if verified: request.user.robot.save(update_fields=["nostr_pubkey"])
request.user.robot.nostr_pubkey = pubkey
request.user.robot.save(update_fields=["nostr_pubkey"])
else:
return Response(
{"bad_request": "Invalid hex pubkey"},
status.HTTP_400_BAD_REQUEST,
)
if request.user.robot.nostr_pubkey != pubkey: if request.user.robot.nostr_pubkey != pubkey:
return Response( return Response(
{"bad_request": "Wrong hex pubkey"}, {"bad_request": "Wrong hex pubkey"},