public static NxtSendRequest to(NxtFamilyWallet from, NxtAddress destination, Value amount) {
checkNotNull(destination.getType(), "Address is for an unknown network");
checkState(from.getCoinType() == destination.getType(), "Incompatible destination address coin type");
checkState(TypeUtils.is(destination.getType(), amount.type), "Incompatible sending amount type");
checkTypeCompatibility(destination.getType());
NxtSendRequest req = new NxtSendRequest(destination.getType());
byte version = (byte) 1;
int timestamp;
if (req.type instanceof NxtMain) {
timestamp = Convert.toNxtEpochTime(System.currentTimeMillis());
} else if (req.type instanceof BurstMain) {
timestamp = Convert.toBurstEpochTime(System.currentTimeMillis());
} else {
throw new RuntimeException("Unexpected NXT family type: " + req.type.toString());
}
TransactionImpl.BuilderImpl builder = new TransactionImpl.BuilderImpl(version,
from.getPublicKey(), amount.value, req.fee.value, timestamp,
NxtFamily.DEFAULT_DEADLINE, Attachment.ORDINARY_PAYMENT);
builder.recipientId(destination.getAccountId());
if (destination.getPublicKey() != null) {
Appendix.PublicKeyAnnouncement publicKeyAnnouncement
= new Appendix.PublicKeyAnnouncement(destination.getPublicKey());
builder.publicKeyAnnouncement(publicKeyAnnouncement);
}
req.nxtTxBuilder = builder;
return req;
}