diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ff3faf1b..581a7f00f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ at anytime. * `file_list` for files with bad signatures * return None from resolve commands when nothing is found * return lbry files with claims that are abandoned + * unhelpful error messages in `publish` and `channel_new` ## [0.9.2rc9] - 2017-04-08 ### Added diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 419b59f6a..363ca67a7 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -17,6 +17,8 @@ from twisted.internet.task import LoopingCall from twisted.python.failure import Failure from lbryschema.claim import ClaimDict +from lbryschema.uri import parse_lbry_uri +from lbryschema.error import URIParseError # TODO: importing this when internet is disabled raises a socket.gaierror from lbryum.version import LBRYUM_VERSION @@ -1681,6 +1683,19 @@ class Daemon(AuthJSONRPCServer): } """ + try: + parsed = parse_lbry_uri(channel_name) + if not parsed.is_channel: + raise Exception("Cannot make a new channel for a non channel name") + if parsed.path: + raise Exception("Invalid channel uri") + except (TypeError, URIParseError): + raise Exception("Invalid channel name") + if amount <= 0: + raise Exception("Invalid amount") + if amount > self.session.wallet.wallet_balance: + raise InsufficientFundsError() + result = yield self.session.wallet.claim_new_channel(channel_name, amount) log.info("Claimed a new channel! Result: %s", result) response = yield self._render_response(result) @@ -1758,9 +1773,17 @@ class Daemon(AuthJSONRPCServer): } """ + try: + parse_lbry_uri(name) + except (TypeError, URIParseError): + raise Exception("Invalid name given to publish") + if bid <= 0.0: raise Exception("Invalid bid") + if bid < self.session.wallet.wallet_balance: + raise InsufficientFundsError() + metadata = metadata or {} if fee is not None: metadata['fee'] = fee