Esempio n. 1
0
class Application(tornado.web.Application):
    def __init__(self):
        # wallet_servers = bismuthapi.get_wallet_servers_legacy()
        servers = None
        if options.server:
            servers = [options.server]
        bismuth_client = bismuthclient.BismuthClient(verbose=options.verbose,
                                                     servers_list=servers)
        wallet_dir = helpers.get_private_dir()
        print("Please store your wallets under '{}'".format(wallet_dir))
        bismuth_client.get_server()
        # Convert relative to absolute
        options.theme = os.path.join(helpers.base_path(), options.theme)
        static_path = os.path.join(options.theme, 'static')
        self.default_handlers = [(r"/", HomeHandler),
                                 (r"/transactions/(.*)", TransactionsHandler),
                                 (r"/json/(.*)", JsonHandler),
                                 (r"/address/(.*)", AddressHandler),
                                 (r"/messages/(.*)", AddressHandler),
                                 (r"/wallet/(.*)", WalletHandler),
                                 (r"/about/(.*)", AboutHandler),
                                 (r"/tokens/(.*)", TokensHandler),
                                 (r"/search/(.*)", SearchHandler),
                                 (r"/crystals/(.*)", CrystalsHandler),
                                 (r"/(apple-touch-icon\.png)",
                                  tornado.web.StaticFileHandler,
                                  dict(path=static_path))]
        # Parse crystals dir, import and plug handlers.
        self.crystals_manager = CrystalManager(init=options.crystals)
        handlers = self.default_handlers.copy()
        handlers.extend(self.crystals_manager.get_handlers())
        # print("handlers", handlers)
        self.crystals_manager.execute_action_hook('init')

        settings = dict(
            app_title=u"Tornado Bismuth Wallet",
            # template_loader = CrystalLoader(options.theme),
            template_path=os.path.join(os.path.dirname(__file__),
                                       options.theme),
            static_path=os.path.join(os.path.dirname(__file__), static_path),
            ui_modules={"Transaction": TxModule},
            xsrf_cookies=True,
            cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
            login_url="/auth/login",
            compress_response=True,
            debug=options.debug,  # Also activates auto reload
            serve_traceback=options.debug,
            # wallet_servers = wallet_servers
            bismuth_client=bismuth_client,
            bismuth_vars={'wallet_version': __version__},
            bismuth_crystals={})
        super(Application, self).__init__(handlers, **settings)
