use of com.eclipsesource.json.JsonArray in project zencash-swing-wallet-ui by ZencashOfficial.
the class ZCashClientCaller method getSuccessfulOperationTXID.
public synchronized String getSuccessfulOperationTXID(String opID) throws WalletCallException, IOException, InterruptedException {
String TXID = null;
JsonArray response = this.executeCommandAndGetJsonArray("z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
JsonObject jsonStatus = response.get(0).asObject();
JsonValue opResultValue = jsonStatus.get("result");
if (opResultValue != null) {
JsonObject opResult = opResultValue.asObject();
if (opResult.get("txid") != null) {
TXID = opResult.get("txid").asString();
}
}
return TXID;
}
use of com.eclipsesource.json.JsonArray in project zencash-swing-wallet-ui by ZencashOfficial.
the class ZCashClientCaller method getWalletZReceivedTransactions.
public synchronized String[][] getWalletZReceivedTransactions() throws WalletCallException, IOException, InterruptedException {
String[] zAddresses = this.getWalletZAddresses();
List<String[]> zReceivedTransactions = new ArrayList<String[]>();
for (String zAddress : zAddresses) {
JsonArray jsonTransactions = executeCommandAndGetJsonArray("z_listreceivedbyaddress", wrapStringParameter(zAddress), "0");
for (int i = 0; i < jsonTransactions.size(); i++) {
String[] currentTransaction = new String[7];
JsonObject trans = jsonTransactions.get(i).asObject();
String txID = trans.getString("txid", "ERROR!");
// Needs to be the same as in getWalletPublicTransactions()
// TODO: some day refactor to use object containers
currentTransaction[0] = "\u2605Z (Private)";
currentTransaction[1] = "receive";
// Transaction confirmations cached - cleared every 10 min
if ((System.currentTimeMillis() - this.lastTransactionConfirmationsAccess) > (10 * 60 * 1000)) {
this.lastTransactionConfirmationsAccess = System.currentTimeMillis();
this.transactionConfirmations.clear();
}
String confirmations = this.transactionConfirmations.get(txID);
if ((confirmations == null) || confirmations.equals("0")) {
currentTransaction[2] = this.getWalletTransactionConfirmations(txID);
this.transactionConfirmations.put(txID, currentTransaction[2]);
} else {
currentTransaction[2] = confirmations;
}
currentTransaction[3] = trans.get("amount").toString();
// Transaction time is cached - cleared every 10 min
if ((System.currentTimeMillis() - this.lastTransactionTimesAccess) > (10 * 60 * 1000)) {
this.lastTransactionTimesAccess = System.currentTimeMillis();
this.transactionTimes.clear();
}
String time = this.transactionTimes.get(txID);
if ((time == null) || (time.equals("-1"))) {
currentTransaction[4] = this.getWalletTransactionTime(txID);
this.transactionTimes.put(txID, currentTransaction[4]);
} else {
currentTransaction[4] = time;
}
currentTransaction[5] = zAddress;
currentTransaction[6] = trans.get("txid").toString();
zReceivedTransactions.add(currentTransaction);
}
}
return zReceivedTransactions.toArray(new String[0][]);
}
use of com.eclipsesource.json.JsonArray in project zencash-swing-wallet-ui by ZencashOfficial.
the class ZCashClientCaller method getWalletZAddresses.
public synchronized String[] getWalletZAddresses() throws WalletCallException, IOException, InterruptedException {
JsonArray jsonAddresses = executeCommandAndGetJsonArray("z_listaddresses", null);
String[] strAddresses = new String[jsonAddresses.size()];
for (int i = 0; i < jsonAddresses.size(); i++) {
strAddresses[i] = jsonAddresses.get(i).asString();
}
return strAddresses;
}
use of com.eclipsesource.json.JsonArray in project box-android-sdk by box.
the class BoxRequestCollectionUpdate method setCollectionId.
/**
* Sets the id of the collection to update.
*
* @param id id of the collection to update.
* @return request with the updated collection id.
*/
protected R setCollectionId(String id) {
JsonArray jsonArray = new JsonArray();
if (!TextUtils.isEmpty(id)) {
BoxCollection col = BoxCollection.createFromId(id);
jsonArray.add(col.toJsonObject());
}
mBodyMap.put(FIELD_COLLECTIONS, jsonArray);
return (R) this;
}
use of com.eclipsesource.json.JsonArray in project box-android-sdk by box.
the class BoxRequestItemUpdate method setTags.
/**
* Sets the new tags for the item.
*
* @param tags new tags for the item.
* @return request with the updated tags.
*/
public R setTags(List<String> tags) {
JsonArray jsonArray = new JsonArray();
for (String s : tags) {
jsonArray.add(s);
}
mBodyMap.put(BoxItem.FIELD_TAGS, jsonArray);
return (R) this;
}
Aggregations