From 002faf7a588b626776acd6e3be25e69aff6e8bd8 Mon Sep 17 00:00:00 2001 From: hackrush Date: Sat, 18 Aug 2018 00:32:14 +0530 Subject: [PATCH] Convert str to Decimals --- lbrynet/daemon/Daemon.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index d9230e58b..679390647 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -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()