@Override public boolean isType(ValueType otherType) { return TypeUtils.is(type, otherType); }
@Override public boolean isType(WalletAccount other) { return TypeUtils.is(type, other); }
@Override public boolean isType(AbstractAddress address) { return TypeUtils.is(type, address); }
/** * <p>Creates a new SendRequest to the given address for the given value.</p> * * <p>Be very careful when value is smaller than {@link Transaction#MIN_NONDUST_OUTPUT} as the transaction will * likely be rejected by the network in this case.</p> */ public static BitSendRequest to(BitAddress destination, Value amount) { checkNotNull(destination.getType(), "Address is for an unknown network"); checkState(TypeUtils.is(destination.getType(), amount.type), "Incompatible sending amount type"); checkTypeCompatibility(destination.getType()); BitSendRequest req = new BitSendRequest(destination.getType()); Transaction tx = new Transaction(req.type); tx.addOutput(amount.toCoin(), destination); req.tx = new BitTransaction(tx); return req; }
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()); // TODO extra check, query the server if the public key announcement is actually needed if (destination.getPublicKey() != null) { Appendix.PublicKeyAnnouncement publicKeyAnnouncement = new Appendix.PublicKeyAnnouncement(destination.getPublicKey()); builder.publicKeyAnnouncement(publicKeyAnnouncement); } req.nxtTxBuilder = builder; return req; }