Merge #754: wallet: load name from settings

1cbbb8c0befe3c168fbbd34129a2f4f2a8c8726f wallet: load name from settings (edouardparis)

Pull request description:

  If an wallet settings already exists, the wallet name attached to the hardware wallet credentials must be use, instead of the new generated one.

  close #745

ACKs for top commit:
  darosior:
    ACK 1cbbb8c0befe3c168fbbd34129a2f4f2a8c8726f -- tested locally and discussed it with Edouard. I can't think of another place where we'd like to use the old wallet name.

Tree-SHA512: a06e64f4ada4fbadb6e132be740b480055113e733d658f4694cfcad15bb2901e6626af211ba5df95f4e08d9cb47080a96e97e29bf1c18e094dfbde6364408ce2
This commit is contained in:
Antoine Poinsot 2023-10-30 13:47:49 +01:00
commit 54969bba71
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304

View File

@ -48,6 +48,11 @@ impl Wallet {
} }
} }
pub fn with_name(mut self, name: String) -> Self {
self.name = name;
self
}
pub fn with_key_aliases(mut self, aliases: HashMap<Fingerprint, String>) -> Self { pub fn with_key_aliases(mut self, aliases: HashMap<Fingerprint, String>) -> Self {
self.keys_aliases = aliases; self.keys_aliases = aliases;
self self
@ -101,7 +106,8 @@ impl Wallet {
let mut wallet = match settings::Settings::from_file(datadir_path.to_path_buf(), network) { let mut wallet = match settings::Settings::from_file(datadir_path.to_path_buf(), network) {
Ok(settings) => { Ok(settings) => {
if let Some(wallet_setting) = settings.wallets.first() { if let Some(wallet_setting) = settings.wallets.first() {
self.with_hardware_wallets(wallet_setting.hardware_wallets.clone()) self.with_name(wallet_setting.name.clone())
.with_hardware_wallets(wallet_setting.hardware_wallets.clone())
.with_key_aliases(wallet_setting.keys_aliases()) .with_key_aliases(wallet_setting.keys_aliases())
} else { } else {
self.with_hardware_wallets(gui_config_hws) self.with_hardware_wallets(gui_config_hws)