public void copyFromJSONObject(JsonObject obj) throws IOException { // Mandatory fields! this.automaticallyAddUsersIfNotExplicitlyImported = obj.getBoolean("automaticallyaddusersifnotexplicitlyimported", true); this.amountToSend = obj.getDouble("amounttosend", 0.0001d); this.transactionFee = obj.getDouble("transactionfee", 0.0001d); }
public void copyFromJSONObject(JsonObject obj) throws IOException { // Mandatory fields! this.automaticallyAddUsersIfNotExplicitlyImported = obj.getBoolean("automaticallyaddusersifnotexplicitlyimported", true); this.amountToSend = obj.getDouble("amounttosend", 0.0001d); this.transactionFee = obj.getDouble("transactionfee", 0.0001d); }
public synchronized ShieldCoinbaseResponse shieldCoinbase(String from, String to) throws WalletCallException, IOException, InterruptedException { JsonObject objResponse = this.executeCommandAndGetJsonObject( "z_shieldcoinbase", wrapStringParameter(from), wrapStringParameter(to)); ShieldCoinbaseResponse shieldCoinbaseResponse = new ShieldCoinbaseResponse(); shieldCoinbaseResponse.operationid = objResponse.getString("operationid", null); shieldCoinbaseResponse.shieldedUTXOs = objResponse.getInt("shieldedUTXOs", -1); if (shieldCoinbaseResponse.shieldedUTXOs == -1) { shieldCoinbaseResponse.shieldedUTXOs = objResponse.getInt("shieldingUTXOs", -1); } shieldCoinbaseResponse.shieldedValue = objResponse.getDouble("shieldedValue", -1); if (shieldCoinbaseResponse.shieldedValue == -1) { shieldCoinbaseResponse.shieldedValue = objResponse.getDouble("shieldingValue", -1); } shieldCoinbaseResponse.remainingUTXOs = objResponse.getInt("remainingUTXOs", -1); shieldCoinbaseResponse.remainingValue = objResponse.getDouble("remainingValue", -1); if (shieldCoinbaseResponse.shieldedValue != -1) { return shieldCoinbaseResponse; } else { throw new WalletCallException("Unexpected z_shieldcoinbase response from wallet: " + objResponse.toString()); } }
JsonArray toManyVerificationArr = Json.parse(toManyArrayStr).asArray(); BigDecimal bdFinalAmount = new BigDecimal(toManyVerificationArr.get(0).asObject().getDouble("amount", -1)); BigDecimal difference = bdAmout.subtract(bdFinalAmount).abs(); if (difference.compareTo(new BigDecimal("0.000000015")) >= 0) {
JsonArray toManyVerificationArr = Json.parse(toManyArrayStr).asArray(); BigDecimal bdFinalAmount = new BigDecimal(toManyVerificationArr.get(0).asObject().getDouble("amount", -1)); BigDecimal difference = bdAmout.subtract(bdFinalAmount).abs(); if (difference.compareTo(new BigDecimal("0.000000015")) >= 0)
/** * Gets Stats from input stream and closes the stream at the end. * @param is where data is present. It is closed at the end. * @return Stats object. * @throws IOException */ public static final Stats fromInputStream(final InputStream is) throws IOException { final Stats currentStats = new Stats(); try (final BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { final JsonValue parse = Json.parse(reader); final JsonArray arrayOfStats = parse.asArray(); for (JsonValue value : arrayOfStats) { final JsonObject stat = value.asObject(); final JsonObject endpoint = stat.get("endpoint").asObject(); final String method = endpoint.getString("method", ""); final String path = endpoint.getString("path", ""); final int errors = stat.getInt("errors", 0); final int success = stat.getInt("success", 0); final double averagePrimaryDuration = stat.getDouble("averagePrimaryDuration", 0.0); final double averageCandidateDuration = stat.getDouble("averageCandidateDuration", 0.0); final List<ErrorDetail> errorDetailList = parseErrorDetails(stat); currentStats.stats.add( new Stat(method, path, errors, success, averagePrimaryDuration, averageCandidateDuration, errorDetailList) ); } } return currentStats; }