Пример #1
0
  public void check(CBlockPayload block) throws Exception {
    // Super class
    super.check(block);

    // Check Message
    if (!UTILS.BASIC.isDesc(mes, 1000))
      throw new Exception("Invalid message - CTweetMesPayload.java");

    //  CommentID valid
    if (!UTILS.BASIC.validID(this.comID))
      throw new Exception("Invalid message ID - CTweetMesPayload.java");

    // Parent type
    if (!this.parent_type.equals("ID_POST") && !this.parent_type.equals("ID_COM"))
      throw new Exception("Invalid parent type - CTweetMesPayload.java");

    // Already commented ?
    ResultSet rs =
        UTILS.DB.executeQuery(
            "SELECT * "
                + "FROM comments "
                + "WHERE parent_type='"
                + this.parent_type
                + "' "
                + "AND parentID='"
                + this.parentID
                + "' "
                + "AND adr='"
                + this.target_adr
                + "'");

    if (UTILS.DB.hasData(rs)) throw new Exception("Already commented - CTweetMesPayload.java");

    // Target valid
    if (!UTILS.BASIC.targetValid(this.parent_type, this.parentID))
      throw new Exception("Invalid target type - CTweetMesPayload.java");

    // Check Hash
    String h =
        UTILS.BASIC.hash(this.getHash() + this.parent_type + this.parentID + this.comID + this.mes);

    if (!h.equals(this.hash)) throw new Exception("Invalid hash - CTweetMesPayload.java");
  }
Пример #2
0
  public void check(CBlockPayload block) throws Exception {
    // Super class
    super.check(block);

    // Valid asset ID
    if (!UTILS.BASIC.validID(this.assetID))
      throw new Exception("Invalid asset ID - CIssueAssetPayload.java");

    // Symbol length
    if (!UTILS.BASIC.isSymbol(this.symbol))
      throw new Exception("Invalid symbol - CIssueAssetPayload.java");

    // Same symbol
    ResultSet rs =
        UTILS.DB.executeQuery("SELECT * " + "FROM assets " + "WHERE symbol='" + this.symbol + "'");

    if (UTILS.DB.hasData(rs))
      throw new Exception("Asset symbol already exist - CIssueAssetPayload.java");

    // Qty
    if (this.qty < 1000 || this.qty > 10000000000L)
      throw new Exception("Invalid qty - CIssueAssetPayload.java");

    // Title
    if (!UTILS.BASIC.isTitle(this.title))
      throw new Exception("Invalid title - CIssueAssetPayload.java");

    // Description
    if (!UTILS.BASIC.isDesc(this.description))
      throw new Exception("Invalid description - CIssueAssetPayload.java");

    // Web page
    if (!this.web_page.equals(""))
      if (!UTILS.BASIC.isLink(this.web_page))
        throw new Exception("Invalid web page - CIssueAssetPayload.java");

    // How buy
    if (!this.how_buy.equals(""))
      if (!UTILS.BASIC.isDesc(this.how_buy))
        throw new Exception("Invalid how to buy - CIssueAssetPayload.java");

    // How sell
    if (!this.how_sell.equals(""))
      if (!UTILS.BASIC.isDesc(this.how_sell))
        throw new Exception("Invalid to sell - CIssueAssetPayload.java");

    // Pic
    if (!this.pic.equals(""))
      if (!UTILS.BASIC.isPic(this.pic))
        throw new Exception("Invalid pic - CIssueAssetPayload.java");

    // Days
    if (this.days < 1000) throw new Exception("Invalid days - CIssueAssetPayload.java");

    // Transaction fee address
    if (!UTILS.BASIC.isAdr(this.trans_fee_adr))
      throw new Exception("Invalid transaction fee address - CIssueAssetPayload.java");

    // Transaction fee
    if (this.trans_fee < 0.01 || this.trans_fee > 10)
      throw new Exception("Invalid transaction fee - CIssueAssetPayload.java");

    // Sealed ?
    if (UTILS.BASIC.isSealed(this.target_adr))
      throw new Exception("Sealed address - CIssueAssetPayload.java");

    // Mkt address ?
    if (UTILS.BASIC.isMktAdr(this.target_adr) || UTILS.BASIC.isContractAdr(this.target_adr))
      throw new Exception("Market address - CIssueAssetPayload.java");

    // Calculates hash
    String h =
        UTILS.BASIC.hash(
            this.getHash()
                + this.assetID
                + this.symbol
                + this.title
                + this.description
                + this.how_buy
                + this.how_sell
                + this.web_page
                + this.pic
                + days
                + this.qty
                + this.trans_fee_adr
                + UTILS.FORMAT_2.format(this.trans_fee));

    // Check hash
    if (!this.hash.equals(h)) throw new Exception("Invalid hash - CIssueAssetPayload.java");
  }