diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index cb586fa6..53985ff0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -836,7 +836,10 @@ public class AppServices { @Subscribe public void openWallets(OpenWalletsEvent event) { if(event.getWalletTabDataList().isEmpty()) { - walletWindows.remove(event.getWindow()); + List closedTabData = walletWindows.remove(event.getWindow()); + if(closedTabData != null && !closedTabData.isEmpty()) { + EventManager.get().post(new WalletTabsClosedEvent(closedTabData)); + } } else { walletWindows.put(event.getWindow(), event.getWalletTabDataList()); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java index 0a1149c0..df877a04 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoneSinglesig.java @@ -61,6 +61,9 @@ public class KeystoneSinglesig implements KeystoreFileImport, WalletImport { keystore.setExtendedPublicKey(xpub); return keystore; + } catch (IllegalArgumentException e) { + log.error("Error getting Keystone keystore - not an output descriptor"); + throw new ImportException("Error getting Keystone keystore", e); } catch (Exception e) { log.error("Error getting Keystone keystore", e); throw new ImportException("Error getting Keystone keystore", e); diff --git a/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java b/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java index 9b5ecaf4..624f8df5 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/db/DbPersistence.java @@ -86,6 +86,7 @@ public class DbPersistence implements Persistence { Wallet backupWallet = null; if(backupFile != null) { Persistence backupPersistence = PersistenceType.DB.getInstance(); + backupPersistence.setKeyDeriver(keyDeriver); backupWallet = backupPersistence.loadWallet(new Storage(backupPersistence, backupFile), password, encryptionKey).getWallet(); } @@ -392,16 +393,16 @@ public class DbPersistence implements Persistence { } private ECKey getEncryptionKey(CharSequence password, File walletFile, ECKey alreadyDerivedKey) throws IOException { - if(password != null && password.equals("")) { + if(alreadyDerivedKey != null) { + return alreadyDerivedKey; + } else if(password == null) { + return null; + } else if(password.equals("")) { return Storage.NO_PASSWORD_KEY; } AsymmetricKeyDeriver keyDeriver = getKeyDeriver(walletFile); - if(alreadyDerivedKey != null) { - return alreadyDerivedKey; - } - - return password == null ? null : keyDeriver.deriveECKey(password); + return keyDeriver.deriveECKey(password); } @Override diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java index b3eedb94..6ca086b0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java @@ -555,6 +555,9 @@ public class SettingsController extends WalletFormController implements Initiali walletForm.getStorage().setEncryptionPubKey(null); walletForm.getWallet().decrypt(key); + for(Wallet childWallet : walletForm.getWallet().getChildWallets()) { + childWallet.decrypt(key); + } saveWallet(true, false); return; } @@ -564,6 +567,9 @@ public class SettingsController extends WalletFormController implements Initiali } walletForm.getWallet().encrypt(key); + for(Wallet childWallet : walletForm.getWallet().getChildWallets()) { + childWallet.encrypt(key); + } walletForm.getStorage().setEncryptionPubKey(encryptionPubKey); walletForm.saveAndRefresh(); EventManager.get().post(new RequestOpenWalletsEvent()); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java index 49e0e571..61994685 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsWalletForm.java @@ -95,6 +95,17 @@ public class SettingsWalletForm extends WalletForm { EventManager.get().post(new KeystoreEncryptionChangedEvent(wallet, pastWallet, getWalletId(), encryptionChangedKeystores)); } + for(Wallet childWallet : wallet.getChildWallets()) { + Wallet childWalletCopy = walletCopy.getChildWallet(childWallet.getName()); + if(childWalletCopy != null) { + Wallet pastChildWallet = childWallet.copy(); + List childEncryptionChangedKeystores = getEncryptionChangedKeystores(childWallet, childWalletCopy); + if(!childEncryptionChangedKeystores.isEmpty()) { + EventManager.get().post(new KeystoreEncryptionChangedEvent(childWallet, pastChildWallet, getStorage().getWalletId(childWallet), childEncryptionChangedKeystores)); + } + } + } + if(labelChangedKeystores.isEmpty() && encryptionChangedKeystores.isEmpty()) { //Can only be a wallet password change on a wallet without private keys EventManager.get().post(new WalletPasswordChangedEvent(wallet, pastWallet, getWalletId()));