Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hard coded network signet for remote backend #1246

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions gui/src/installer/step/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -303,9 +304,10 @@ pub async fn connect(
auth: AuthClient,
token: String,
backend_api_url: String,
network: Network,
) -> Result<context::RemoteBackend, Error> {
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))
}

Expand Down
3 changes: 2 additions & 1 deletion gui/src/lianalite/client/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ impl BackendClient {
auth_client: auth::AuthClient,
url: String,
credentials: auth::AccessTokenResponse,
network: Network,
) -> Result<Self, DaemonError> {
let http = reqwest::Client::new();
let response = request(
Expand All @@ -90,7 +91,7 @@ impl BackendClient {
Ok(Self {
auth: Arc::new(RwLock::new(credentials)),
auth_client,
network: Network::Signet,
network,
url,
user_id,
http,
Expand Down
12 changes: 9 additions & 3 deletions gui/src/lianalite/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ impl LianaLiteLogin {
auth_config.refresh_token,
auth_config.wallet_id,
service_config.backend_api_url,
network,
)
.await
},
Expand Down Expand Up @@ -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,
);
}
Expand Down Expand Up @@ -531,9 +535,10 @@ pub async fn connect(
token: String,
wallet_id: String,
backend_api_url: String,
network: Network,
) -> Result<BackendState, Error> {
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() {
Expand All @@ -557,9 +562,10 @@ pub async fn connect_with_refresh_token(
refresh_token: String,
wallet_id: String,
backend_api_url: String,
network: Network,
) -> Result<BackendState, Error> {
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()
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading