/****************************************************************************** * 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.NxtException; import nxt.PhasingParams; import org.json.simple.JSONStreamAware; import javax.servlet.http.HttpServletRequest; /** * Sets an account control that blocks transactions unless they are phased with certain parameters * * <p> * Parameters * <ul> * <li>controlVotingModel - The expected voting model of the phasing. Possible values: * <ul> * <li>NONE(-1) - the phasing control is removed</li> * <li>ACCOUNT(0) - only by-account voting is allowed</li> * <li>NQT(1) - only balance voting is allowed</li> * <li>ASSET(2) - only asset voting is allowed</li> * <li>CURRENCY(3) - only currency voting is allowed</li> * </ul> * </li> * <li>controlQuorum - The expected quorum.</li> * <li>controlMinBalance - The expected minimum balance</li> * <li>controlMinBalanceModel - The expected minimum balance model. Possible values: * <ul> * <li>NONE(0) No minimum balance restriction</li> * <li>NQT(1) Nxt balance threshold</li> * <li>ASSET(2) Asset balance threshold</li> * <li>CURRENCY(3) Currency balance threshold</li> * </ul> * </li> * <li>controlHolding - The expected holding ID - asset ID or currency ID.</li> * <li>controlWhitelisted - multiple values - the expected whitelisted accounts</li> * <li>controlMaxFees - The maximum allowed accumulated total fees for not yet finished phased transactions.</li> * <li>controlMinDuration - The minimum phasing duration (finish height minus current height).</li> * <li>controlHolding - The maximum allowed phasing duration.</li> * </ul> * * */ public final class SetPhasingOnlyControl extends CreateTransaction { static final SetPhasingOnlyControl instance = new SetPhasingOnlyControl(); private SetPhasingOnlyControl() { super(new APITag[] {APITag.ACCOUNT_CONTROL, APITag.CREATE_TRANSACTION}, "controlVotingModel", "controlQuorum", "controlMinBalance", "controlMinBalanceModel", "controlHolding", "controlWhitelisted", "controlWhitelisted", "controlWhitelisted", "controlMaxFees", "controlMinDuration", "controlMaxDuration"); } @Override JSONStreamAware processRequest(HttpServletRequest request) throws NxtException { Account account = ParameterParser.getSenderAccount(request); PhasingParams phasingParams = parsePhasingParams(request, "control"); long maxFees = ParameterParser.getLong(request, "controlMaxFees", 0, Constants.MAX_BALANCE_NQT, false); short minDuration = (short)ParameterParser.getInt(request, "controlMinDuration", 0, Constants.MAX_PHASING_DURATION - 1, false); short maxDuration = (short) ParameterParser.getInt(request, "controlMaxDuration", 0, Constants.MAX_PHASING_DURATION - 1, false); return createTransaction(request, account, new Attachment.SetPhasingOnly(phasingParams, maxFees, minDuration, maxDuration)); } }