mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Factor duplicate unlocked wallet checks into new method
Response to comment in PR 4299: https://github.com/bisq-network/bisq/pull/4299#discussion_r440769032 This PR should be reviewed/merged after PR 4309. https://github.com/bisq-network/bisq/pull/4309
This commit is contained in:
parent
bac3ed5697
commit
258d1801d2
1 changed files with 8 additions and 4 deletions
|
@ -65,8 +65,7 @@ class CoreWalletsService {
|
|||
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 @@ class CoreWalletsService {
|
|||
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 @@ class CoreWalletsService {
|
|||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue