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


Java TransferTransaction.setDeadline方法代码示例

本文整理汇总了Java中org.nem.core.model.TransferTransaction.setDeadline方法的典型用法代码示例。如果您正苦于以下问题:Java TransferTransaction.setDeadline方法的具体用法?Java TransferTransaction.setDeadline怎么用?Java TransferTransaction.setDeadline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.nem.core.model.TransferTransaction的用法示例。


在下文中一共展示了TransferTransaction.setDeadline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTransaction

import org.nem.core.model.TransferTransaction; //导入方法依赖的package包/类
/**
 * Creates the transaction.
 *
 * @param timeInstant
 *            the time instant
 * @param sender
 *            the sender
 * @param recipient
 *            the recipient
 * @param amount
 *            the amount
 * @param attachment
 *            the attachment
 * @return the transaction
 */
public static Transaction createTransaction(final TimeInstant timeInstant, final Account sender,
		final Account recipient, final long amount, final TransferTransactionAttachment attachment) {

	final TransferTransaction transaction = new TransferTransaction(timeInstant, // instant
			sender, recipient, // recipient
			Amount.fromMicroNem(amount), // amount in micro xem
			attachment); // attachment (message, mosaics)

	if (transaction.getFee() == null) {
		transaction.setFee(NemAppsLibGlobals.getGlobalTransactionFee().calculateMinimumFee(transaction));
	} else {
		transaction.setFee(Amount.fromNem(0));
	}

	transaction.setDeadline(timeInstant.addHours(23));
	return transaction;
}
 
开发者ID:NEMPH,项目名称:nem-apps-lib,代码行数:33,代码来源:BlockchainTransactionService.java

示例2: send_v2

import org.nem.core.model.TransferTransaction; //导入方法依赖的package包/类
public String send_v2(String recipient, long amount, String messagePayload, MosaicId mosaicId, Quantity mosaicQuantity, String fee){
	// collect parameters
	TimeInstant timeInstant = new SystemTimeProvider().getCurrentTime();
	KeyPair senderKeyPair = new KeyPair(PrivateKey.fromHexString(this.privateKey));
	Account senderAccount = new Account(senderKeyPair);
	Account recipientAccount = new Account(Address.fromEncoded(recipient));
	// add message and mosaic
	TransferTransactionAttachment attachment = new TransferTransactionAttachment();
	if(!"".equals(messagePayload.trim())){
		PlainMessage message = new PlainMessage(messagePayload.getBytes());
		attachment.setMessage(message);
	}
	if(mosaicId!=null && mosaicQuantity!=null){
		attachment.addMosaic(mosaicId, mosaicQuantity);
	}
	if(attachment.getMessage()==null && attachment.getMosaics().size()==0){
		attachment = null;
	}
	// create transaction
	TransferTransaction transaction = new TransferTransaction(2, timeInstant, senderAccount, recipientAccount, Amount.fromNem(amount), attachment);
	// ignore fee or not
	if(fee==null){
		TransactionFeeCalculatorAfterForkForApp feeCalculator = new TransactionFeeCalculatorAfterForkForApp();
		transaction.setFee(feeCalculator.calculateMinimumFee(transaction));
	} else {
		transaction.setFee(Amount.fromNem(0));
	}
	transaction.setDeadline(timeInstant.addHours(23));
	transaction.sign();
	JSONObject params = new JSONObject();
	final byte[] data = BinarySerializer.serializeToBytes(transaction.asNonVerifiable());
	params.put("data", ByteUtils.toHexString(data));
	params.put("signature", transaction.getSignature().toString());
	return HttpClientUtils.post(Constants.URL_TRANSACTION_ANNOUNCE, params.toString());
}
 
开发者ID:NEMChina,项目名称:nem-apps,代码行数:36,代码来源:InitTransaction.java

示例3: send_v2

import org.nem.core.model.TransferTransaction; //导入方法依赖的package包/类
public String send_v2(String recipient, long amount, String messagePayload, MosaicId mosaicId, Quantity mosaicQuantity, String fee){
	// collect parameters
	TimeInstant timeInstant = new SystemTimeProvider().getCurrentTime();
	KeyPair senderKeyPair = new KeyPair(PrivateKey.fromHexString(this.privateKey));
	Account senderAccount = new Account(senderKeyPair);
	Account multisigAccount = new Account(Address.fromPublicKey(PublicKey.fromHexString(this.multisigPublicKey)));
	Account recipientAccount = new Account(Address.fromEncoded(recipient));
	TransferTransactionAttachment attachment = new TransferTransactionAttachment();
	if(!"".equals(messagePayload.trim())){
		PlainMessage message = new PlainMessage(messagePayload.getBytes());
		attachment.setMessage(message);
	}
	if(mosaicId!=null && mosaicQuantity!=null){
		attachment.addMosaic(mosaicId, mosaicQuantity);
	}
	if(attachment.getMessage()==null && attachment.getMosaics().size()==0){
		attachment = null;
	}
	// create transaction
	TransferTransaction transaction = new TransferTransaction(2, timeInstant, multisigAccount, recipientAccount, Amount.fromNem(amount), attachment);
	TransactionFeeCalculatorAfterForkForApp feeCalculator = new TransactionFeeCalculatorAfterForkForApp();
	// ignore fee or not
	if(fee==null){
		transaction.setFee(feeCalculator.calculateMinimumFee(transaction));
	} else {
		transaction.setFee(Amount.fromNem(0));
	}
	// create multisig transaction
	MultisigTransaction multisigTransaction = new MultisigTransaction(timeInstant, senderAccount, transaction);
	if(fee==null){
		multisigTransaction.setFee(feeCalculator.calculateMinimumFee(multisigTransaction));
	} else {
		multisigTransaction.setFee(Amount.fromNem(0));
	}
	transaction.setDeadline(timeInstant.addHours(23));
	multisigTransaction.setDeadline(timeInstant.addHours(23));
	multisigTransaction.sign();
	JSONObject params = new JSONObject();
	final byte[] data = BinarySerializer.serializeToBytes(multisigTransaction.asNonVerifiable());
	params.put("data", ByteUtils.toHexString(data));
	params.put("signature", multisigTransaction.getSignature().toString());
	return HttpClientUtils.post(Constants.URL_TRANSACTION_ANNOUNCE, params.toString());
}
 
开发者ID:NEMChina,项目名称:nem-apps,代码行数:44,代码来源:InitMultisigTransaction.java


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