diff --git a/core/src/main/java/bisq/core/grpc/CoreWalletsService.java b/core/src/main/java/bisq/core/grpc/CoreWalletsService.java index f9e3b7d1c60..be44122ab2e 100644 --- a/core/src/main/java/bisq/core/grpc/CoreWalletsService.java +++ b/core/src/main/java/bisq/core/grpc/CoreWalletsService.java @@ -65,8 +65,7 @@ public long getAvailableBalance() { if (!walletsManager.areWalletsAvailable()) throw new IllegalStateException("wallet is not yet available"); - if (walletsManager.areWalletsEncrypted() && tempAesKey == null) - throw new IllegalStateException("wallet is locked"); + verifyEncryptedWalletIsUnlocked(); var balance = balances.getAvailableBalance().get(); if (balance == null) @@ -93,8 +92,7 @@ public String getFundingAddresses() { if (!walletsManager.areWalletsAvailable()) throw new IllegalStateException("wallet is not yet available"); - if (walletsManager.areWalletsEncrypted() && tempAesKey == null) - throw new IllegalStateException("wallet is locked"); + verifyEncryptedWalletIsUnlocked(); // Create a new funding address if none exists. if (btcWalletService.getAvailableAddressEntries().size() == 0) @@ -246,6 +244,12 @@ private void verifyWalletIsAvailableAndEncrypted() { throw new IllegalStateException("wallet is not encrypted with a password"); } + // Throws a RuntimeException if wallets are encrypted and locked. + private void verifyEncryptedWalletIsUnlocked() { + if (walletsManager.areWalletsEncrypted() && tempAesKey == null) + throw new IllegalStateException("wallet is locked"); + } + private KeyCrypterScrypt getKeyCrypterScrypt() { KeyCrypterScrypt keyCrypterScrypt = walletsManager.getKeyCrypterScrypt(); if (keyCrypterScrypt == null)