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

Set network in launcher #1098

Merged
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
12 changes: 10 additions & 2 deletions gui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use tokio::runtime::Handle;
use tracing::{error, info, warn};

pub use liana::{commands::CoinStatus, config::Config as DaemonConfig, miniscript::bitcoin};
use liana_ui::widget::Element;
use liana_ui::{
component::network_banner,
widget::{Column, Element},
};

pub use config::Config;
pub use message::Message;
Expand Down Expand Up @@ -318,6 +321,11 @@ impl App {
}

pub fn view(&self) -> Element<Message> {
self.panels.current().view(&self.cache).map(Message::View)
let content = self.panels.current().view(&self.cache).map(Message::View);
if self.cache.network != bitcoin::Network::Bitcoin {
Column::with_children(vec![network_banner(self.cache.network).into(), content]).into()
} else {
content
}
}
}
7 changes: 2 additions & 5 deletions gui/src/installer/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use liana::miniscript::{
bitcoin::{bip32::Fingerprint, Network},
DescriptorPublicKey,
};
use liana::miniscript::{bitcoin::bip32::Fingerprint, DescriptorPublicKey};
use std::path::PathBuf;

use super::Error;
Expand All @@ -23,13 +20,13 @@ pub enum Message {
Next,
Skip,
Previous,
BackToLauncher,
Install,
Close,
Reload,
Select(usize),
UseHotSigner,
Installed(Result<PathBuf, Error>),
Network(Network),
CreateTaprootDescriptor(bool),
SelectBitcoindType(SelectBitcoindTypeMsg),
InternalBitcoind(InternalBitcoindMsg),
Expand Down
32 changes: 24 additions & 8 deletions gui/src/installer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ mod step;
mod view;

use iced::{clipboard, Command, Subscription};
use liana::miniscript::bitcoin;
use liana_ui::widget::Element;
use liana::miniscript::bitcoin::{self, Network};
use liana_ui::{
component::network_banner,
widget::{Column, Element},
};
use tracing::{error, info, warn};

use context::Context;
Expand All @@ -29,6 +32,7 @@ use step::{
};

pub struct Installer {
network: bitcoin::Network,
current: usize,
steps: Vec<Box<dyn Step>>,
hws: HardwareWallets,
Expand Down Expand Up @@ -61,6 +65,7 @@ impl Installer {
) -> (Installer, Command<Message>) {
(
Installer {
network,
current: 0,
hws: HardwareWallets::new(destination_path.clone(), network),
steps: vec![Welcome::default().into()],
Expand All @@ -71,6 +76,10 @@ impl Installer {
)
}

pub fn destination_path(&self) -> PathBuf {
self.context.data_dir.clone()
}

pub fn subscription(&self) -> Subscription<Message> {
if self.current > 0 {
self.steps
Expand Down Expand Up @@ -135,7 +144,7 @@ impl Installer {
Message::CreateWallet => {
self.steps = vec![
Welcome::default().into(),
DefineDescriptor::new(self.signer.clone()).into(),
DefineDescriptor::new(self.network, self.signer.clone()).into(),
BackupMnemonic::new(self.signer.clone()).into(),
BackupDescriptor::default().into(),
RegisterDescriptor::new_create_wallet().into(),
Expand All @@ -149,8 +158,8 @@ impl Installer {
Message::ParticipateWallet => {
self.steps = vec![
Welcome::default().into(),
ParticipateXpub::new(self.signer.clone()).into(),
ImportDescriptor::new(false).into(),
ParticipateXpub::new(self.network, self.signer.clone()).into(),
ImportDescriptor::new(self.network).into(),
BackupMnemonic::new(self.signer.clone()).into(),
RegisterDescriptor::new_import_wallet().into(),
SelectBitcoindTypeStep::new().into(),
Expand All @@ -163,7 +172,7 @@ impl Installer {
Message::ImportWallet => {
self.steps = vec![
Welcome::default().into(),
ImportDescriptor::new(true).into(),
ImportDescriptor::new(self.network).into(),
RecoverMnemonic::default().into(),
RegisterDescriptor::new_import_wallet().into(),
SelectBitcoindTypeStep::new().into(),
Expand Down Expand Up @@ -246,10 +255,17 @@ impl Installer {
}

pub fn view(&self) -> Element<Message> {
self.steps
let content = self
.steps
.get(self.current)
.expect("There is always a step")
.view(&self.hws, self.progress())
.view(&self.hws, self.progress());

if self.network != Network::Bitcoin {
Column::with_children(vec![network_banner(self.network).into(), content]).into()
} else {
content
}
}
}

Expand Down
Loading
Loading