本文整理汇总了Java中com.ripple.core.types.known.tx.txns.Payment.destination方法的典型用法代码示例。如果您正苦于以下问题:Java Payment.destination方法的具体用法?Java Payment.destination怎么用?Java Payment.destination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ripple.core.types.known.tx.txns.Payment
的用法示例。
在下文中一共展示了Payment.destination方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPayment
import com.ripple.core.types.known.tx.txns.Payment; //导入方法依赖的package包/类
public ManagedTxn createPayment(Alternative alternative, BigDecimal sendMaxMultiplier) {
Amount sourceAmount = alternative.sourceAmount;
boolean hasPaths = alternative.hasPaths();
ignoreCurrentRequestAndPublishStaleState();
// Cancel the path finding request.
requestPathFindClose();
Payment payment = new Payment();
ManagedTxn managed = srcAccount.transactionManager().manage(payment);
payment.destination(dest);
if (hasPaths) {
// A payment with an empty, but specified paths is invalid
payment.paths(alternative.paths);
}
// If we are sending XRP directly it's pointless to specify SendMax
if (!alternative.directXRP()) {
payment.sendMax(sourceAmount.multiply(sendMaxMultiplier));
}
payment.amount(destinationAmount);
return managed;
}
示例2: createRipplePaymentBuy
import com.ripple.core.types.known.tx.txns.Payment; //导入方法依赖的package包/类
public void createRipplePaymentBuy(JSONObject exchange) {
String pathfindKey = "pathfind1";
JSONObject p = exchange.getJSONObject("pathfind");
JSONObject pathfind = p.getJSONObject(pathfindKey);
JSONObject result = pathfind.getJSONObject("result");
JSONObject destination_amount = result.getJSONObject("destination_amount");
JSONObject alternative = pathfind.getJSONObject("alternative");
JSONArray paths = alternative.getJSONArray("paths_computed");
Amount amount = Amount.translate.fromJSONObject(alternative.getJSONObject("source_amount"));
Amount maxAmount = amount.multiply(slippageMaxAmount);
Payment payment = new Payment();
payment.destination(rippleAccount.id());
payment.account(rippleAccount.id());
payment.paths(PathSet.translate.fromJSONArray(paths));
payment.amount(Amount.translate.fromJSONObject(destination_amount));
payment.sendMax(maxAmount);
log.info("Create Ripple Payment Buy " + pathfindKey + ": " + payment.prettyJSON());
template.convertAndSend(Channels.PAYMENT_CREATE, payment.toJSON().toString());
}
示例3: createRipplePaymentSell
import com.ripple.core.types.known.tx.txns.Payment; //导入方法依赖的package包/类
public void createRipplePaymentSell(JSONObject exchange) {
String pathfindKey = "pathfind2";
JSONObject p = exchange.getJSONObject("pathfind");
JSONObject pathfind = p.getJSONObject(pathfindKey);
JSONObject result = pathfind.getJSONObject("result");
JSONObject destination_amount = result.getJSONObject("destination_amount");
JSONObject alternative = pathfind.getJSONObject("alternative");
JSONArray paths = alternative.getJSONArray("paths_computed");
Payment payment = new Payment();
payment.destination(rippleAccount.id());
payment.account(rippleAccount.id());
payment.paths(PathSet.translate.fromJSONArray(paths));
payment.amount(Amount.translate.fromJSONObject(destination_amount));
JSONObject deliverMin = result.getJSONObject("destination_amount");
Double deliverMin_value = p.getDouble("bid") * listAmounts.get(p.getString("baseIssue"));
deliverMin.put("value", String.format("%.12f", deliverMin_value));
payment.deliverMin(Amount.translate.fromJSONObject(deliverMin));
payment.flags(new UInt32(131072));
JSONObject sendMax = alternative.getJSONObject("source_amount");
Double sendMax_value = listAmounts.get(p.getString("baseIssue")) * slippageMaxAmount;
sendMax.put("value", String.format("%.12f", sendMax_value));
payment.sendMax(Amount.translate.fromJSONObject(sendMax));
log.info("Create Ripple Payment Sell " + pathfindKey + ": " + payment.prettyJSON());
template.convertAndSend(Channels.PAYMENT_CREATE, payment.toJSON().toString());
}