Search in sources :

Example 21 with JSONObject

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;
}
Also used : JSONObject(run.wallet.common.json.JSONObject)

Example 22 with JSONObject

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;
}
Also used : JSONObject(run.wallet.common.json.JSONObject) JSONArray(run.wallet.common.json.JSONArray)

Example 23 with JSONObject

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();
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 24 with JSONObject

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);
    }
}
Also used : JSONObject(run.wallet.common.json.JSONObject) SharedPreferences(android.content.SharedPreferences) JSONArray(run.wallet.common.json.JSONArray)

Example 25 with JSONObject

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());
}
Also used : JSONObject(run.wallet.common.json.JSONObject) TextFile(run.wallet.common.TextFile) File(java.io.File)

Aggregations

JSONObject (run.wallet.common.json.JSONObject)37 SharedPreferences (android.content.SharedPreferences)24 JSONArray (run.wallet.common.json.JSONArray)21 ArrayList (java.util.ArrayList)6 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 URL (java.net.URL)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Fragment (android.app.Fragment)1 FragmentManager (android.app.FragmentManager)1 FragmentTransaction (android.app.FragmentTransaction)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 File (java.io.File)1 HttpURLConnection (java.net.HttpURLConnection)1 TextFile (run.wallet.common.TextFile)1 JSONException (run.wallet.common.json.JSONException)1 WebGetExchangeRatesHistoryRequest (run.wallet.iota.api.requests.WebGetExchangeRatesHistoryRequest)1