private String getEcUrl() { return getBaseUrl() + GET_REQUEST + GET_EC_BLOCK; }
private String getTransactionBytesUrl(String txId) { StringBuilder builder = new StringBuilder(); builder.append(getBaseUrl()).append(GET_REQUEST).append(GET_TRANSACTION_BYTES) .append("&transaction=").append(txId); return builder.toString(); }
private String getBlockChainTxsUrl(String address) { StringBuilder builder = new StringBuilder(); builder.append(getBaseUrl()).append(GET_REQUEST).append(GET_BLOCKCHAIN_TXS) .append("&account=").append(address); return builder.toString(); }
private String getTransactionUrl(String txHash) { StringBuilder builder = new StringBuilder(); builder.append(getBaseUrl()).append(GET_REQUEST).append(GET_TRANSACTION) .append("&fullHash=").append(txHash); return builder.toString(); }
private String getAccountInfo(AbstractAddress address) { StringBuilder builder = new StringBuilder(); builder.append(getBaseUrl()).append(GET_REQUEST).append(GET_ACCOUNT) .append("&account=").append(address.toString()); return builder.toString(); }
@Override public boolean broadcastTxSync(final NxtTransaction tx) { RequestBody formBody = new FormEncodingBuilder().add("requestType","broadcastTransaction") .add("transactionBytes", Convert.toHexString(tx.getRawTransaction().getBytes())).build(); Request request = new Request.Builder().url(getBaseUrl()).post(formBody).build(); // FIXME this is not a sync call getHttpClient().newCall(request).enqueue(new Callback() { @Override public void onFailure(Request request, IOException e) { log.info("Failed to communicate with server: " + request.toString()); } @Override public void onResponse(Response response) throws IOException { try { if (!response.isSuccessful()) { log.info("Unable to fetch txs."); log.info("[Error code] = " + response.code()); } JSONObject reply = parseReply(response); log.info("Transaction broadcasted {0}", reply.toString()); } catch (IOException e) { log.info("IOException: " + e.getMessage()); } catch (JSONException e) { log.info("Could not parse JSON: " + e.getMessage()); } } }); return true; }