From c8b6ade3884954ffc422f4136c5d8c52ae9f90f3 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Mon, 2 Feb 2015 20:44:03 +0000 Subject: [PATCH] Add a payment id format checker --- tipbot/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tipbot/utils.py b/tipbot/utils.py index da1f350..827802f 100644 --- a/tipbot/utils.py +++ b/tipbot/utils.py @@ -15,6 +15,7 @@ import json import httplib import time import math +import string from decimal import * import tipbot.config as config import tipbot.coinspecs as coinspecs @@ -80,6 +81,14 @@ def IsValidAddress(address): return True return False +def IsValidPaymentID(payment_id): + if len(payment_id)!=64: + return False + for char in payment_id: + if char not in string.hexdigits: + return False + return True + # Code taken from the Python documentation def moneyfmt(value, places=2, curr='', sep=',', dp='.', pos='', neg='-', trailneg=''):