@SuppressWarnings("rawtypes") public Object loadResponse(InputStream in, Object expectedID, boolean close) throws IOException, GenericRpcException { try { String r = new String(loadStream(in, close), QUERY_CHARSET); logger.log(Level.FINE, "Bitcoin JSON-RPC response:\n{0}", r); try { Map response = (Map) JSON.parse(r); if (!expectedID.equals(response.get("id"))) throw new BitcoinRPCException("Wrong response ID (expected: " + String.valueOf(expectedID) + ", response: " + response.get("id") + ")"); if (response.get("error") != null) throw new BitcoinRPCException(new BitcoinRPCError((Map)response.get("error"))); return response.get("result"); } catch (ClassCastException ex) { throw new BitcoinRPCException("Invalid server response format (data: \"" + r + "\")"); } } finally { if (close) in.close(); } }
private String pageError(VelocityContext context, Throwable th) { String errmsg = th.getMessage(); if (errmsg == null || errmsg.length() == 0) errmsg = th.toString(); if (th instanceof BitcoinRPCException) { errmsg = ((BitcoinRPCException) th).getRPCError().getMessage(); errmsg = "Blockchain not available: " + errmsg; } context.put("errmsg", errmsg); return "templates/portal-error.vm"; }
@SuppressWarnings("rawtypes") public Object loadResponse(InputStream in, Object expectedID, boolean close) throws IOException, GenericRpcException { try { String r = new String(loadStream(in, close), QUERY_CHARSET); logger.log(Level.FINE, "Bitcoin JSON-RPC response:\n{0}", r); try { Map response = (Map) JSON.parse(r); if (!expectedID.equals(response.get("id"))) throw new BitcoinRPCException("Wrong response ID (expected: " + String.valueOf(expectedID) + ", response: " + response.get("id") + ")"); if (response.get("error") != null) throw new BitcoinRPCException(new BitcoinRPCError((Map)response.get("error"))); return response.get("result"); } catch (ClassCastException ex) { throw new BitcoinRPCException("Invalid server response format (data: \"" + r + "\")"); } } finally { if (close) in.close(); } }
@SuppressWarnings("rawtypes") public Object loadResponse(InputStream in, Object expectedID, boolean close) throws IOException, GenericRpcException { try { String r = new String(loadStream(in, close), QUERY_CHARSET); logger.log(Level.FINE, "Bitcoin JSON-RPC response:\n{0}", r); try { Map response = (Map) JSON.parse(r); if (!expectedID.equals(response.get("id"))) throw new BitcoinRPCException("Wrong response ID (expected: " + String.valueOf(expectedID) + ", response: " + response.get("id") + ")"); if (response.get("error") != null) throw new BitcoinRPCException(new BitcoinRPCError((Map)response.get("error"))); return response.get("result"); } catch (ClassCastException ex) { throw new BitcoinRPCException("Invalid server response format (data: \"" + r + "\")"); } } finally { if (close) in.close(); } }
if (responseCode != 200) { InputStream errorStream = conn.getErrorStream(); throw new BitcoinRPCException(method, Arrays.deepToString(o), responseCode, throw new BitcoinRPCException(method, Arrays.deepToString(o), ex);
if (responseCode != 200) { InputStream errorStream = conn.getErrorStream(); throw new BitcoinRPCException(method, Arrays.deepToString(o), responseCode, throw new BitcoinRPCException(method, Arrays.deepToString(o), ex);
if (responseCode != 200) { InputStream errorStream = conn.getErrorStream(); throw new BitcoinRPCException(method, Arrays.deepToString(o), responseCode, throw new BitcoinRPCException(method, Arrays.deepToString(o), ex);
@Override @SuppressWarnings("unchecked") public Transaction getTransaction(String txId) { TransactionWrapper tx = new TransactionWrapper((Map<String, ?>) query("gettransaction", txId)); // [#88] Request for invalid Tx should fail // https://github.com/Polve/JavaBitcoindRpcClient/issues/88 RawTransaction rawTx = tx.raw(); if (rawTx == null || rawTx.vIn().isEmpty() || rawTx.vOut().isEmpty()) { throw new BitcoinRPCException("Invalid Tx: " + txId); } return tx; }
@Override @SuppressWarnings("unchecked") public Transaction getTransaction(String txId) { TransactionWrapper tx = new TransactionWrapper((Map<String, ?>) query("gettransaction", txId)); // [#88] Request for invalid Tx should fail // https://github.com/Polve/JavaBitcoindRpcClient/issues/88 RawTransaction rawTx = tx.raw(); if (rawTx == null || rawTx.vIn().isEmpty() || rawTx.vOut().isEmpty()) { throw new BitcoinRPCException("Invalid Tx: " + txId); } return tx; }