Example #1
0
 @Override
 Fee getBaselineFee(Transaction transaction) {
   Attachment.MonetarySystemCurrencyIssuance attachment =
       (Attachment.MonetarySystemCurrencyIssuance) transaction.getAttachment();
   if (Currency.getCurrencyByCode(attachment.getCode()) != null
       || Currency.getCurrencyByCode(attachment.getName()) != null
       || Currency.getCurrencyByName(attachment.getName()) != null
       || Currency.getCurrencyByName(attachment.getCode()) != null) {
     return FIVE_LETTER_CURRENCY_ISSUANCE_FEE;
   }
   switch (Math.min(attachment.getCode().length(), attachment.getName().length())) {
     case 3:
       return THREE_LETTER_CURRENCY_ISSUANCE_FEE;
     case 4:
       return FOUR_LETTER_CURRENCY_ISSUANCE_FEE;
     case 5:
       return FIVE_LETTER_CURRENCY_ISSUANCE_FEE;
     default:
       // never, invalid code length will be checked and caught later
       return THREE_LETTER_CURRENCY_ISSUANCE_FEE;
   }
 }
Example #2
0
 @Override
 boolean isDuplicate(
     Transaction transaction, Map<TransactionType, Map<String, Integer>> duplicates) {
   Attachment.MonetarySystemCurrencyIssuance attachment =
       (Attachment.MonetarySystemCurrencyIssuance) transaction.getAttachment();
   String nameLower = attachment.getName().toLowerCase();
   String codeLower = attachment.getCode().toLowerCase();
   boolean isDuplicate =
       TransactionType.isDuplicate(CURRENCY_ISSUANCE, nameLower, duplicates, true);
   if (!nameLower.equals(codeLower)) {
     isDuplicate =
         isDuplicate
             || TransactionType.isDuplicate(CURRENCY_ISSUANCE, codeLower, duplicates, true);
   }
   return isDuplicate;
 }