catch InvalidOperation exception when parsing decimals

This commit is contained in:
Lex Berezhny 2018-08-27 11:47:32 -04:00
parent eff66bdf80
commit 7698ab7053

View file

@ -3294,7 +3294,10 @@ class Daemon(AuthJSONRPCServer):
def get_dewies_or_error(argument: str, amount: Union[str, int, float]):
if isinstance(amount, str):
if '.' in amount:
return int(Decimal(amount) * COIN)
try:
return int(Decimal(amount) * COIN)
except InvalidOperation:
raise ValueError("Invalid decimal for '{}' argument: {}".format(argument, amount))
elif amount.isdigit():
amount = int(amount)
if isinstance(amount, (float, int)):