From 55809b7dc35e5c894e60c505897f21cbf6cc8edc Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 3 Feb 2023 08:20:09 +0200 Subject: [PATCH] decrypt keystore before requesting passphrase to show masterfingerprint --- .../com/sparrowwallet/sparrow/io/Storage.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Storage.java b/src/main/java/com/sparrowwallet/sparrow/io/Storage.java index 07ff0956..1abf8ca8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Storage.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Storage.java @@ -8,6 +8,7 @@ import com.sparrowwallet.drongo.wallet.StandardAccount; import com.sparrowwallet.drongo.wallet.Wallet; import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.SparrowWallet; +import com.sparrowwallet.sparrow.control.WalletPasswordDialog; import com.sparrowwallet.sparrow.soroban.Soroban; import com.sparrowwallet.sparrow.whirlpool.Whirlpool; import javafx.concurrent.ScheduledService; @@ -146,6 +147,14 @@ public class Storage { if(wallet.containsMasterPrivateKeys()) { //Derive xpub and master fingerprint from seed, potentially with passphrase Wallet copy = wallet.copy(false); + if(wallet.isEncrypted()) { + if(key == null) { + throw new IllegalStateException("Wallet was not encrypted, but seed is"); + } + + copy.decrypt(key); + } + for(int i = 0; i < copy.getKeystores().size(); i++) { Keystore copyKeystore = copy.getKeystores().get(i); if(copyKeystore.hasSeed() && copyKeystore.getSeed().getPassphrase() == null) { @@ -166,14 +175,6 @@ public class Storage { } } - if(wallet.isEncrypted()) { - if(key == null) { - throw new IllegalStateException("Wallet was not encrypted, but seed is"); - } - - copy.decrypt(key); - } - if(wallet.isWhirlpoolMasterWallet()) { String walletId = getWalletId(wallet); Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(walletId);