mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Remove duplication in wallets availability checks
This change adds a new 'verifyWalletsAreAvailable' method to the client, which eliminates this duplicated statement: throw new IllegalStateException("wallet is not yet available"); The commit is in response to a requested change in PR 4312: https://github.com/bisq-network/bisq/pull/4312#pullrequestreview-435659314
This commit is contained in:
parent
9691f35082
commit
e1fddfacf8
@ -72,9 +72,7 @@ class CoreWalletsService {
|
||||
}
|
||||
|
||||
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 @@ class CoreWalletsService {
|
||||
}
|
||||
|
||||
public List<AddressBalanceInfo> 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 @@ class CoreWalletsService {
|
||||
}
|
||||
|
||||
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 @@ class CoreWalletsService {
|
||||
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())
|
||||
|
Loading…
Reference in New Issue
Block a user