func main() { f := tests_utils.InitLog() defer f.Close() txType := "NewPct" txTime := "1599278817" userId := []byte("2") var blockId int64 = 140015 //data:=`{"currency":{"1":{"miner_pct":"0.0000000617044","user_pct":"0.0000000439591"},"72":{"miner_pct":"0.0000000617044","user_pct":"0.0000000439591"}},"referral":{"first":10,"second":0,"third":0}}` data := `{"currency":{"1":{"miner_pct":"0.0000000617044","user_pct":"0.0000000435602"},"72":{"miner_pct":"0.0000000760368","user_pct":"0.0000000562834"}},"referral":{"first":30,"second":20,"third":5}}` var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, userId) // promised_amount_id txSlice = append(txSlice, []byte(data)) dataForSign := fmt.Sprintf("%v,%v,%s,%s", utils.TypeInt(txType), txTime, userId, data) err := tests_utils.MakeFrontTest(txSlice, utils.StrToInt64(txTime), dataForSign, txType, utils.BytesToInt64(userId), "", blockId) if err != nil { fmt.Println(err) } }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "ChangeHost" txTime := "1399278817" userId := []byte("2") var blockId int64 = 1415 host := "http://fdfdfd.ru/" var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, userId) // promised_amount_id txSlice = append(txSlice, []byte(host)) dataForSign := fmt.Sprintf("%v,%v,%s,%s", utils.TypeInt(txType), txTime, userId, host) err := tests_utils.MakeFrontTest(txSlice, utils.StrToInt64(txTime), dataForSign, txType, utils.BytesToInt64(userId), "", blockId) if err != nil { fmt.Println(err) } }
func (c *Controller) VotesExchange() (string, error) { txType := "VotesExchange" txTypeId := utils.TypeInt(txType) timeNow := time.Now().Unix() eOwner := utils.StrToInt64(c.Parameters["e_owner_id"]) result := utils.StrToInt64(c.Parameters["result"]) signData := fmt.Sprintf("%d,%d,%d,%d,%d", txTypeId, timeNow, c.SessUserId, eOwner, result) if eOwner == 0 { signData = "" } TemplateStr, err := makeTemplate("votes_exchange", "votesExchange", &VotesExchangePage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, EOwner: eOwner, Result: result, SignData: signData}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func (c *Controller) ChangeCreditor() (string, error) { txType := "ChangeCreditor" txTypeId := utils.TypeInt(txType) timeNow := time.Now().Unix() creditId := utils.Round(utils.StrToFloat64(c.Parameters["credit_id"]), 0) log.Debug("creditId", creditId) TemplateStr, err := makeTemplate("change_creditor", "changeCreditor", &changeCreditorPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, SignData: "", CreditId: creditId}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func (c *Controller) DelCfFunding() (string, error) { var err error txType := "DelCfFunding" txTypeId := utils.TypeInt(txType) timeNow := utils.Time() delId := int64(utils.StrToFloat64(c.Parameters["del_id"])) TemplateStr, err := makeTemplate("del_cf_funding", "delCfFunding", &DelCfFundingPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, SignData: fmt.Sprintf(`%d,%d,%d,%d`, txTypeId, timeNow, c.SessUserId, delId), UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, DelId: delId}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "ChangeArbitrationDaysRefund" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("91573")) // arbitration_days_refund txSlice = append(txSlice, []byte("150")) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "NewUser" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("1")) // public_key txSlice = append(txSlice, utils.HexToBin([]byte("30820122300d06092a864886f70d01010105000382010f003082010a0282010100ae7797b5c16358862f083bb26cde86b233ba97c48087df44eaaf88efccfe554bf51df8dc7e99072cbe433933f1b87aa9ef62bd5d49dc40e75fe398426c727b0773ea9e4d88184d64c1aa561b1cdf78abe07ca5d23711c403f58abf30d41f4b96161649a91a95818d9d482e8fa3f91829abce3d80f6fc3708ce23f6841bb4a8bae301b23745fce5134420fec0519a081f162d16e4dd0da2e8869b5b67122a1fb7e9bcdb8b2512d1edabdb271bee190563b36a66f5498f50d2fc7202ad2f43b90f860428d5ecd67973900d9997475d4e1a1e4c56b44411cc4b5e9c660fe23fdcd5ab956a834fa05a4ecac9d815143d84993c9424d86379b6f76e3be9aeaaff48fb0203010001)"))) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "Abuses" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("1")) // message txSlice = append(txSlice, []byte(`{"1":"fdfdsfdd", "2":"fsdfkj43 43 34"}`)) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func (c *Controller) DelCfProject() (string, error) { var err error txType := "DelCfProject" txTypeId := utils.TypeInt(txType) timeNow := utils.Time() delId := int64(utils.StrToFloat64(c.Parameters["del_id"])) projectCurrencyName, err := c.Single("SELECT project_currency_name FROM cf_projects WHERE id = ?", delId).String() if err != nil { return "", utils.ErrInfo(err) } TemplateStr, err := makeTemplate("del_cf_project", "delCfProject", &DelCfProjectPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, SignData: fmt.Sprintf(`%d,%d,%d,%d`, txTypeId, timeNow, c.SessUserId, delId), UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, DelId: delId, ProjectCurrencyName: projectCurrencyName}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func (c *Controller) MiningPromisedAmount() (string, error) { txType := "Mining" txTypeId := utils.TypeInt(txType) timeNow := time.Now().Unix() amount := utils.StrToMoney(c.Parameters["amount"]) amount = math.Floor(amount*100) / 100 promisedAmountId := int64(utils.StrToFloat64(c.Parameters["promised_amount_id"])) log.Debug("c.Parameters[promised_amount_id]):", c.Parameters["promised_amount_id"]) log.Debug("promisedAmountId:", promisedAmountId) TemplateStr, err := makeTemplate("mining_promised_amount", "miningPromisedAmount", &miningPromisedAmountPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, SignData: fmt.Sprintf("%v,%v,%v,%v,%v", txTypeId, timeNow, c.SessUserId, promisedAmountId, amount), Amount: amount, PromisedAmountId: promisedAmountId}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func (c *Controller) ChangeMoneyBackTime() (string, error) { txType := "ChangeMoneyBackTime" txTypeId := utils.TypeInt(txType) timeNow := utils.Time() orderId := int64(utils.StrToFloat64(c.Parameters["order_id"])) days := int64(utils.StrToFloat64(c.Parameters["days"])) TemplateStr, err := makeTemplate("change_money_back_time", "changeMoneyBackTime", &changeMoneyBackTimePage{ Alert: c.Alert, Lang: c.Lang, ShowSignData: c.ShowSignData, SignData: "", UserId: c.SessUserId, OrderId: orderId, Days: days, CountSignArr: c.CountSignArr, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func (c *Controller) ChangePromisedAmount() (string, error) { txType := "ChangePromisedAmount" txTypeId := utils.TypeInt(txType) timeNow := time.Now().Unix() promisedAmountId := int64(utils.StrToFloat64(c.Parameters["promised_amount_id"])) amount := c.Parameters["amount"] TemplateStr, err := makeTemplate("change_promised_amount", "changePromisedAmount", &changePromisedAmountPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, SignData: fmt.Sprintf("%v,%v,%v,%v,%v", txTypeId, timeNow, c.SessUserId, promisedAmountId, amount), PromisedAmountId: promisedAmountId, Amount: amount}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "NewMaxOtherCurrencies" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("1")) // json data txSlice = append(txSlice, []byte(`{"1":"1000", "72":500}`)) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "DelPromisedAmount" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("1")) // promised_amount_id txSlice = append(txSlice, []byte("4")) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func (c *Controller) Abuse() (string, error) { var err error txType := "Abuses" txTypeId := utils.TypeInt(txType) timeNow := utils.Time() var countAbusesArr []int for i := 0; i < 20; i++ { countAbusesArr = append(countAbusesArr, i) } TemplateStr, err := makeTemplate("abuse", "abuse", &AbusePage{ Alert: c.Alert, Lang: c.Lang, CountAbusesArr: countAbusesArr, ShowSignData: c.ShowSignData, SignData: "", UserId: c.SessUserId, CountSignArr: c.CountSignArr, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func (c *Controller) RepaymentCredit() (string, error) { txType := "RepaymentCredit" txTypeId := utils.TypeInt(txType) timeNow := time.Now().Unix() creditId := utils.Round(utils.StrToFloat64(c.Parameters["credit_id"]), 0) TemplateStr, err := makeTemplate("repayment_credit", "repaymentCredit", &repaymentCreditPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, SignData: "", CreditId: creditId, CurrencyList: c.CurrencyList}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "ChangeKeyActive" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("91573")) // secret txSlice = append(txSlice, []byte("156516546572676276827")) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func (c *Controller) MoneyBackRequest() (string, error) { txType := "MoneyBackRequest" txTypeId := utils.TypeInt(txType) timeNow := utils.Time() orderId := int64(utils.StrToFloat64(c.Parameters["order_id"])) order, err := c.OneRow("SELECT * FROM orders WHERE id = ?", orderId).String() if err != nil { return "", utils.ErrInfo(err) } TemplateStr, err := makeTemplate("money_back_request", "moneyBackRequest", &moneyBackRequestPage{ Alert: c.Alert, Lang: c.Lang, ShowSignData: c.ShowSignData, SignData: "", UserId: c.SessUserId, OrderId: orderId, Order: order, CountSignArr: c.CountSignArr, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "NewMiner." txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("91573")) //race txSlice = append(txSlice, []byte("1")) //country txSlice = append(txSlice, []byte("1")) //latitude txSlice = append(txSlice, []byte("55")) //longitude txSlice = append(txSlice, []byte("55")) //host txSlice = append(txSlice, []byte("http://55.55.55.55/")) //face_coords txSlice = append(txSlice, []byte("[[118,275],[241,274],[39,274],[316,276],[180,364],[182,430],[181,490],[93,441],[259,433]]")) //profile_coords txSlice = append(txSlice, []byte("[[289,224],[148,216],[172,304],[123,239],[328,261],[305,349]]")) //face_hash txSlice = append(txSlice, []byte("face_hash")) //profile_hash txSlice = append(txSlice, []byte("profile_hash")) //video_type txSlice = append(txSlice, []byte("youtube")) //video_url_id txSlice = append(txSlice, []byte("video_url_id")) //node_public_key txSlice = append(txSlice, []byte("node_public_key")) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "CfProjectData" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("4")) //project_id txSlice = append(txSlice, []byte("1")) //lang_id txSlice = append(txSlice, []byte("45")) //blurb_img txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg")) //head_img txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg")) //description_img txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg")) //picture txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg")) //video_type txSlice = append(txSlice, []byte("youtube")) //video_url_id txSlice = append(txSlice, []byte("X-_fg47G5yf-_f")) //news_img txSlice = append(txSlice, []byte("http://i.imgur.com/YRCoVnc.jpg")) //links txSlice = append(txSlice, []byte(`[["http:\/\/goo.gl\/fnfh1Dg",1,532,234,0],["http:\/\/goo.gl\/28Fh4h",1355,1344,2222,66]]`)) //hide txSlice = append(txSlice, []byte("1")) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func (c *Controller) ChangeHost() (string, error) { txType := "ChangeHost" txTypeId := utils.TypeInt(txType) timeNow := utils.Time() if !c.PoolAdmin || c.SessRestricted != 0 { return "", utils.ErrInfo(errors.New("access denied")) } data, err := c.OneRow("SELECT http_host, tcp_host, host_status FROM " + c.MyPrefix + "my_table").String() if err != nil { return "", utils.ErrInfo(err) } data2, err := c.OneRow("SELECT http_host, tcp_host, e_host FROM miners_data WHERE user_id = ?", c.SessUserId).String() if err != nil { return "", utils.ErrInfo(err) } if len(data["http_host"]) == 0 { data["http_host"] = data2["http_host"] } if len(data["tcp_host"]) == 0 { data["tcp_host"] = data2["tcp_host"] } if len(data["e_host"]) == 0 { data["e_host"] = data2["e_host"] } if data["e_host"] == "" { data["e_host"] = "0" } statusArray := map[string]string{"my_pending": c.Lang["local_pending"], "approved": c.Lang["status_approved"]} data["host_status"] = statusArray[data["host_status"]] limitsText := strings.Replace(c.Lang["change_host_limits_text"], "[limit]", utils.Int64ToStr(c.Variables.Int64["limit_change_host"]), -1) limitsText = strings.Replace(limitsText, "[period]", c.Periods[c.Variables.Int64["limit_change_host_period"]], -1) TemplateStr, err := makeTemplate("change_host", "changeHost", &changeHostPage{ Alert: c.Alert, UserId: c.SessUserId, CountSignArr: c.CountSignArr, Data: data, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, LimitsText: limitsText, ShowSignData: c.ShowSignData, Community: c.Community, SignData: "", Lang: c.Lang}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f, err := os.OpenFile("dclog.txt", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0777) defer f.Close() //log.SetOutput(f) log.SetOutput(io.MultiWriter(f, os.Stdout)) log.SetFlags(log.LstdFlags | log.Lshortfile) txType := "Mining" txTime := "1406545938" userId := []byte("105") var blockId int64 = 123925 promised_amount_id := "24" amount := "5.69" var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, userId) // promised_amount_id txSlice = append(txSlice, []byte(promised_amount_id)) // amount txSlice = append(txSlice, []byte(amount)) dataForSign := fmt.Sprintf("%v,%v,%s,%s,%s", utils.TypeInt(txType), txTime, userId, promised_amount_id, amount) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err = tests_utils.MakeFrontTest(txSlice, utils.StrToInt64(txTime), dataForSign, txType, utils.BytesToInt64(userId), "", blockId) if err != nil { fmt.Println(err) } }
func main() { f, err := os.OpenFile("dclog.txt", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0777) defer f.Close() //log.SetOutput(f) log.SetOutput(io.MultiWriter(f, os.Stdout)) log.SetFlags(log.LstdFlags | log.Lshortfile) txType := "Mining" txTime := "1406545931" userId := []byte("2") var blockId int64 = 123924 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, userId) // promised_amount_id txSlice = append(txSlice, []byte(`26`)) // amount txSlice = append(txSlice, []byte(`6`)) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) dir, err := utils.GetCurrentDir() if err != nil { fmt.Println(err) } configIni_, err := config.NewConfig("ini", dir+"/config.ini") if err != nil { fmt.Println(err) } configIni, err := configIni_.GetSection("default") db := utils.DbConnect(configIni) // делаем снимок БД в виде хэшей до начала тестов hashesStart, err := tests_utils.AllHashes(db) err = tests_utils.MakeTest(txSlice, blockData, txType, hashesStart, db, "work") if err != nil { fmt.Println(err) } }
func main() { /* Currency map[string][]float64 `json:"currency"` Referral map[string]int64 `json:"referral"` Admin int64 `json:"admin"` */ f := tests_utils.InitLog() defer f.Close() txType := "VotesComplex" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 newPct := new(vComplex) newPct.Currency = make(map[string][]float64) newPct.Referral = make(map[string]int64) newPct.Currency["1"] = []float64{0.0000000760368, 0.0000000497405, 1000, 55, 10} newPct.Currency["33"] = []float64{0.0000000760368, 0.0000000497405, 1000, 55, 10} newPct.Currency["2"] = []float64{0.0000000760368, 0.0000000497405, 1000, 55, 10} newPct.Referral["first"] = 30 newPct.Referral["second"] = 0 newPct.Referral["third"] = 30 newPct.Admin = 100 newPctJson, _ := json.Marshal(newPct) //newPct1:=new(vComplex) //err := json.Unmarshal([]byte(`{"currency":{"1":[7.60368e-08,4.97405e-08,1000,55,10],"2":[7.60368e-08,4.97405e-08,1000,55,10],"33":[7.60368e-08,4.97405e-08,1000,55,10]},"referral":{"first":30,"second":0,"third":30},"admin":100}`), &newPct1) //fmt.Println(newPct1) //fmt.Println(err) var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, userId) // newPctJson txSlice = append(txSlice, []byte(newPctJson)) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func (c *Controller) CurrencyExchangeDelete() (string, error) { txType := "DelForexOrder" txTypeId := utils.TypeInt(txType) timeNow := time.Now().Unix() delId := utils.StrToInt64(c.Parameters["del_id"]) signData := fmt.Sprintf("%d,%d,%d,%d", txTypeId, timeNow, c.SessUserId, delId) /*data, err := static.Asset("static/templates/currency_exchange_delete.html") if err != nil { return "", utils.ErrInfo(err) } signatures, err := static.Asset("static/templates/signatures.html") if err != nil { return "", utils.ErrInfo(err) } alert_success, err := static.Asset("static/templates/alert_success.html") if err != nil { return "", utils.ErrInfo(err) } t := template.Must(template.New("template").Parse(string(data))) t = template.Must(t.Parse(string(alert_success))) t = template.Must(t.Parse(string(signatures))) b := new(bytes.Buffer) t.ExecuteTemplate(b, "currencyExchangeDelete", ¤cyExchangeDeletePage{ Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, DelId: delId, SignData: signData}) return b.String(), nil*/ TemplateStr, err := makeTemplate("currency_exchange_delete", "currencyExchangeDelete", ¤cyExchangeDeletePage{ Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, DelId: delId, SignData: signData}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "VotesComplex" txTime := "1499278817" userId := []byte("2") var blockId int64 = 128008 newPct := new(vComplex) newPct.Currency = make(map[string][]float64) newPct.Referral = make(map[string]string) newPct.Currency["1"] = []float64{0.0000000760368, 0.0000000497405, 1000, 55, 10} newPct.Currency["72"] = []float64{0.0000000760368, 0.0000000497405, 1000, 55, 10} newPct.Referral["first"] = "30" newPct.Referral["second"] = "0" newPct.Referral["third"] = "30" newPct.Admin = 100 newPctJson, _ := json.Marshal(newPct) var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, userId) // newPctJson txSlice = append(txSlice, []byte(newPctJson)) dataForSign := fmt.Sprintf("%v,%v,%s,%s", utils.TypeInt(txType), txTime, userId, newPctJson) err := tests_utils.MakeFrontTest(txSlice, utils.StrToInt64(txTime), dataForSign, txType, utils.BytesToInt64(userId), "", blockId) if err != nil { fmt.Println(err) } }
func (c *Controller) MyCfProjects() (string, error) { var err error txType := "NewCfProject" txTypeId := utils.TypeInt(txType) timeNow := utils.Time() projectsLang := make(map[string]map[string]string) projects := make(map[string]map[string]string) cfProjects, err := c.GetAll(` SELECT id, category_id, project_currency_name, country, city, currency_id, end_time, amount FROM cf_projects WHERE user_id = ? AND del_block_id = 0 `, -1, c.SessUserId) if err != nil { return "", utils.ErrInfo(err) } for _, data := range cfProjects { CfProjectData, err := c.GetCfProjectData(utils.StrToInt64(data["id"]), utils.StrToInt64(data["end_time"]), c.LangInt, utils.StrToFloat64(data["amount"]), "") if err != nil { return "", utils.ErrInfo(err) } for k, v := range CfProjectData { data[k] = v } projects[data["id"]] = data lang, err := c.GetMap(`SELECT id, lang_id FROM cf_projects_data WHERE project_id = ?`, "id", "lang_id", data["id"]) projectsLang[data["id"]] = lang } cfLng, err := c.GetAllCfLng() TemplateStr, err := makeTemplate("my_cf_projects", "myCfProjects", &MyCfProjectsPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, CfLng: cfLng, CurrencyList: c.CurrencyList, Projects: projects, ProjectsLang: projectsLang}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "SendDc" txTime := "1409288580" userId := []byte("2") var blockId int64 = 10000 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("22cb812e53e22ee539af4a1d39b4596d")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, userId) // to_user_id txSlice = append(txSlice, []byte("2")) // currency_id txSlice = append(txSlice, []byte("72")) // amount txSlice = append(txSlice, []byte("8")) // commission txSlice = append(txSlice, []byte("0.1")) /* for i:=0; i<5; i++ { txSlice = append(txSlice, []byte("0")) } for i:=0; i<5; i++ { txSlice = append(txSlice, []byte("0")) }*/ // comment txSlice = append(txSlice, []byte("1111111111111111111111111111111111")) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }
func (c *Controller) AutoPayments() (string, error) { txType := "AutoPayments" txTypeId := utils.TypeInt(txType) timeNow := time.Now().Unix() var autoPayments []*autoPayment rows, err := c.Query(c.FormatQuery("SELECT id, amount, commission, currency_id, last_payment_time, period, sender, recipient FROM auto_payments WHERE sender = ? AND del_block_id = 0"), c.SessUserId) if err != nil { return "", utils.ErrInfo(err) } defer rows.Close() for rows.Next() { var amount, commission float64 var id, currency_id, last_payment_time, period, sender, recipient int64 err = rows.Scan(&id, &amount, &commission, ¤cy_id, &last_payment_time, &period, &sender, &recipient) if err != nil { return "", utils.ErrInfo(err) } auto_ := &autoPayment{Id: id, Amount: amount, Commission: commission, Currency_id: currency_id, Last_payment_time: last_payment_time, Period: period, Sender: sender, Recipient: recipient} autoPayments = append(autoPayments, auto_) } last_tx, err := c.GetLastTx(c.SessUserId, utils.TypesToIds([]string{"AutoPayments", "DelAutoPayment", "NewAutoPayment"}), 3, c.TimeFormat) lastTxFormatted := "" if len(last_tx) > 0 { lastTxFormatted, _ = utils.MakeLastTx(last_tx, c.Lang) } TemplateStr, err := makeTemplate("auto_payments", "AutoPayments", &AutoPaymentsPage{ Alert: c.Alert, Lang: c.Lang, CountSignArr: c.CountSignArr, ShowSignData: c.ShowSignData, UserId: c.SessUserId, TimeNow: timeNow, TxType: txType, TxTypeId: txTypeId, SignData: "", CurrencyList: c.CurrencyListCf, AutoPayments: autoPayments, LastTxFormatted: lastTxFormatted}) if err != nil { return "", utils.ErrInfo(err) } return TemplateStr, nil }
func main() { f := tests_utils.InitLog() defer f.Close() txType := "NewCfProject" txTime := "1427383713" userId := []byte("2") var blockId int64 = 128008 var txSlice [][]byte // hash txSlice = append(txSlice, []byte("1111111111")) // type txSlice = append(txSlice, utils.Int64ToByte(utils.TypeInt(txType))) // time txSlice = append(txSlice, []byte(txTime)) // user_id txSlice = append(txSlice, []byte("4")) //currency_id txSlice = append(txSlice, []byte("72")) //amount txSlice = append(txSlice, []byte("5000")) //end_time txSlice = append(txSlice, []byte("1427383713")) //latitude txSlice = append(txSlice, []byte("39.94801")) //langitude txSlice = append(txSlice, []byte("39.94801")) //category txSlice = append(txSlice, []byte("1")) //project_currency_name txSlice = append(txSlice, []byte("0VVDDDF")) // sign txSlice = append(txSlice, []byte("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")) blockData := new(utils.BlockData) blockData.BlockId = blockId blockData.Time = utils.StrToInt64(txTime) blockData.UserId = utils.BytesToInt64(userId) err := tests_utils.MakeTest(txSlice, blockData, txType, "work_and_rollback") if err != nil { fmt.Println(err) } }