diff --git a/core/src/main/java/bisq/core/grpc/CoreWalletsService.java b/core/src/main/java/bisq/core/grpc/CoreWalletsService.java index 3eb4cac51ae..1d3719558b7 100644 --- a/core/src/main/java/bisq/core/grpc/CoreWalletsService.java +++ b/core/src/main/java/bisq/core/grpc/CoreWalletsService.java @@ -72,9 +72,7 @@ public CoreWalletsService(Balances balances, } public long getAvailableBalance() { - if (!walletsManager.areWalletsAvailable()) - throw new IllegalStateException("wallet is not yet available"); - + verifyWalletsAreAvailable(); verifyEncryptedWalletIsUnlocked(); var balance = balances.getAvailableBalance().get(); @@ -96,9 +94,7 @@ public AddressBalanceInfo getAddressBalanceInfo(String addressString) { } public List getFundingAddresses() { - if (!walletsManager.areWalletsAvailable()) - throw new IllegalStateException("wallet is not yet available"); - + verifyWalletsAreAvailable(); verifyEncryptedWalletIsUnlocked(); // Create a new funding address if none exists. @@ -140,8 +136,7 @@ public int getNumConfirmationsForMostRecentTransaction(String addressString) { } public void setWalletPassword(String password, String newPassword) { - if (!walletsManager.areWalletsAvailable()) - throw new IllegalStateException("wallet is not yet available"); + verifyWalletsAreAvailable(); KeyCrypterScrypt keyCrypterScrypt = getKeyCrypterScrypt(); @@ -230,6 +225,12 @@ public void removeWalletPassword(String password) { walletsManager.backupWallets(); } + // Throws a RuntimeException if wallets are not available (encrypted or not). + private void verifyWalletsAreAvailable() { + if (!walletsManager.areWalletsAvailable()) + throw new IllegalStateException("wallet is not yet available"); + } + // Throws a RuntimeException if wallets are not available or not encrypted. private void verifyWalletIsAvailableAndEncrypted() { if (!walletsManager.areWalletsAvailable())