handle amount passed as float

This commit is contained in:
Lex Berezhny 2018-08-27 11:30:43 -04:00
parent 2a53afbfd8
commit 70e68c6361

View file

@ -3297,7 +3297,7 @@ class Daemon(AuthJSONRPCServer):
raise ValueError("Account with name '{}' already exists.".format(account_name)) raise ValueError("Account with name '{}' already exists.".format(account_name))
@staticmethod @staticmethod
def get_dewies_or_error(argument: str, amount: Union[str, int]): def get_dewies_or_error(argument: str, amount: Union[str, int, float]):
if isinstance(amount, str): if isinstance(amount, str):
if '.' in amount: if '.' in amount:
return int(Decimal(amount) * COIN) return int(Decimal(amount) * COIN)
@ -3305,6 +3305,8 @@ class Daemon(AuthJSONRPCServer):
amount = int(amount) amount = int(amount)
if isinstance(amount, int): if isinstance(amount, int):
return amount * COIN return amount * COIN
if isinstance(amount, float):
return int(amount * COIN)
raise ValueError("Invalid value for '{}' argument: {}".format(argument, amount)) raise ValueError("Invalid value for '{}' argument: {}".format(argument, amount))