From c9882124418707436b8de03886e6df2a5c4082c1 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 15 Mar 2013 16:11:29 +0100 Subject: [PATCH] Remove a redundant null check in checkAESKey() --- .../main/java/com/google/bitcoin/core/Wallet.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index eac13a91..9f3aefa0 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -2799,10 +2799,8 @@ public class Wallet implements Serializable, BlockChainListener { lock.lock(); try { // If no keys then cannot decrypt. - if (!getKeys().iterator().hasNext()) { + if (!getKeys().iterator().hasNext()) return false; - } - // Find the first encrypted key in the wallet. ECKey firstEncryptedECKey = null; Iterator iterator = getKeys().iterator(); @@ -2812,15 +2810,11 @@ public class Wallet implements Serializable, BlockChainListener { firstEncryptedECKey = loopECKey; } } - // There are no encrypted keys in the wallet. - if (firstEncryptedECKey == null) { + if (firstEncryptedECKey == null) return false; - } - String originalAddress = firstEncryptedECKey.toAddress(getNetworkParameters()).toString(); - - if (firstEncryptedECKey != null && firstEncryptedECKey.isEncrypted() && firstEncryptedECKey.getEncryptedPrivateKey() != null) { + if (firstEncryptedECKey.isEncrypted() && firstEncryptedECKey.getEncryptedPrivateKey() != null) { try { ECKey rebornKey = firstEncryptedECKey.decrypt(keyCrypter, aesKey);