Convert str to Decimals

This commit is contained in:
hackrush 2018-08-18 00:32:14 +05:30 committed by Jack Robison
parent d1bbb7af74
commit 002faf7a58
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -1555,7 +1555,13 @@ class Daemon(AuthJSONRPCServer):
raise Exception("Invalid channel uri")
except (TypeError, URIParseError):
raise Exception("Invalid channel name")
if amount <= 0:
try:
amount = Decimal(amount)
except InvalidOperation:
raise TypeError("Amount does not represent a valid decimal")
if amount <= 0.0:
raise Exception("Invalid amount")
amount = int(amount * COIN)
tx = yield self.wallet.claim_new_channel(channel_name, amount)
@ -2469,7 +2475,12 @@ class Daemon(AuthJSONRPCServer):
(dict) the resulting transaction
"""
if amount < 0:
try:
amount = Decimal(amount)
except InvalidOperation:
raise TypeError("Amount does not represent a valid decimal")
if amount < 0.0:
raise NegativeFundsError()
elif not amount:
raise NullFundsError()