当前位置: 首页>>代码示例>>Java>>正文


Java Payment类代码示例

本文整理汇总了Java中com.ripple.core.types.known.tx.txns.Payment的典型用法代码示例。如果您正苦于以下问题:Java Payment类的具体用法?Java Payment怎么用?Java Payment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Payment类属于com.ripple.core.types.known.tx.txns包,在下文中一共展示了Payment类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:26,代码来源:PaymentFlow.java

示例2: checkMaxRequestPayment

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
public void checkMaxRequestPayment(Account account, TransactionManager transactionManager, Payment payment,
		int maxOrdersOffers, int currentOpenOffers) {

	log.info("checkMaxRequestPayment maxOrdersOffers: " + maxOrdersOffers + " currentOpenOffers: "
			+ currentOpenOffers + " Payment: " + payment.accountTxnID());

	int x = countTransactionManagerPayment(transactionManager);
	int c = transactionManager.txnsPending() - x;
	if (c > currentOpenOffers) {
		log.warn("transactionManager " + c + " currentOpenOffers: " + currentOpenOffers);
		return;
	}

	// TODO check and count for ask and bid

	if (arbitragerCreateOffersEnabled) {
		prepareAndQueuePayment(payment);
	}
}
 
开发者ID:mileschet,项目名称:ripple-marketmaker,代码行数:20,代码来源:RipplePaymentCreateListener.java

示例3: 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());
}
 
开发者ID:mileschet,项目名称:ripple-marketmaker,代码行数:26,代码来源:RippexArbitrager.java

示例4: testSerializedPaymentTransaction

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
@Test
public void testSerializedPaymentTransaction() {
    String expectedSerialization = "120000240000000561D4C44364C5BB00000000000000000000000000005553440000000000B5F762798A53D543A014CAF8B297CFF8F2F937E868400000000000000F73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0208114B5F762798A53D543A014CAF8B297CFF8F2F937E88314FD94A75318DE40B1D513E6764ECBCB6F1E7056ED";

    IKeyPair kp = Seed.getKeyPair(TestFixtures.master_seed);
    AccountID ac = AccountID.fromKeyPair(kp);

    Payment payment = new Payment();

    payment.put(AccountID.Account, ac);
    payment.put(AccountID.Destination, TestFixtures.bob_account);

    payment.putTranslated(UInt32.Sequence, 5);
    payment.putTranslated(Amount.Fee, "15");
    payment.putTranslated(Blob.SigningPubKey, kp.canonicalPubHex());
    payment.putTranslated(Amount.Amount, "12/USD/" + ac.address);

    assertEquals(expectedSerialization, payment.toHex());
}
 
开发者ID:ripple,项目名称:ripple-lib-java,代码行数:20,代码来源:STObjectTest.java

示例5: testSymbolics

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
@Test
public void testSymbolics() {
    assertNotNull(TxFormat.fromString("Payment"));

    String json = "{\"Expiration\"        : 21, " +
            "\"TransactionResult\" : 0,  " +
            "\"TransactionType\"   : 0  }";

    STObject so = STObject.fromJSON(json);
    assertEquals(so.getFormat(), TxFormat.Payment);
    so.setFormat(null); // Else it (SHOULD) attempt to validate something clearly unFormatted

    JSONObject object = so.toJSONObject();

    assertEquals(object.get("TransactionResult"), "tesSUCCESS");
    assertEquals(object.get("TransactionType"), "Payment");

}
 
开发者ID:ripple,项目名称:ripple-lib-java,代码行数:19,代码来源:STObjectTest.java

示例6: processOpportunity

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
@JmsListener(destination = "payment_create")
public void processOpportunity(String message) throws JSONException {
	JSONObject json = new JSONObject(message);
	Payment payment = (Payment) Payment.fromJSONObject(json);

	checkMaxRequestPayment(rippleAccount, transactionManager, payment, maxOpenOffers, currentOpenOffers);
}
 
