use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Transaction method toJson.
public JSONObject toJson() {
JSONObject job = new JSONObject();
job.put("hash", hash);
job.put("signatureFragments", signatureFragments);
job.put("address", address);
job.put("value", value);
job.put("tag", tag);
job.put("obsoleteTag", obsoleteTag);
job.put("timestamp", timestamp);
job.put("attachmentTimestamp", attachmentTimestamp);
job.put("attachmentTimestampLowerBound", attachmentTimestampLowerBound);
job.put("attachmentTimestampUpperBound", attachmentTimestampUpperBound);
job.put("currentIndex", currentIndex);
job.put("lastIndex", lastIndex);
job.put("bundle", bundle);
job.put("trunkTransaction", trunkTransaction);
job.put("branchTransaction", branchTransaction);
job.put("nonce", nonce);
job.put("persistence", persistence);
return job;
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Transfer method toJson.
public JSONObject toJson() {
JSONObject job = new JSONObject();
job.put("ts", timestamp);
job.put("add", address);
job.put("hash", hash);
job.put("ps", persistence);
job.put("val", value);
job.put("msg", message);
job.put("tag", tag);
job.put("mil", getMilestone());
job.put("dbl", isMarkDoubleSpend());
job.put("dba", markDoubleAddress);
job.put("ldb", lastDoubleCheck);
job.put("tsc", getTimestampConfirmed());
JSONArray jar = new JSONArray();
for (TransferTransaction t : getTransactions()) {
jar.put(t.toJson());
}
job.put("tra", jar);
JSONArray ojar = new JSONArray();
for (TransferTransaction t : othertransactions) {
ojar.put(t.toJson());
}
job.put("tro", ojar);
JSONArray njar = new JSONArray();
for (String hash : nudgeHashes) {
njar.put(hash);
}
job.put("nudge", njar);
job.put("milc", milestoneCreated);
return job;
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Nodes method saveDownloadNodes.
protected void saveDownloadNodes(Context context, List<Node> nodes) {
SharedPreferences sp = context.getSharedPreferences(SP_NODES, Context.MODE_PRIVATE);
JSONArray jar = new JSONArray();
try {
for (Node node : nodes) {
JSONObject job = new JSONObject();
job.put(J_IP, node.ip);
job.put(J_PORT, node.port);
job.put(J_SYNC, node.syncVal);
job.put(J_PROTO, node.protocol);
job.put(J_NAME, node.name);
job.put(J_LAST, node.lastused);
job.put(J_Dead, node.deadcount);
jar.put(job);
}
} catch (Exception e) {
}
if (jar.length() > 0) {
sp.edit().putString(PREF_NODES, jar.toString()).commit();
}
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class Nodes method update.
protected void update(Context context, Node updatenode) {
SharedPreferences sp = context.getSharedPreferences(SP_NODES, Context.MODE_PRIVATE);
JSONArray jar = new JSONArray();
try {
for (Node usenode : usenodes) {
Node node = usenode;
if (node.ip.equals(updatenode.ip) && node.port == updatenode.port) {
node = updatenode;
}
JSONObject job = new JSONObject();
job.put(J_IP, node.ip);
job.put(J_PORT, node.port);
job.put(J_SYNC, node.syncVal);
job.put(J_PROTO, node.protocol);
job.put(J_NAME, node.name);
job.put(J_LAST, node.lastused);
job.put(J_Dead, node.deadcount);
jar.put(job);
}
} catch (Exception e) {
}
if (jar.length() > 0) {
sp.edit().putString(PREF_USE_NODEs, jar.toString()).commit();
load(context);
}
}
use of run.wallet.common.json.JSONObject in project run-wallet-android by runplay.
the class OutState method Go.
public static void Go(String appendname, Seeds.Seed seed, Wallet wallet, JSONArray transfers, JSONArray addresses) {
JSONObject job = new JSONObject();
job.put("wallet", wallet.toJson());
job.put("seed", seed.getSystemShortValue());
job.put("transfers", transfers);
job.put("addresses", addresses);
File dir = new File(Environment.getExternalStorageDirectory().toString() + "/runplay/wallet");
File file = new File(Environment.getExternalStorageDirectory().toString() + "/runplay/wallet/" + appendname + "-" + seed.name + "-" + System.currentTimeMillis() + ".json");
if (!dir.exists()) {
dir.mkdirs();
}
TextFile.writeToFile(file.getAbsolutePath(), job.toString());
}
Aggregations