catch InvalidOperation exception when parsing decimals
This commit is contained in:
parent
eff66bdf80
commit
7698ab7053
1 changed files with 4 additions and 1 deletions
|
@ -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)):
|
||||
|
|
Loading…
Reference in a new issue