This can be written more simply:

```
lock.lock();
try {
  DeterministicKey k = (DeterministicKey) basicKeyChain.findKeyFromPubHash(pubkeyHash);
  if (k != null)
    markKeyAsUsed(k);
  return k != null;
} finally {
  lock.unlock();
}
```