@Override JSONStreamAware processRequest(HttpServletRequest req) throws NxtException { Long orderId = ParameterParser.getOrderId(req); Order.Ask askOrder = Order.Ask.getAskOrder(orderId); if (askOrder == null) { return UNKNOWN_ORDER; } return JSONData.askOrder(askOrder); }
@Override JSONStreamAware processRequest(HttpServletRequest req) throws NxtException { long orderId = ParameterParser.getUnsignedLong(req, "order", true); Account account = ParameterParser.getSenderAccount(req); Order.Ask orderData = Order.Ask.getAskOrder(orderId); if (orderData == null || orderData.getAccountId() != account.getId()) { return UNKNOWN_ORDER; } Attachment attachment = new Attachment.ColoredCoinsAskOrderCancellation(orderId); return createTransaction(req, account, attachment); }
public static Transaction create( IAccount sender, Long order, short deadline, int fee, Long referencedTransaction, NXTService nxt) throws TransactionException, ValidationException { String secretPhrase = sender.getPrivateKey(); byte[] publicKey = Crypto.getPublicKey(secretPhrase); if ((fee <= 0) || (fee >= 1000000000L)) throw new TransactionException(TransactionException.INCORRECT_FEE); if ((deadline < 1) || (deadline > 1440)) throw new TransactionException(TransactionException.INCORRECT_DEADLINE); Account account = Account.getAccount(publicKey); if (account == null) throw new TransactionException(TransactionException.INTERNAL_ERROR); Order.Ask orderData = Order.Ask.getAskOrder(order); if (orderData == null || !orderData.getAccount().getId().equals(account.getId())) throw new TransactionException(TransactionException.UNKNOWN_ORDER); Attachment attachment = new Attachment.ColoredCoinsAskOrderCancellation(order); Transaction transaction = Nxt.getTransactionProcessor() .newTransaction( deadline, publicKey, Genesis.CREATOR_ID, 0, fee, referencedTransaction, attachment); transaction.sign(secretPhrase); nxt.broacastTransaction(transaction); return transaction; }