static public Hop fromJSONObject(JSONObject json) { Hop hop = new Hop(); if (json.has("account")) { hop.account = AccountID.fromAddress(json.getString("account")); } if (json.has("issuer")) { hop.issuer = AccountID.fromAddress(json.getString("issuer")); } if (json.has("currency")) { hop.currency = Currency.fromString(json.getString("currency")); } if (json.has("type")) { hop.type = json.getInt("type"); } return hop; }
public static AccountID fromString(String value) { if (value.length() == 160 / 4) { return fromAddressBytes(B16.decode(value)); } else { if (value.startsWith("r") && value.length() >= 26) { return fromAddress(value); } AccountID accountID = accountForAlias(value); if (accountID == null) { throw new UnknownAlias("Alias unset: " + value); } return accountID; } }
public static AccountLine fromJSON(AccountID orientedTo, JSONObject line) { AccountLine l = new AccountLine(); AccountID peer = AccountID.fromAddress(line.getString("account")); BigDecimal balance = new BigDecimal(line.getString("balance")); BigDecimal limit = new BigDecimal(line.getString("limit")); BigDecimal limit_peer = new BigDecimal(line.getString("limit_peer")); l.currency = Currency.fromString(line.getString("currency")); l.balance = new Amount(balance, l.currency, peer); l.limit = new Amount(limit, l.currency, peer); l.limit_peer = new Amount(limit_peer, l.currency, orientedTo); l.freeze = line.optBoolean("freeze", false); l.freeze_peer = line.optBoolean("freeze_peer", false); l.authorized = line.optBoolean("authorized", false); l.authorized_peer = line.optBoolean("authorized_peer", false); l.no_ripple = line.optBoolean("no_ripple", false); l.no_ripple_peer = line.optBoolean("no_ripple_peer", false); l.quality_in = line.optInt("quality_in", 0); l.quality_out = line.optInt("quality_out", 0); return l; }
@Override public Hash160 fromString(String value) { if (value.startsWith("r")) { return newInstance(AccountID.fromAddress(value).bytes()); } return super.fromString(value); } }
@Override protected void onNewIntent(Intent intent) { log(Level.INFO, intent.getAction()); super.onNewIntent(intent); Uri data = intent.getData(); if (data != null) { if (data.getPath().matches("^/+contact.*")) { String to = data.getQueryParameter("to"); AccountID contact = AccountID.fromAddress(to); // We haven't bootstrapped yet if (contactsAdapter.isEmpty()) { if (!contactsAddresses.contains(contact)) { contactsAddresses.add(contact); } } // We've already bootstrapped contacts from the blobvault else { int position; position = contactsAddresses.indexOf(contact); if (position == -1) { unshiftContact(to.substring(0, 16) + "...", to); contacts.setSelection(0, true); } else { contacts.setSelection(position, true); } } } } }
private static void analyzeDump() throws IOException, JSONException { BufferedReader bufferedReader = openDumpReader(); AccountID giveAwayAccount = AccountID.fromAddress("rMTzGg7nPPEMJthjgEBfiPZGoAM7MEVa1r");
AccountID destination = fromAddress("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"); BigDecimal slippageFactor = new BigDecimal("1.001"); BigDecimal amount = new BigDecimal("0.0000001");