fix hard coded network signet for remote backend

remote backend supports now also mainnet.
This commit is contained in:
edouardparis 2024-08-30 15:46:43 +02:00
parent e1e5860a26
commit a331f9fd70
4 changed files with 16 additions and 7 deletions

View File

@ -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<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))
}

View File

@ -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(
@ -90,7 +91,7 @@ impl BackendClient {
Ok(Self {
auth: Arc::new(RwLock::new(credentials)),
auth_client,
network: Network::Signet,
network,
url,
user_id,
http,

View File

@ -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<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() {
@ -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()

View File

@ -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(),