1
0

network: catch untrusted exceptions from server in public methods

and re-raise a wrapper exception (that retains the original exc in a field)

closes #5111
This commit is contained in:
SomberNight
2019-02-12 17:02:15 +01:00
parent fd62ba874b
commit 38ab7ee554
4 changed files with 78 additions and 4 deletions

View File

@@ -506,6 +506,26 @@ def is_valid_email(s):
return re.match(regexp, s) is not None
def is_hash256_str(text: str) -> bool:
if not isinstance(text, str): return False
if len(text) != 64: return False
try:
bytes.fromhex(text)
except:
return False
return True
def is_non_negative_integer(val) -> bool:
try:
val = int(val)
if val >= 0:
return True
except:
pass
return False
def format_satoshis_plain(x, decimal_point = 8):
"""Display a satoshi amount scaled. Always uses a '.' as a decimal
point and has no thousands separator"""