本文整理汇总了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;
}
示例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());
}
示例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());
}