Пример #1
0
 @Override
 void validateAttachment(Transaction transaction) throws NxtException.ValidationException {
   Attachment.MonetarySystemCurrencyIssuance attachment =
       (Attachment.MonetarySystemCurrencyIssuance) transaction.getAttachment();
   if (attachment.getMaxSupply() > Constants.MAX_CURRENCY_TOTAL_SUPPLY
       || attachment.getMaxSupply() <= 0
       || attachment.getInitialSupply() < 0
       || attachment.getInitialSupply() > attachment.getMaxSupply()
       || attachment.getReserveSupply() < 0
       || attachment.getReserveSupply() > attachment.getMaxSupply()
       || attachment.getIssuanceHeight() < 0
       || attachment.getMinReservePerUnitNQT() < 0
       || attachment.getDecimals() < 0
       || attachment.getDecimals() > 8
       || attachment.getRuleset() != 0) {
     throw new NxtException.NotValidException(
         "Invalid currency issuance: " + attachment.getJSONObject());
   }
   int t = 1;
   for (int i = 0; i < 32; i++) {
     if ((t & attachment.getType()) != 0 && CurrencyType.get(t) == null) {
       throw new NxtException.NotValidException(
           "Invalid currency type: " + attachment.getType());
     }
     t <<= 1;
   }
   CurrencyType.validate(attachment.getType(), transaction);
   CurrencyType.validateCurrencyNaming(transaction.getSenderId(), attachment);
 }