开发者ID:mileschet,项目名称:ripple-marketmaker,代码行数:8,代码来源:RipplePaymentCreateListener.java

示例7: countTransactionManagerPayment

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
private int countTransactionManagerPayment(TransactionManager transactionManager) {
	Iterator<ManagedTxn> it = transactionManager.getPending().iterator();
	int a = 0;
	while (it.hasNext()) {
		ManagedTxn t = it.next();
		if (t.transactionType() == TransactionType.Payment) {
			a++;
		}
	}
	return a;
}
 
开发者ID:mileschet,项目名称:ripple-marketmaker,代码行数:12,代码来源:RipplePaymentCreateListener.java

示例8: 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());
}
 
开发者ID:mileschet,项目名称:ripple-marketmaker,代码行数:32,代码来源:RippexArbitrager.java

示例9: main

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
public static void main(String[] args) {
    String secret = "ssStiMFzkGefDoTqgk9w9WpYkTepQ";
    Payment payment = new Payment();

    // Put `as` AccountID field Account, `Object` o
    payment.as(AccountID.Account,     "rGZG674DSZJfoY8abMPSgChxZTJZEhyMRm");
    payment.as(AccountID.Destination, "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK");
    payment.as(Amount.Amount,         "1000000000");
    payment.as(UInt32.Sequence,       10);
    payment.as(Amount.Fee,            "10000");

    // Try commenting out the Fee, you'll get STObject.FormatException
    SignedTransaction signed = payment.sign(secret);
    // Sign doesn't mutate the original transaction
    // `txn` is a shallow copy
    if (signed.txn == payment)
        throw new AssertionError();

    // MessageFormat which does the heavy lifting for print gets confused
    // by the `{` and `}` in the json.
    print("The original transaction:");
    print("{0}", payment.prettyJSON());
    print("The signed transaction, with SigningPubKey and TxnSignature:");
    print("{0}", signed.txn.prettyJSON());
    print("The transaction id: {0}", signed.hash);
    print("The blob to submit to rippled:");
    print(signed.tx_blob);

    // What if we just have some JSON as a string we want to sign?
    // That's pretty easy to do as well!
    String tx_json = payment.prettyJSON();
    signAgain(tx_json, secret, signed);
}
 
开发者ID:ripple,项目名称:ripple-lib-java,代码行数:34,代码来源:SignTransaction.java

示例10: signAgain

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
private static void signAgain(String tx_json,
                              String secret,
                              SignedTransaction signedAlready) {
    // fromJSON will give us a payment object but we must cast it
    Payment txn = (Payment) STObject.fromJSON(tx_json);
    SignedTransaction signedAgain = txn.sign(secret);
    // The hash will actually be exactly the same due to rfc6979
    // deterministic signatures.
    if (!signedAlready.hash.equals(signedAgain.hash))
        throw new AssertionError();
}
 
开发者ID:ripple,项目名称:ripple-lib-java,代码行数:12,代码来源:SignTransaction.java

示例11: testCreatePaymentTransaction

import com.ripple.core.types.known.tx.txns.Payment; //导入依赖的package包/类
@Test
public void testCreatePaymentTransaction() throws Exception {
    String secret = "ssStiMFzkGefDoTqgk9w9WpYkTepQ";
    Payment payment = new Payment();

    // Put `as` AccountID field Account, `Object` o
    payment.as(AccountID.Account,     "rGZG674DSZJfoY8abMPSgChxZTJZEhyMRm");
    payment.as(AccountID.Destination, "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK");
    payment.as(Amount.Amount,         "1000000000");
    payment.as(Amount.Fee,            "10000");
    payment.as(UInt32.Sequence,       10);

    payment.sign(secret);
}
 
开发者ID:ripple,项目名称:ripple-lib-java,代码行数:15,代码来源:TransactionTest.java


注:本文中的com.ripple.core.types.known.tx.txns.Payment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。