@Override JSONStreamAware processRequest(HttpServletRequest req) { String accountIdString = Convert.emptyToNull(req.getParameter("account")); Long accountId = null; if (accountIdString != null) { try { accountId = Convert.parseUnsignedLong(accountIdString); } catch (RuntimeException e) { return INCORRECT_ACCOUNT; } } JSONArray transactions = new JSONArray(); for (Transaction transaction : Nhz.getTransactionProcessor().getAllUnconfirmedTransactions()) { if (accountId != null && !(accountId.equals(transaction.getSenderId()) || accountId.equals(transaction.getRecipientId()))) { continue; } transactions.add(JSONData.unconfirmedTransaction(transaction)); } JSONObject response = new JSONObject(); response.put("unconfirmedTransactions", transactions); return response; }