/* * @project: TERA * @version: Development (beta) * @license: MIT (not for evil) * @copyright: Yuriy Ivanov (Vtools) 2017-2019 [progr76@gmail.com] * Web: https://terafoundation.org * Twitter: https://twitter.com/terafoundation * Telegram: https://t.me/terafoundation */ function SavePrivateKey() { var Select = document.getElementById("idTypeKey"); if(Select.value === "brain") { ConvertToPrivateKey(); return ; } var Str = document.getElementById("idKeyNew").value; Str = Str.trim(); if(Select.value === "private" && (Str.length !== 64 || !IsHexStr(Str))) { SetError("Error: Length must 64 HEX chars. (Length=" + Str.length + ")"); return ; } else if(Select.value !== "private" && (Str.length !== 66 || Str.substr(0, 1) !== "0" || !IsHexStr(Str))) { SetError("Error: Length must 66 HEX chars. (Length=" + Str.length + ")"); return ; } if(Select.value === "private" && PrivKeyStr !== Str) SetStatus("Changed privat key"); else if(Select.value === "public" && PubKeyStr !== Str) SetStatus("Changed public key"); GetData("SetWalletKey", Str, function (Data) { if(Data && Data.result === 1) { if(Select.value === "private") SelectStyle("styleContrast1"); else if(Select.value === "public") SelectStyle("styleContrast2"); SetVisibleEditKeys(0); UpdatesData(); } }); }; function CreateCheckPoint() { if(!ServerBlockNumDB || ServerBlockNumDB < 16) { SetError("Not set ServerBlockNumDB"); return ; } var BlockNum = ServerBlockNumDB - 10; SetCheckPoint(BlockNum); }; function UseAutoCheckPoint() { var Set = $("idUseAutoCheckPoint").checked; var Period = ParseNum($("idPeriodAutoCheckPoint").value); GetData("SetAutoCheckPoint", {Set:Set, Period:Period}, function (Data) { if(Data) { SetStatus(Data.text, !Data.result); } }); }; function UseAutoCorrTime() { GetData("SetAutoCorrTime", document.getElementById("idUseAutoCorrTime").checked, function (Data) { if(Data) { SetStatus(Data.text, !Data.result); } }); }; function SetCodeVersionJSON() { var Data = JSON.parse(JSON.stringify(CONFIG_DATA.CODE_VERSION)); if(!Data.BlockNum) { Data.LevelUpdate = 160; } Data.BlockNum = CONFIG_DATA.CurBlockNum; Data.addrArr = GetHexFromArr(Data.addrArr); Data.Hash = GetHexFromArr(Data.Hash); Data.Sign = GetHexFromArr(Data.Sign); Data.Hash = undefined; Data.Sign = undefined; Data.StartLoadVersionNum = undefined; var Str = JSON.stringify(Data, "", 2); document.getElementById("idDevService").value = Str; }; function SetCorrTimeJSON() { var AutoDelta = parseInt(document.getElementById("idDevValue").value); var Data = {Num:CONFIG_DATA.CurBlockNum, bUse:1, bAddTime:1}; if(AutoDelta < 0) { AutoDelta = - AutoDelta; Data.bAddTime = 0; } Data.DeltaTime = 40; Data.StartBlockNum = ServerCurBlockNum + 10; Data.EndBlockNum = Data.StartBlockNum + Math.floor(AutoDelta / Data.DeltaTime); var Str = JSON.stringify(Data, "", 2); document.getElementById("idDevService").value = Str; }; function SetNetConstJSON() { var Str = JSON.stringify(Data, "", 2); document.getElementById("idDevService").value = Str; var Data = {MaxTrasactionLimit:CONFIG_DATA.MAX_TRANSACTION_LIMIT}; var Str = JSON.stringify(Data, "", 2); document.getElementById("idDevService").value = Str; }; function SetNewCodeVersion() { try { var Data = JSON.parse(document.getElementById("idDevService").value); } catch(e) { SetError("Error format setting data"); return ; } Data.addrArr = GetArrFromHex(Data.addrArr); GetData("SetNewCodeVersion", Data, function (Data) { if(Data) { SetStatus(Data.text, !Data.result); } }); }; function StartTimeCorrect() { try { var Data = JSON.parse(document.getElementById("idDevService").value); } catch(e) { SetError("Error format setting data"); return ; } GetData("SetCheckDeltaTime", Data, function (Data) { if(Data) { SetStatus(Data.text, !Data.result); } }); }; function StartNetConst() { try { var Data = JSON.parse(document.getElementById("idDevService").value); } catch(e) { SetError("Error format setting data"); return ; } GetData("SetCheckNetConstant", Data, function (Data) { if(Data) { SetStatus(Data.text, !Data.result); } }); }; function RestartNode() { GetData("RestartNode", {}); DoRestartWallet(); }; function UseAutoUpdate() { var Data = {USE_AUTO_UPDATE:document.getElementById("idAutoUpdate").checked, DoMining:1}; GetData("SaveConstant", Data, function (Data) { if(Data && Data.result) { SetStatus("Save AutoUpdate: " + document.getElementById("idAutoUpdate").checked); } }); }; function UseMining() { if(!MiningAccount) { SetError("Not set mining account"); return ; } var Data = {USE_MINING:document.getElementById("idUseMining").checked, DoMining:1}; GetData("SaveConstant", Data, function (Data) { if(Data && Data.result) { SetStatus("Save Mining: " + document.getElementById("idUseMining").checked); } }); }; function SetPercentMining() { var Data = {POW_MAX_PERCENT:document.getElementById("idPercentMining").value}; GetData("SaveConstant", Data, function (Data) { if(Data && Data.result) { SetStatus("Save Mining percent: " + document.getElementById("idPercentMining").value + " %"); } }); }; function MiningSets() { var name = "edit_mining_set"; if(IsVisibleBlock(name)) { SetVisibleBlock(name, false); } else { SetVisibleBlock(name, true); document.getElementById("idMiningAccount").value = MiningAccount; document.getElementById("idMiningAccount").focus(); } }; function SaveMiningSet(Value) { SetVisibleBlock("edit_mining_set", false); if(Value) { MiningAccount = Value; } else { MiningAccount = ParseNum(document.getElementById("idMiningAccount").value); } GetData("SetMining", MiningAccount, function (Data) { }); }; function CancalMiningSet() { var name = "edit_mining_set"; SetVisibleBlock(name, false); }; var WasHistoryMaxNum; var WasLastNumSound = 0; function CheckNewMoney() { return ; if(!$("idUseSoundHistory").checked) return ; if(WasHistoryMaxNum === HistoryMaxNum || !ServerBlockNumDB) return ; WasHistoryMaxNum = HistoryMaxNum; GetData("GetHistoryAct", {StartNum:HistoryMaxNum - 40, CountNum:40}, function (Data) { if(Data && Data.result) { var arr = Data.arr; for(var i = 0; i < arr.length; i++) { var Item = arr[i]; if(Item.Direct === "+" && Item.BlockNum > ServerBlockNumDB - 60 && Item.BlockNum < ServerBlockNumDB - 20 && Item.BlockNum > WasLastNumSound) { WasLastNumSound = Item.BlockNum; $("sound_coin").play(); } } } }); }; function DoRestartWallet() { SetStatus("