Merge #1717: fix settings: missing update_aliases for backup restore

654be987f2da61ed47310c3d30720126b64aa292 fix settings: missing update_aliases for backup restore (edouardparis)

Pull request description:

  While restoring a backup at the import/export panel, the message to update the wallet keys aliases was not handled and although the aliases are stored in the settings file, the wallet was not "reloaded" through the Message::WalletUpdated result. The consequence was while opening the wallet section, users found the aliases not updated by the backup (even if the file was updated).

  The change in the update_aliases is to update the wallet alias only if the function require the change by passing
  `Some(alias)` in arg.

ACKs for top commit:
  jp1ac4:
    utACK 654be987f2da61ed47310c3d30720126b64aa292.

Tree-SHA512: eabaeb48f6167365373a1839ca317879c1314d79c687d0648cae1d001ee125c364ad10a411c3392be4f001fbfb2cf85be63371e0cc36f8351066c832adfe9789
This commit is contained in:
edouardparis 2025-05-21 17:26:34 +02:00
commit 66217751be
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
2 changed files with 16 additions and 3 deletions

View File

@ -9,7 +9,7 @@ use iced::Task;
use liana_ui::{component::form, widget::Element};
use bitcoind::BitcoindSettingsState;
use wallet::WalletSettingsState;
use wallet::{update_aliases, WalletSettingsState};
use crate::{
app::{
@ -223,7 +223,19 @@ impl State for ImportExportSettingsState {
self.modal = None;
}
Message::View(view::Message::ImportExport(m)) => {
if let Some(modal) = self.modal.as_mut() {
if let ImportExportMessage::UpdateAliases(aliases) = m {
return Task::perform(
update_aliases(
cache.datadir_path.clone(),
cache.network,
self.wallet.clone(),
None,
aliases.into_iter().map(|(fg, ks)| (fg, ks.name)).collect(),
daemon,
),
Message::WalletUpdated,
);
} else if let Some(modal) = self.modal.as_mut() {
return modal.update(m);
};
}

View File

@ -516,9 +516,10 @@ pub async fn update_aliases(
keys_aliases: Vec<(Fingerprint, String)>,
daemon: Arc<dyn Daemon + Sync + Send>,
) -> Result<Arc<Wallet>, Error> {
let mut wallet = wallet.as_ref().clone().with_alias(wallet_alias.clone());
let mut wallet = wallet.as_ref().clone();
if let Some(wallet_alias) = wallet_alias.as_ref() {
wallet = wallet.with_alias(Some(wallet_alias.clone()));
let network_dir = data_dir.network_directory(network);
let wallet_id = wallet.id();
update_settings_file(&network_dir, |mut settings| {