Use get_dewies_or_error method instead

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

View file

@ -1556,14 +1556,10 @@ class Daemon(AuthJSONRPCServer):
except (TypeError, URIParseError): except (TypeError, URIParseError):
raise Exception("Invalid channel name") raise Exception("Invalid channel name")
try: amount = self.get_dewies_or_error("amount", amount)
amount = Decimal(amount)
except InvalidOperation:
raise TypeError("Amount does not represent a valid decimal")
if amount <= 0.0: if amount <= 0.0:
raise Exception("Invalid amount") raise Exception("Invalid amount")
amount = int(amount * COIN)
tx = yield self.wallet.claim_new_channel(channel_name, amount) tx = yield self.wallet.claim_new_channel(channel_name, amount)
self.wallet.save() self.wallet.save()
self.analytics_manager.send_new_channel() self.analytics_manager.send_new_channel()
@ -2475,10 +2471,7 @@ class Daemon(AuthJSONRPCServer):
(dict) the resulting transaction (dict) the resulting transaction
""" """
try: amount = self.get_dewies_or_error("amount", amount)
amount = Decimal(amount)
except InvalidOperation:
raise TypeError("Amount does not represent a valid decimal")
if amount < 0.0: if amount < 0.0:
raise NegativeFundsError() raise NegativeFundsError()