diff --git a/lbrynet/conf.py b/lbrynet/conf.py index d984f0454..9ead15f4d 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -38,7 +38,7 @@ API_CONNECTION_STRING = "http://%s:%i/%s" % (API_INTERFACE, API_PORT, API_ADDRES UI_ADDRESS = "http://%s:%i" % (API_INTERFACE, API_PORT) PROTOCOL_PREFIX = "lbry" -DEFAULT_WALLET = "lbrycrd" +DEFAULT_WALLET = "lbryum" WALLET_TYPES = ["lbryum", "lbrycrd"] DEFAULT_TIMEOUT = 30 DEFAULT_MAX_SEARCH_RESULTS = 25 diff --git a/lbrynet/core/LBRYWallet.py b/lbrynet/core/LBRYWallet.py index 7f7dd7e88..0bf99f7a5 100644 --- a/lbrynet/core/LBRYWallet.py +++ b/lbrynet/core/LBRYWallet.py @@ -7,7 +7,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked from lbrynet.conf import BASE_METADATA_FIELDS, SOURCE_TYPES, OPTIONAL_METADATA_FIELDS from lbryum import SimpleConfig, Network -from lbryum.bitcoin import COIN, TYPE_ADDRESS +from lbryum.lbrycrd import COIN, TYPE_ADDRESS from lbryum.wallet import WalletStorage, Wallet from lbryum.commands import known_commands, Commands from lbryum.transaction import Transaction diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 4bdb9c08d..8e2c98cc5 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -145,7 +145,7 @@ class LBRYDaemon(jsonrpc.JSONRPC): isLeaf = True - def __init__(self, root, wallet_type="lbrycrd"): + def __init__(self, root, wallet_type=None): jsonrpc.JSONRPC.__init__(self) reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown) @@ -877,13 +877,13 @@ class LBRYDaemon(jsonrpc.JSONRPC): return d def get_wallet(): - if self.wallet_type in ["lbrycrd", "lbryum"]: #force lbrycrd wallet no matter what while lbryum is down + if self.wallet_type == "lbrycrd": #force lbrycrd wallet no matter what while lbryum is down log.info("Using lbrycrd wallet") d = defer.succeed(LBRYcrdWallet(self.db_dir, wallet_dir=self.wallet_dir, wallet_conf=self.lbrycrd_conf, lbrycrdd_path=self.lbrycrdd_path)) - # elif self.wallet_type == "lbryum": - # log.info("Using lbryum wallet") - # d = defer.succeed(LBRYumWallet(self.db_dir)) + elif self.wallet_type == "lbryum": + log.info("Using lbryum wallet") + d = defer.succeed(LBRYumWallet(self.db_dir)) elif self.wallet_type == "ptc": log.info("Using PTC wallet") d = defer.succeed(PTCWallet(self.db_dir)) @@ -918,61 +918,61 @@ class LBRYDaemon(jsonrpc.JSONRPC): return dl - def _check_first_run(self): - def _set_first_run_false(): - log.info("Not first run") - self.first_run = False - self.session_settings['requested_first_run_credits'] = True - f = open(self.daemon_conf, "w") - f.write(json.dumps(self.session_settings)) - f.close() - return 0.0 - - if self.wallet_type == 'lbryum': - d = self.session.wallet.is_first_run() - d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run or not self.requested_first_run_credits - else _set_first_run_false()) - else: - d = defer.succeed(None) - d.addCallback(lambda _: _set_first_run_false()) - return d - - def _do_first_run(self): - def send_request(url, data): - log.info("Requesting first run credits") - r = requests.post(url, json=data) - if r.status_code == 200: - self.requested_first_run_credits = True - self.session_settings['requested_first_run_credits'] = True - f = open(self.daemon_conf, "w") - f.write(json.dumps(self.session_settings)) - f.close() - return r.json()['credits_sent'] - return 0.0 - - def log_error(err): - log.warning("unable to request free credits. %s", err.getErrorMessage()) - return 0.0 - - def request_credits(address): - url = "http://credreq.lbry.io/requestcredits" - data = {"address": address} - d = threads.deferToThread(send_request, url, data) - d.addErrback(log_error) - return d - - self.first_run = True - d = self.session.wallet.get_new_address() - d.addCallback(request_credits) - - return d - - def _show_first_run_result(self, credits_received): - if credits_received != 0.0: - points_string = locale.format_string("%.2f LBC", (round(credits_received, 2),), grouping=True) - self.startup_message = "Thank you for testing the alpha version of LBRY! You have been given %s for free because we love you. Please hang on for a few minutes for the next block to be mined. When you refresh this page and see your credits you're ready to go!." % points_string - else: - self.startup_message = None + # def _check_first_run(self): + # def _set_first_run_false(): + # log.info("Not first run") + # self.first_run = False + # self.session_settings['requested_first_run_credits'] = True + # f = open(self.daemon_conf, "w") + # f.write(json.dumps(self.session_settings)) + # f.close() + # return 0.0 + # + # if self.wallet_type == 'lbryum': + # d = self.session.wallet.is_first_run() + # d.addCallback(lambda is_first_run: self._do_first_run() if is_first_run or not self.requested_first_run_credits + # else _set_first_run_false()) + # else: + # d = defer.succeed(None) + # d.addCallback(lambda _: _set_first_run_false()) + # return d + # + # def _do_first_run(self): + # def send_request(url, data): + # log.info("Requesting first run credits") + # r = requests.post(url, json=data) + # if r.status_code == 200: + # self.requested_first_run_credits = True + # self.session_settings['requested_first_run_credits'] = True + # f = open(self.daemon_conf, "w") + # f.write(json.dumps(self.session_settings)) + # f.close() + # return r.json()['credits_sent'] + # return 0.0 + # + # def log_error(err): + # log.warning("unable to request free credits. %s", err.getErrorMessage()) + # return 0.0 + # + # def request_credits(address): + # url = "http://credreq.lbry.io/requestcredits" + # data = {"address": address} + # d = threads.deferToThread(send_request, url, data) + # d.addErrback(log_error) + # return d + # + # self.first_run = True + # d = self.session.wallet.get_new_address() + # d.addCallback(request_credits) + # + # return d + # + # def _show_first_run_result(self, credits_received): + # if credits_received != 0.0: + # points_string = locale.format_string("%.2f LBC", (round(credits_received, 2),), grouping=True) + # self.startup_message = "Thank you for testing the alpha version of LBRY! You have been given %s for free because we love you. Please hang on for a few minutes for the next block to be mined. When you refresh this page and see your credits you're ready to go!." % points_string + # else: + # self.startup_message = None def _setup_stream_identifier(self): file_saver_factory = LBRYFileSaverFactory(self.session.peer_finder, self.session.rate_limiter, diff --git a/lbrynet/lbrynet_daemon/LBRYDaemonCLI.py b/lbrynet/lbrynet_daemon/LBRYDaemonCLI.py index b146cb1a6..2b34d4301 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemonCLI.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemonCLI.py @@ -35,7 +35,7 @@ def main(): if len(args) > 1: if isinstance(args[1], dict): params = args[1] - elif isinstance(args[1], str) or isinstance(args[1], unicode): + elif isinstance(args[1], str, unicode): params = json.loads(args[1]) else: params = None diff --git a/lbrynet/lbrynet_daemon/LBRYDaemonServer.py b/lbrynet/lbrynet_daemon/LBRYDaemonServer.py index 0fae59410..74906da0b 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemonServer.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemonServer.py @@ -183,7 +183,7 @@ class HostedLBRYFile(resource.Resource): class LBRYDaemonServer(object): def _setup_server(self, wallet): self.root = LBRYindex(os.path.join(os.path.join(data_dir, "lbry-ui"), "active")) - self._api = LBRYDaemon(self.root, wallet_type="lbrycrd") + self._api = LBRYDaemon(self.root, wallet_type=wallet) self.root.putChild("view", HostedLBRYFile(self._api)) self.root.putChild(API_ADDRESS, self._api) return defer.succeed(True) diff --git a/lbrynet/lbrynet_daemon/LBRYPublisher.py b/lbrynet/lbrynet_daemon/LBRYPublisher.py index c2ef94d1d..c0658bfec 100644 --- a/lbrynet/lbrynet_daemon/LBRYPublisher.py +++ b/lbrynet/lbrynet_daemon/LBRYPublisher.py @@ -127,11 +127,11 @@ class Publisher(object): log.info(err.getTraceback()) message = "An error occurred publishing %s to %s. Error: %s." if err.check(InsufficientFundsError): - d = defer.succeed(True) error_message = "Insufficient funds" else: - d = defer.succeed(True) error_message = err.getErrorMessage() + log.error(error_message) log.error(message, str(self.file_name), str(self.publish_name), err.getTraceback()) - return d + + return defer.succeed(error_message)