mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-08-31 09:21:29 +00:00
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")
|
raise Exception("Invalid channel uri")
|
||||||
except (TypeError, URIParseError):
|
except (TypeError, URIParseError):
|
||||||
raise Exception("Invalid channel name")
|
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")
|
raise Exception("Invalid amount")
|
||||||
amount = int(amount * COIN)
|
amount = int(amount * COIN)
|
||||||
tx = yield self.wallet.claim_new_channel(channel_name, amount)
|
tx = yield self.wallet.claim_new_channel(channel_name, amount)
|
||||||
|
@ -2469,7 +2475,12 @@ class Daemon(AuthJSONRPCServer):
|
||||||
(dict) the resulting transaction
|
(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()
|
raise NegativeFundsError()
|
||||||
elif not amount:
|
elif not amount:
|
||||||
raise NullFundsError()
|
raise NullFundsError()
|
||||||
|
|
Loading…
Add table
Reference in a new issue