From a331f9fd706c34ba8ab639ca1c7b16a2a80a4fc3 Mon Sep 17 00:00:00 2001 From: edouardparis Date: Fri, 30 Aug 2024 15:46:43 +0200 Subject: [PATCH] fix hard coded network signet for remote backend remote backend supports now also mainnet. --- gui/src/installer/step/backend.rs | 6 ++++-- gui/src/lianalite/client/backend/mod.rs | 3 ++- gui/src/lianalite/login.rs | 12 +++++++++--- gui/src/main.rs | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gui/src/installer/step/backend.rs b/gui/src/installer/step/backend.rs index 64fcd91dd..05243a8e0 100644 --- a/gui/src/installer/step/backend.rs +++ b/gui/src/installer/step/backend.rs @@ -190,8 +190,9 @@ impl Step for ChooseBackend { self.processing = true; self.connection_error = None; self.auth_error = None; + let network = self.network; return Command::perform( - async move { connect(client, otp, backend_api_url).await }, + async move { connect(client, otp, backend_api_url, network).await }, message::SelectBackend::Connected, ) .map(Message::SelectBackend); @@ -303,9 +304,10 @@ pub async fn connect( auth: AuthClient, token: String, backend_api_url: String, + network: Network, ) -> Result { let access = auth.verify_otp(token.trim_end()).await?; - let client = BackendClient::connect(auth, backend_api_url, access.clone()).await?; + let client = BackendClient::connect(auth, backend_api_url, access.clone(), network).await?; Ok(RemoteBackend::WithoutWallet(client)) } diff --git a/gui/src/lianalite/client/backend/mod.rs b/gui/src/lianalite/client/backend/mod.rs index 1bc7099dc..306394fad 100644 --- a/gui/src/lianalite/client/backend/mod.rs +++ b/gui/src/lianalite/client/backend/mod.rs @@ -71,6 +71,7 @@ impl BackendClient { auth_client: auth::AuthClient, url: String, credentials: auth::AccessTokenResponse, + network: Network, ) -> Result { let http = reqwest::Client::new(); let response = request( @@ -90,7 +91,7 @@ impl BackendClient { Ok(Self { auth: Arc::new(RwLock::new(credentials)), auth_client, - network: Network::Signet, + network, url, user_id, http, diff --git a/gui/src/lianalite/login.rs b/gui/src/lianalite/login.rs index 88c5406b5..1e4d11c03 100644 --- a/gui/src/lianalite/login.rs +++ b/gui/src/lianalite/login.rs @@ -164,6 +164,7 @@ impl LianaLiteLogin { auth_config.refresh_token, auth_config.wallet_id, service_config.backend_api_url, + network, ) .await }, @@ -307,8 +308,11 @@ impl LianaLiteLogin { self.connection_error = None; self.auth_error = None; let wallet_id = self.wallet_id.clone(); + let network = self.network; return Command::perform( - async move { connect(client, otp, wallet_id, backend_api_url).await }, + async move { + connect(client, otp, wallet_id, backend_api_url, network).await + }, Message::Connected, ); } @@ -531,9 +535,10 @@ pub async fn connect( token: String, wallet_id: String, backend_api_url: String, + network: Network, ) -> Result { let access = auth.verify_otp(token.trim_end()).await?; - let client = BackendClient::connect(auth, backend_api_url, access.clone()).await?; + let client = BackendClient::connect(auth, backend_api_url, access.clone(), network).await?; let wallets = client.list_wallets().await?; if wallets.is_empty() { @@ -557,9 +562,10 @@ pub async fn connect_with_refresh_token( refresh_token: String, wallet_id: String, backend_api_url: String, + network: Network, ) -> Result { let access = auth.refresh_token(&refresh_token).await?; - let client = BackendClient::connect(auth, backend_api_url, access.clone()).await?; + let client = BackendClient::connect(auth, backend_api_url, access.clone(), network).await?; if let Some(wallet) = client .list_wallets() diff --git a/gui/src/main.rs b/gui/src/main.rs index b950391a1..ab33981ee 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -456,7 +456,7 @@ pub fn create_app_with_remote_backend( .collect(); App::new( Cache { - network: bitcoin::Network::Signet, + network, coins: Vec::new(), rescan_progress: None, datadir_path: datadir.clone(),