Esempio n. 2
0
class Application(tornado.web.Application):
    def __init__(self):
        # wallet_servers = bismuthapi.get_wallet_servers_legacy()
        servers = None
        if options.server:
            servers = [options.server]
        bismuth_client = bismuthclient.BismuthClient(
            verbose=options.verbose, servers_list=servers
        )
        wallet_dir = helpers.get_private_dir()
        self.wallet_settings = None
        print("Please store your wallets under '{}'".format(wallet_dir))
        # self.load_user_data("{}/options.json".format(wallet_dir))
        bismuth_client.load_multi_wallet("{}/wallet.json".format(wallet_dir))
        bismuth_client.set_alias_cache_file("{}/alias_cache.json".format(wallet_dir))
        bismuth_client.get_server()
        # Convert relative to absolute
        options.theme = os.path.join(helpers.base_path(), options.theme)
        static_path = os.path.join(options.theme, "static")
        self.default_handlers = [
            (r"/", HomeHandler),
            (r"/transactions/(.*)", TransactionsHandler),
            (r"/json/(.*)", JsonHandler),
            (r"/address/(.*)", AddressHandler),
            (r"/messages/(.*)", MessagesHandler),
            (r"/wallet/(.*)", WalletHandler),
            (r"/about/(.*)", AboutHandler),
            (r"/tokens/(.*)", TokensHandler),
            (r"/search/(.*)", SearchHandler),
            (r"/crystals/(.*)", CrystalsHandler),
            (
                r"/(apple-touch-icon\.png)",
                tornado.web.StaticFileHandler,
                dict(path=static_path),
            ),
        ]
        # Parse crystals dir, import and plug handlers.
        self.crystals_manager = CrystalManager(init=options.crystals)
        handlers = self.default_handlers.copy()
        handlers.extend(self.crystals_manager.get_handlers())
        # print("handlers", handlers)
        self.crystals_manager.execute_action_hook("init")

        settings = dict(
            app_title=u"Tornado Bismuth Wallet",
            # template_loader = CrystalLoader(options.theme),
            template_path=os.path.join(os.path.dirname(__file__), options.theme),
            static_path=os.path.join(os.path.dirname(__file__), static_path),
            ui_modules={"Transaction": TxModule},
            xsrf_cookies=True,
            cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
            login_url="/auth/login",
            compress_response=True,
            debug=options.debug,  # Also activates auto reload
            serve_traceback=options.debug,
            lang=options.lang,
            # wallet_servers = wallet_servers
            bismuth_client=bismuth_client,
            bismuth_vars={
                "wallet_version": __version__,
                "bismuthclient_version": bismuthclient.__version__,
            },
            bismuth_crystals={},
        )
        super(Application, self).__init__(handlers, **settings)

    def load_user_data(self, filename: str):
        """User data is config + optional integrated wallets."""
        # TODO: no, already in wallet.
        raise RuntimeError("Deprecated, do not use")
        """
Esempio n. 3
0
    def __init__(self):
        # wallet_servers = bismuthapi.get_wallet_servers_legacy()
        servers = None
        if options.server:
            servers = [options.server]
        bismuth_client = bismuthclient.BismuthClient(verbose=options.verbose,
                                                     servers_list=servers)
        wallet_dir = helpers.get_private_dir()
        self.wallet_settings = None
        print("Please store your wallets under '{}'".format(wallet_dir))
        if options.romode:
            print("Read only mode")
        # self.load_user_data("{}/options.json".format(wallet_dir))
        if options.nowallet:
            print("No Wallet mode")
            bismuth_client.wallet_file = None
            bismuth_client.address = 'FakeAddressMode'
        else:
            bismuth_client.load_multi_wallet(
                "{}/wallet.json".format(wallet_dir))
        bismuth_client.set_alias_cache_file(
            "{}/alias_cache.json".format(wallet_dir))
        bismuth_client.get_server()
        # Convert relative to absolute
        options.theme = os.path.join(helpers.base_path(), options.theme)
        static_path = os.path.join(options.theme, "static")
        common_path = os.path.join(helpers.base_path(), "themes/common")
        self.default_handlers = [
            (r"/", HomeHandler),
            (r"/transactions/(.*)", TransactionsHandler),
            (r"/json/(.*)", JsonHandler),
            (r"/address/(.*)", AddressHandler),
            (r"/messages/(.*)", MessagesHandler),
            (r"/wallet/(.*)", WalletHandler),
            (r"/about/(.*)", AboutHandler),
            (r"/tokens/(.*)", TokensHandler),
            (r"/search/(.*)", SearchHandler),
            (r"/crystals/(.*)", CrystalsHandler),
            (r"/tools/(.*)", ToolsHandler),
            (
                r"/(apple-touch-icon\.png)",
                tornado.web.StaticFileHandler,
                dict(path=static_path),
            ),
            (r'/common/(.*)', tornado.web.StaticFileHandler, {
                'path': common_path
            }),
        ]
        # Parse crystals dir, import and plug handlers.
        self.crystals_manager = CrystalManager(init=options.crystals)
        handlers = self.default_handlers.copy()
        handlers.extend(self.crystals_manager.get_handlers())
        # print("handlers", handlers)
        self.crystals_manager.execute_action_hook("init")

        settings = dict(
            app_title=options.app_title,
            # template_loader = CrystalLoader(options.theme),
            template_path=os.path.join(os.path.dirname(__file__),
                                       options.theme),
            static_path=os.path.join(os.path.dirname(__file__), static_path),
            ui_modules={"Transaction": TxModule},
            xsrf_cookies=True,
            cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
            login_url="/auth/login",
            compress_response=True,
            debug=options.debug,  # Also activates auto reload
            serve_traceback=options.debug,
            max_addresses=options.maxa,
            lang=options.lang,
            ro_mode=options.romode,
            # wallet_servers = wallet_servers
            bismuth_client=bismuth_client,
            bismuth_vars={
                "wallet_version": __version__,
                "bismuthclient_version": bismuthclient.__version__,
            },
            bismuth_crystals={},
        )
        super(Application, self).__init__(handlers, **settings)