protected boolean monitorYoungTransactions() { Collection<TransactionEx> list = _backing.getYoungTransactions(5, getBlockChainHeight()); if (list.isEmpty()) { return true; } List<Sha256Hash> txids = new ArrayList<Sha256Hash>(list.size()); for (TransactionEx tex : list) { txids.add(tex.txid); } CheckTransactionsResponse result; try { result = _wapi.checkTransactions(new CheckTransactionsRequest(txids)).getResult(); } catch (WapiException e) { postEvent(Event.SERVER_CONNECTION_ERROR); _logger.logError("Server connection failed with error code: " + e.errorCode, e); // We failed to check transactions return false; } for (TransactionStatus t : result.transactions) { if (!t.found) { // We have a transaction locally that does not exist in the // blockchain. Must be a residue due to double-spend or malleability _backing.deleteTransaction(t.txid); continue; } TransactionEx tex = _backing.getTransaction(t.txid); Preconditions.checkNotNull(tex); if (tex.height != t.height || tex.time != t.time) { // The transaction got a new height or timestamp. There could be // several reasons for that. It got a new timestamp from the server, // it confirmed, or might also be a reorg. TransactionEx newTex = new TransactionEx(tex.txid, t.height, t.time, tex.binary); System.out.println("Replacing:\n" + tex.toString() + "\nWith:\n" + newTex.toString()); postEvent(Event.TRANSACTION_HISTORY_CHANGED); _backing.deleteTransaction(tex.txid); _backing.putTransaction(newTex); } } return true; }