/******************************************************************************
* Copyright © 2013-2016 The Nxt Core Developers. *
* *
* See the AUTHORS.txt, DEVELOPER-AGREEMENT.txt and LICENSE.txt files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* Nxt software, including this file, may be copied, modified, propagated, *
* or distributed except according to the terms contained in the LICENSE.txt *
* file. *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
package nxt.http;
import nxt.Account;
import nxt.Attachment;
import nxt.Constants;
import nxt.Currency;
import nxt.NxtException;
import org.json.simple.JSONStreamAware;
import javax.servlet.http.HttpServletRequest;
/**
* Increase the value of currency units by paying NXT
* <p>
* Parameters
* <ul>
* <li>currency - currency id
* <li>amountPerUnitNQT - the NQT amount invested into increasing the value of a single currency unit.<br>
* This value is multiplied by the currency total supply and the result is deducted from the sender's account balance.
* </ul>
* <p>
* Constraints
* <p>
* This API is allowed only when the currency is {@link nxt.CurrencyType#RESERVABLE} and is not yet active.
* <p>
* The sender account is registered as a founder. Once the currency becomes active
* the total supply is distributed between the founders based on their proportional investment<br>
* The list of founders and their NQT investment can be obtained using the {@link nxt.http.GetCurrencyFounders} API.
*/
public final class CurrencyReserveIncrease extends CreateTransaction {
static final CurrencyReserveIncrease instance = new CurrencyReserveIncrease();
private CurrencyReserveIncrease() {
super(new APITag[] {APITag.MS, APITag.CREATE_TRANSACTION}, "currency", "amountPerUnitNQT");
}
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
Currency currency = ParameterParser.getCurrency(req);
long amountPerUnitNQT = ParameterParser.getLong(req, "amountPerUnitNQT", 1L, Constants.MAX_BALANCE_NQT, true);
Account account = ParameterParser.getSenderAccount(req);
Attachment attachment = new Attachment.MonetarySystemReserveIncrease(currency.getId(), amountPerUnitNQT);
return createTransaction(req, account, attachment);
}
}