catch exception on invalid hash passed to sparko.

This commit is contained in:
fiatjaf 2021-03-21 18:12:26 -03:00
parent 8e62d9287d
commit e6ea77e682

View file

@ -108,6 +108,15 @@ class SparkWallet(Wallet):
return PaymentStatus(True)
def get_payment_status(self, checking_id: str) -> PaymentStatus:
# check if it's 32 bytes hex
if len(checking_id) != 64:
return PaymentStatus(None)
try:
int(checking_id, 16)
except ValueError:
return PaymentStatus(None)
# ask sparko
r = self.listpays(payment_hash=checking_id)
if not r["pays"]:
return PaymentStatus(False)