예제 #1
0
    def _run_setup(self, **kw):
        account_file = kw.get("account_file")
        account = Account(account_file, passphrase=get_passphrase())
        form = QuickSetupForm(
            meta=dict(network=self.installer_settings.network),
            endpoint=kw.get("endpoint"))
        if form.validate():
            self._send_status_update(
                "Generating new wallet and configuration file for raiden")

            network = Network.get_by_name(self.installer_settings.network)
            infura_url_or_id = form.data["endpoint"].strip()
            ethereum_rpc_provider = Infura.make(network, infura_url_or_id)

            try:
                check_eth_node_responsivity(ethereum_rpc_provider.url)
            except ValueError as e:
                self._send_error_message(f"Ethereum node unavailable: {e}.")
                return

            conf_file = RaidenConfigurationFile(
                account.keystore_file_path,
                self.installer_settings,
                ethereum_rpc_provider.url,
                routing_mode=self.installer_settings.routing_mode,
                enable_monitoring=self.installer_settings.monitoring_enabled,
            )
            conf_file.save()

            self._send_redirect(
                self.reverse_url("account", conf_file.file_name))
        else:
            self._send_error_message(
                f"Failed to create account. Error: {form.errors}")
예제 #2
0
    def _run_setup(self, **kw):
        account_file = kw.get("account_file")
        account = Account(account_file)
        passphrase_path = RaidenConfigurationFile.FOLDER_PATH.joinpath(
            f"{account.address}.passphrase.txt")
        passphrase_file = PassphraseFile(passphrase_path)
        passphrase = passphrase_file.retrieve()
        account.passphrase = passphrase
        form = QuickSetupForm(endpoint=kw.get("endpoint"),
                              network=kw.get("network"))
        if form.validate():
            self._send_status_update(
                "Generating new wallet and configuration file for raiden")

            network = Network.get_by_name(form.data["network"])
            url_or_infura_id = form.data["endpoint"].strip()

            if Infura.is_valid_project_id_or_endpoint(url_or_infura_id):
                ethereum_rpc_provider = Infura.make(network, url_or_infura_id)
            else:
                ethereum_rpc_provider = EthereumRPCProvider(url_or_infura_id)

            try:
                check_eth_node_responsivity(ethereum_rpc_provider.url)
            except ValueError as e:
                self._send_error_message(f"Ethereum node unavailable: {e}.")
                return

            conf_file = RaidenConfigurationFile(
                account,
                network,
                ethereum_rpc_provider.url,
                routing_mode="pfs" if form.data["use_rsb"] else "local",
                enable_monitoring=form.data["use_rsb"],
            )
            conf_file.save()

            if network.FAUCET_AVAILABLE:
                self._run_funding(configuration_file=conf_file)
                self._send_redirect(
                    self.reverse_url("launch", conf_file.file_name))
            else:
                self._send_redirect(
                    self.reverse_url("account", conf_file.file_name))
        else:
            self._send_error_message(
                f"Failed to create account. Error: {form.errors}")