Ejemplo n.º 1
0
  public void commit(CBlockPayload block) throws Exception {
    // Superclass
    super.commit(block);

    // Commit
    UTILS.DB.executeUpdate(
        "INSERT INTO comments "
            + "SET adr='"
            + this.target_adr
            + "',"
            + "parent_type='"
            + this.parent_type
            + "', "
            + "parentID='"
            + this.parentID
            + "', "
            + "comID='"
            + this.comID
            + "', "
            + "mes='"
            + UTILS.BASIC.base64_encode(this.mes)
            + "', "
            + "expire='"
            + (this.block + 43200)
            + "', "
            + "block='"
            + this.block
            + "'");

    // Post ?
    if (this.parent_type.equals("ID_POST"))
      UTILS.DB.executeUpdate(
          "UPDATE tweets " + "SET comments=comments+1 " + "WHERE tweetID='" + this.parentID + "'");
  }
Ejemplo n.º 2
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");
  }
Ejemplo n.º 3
0
  public CCommentPayload(String adr, String parent_type, long parentID, String mes)
      throws Exception {
    // Superclass
    super(adr);

    // Parent type
    this.parent_type = parent_type;

    // Parent ID
    this.parentID = parentID;

    // Message
    this.mes = mes;

    // Row ID
    this.comID = UTILS.BASIC.getID();

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

    // Sign
    this.sign();
  }
Ejemplo n.º 4
0
  public CIssueAssetPayload(
      String adr,
      String symbol,
      String title,
      String description,
      String how_buy,
      String how_sell,
      String web_page,
      String pic,
      long days,
      long qty,
      String trans_fee_adr,
      double trans_fee)
      throws Exception {
    super(adr);

    // Symbol
    this.symbol = symbol;

    // Title
    this.title = title;

    // Description
    this.description = description;

    // How to buy
    this.how_buy = how_buy;

    // How to sell
    this.how_sell = how_sell;

    // Web page
    this.web_page = web_page;

    // Pic
    this.pic = pic;

    // Market days
    this.days = days;

    // Qty
    this.qty = qty;

    // Transaction fee address
    this.trans_fee_adr = trans_fee_adr;

    // Transaction fee
    this.trans_fee = trans_fee;

    // Asset ID
    this.assetID = UTILS.BASIC.getID();

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

    // Sign
    this.sign();
  }
Ejemplo n.º 5
0
  public void commit(CBlockPayload block) throws Exception {
    // Superclass
    super.commit(block);

    // Insert asset
    UTILS.DB.executeUpdate(
        "INSERT INTO assets "
            + "SET adr='"
            + this.target_adr
            + "', "
            + "assetID='"
            + this.assetID
            + "', "
            + "symbol='"
            + this.symbol
            + "', "
            + "title='"
            + UTILS.BASIC.base64_encode(this.title)
            + "', "
            + "description='"
            + UTILS.BASIC.base64_encode(this.description)
            + "', "
            + "how_buy='"
            + UTILS.BASIC.base64_encode(this.how_buy)
            + "', "
            + "how_sell='"
            + UTILS.BASIC.base64_encode(this.how_sell)
            + "', "
            + "web_page='"
            + UTILS.BASIC.base64_encode(this.web_page)
            + "', "
            + "pic='"
            + UTILS.BASIC.base64_encode(this.pic)
            + "', "
            + "expire='"
            + (this.block + (1440 * this.days))
            + "', "
            + "qty='"
            + this.qty
            + "', "
            + "trans_fee_adr='"
            + this.trans_fee_adr
            + "', "
            + "trans_fee='"
            + UTILS.FORMAT_2.format(this.trans_fee)
            + "', "
            + "block='"
            + this.block
            + "'");

    // Update
    UTILS.DB.executeUpdate(
        "INSERT INTO assets_owners "
            + "SET owner='"
            + this.target_adr
            + "', "
            + "symbol='"
            + this.symbol
            + "', "
            + "qty='"
            + this.qty
            + "', "
            + "block='"
            + this.block
            + "'");
  }
Ejemplo n.º 6
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");
  }