From b80f2f8e4d6c325b9d39a8cd297bd79f2fd85db0 Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Fri, 19 Aug 2022 16:47:33 -0600 Subject: [PATCH] error handling if bad input data in db --- lnbits/extensions/boltcards/views_api.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lnbits/extensions/boltcards/views_api.py b/lnbits/extensions/boltcards/views_api.py index d1f3cb39..2271f150 100644 --- a/lnbits/extensions/boltcards/views_api.py +++ b/lnbits/extensions/boltcards/views_api.py @@ -117,11 +117,14 @@ async def api_scane(p, c, request: Request): # so I try one by one until decrypted uid matches for cand in await get_all_cards(): if cand.k1: - card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(cand.k1)) + try: + card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(cand.k1)) - if card_uid.hex().upper() == cand.uid: - card = cand - break + if card_uid.hex().upper() == cand.uid: + card = cand + break + except: + continue if card == None: return {"status": "ERROR", "reason": "Unknown card."}