/** * @return Amount * The real native unit is a drop, one million of which are an XRP. * We want `one` unit at XRP scale (1e6 drops), or if it's an IOU, * just `one`. */ public Amount one() { if (isNative()) { return ONE_XRP; } else { return issue().amount(1); } }
public Issue issue() { // TODO: store the currency and issuer as an Issue return new Issue(currency, issuer); }
@Override public String toString() { if (isNative()) { return "XRP"; } else { return String.format("%s/%s", currency, issuer); } }
public Issue takerGetsIssue() { // TODO: remove wrapper return Issue.from160s(takerGetsCurrency(), takerGetsIssuer()); } public Issue takerPaysIssue() {
public static Issue fromString(String pair) { String[] split = pair.split("/"); return fromStringPair(split); }
private Amount issuedBy(boolean hi) { Amount balance; if (hi) { balance = balance().newIssuer(highAccount()); } else { balance = balance().negate().newIssuer(lowAccount()); } if (!balance.isPositive()) { balance = balance.issue().amount(0); } return balance; }
public Issue issue(Currency c) { return new Issue(c, this); }
public JSONObject toJSON() { JSONObject o = new JSONObject(); o.put("currency", currency); if (!isNative()) { o.put("issuer", issuer); } return o; }
public Issue takerPaysIssue() { // TODO: remove wrapper return Issue.from160s(takerPaysCurrency(), takerPaysIssuer()); }
public Request subscribeBookOffers(Issue get, Issue pay) { Request request = newRequest(Command.subscribe); JSONObject book = new JSONObject(); JSONArray books = new JSONArray(new Object[] { book }); book.put("snapshot", true); book.put("taker_gets", get.toJSON()); book.put("taker_pays", pay.toJSON()); request.json("books", books); return request; }
destinationAmount = Issue.XRP.amount(destAmountValue); } else { destinationAmount = new Amount(destAmountValue, destAmountCurrency, dest);
private static Issue fromStringPair(String[] split) { if (split.length == 2) { return new Issue(Currency.fromString(split[0]), AccountID.fromString(split[1])); } else if (split[0].equals("XRP")) { return new Issue(Currency.XRP, AccountID.XRP_ISSUER); } else { throw new RuntimeException("Issue string must be XRP or $currency/$issuer"); } }
public Amount amount(Number value) { return new Amount(BigDecimal.valueOf(value.doubleValue()), currency, issuer, isNative()); }