Merge #1246: fix hard coded network signet for remote backend

a331f9fd706c34ba8ab639ca1c7b16a2a80a4fc3 fix hard coded network signet for remote backend (edouardparis)

Pull request description:

  remote backend supports now also mainnet, we have to load downstream the chosen network.

ACKs for top commit:
  edouardparis:
    Self-ACK a331f9fd706c34ba8ab639ca1c7b16a2a80a4fc3

Tree-SHA512: a8ea2d349e647f766ecd3283eb72c3897b0e73799e17f602b563609d6258290da7347dd3f76d18f6f6e0ee7736a30e2c59ff3775fcded19f914846077bbe82ae
This commit is contained in:
edouardparis 2024-08-30 15:58:07 +02:00
commit e6c592955e
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
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(),