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

[GUI] display wallet birthday #943

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions gui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,9 @@ impl App {
}

pub fn load_wallet(&mut self) -> Result<Arc<Wallet>, Error> {
let wallet = Wallet::new(self.wallet.main_descriptor.clone()).load_settings(
&self.config,
&self.data_dir,
self.cache.network,
)?;
let info = self.daemon.get_info()?;
let wallet = Wallet::new(self.wallet.main_descriptor.clone(), info.timestamp)
.load_settings(&self.config, &self.data_dir, self.cache.network)?;

self.wallet = Arc::new(wallet);

Expand Down
2 changes: 1 addition & 1 deletion gui/src/app/state/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ mod tests {

let sandbox: Sandbox<ReceivePanel> = Sandbox::new(ReceivePanel::new(
PathBuf::new(),
Arc::new(Wallet::new(LianaDescriptor::from_str(DESC).unwrap())),
Arc::new(Wallet::new(LianaDescriptor::from_str(DESC).unwrap(), 0)),
));
let client = Arc::new(Lianad::new(daemon.run()));
let sandbox = sandbox.load(client, &Cache::default()).await;
Expand Down
7 changes: 6 additions & 1 deletion gui/src/app/state/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ impl State for SettingsState {
}
Message::View(view::Message::Settings(view::SettingsMessage::EditWalletSettings)) => {
self.setting = Some(
WalletSettingsState::new(self.data_dir.clone(), self.wallet.clone()).into(),
WalletSettingsState::new(
self.data_dir.clone(),
self.wallet.clone(),
self.wallet.timestamp,
)
.into(),
);
self.setting
.as_mut()
Expand Down
5 changes: 4 additions & 1 deletion gui/src/app/state/settings/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ pub struct WalletSettingsState {
modal: Option<RegisterWalletModal>,
processing: bool,
updated: bool,
creation_date: u32,
}

impl WalletSettingsState {
pub fn new(data_dir: PathBuf, wallet: Arc<Wallet>) -> Self {
pub fn new(data_dir: PathBuf, wallet: Arc<Wallet>, creation_date: u32) -> Self {
WalletSettingsState {
data_dir,
descriptor: wallet.main_descriptor.to_string(),
Expand All @@ -42,6 +43,7 @@ impl WalletSettingsState {
modal: None,
processing: false,
updated: false,
creation_date,
}
}

Expand Down Expand Up @@ -81,6 +83,7 @@ impl State for WalletSettingsState {
&self.keys_aliases,
self.processing,
self.updated,
self.creation_date,
);
if let Some(m) = &self.modal {
modal::Modal::new(content, m.view())
Expand Down
14 changes: 14 additions & 0 deletions gui/src/app/view/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ pub fn wallet_settings<'a>(
keys_aliases: &[(Fingerprint, form::Value<String>)],
processing: bool,
updated: bool,
creation_date: u32,
) -> Element<'a, Message> {
dashboard(
&Menu::Settings,
Expand All @@ -612,6 +613,7 @@ pub fn wallet_settings<'a>(
.on_press(Message::Settings(SettingsMessage::AboutSection)),
),
)
.push_maybe(creation_date_message(creation_date))
.push(card::simple(
Column::new()
.push(text("Wallet descriptor:").bold())
Expand Down Expand Up @@ -738,3 +740,15 @@ pub fn register_wallet_modal<'a>(
.width(Length::Fixed(500.0))
.into()
}

pub fn creation_date_message(creation_date: u32) -> Option<Row<'static, Message>> {
if let Some(datetime) = chrono::NaiveDateTime::from_timestamp_opt(creation_date as i64, 0) {
return Some(
Row::new()
.push(text("Wallet creation date:").bold())
.spacing(10)
.push(text(datetime.format("%y/%m/%d").to_string())),
);
}
None
}
4 changes: 3 additions & 1 deletion gui/src/app/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ pub struct Wallet {
pub keys_aliases: HashMap<Fingerprint, String>,
pub hardware_wallets: Vec<HardwareWalletConfig>,
pub signer: Option<Signer>,
pub timestamp: u32,
}

impl Wallet {
pub fn new(main_descriptor: LianaDescriptor) -> Self {
pub fn new(main_descriptor: LianaDescriptor, timestamp: u32) -> Self {
Self {
name: wallet_name(&main_descriptor),
main_descriptor,
keys_aliases: HashMap::new(),
hardware_wallets: Vec::new(),
signer: None,
timestamp,
}
}

Expand Down
7 changes: 5 additions & 2 deletions gui/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,11 @@ pub async fn load_application(
),
Error,
> {
let wallet =
Wallet::new(info.descriptors.main).load_settings(&gui_config, &datadir_path, network)?;
let wallet = Wallet::new(info.descriptors.main, info.timestamp).load_settings(
&gui_config,
&datadir_path,
network,
)?;

let coins = daemon.list_coins().map(|res| res.coins)?;
let spend_txs = daemon.list_spend_transactions(None)?;
Expand Down
Loading