Convert str to Decimals
This commit is contained in:
parent
d1bbb7af74
commit
002faf7a58
1 changed files with 13 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue