0.886
This commit is contained in:
parent
4ae7e3b8bc
commit
4087d50a65
Binary file not shown.
Binary file not shown.
177
Doc/Eng/API2.md
Normal file
177
Doc/Eng/API2.md
Normal file
@ -0,0 +1,177 @@
|
||||
# API v2 (for exchanges)
|
||||
|
||||
|
||||
The API is designed to make it easier to write third-party applications. Server-side cryptography and POW operations are performed. Therefore, it is not recommended for public access, because it is not protected from DDOS attacks. Use it if applications such as the exchange server are on the same private network.
|
||||
|
||||
This API is available if server is running http and hosting included constant USE_HARD_API_V2.
|
||||
|
||||
### Set the constants:
|
||||
* HTTP_HOSTING_PORT:80
|
||||
* USE_HARD_API_V2:1
|
||||
|
||||
|
||||
Although the API is designed for use in POST requests, it can be used for GET requests in a limited mode.
|
||||
|
||||
Call format:
|
||||
```js
|
||||
{{Server}}/api/v2/{{MethodName}}
|
||||
```
|
||||
Example:
|
||||
```js
|
||||
http://194.1.237.94/api/v2/GenerateKeys
|
||||
```
|
||||
|
||||
As a result, JSON is returned, which contains the required result field with the value:
|
||||
* 0 - the request contains errors or the result is not possible to get (for example, there is no such account),
|
||||
* 1 - successful execution of the query
|
||||
|
||||
text - the optional field contains a detailed description of the result
|
||||
|
||||
All methods support the Meta parameter, if it is specified, the same value is added to the query result. This is useful for organizing your own query routing, often used in micro-service architectures.
|
||||
|
||||
## GenerateKeys
|
||||
|
||||
1)**/api/v2/GenerateKeys** - create private key - public key pair
|
||||
#### Parameters are not required
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/GenerateKeys
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{
|
||||
"result": 1,
|
||||
"PrivKey": "65C65BE3F436DE58C64461BDC1BF0E2D8AB06C2C4E92470B1F4CDEADB9B2C3FF",
|
||||
"PubKey": "030809551AD9E0E275082C75EC82E9651BF062821EC6DFE31039B0EDE6A2ED26CC"
|
||||
}
|
||||
```
|
||||
|
||||
## CreateAccount
|
||||
|
||||
2)**/api/v2/CreateAccount** - create a new account (account). In Tere free account creation is possible only in the intervals of 10 seconds. The paid version is given in the example of 2 methods **Send**
|
||||
#### Parameters:
|
||||
* Name - account name up to 40 bytes
|
||||
* PubKey - public key in hex-format
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/CreateAccount
|
||||
{
|
||||
"Name": "Hellow, world",
|
||||
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F"
|
||||
}
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{"result":1,"text":"Added to timer","TxID":"DC316BD766AC654E0AF7260F2E010000","BlockNum":19795750}
|
||||
```
|
||||
|
||||
|
||||
## Send
|
||||
|
||||
3)**/api/v2/Send** - sending coins from one account to another (you need to specify the private key of the sender's account)
|
||||
#### Parameters:
|
||||
* FromID - the account number of the sender
|
||||
* FromPrivKey - sender private key in hex format
|
||||
* ToID - the account number of the recipient, the number or public key in hex format (in this case, it will create a new account with the name specified in the first line of the description of the payment and the payment the account will be charged 10 Tera)
|
||||
* Amount - sum, floating-point number, or object format {SumCOIN,SumCENT}
|
||||
* Description - description of payment order (optional)
|
||||
|
||||
|
||||
example1:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/Send
|
||||
{
|
||||
"FromID": 190085,
|
||||
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
|
||||
"ToID":190165,
|
||||
"Amount":10.5,
|
||||
"Description":"Test"
|
||||
|
||||
}
|
||||
```
|
||||
example2 (create a new account):
|
||||
```js
|
||||
http://127.0.0.1/api/v2/Send
|
||||
{
|
||||
"FromID": 190085,
|
||||
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
|
||||
"ToID":"0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
|
||||
"Amount":10,
|
||||
"Description":"New account"
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
return:
|
||||
```js
|
||||
{"result":1,"text":"OK","TxID":"BE10810FDE7A1317D9DF51D62D010000","BlockNum":19781201}
|
||||
```
|
||||
|
||||
## GetBalance
|
||||
|
||||
4)**/api/v2/GetBalance** - get account balance
|
||||
#### Parameters:
|
||||
* AccountID - account number
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/GetBalance
|
||||
{
|
||||
"AccountID": 0
|
||||
}
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{
|
||||
"result": 1,
|
||||
"SumCOIN": 580222966,
|
||||
"SumCENT": 527313901
|
||||
}
|
||||
```
|
||||
|
||||
## GetTransaction
|
||||
|
||||
5)**/api/v2/GetTransaction** - get transaction (returns an object with the contents of the transaction)
|
||||
#### Parameters:
|
||||
* TxID - Transaction ID in hex format
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/GetTransaction
|
||||
{
|
||||
"TxID": "BE10810FDE7A1317D9DF51D62D010000"
|
||||
}
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{
|
||||
"Type": 111,
|
||||
"Version": 3,
|
||||
"Reserve": 0,
|
||||
"FromID": 190085,
|
||||
"To": [
|
||||
{
|
||||
"PubKey": "",
|
||||
"ID": 190165,
|
||||
"SumCOIN": 1,
|
||||
"SumCENT": 0
|
||||
}
|
||||
],
|
||||
"Description": "New6",
|
||||
"OperationID": 41,
|
||||
"Body": "",
|
||||
"Sign": "8C761F539A6A24427CF810A49140CA1FFBF0F3A48DCF58AEE0DD9E4A4E631E1A1B6DA86ED6E2EF92DBF537270AA02B5EAE3A7C822B3F70628CAD78525ED9E0F7",
|
||||
"result": 1
|
||||
}
|
||||
```
|
||||
|
||||
## GetHistoryTransactions
|
||||
|
||||
6)**/api/v2/GetHistoryTransactions** - to get the transaction history of the account
|
||||
|
||||
#### **TODO**
|
||||
|
||||
|
||||
|
176
Doc/Rus/API2.md
Normal file
176
Doc/Rus/API2.md
Normal file
@ -0,0 +1,176 @@
|
||||
# API v2 (для бирж и обменников)
|
||||
|
||||
API предназначено для облегчения написания сторонних приложений. На стороне сервера выполняется криптография и операции POW. Поэтому оно не рекомендуется для публичного доступа, т.к. не защищено от DDOS атак. Используйте его, если приложения такие как сервер биржи находятся в одной приватной сети.
|
||||
|
||||
Данный API доступен если на ноде запущен http-хостинг и включена константа USE_HARD_API_V2.
|
||||
|
||||
### Для этого задайте константы:
|
||||
* HTTP_HOSTING_PORT:80
|
||||
* USE_HARD_API_V2:1
|
||||
|
||||
Несмотря на то что API разработано для использования в POST запросах, в ограниченном режиме его можно использовать для GET запросов.
|
||||
|
||||
Формат вызова
|
||||
```js
|
||||
{{Server}}/api/v2/{{MethodName}}
|
||||
```
|
||||
|
||||
Пример:
|
||||
```js
|
||||
http://194.1.237.94/api/v2/GenerateKeys
|
||||
```
|
||||
|
||||
В качестве результат возвращается JSON, который содержит обязательное поле result со значением:
|
||||
* 0 - запрос содержит ошибки или результат не возможно получить (например нет такого счета),
|
||||
* 1 - успешное выполнение запроса
|
||||
|
||||
text - опциональное поле содержит подробное описание результата
|
||||
|
||||
Все методы поддерживают параметр Meta, если он задан, то это же значение добавляется в результат запроса. Это бывает полезно для организации собственной маршрутизации запросов, часто применяется в микро-сервисных архитектурах.
|
||||
|
||||
## GenerateKeys
|
||||
|
||||
1)**/api/v2/GenerateKeys** - создание пары приватный ключ - публичный ключ
|
||||
#### Параметры не обязательны
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/GenerateKeys
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{
|
||||
"result": 1,
|
||||
"PrivKey": "65C65BE3F436DE58C64461BDC1BF0E2D8AB06C2C4E92470B1F4CDEADB9B2C3FF",
|
||||
"PubKey": "030809551AD9E0E275082C75EC82E9651BF062821EC6DFE31039B0EDE6A2ED26CC"
|
||||
}
|
||||
```
|
||||
|
||||
## CreateAccount
|
||||
|
||||
2)**/api/v2/CreateAccount** - создание нового счета (аккаунта). В Тере бесплатное создание счета возможно только в промежутках из 10 секунд. Платный вариант приведен в примере 2 метода **Send**
|
||||
#### Параметры:
|
||||
* Name - имя счета до 40 байт
|
||||
* PubKey - публичный ключ в hex-формате
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/CreateAccount
|
||||
{
|
||||
"Name": "Hellow, world",
|
||||
"PubKey": "0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F"
|
||||
}
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{"result":1,"text":"Added to timer","TxID":"DC316BD766AC654E0AF7260F2E010000","BlockNum":19795750}
|
||||
```
|
||||
|
||||
|
||||
## Send
|
||||
|
||||
3)**/api/v2/Send** - отправка монет с одного счета на другой (требуется указать приватный ключ счета отправителя)
|
||||
#### Параметры:
|
||||
* FromID - номер счета отправителя
|
||||
* FromPrivKey - приватный ключ отправителя в hex-формате
|
||||
* ToID - номер счета получателя, число или публичный ключ в hex-формате (в этом случае будет создан новый счет с именем заданным в первой строке описания платежа и в качестве оплаты создания счета спишется 10 Тера)
|
||||
* Amount - сумма, число с плавающей точкой или объект в формате {SumCOIN,SumCENT}
|
||||
* Description - описание платежка (необязательный параметр)
|
||||
|
||||
|
||||
example1:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/Send
|
||||
{
|
||||
"FromID": 190085,
|
||||
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
|
||||
"ToID":190165,
|
||||
"Amount":10.5,
|
||||
"Description":"Тест"
|
||||
|
||||
}
|
||||
```
|
||||
example2 (создание нового счета):
|
||||
```js
|
||||
http://127.0.0.1/api/v2/Send
|
||||
{
|
||||
"FromID": 190085,
|
||||
"FromPrivKey": "A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033",
|
||||
"ToID":"0240EDF5ECB25D886FD58DB92A53914FAC975078C1C2EDD1AC292B70C7BC13461F",
|
||||
"Amount":10,
|
||||
"Description":"New account"
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
return:
|
||||
```js
|
||||
{"result":1,"text":"OK","TxID":"BE10810FDE7A1317D9DF51D62D010000","BlockNum":19781201}
|
||||
```
|
||||
|
||||
## GetBalance
|
||||
|
||||
4)**/api/v2/GetBalance** - получить баланс счета
|
||||
#### Параметры:
|
||||
* AccountID - номер счета
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/GetBalance
|
||||
{
|
||||
"AccountID": 0
|
||||
}
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{
|
||||
"result": 1,
|
||||
"SumCOIN": 580222966,
|
||||
"SumCENT": 527313901
|
||||
}
|
||||
```
|
||||
|
||||
## GetTransaction
|
||||
|
||||
5)**/api/v2/GetTransaction** - получить транзакцию (возвращает объект с содержимым транзакции)
|
||||
#### Параметры:
|
||||
* TxID - ИД транзакции в hex-формате
|
||||
|
||||
example:
|
||||
```js
|
||||
http://127.0.0.1/api/v2/GetTransaction
|
||||
{
|
||||
"TxID": "BE10810FDE7A1317D9DF51D62D010000"
|
||||
}
|
||||
```
|
||||
return:
|
||||
```js
|
||||
{
|
||||
"Type": 111,
|
||||
"Version": 3,
|
||||
"Reserve": 0,
|
||||
"FromID": 190085,
|
||||
"To": [
|
||||
{
|
||||
"PubKey": "",
|
||||
"ID": 190165,
|
||||
"SumCOIN": 1,
|
||||
"SumCENT": 0
|
||||
}
|
||||
],
|
||||
"Description": "New6",
|
||||
"OperationID": 41,
|
||||
"Body": "",
|
||||
"Sign": "8C761F539A6A24427CF810A49140CA1FFBF0F3A48DCF58AEE0DD9E4A4E631E1A1B6DA86ED6E2EF92DBF537270AA02B5EAE3A7C822B3F70628CAD78525ED9E0F7",
|
||||
"result": 1
|
||||
}
|
||||
```
|
||||
|
||||
## GetHistoryTransactions
|
||||
|
||||
6)**/api/v2/GetHistoryTransactions** - получить историю транзакций счета
|
||||
|
||||
#### **TODO**
|
||||
|
||||
|
||||
|
@ -55,9 +55,11 @@
|
||||
"RESTART_PERIOD_SEC": 0, //авто рестарт ноды через заданный период в сек
|
||||
"MAX_GRAY_CONNECTIONS_TO_SERVER": 10,//число серверов, к которым подключается нода в режиме серых ip
|
||||
"TRANSACTION_PROOF_COUNT": 2000000, //число транзакций сохраняемых в базе данных для возможности отката цепочки назад
|
||||
"MAX_CONNECTIONS_COUNT": 1000, //максимальное число нод, которые могут одновременно быть соединены с текущей нодой
|
||||
|
||||
//WATCHDOG
|
||||
"WATCHDOG_BADACCOUNT": 1, //слежение за наличием ошибок тип "BAD ACCOUNT"
|
||||
"COREY_WATCH_DOG": 1 //слежение за расcинхронизацией цепочки с общей сетью при майнинге
|
||||
"COREY_WATCH_DOG": 2 //слежение за расcинхронизацией цепочки с общей сетью при майнинге
|
||||
|
||||
}
|
||||
````
|
||||
|
@ -73,6 +73,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
.btlong
|
||||
{
|
||||
width: 160px;
|
||||
|
@ -100,7 +100,6 @@ function CreateHashBody(body,Num,Nonce)
|
||||
window.DELTA_POWER_POW_TR = 0;
|
||||
window.DELTA_FOR_TIME_TX = 0;
|
||||
window.MIN_POWER_POW_TR = 0;
|
||||
window.MIN_POWER_POW_ACC_CREATE = 0;
|
||||
window.CONSENSUS_PERIOD_TIME = 1000;
|
||||
window.FIRST_TIME_BLOCK = 1530446400000;
|
||||
window.SetBlockChainConstant = function (Data)
|
||||
@ -110,7 +109,6 @@ window.SetBlockChainConstant = function (Data)
|
||||
Data.DELTA_CURRENT_TIME = 0;
|
||||
window.DELTA_CURRENT_TIME2 = Data.DELTA_CURRENT_TIME - DeltaServerClient;
|
||||
window.MIN_POWER_POW_TR = DELTA_POWER_POW_TR + Data.MIN_POWER_POW_TR;
|
||||
window.MIN_POWER_POW_ACC_CREATE = Data.MIN_POWER_POW_ACC_CREATE;
|
||||
window.FIRST_TIME_BLOCK = Data.FIRST_TIME_BLOCK;
|
||||
window.CONSENSUS_PERIOD_TIME = Data.CONSENSUS_PERIOD_TIME;
|
||||
window.GetCurrentBlockNumByTime = function ()
|
||||
|
@ -22,6 +22,8 @@ function SetAccountsData(Data,AccountsDataStr)
|
||||
{
|
||||
if(!Data || !Data.result)
|
||||
return ;
|
||||
if($("idBtRun"))
|
||||
$("idBtRun").style.display = (Data.arr.length ? '' : 'none');
|
||||
if(AccountsDataStr === WasAccountsDataStr)
|
||||
return ;
|
||||
WasAccountsDataStr = AccountsDataStr;
|
||||
@ -603,7 +605,7 @@ function SendTrCreateAcc(Currency,PubKey,Description,Adviser,Smart,bFindAcc,bAdd
|
||||
}
|
||||
else
|
||||
{
|
||||
SendTransaction(Body, TR, MIN_POWER_POW_ACC_CREATE);
|
||||
SendTransaction(Body, TR);
|
||||
}
|
||||
$("idAccountName").value = "";
|
||||
CancelCreateAccount();
|
||||
|
@ -40,10 +40,10 @@ function SavePrivateKey()
|
||||
if(Data && Data.result === 1)
|
||||
{
|
||||
if(Select.value === "private")
|
||||
SelectStyle("styleBlue");
|
||||
SelectStyle("styleContrast1");
|
||||
else
|
||||
if(Select.value === "public")
|
||||
SelectStyle("styleGreen");
|
||||
SelectStyle("styleContrast2");
|
||||
SetVisibleEditKeys(0);
|
||||
UpdatesData();
|
||||
}
|
||||
|
@ -1546,7 +1546,7 @@ module.exports = class CConsensus extends require("./block-loader")
|
||||
BlockMining.Power = GetPowPower(BlockMining.PowHash)
|
||||
ADD_TO_STAT("MAX:POWER", BlockMining.Power)
|
||||
var Power = GetPowPower(BlockMining.PowHash);
|
||||
var HashCount = (1 << Power) >>> 0;
|
||||
var HashCount = Math.pow(2, Power);
|
||||
ADD_HASH_RATE(HashCount)
|
||||
AddInfoBlock(BlockMining, "Set POW: " + Power)
|
||||
this.SetNoPOW(BlockMining.BlockNum + 8, 0, BlockMining.BlockNum)
|
||||
|
@ -827,7 +827,7 @@ module.exports = class CBlock extends require("./db/block-db")
|
||||
return ;
|
||||
var startTime = process.hrtime();
|
||||
if(this.LoadHistoryMessage)
|
||||
ToLog("WRITE DATA Count:" + arr.length + " " + arr[0].BlockNum + "-" + arr[arr.length - 1].BlockNum)
|
||||
ToLog("WRITE DATA Count:" + arr.length + " " + arr[0].BlockNum + "-" + arr[arr.length - 1].BlockNum, 2)
|
||||
var CurrentBlockNum = GetCurrentBlockNumByTime();
|
||||
var Block, FirstBlock;
|
||||
for(var i = 0; i < arr.length; i++)
|
||||
|
@ -8,17 +8,18 @@
|
||||
* Telegram: https://web.telegram.org/#/im?p=@terafoundation
|
||||
*/
|
||||
|
||||
global.UPDATE_CODE_VERSION_NUM = 886;
|
||||
global.UPDATE_CODE_VERSION_NUM = 891;
|
||||
global.MIN_CODE_VERSION_NUM = 884;
|
||||
global.MINING_VERSION_NUM = 3;
|
||||
global.InitParamsArg = InitParamsArg;
|
||||
global.CONST_NAME_ARR = ["AUTO_COORECT_TIME", "DELTA_CURRENT_TIME", "COMMON_KEY", "NODES_NAME", "SERVER_PRIVATE_KEY_HEX", "USE_NET_FOR_SERVER_ADDRES",
|
||||
"NET_WORK_MODE", "STAT_MODE", "MAX_STAT_PERIOD", "HTTP_PORT_NUMBER", "HTTP_PORT_PASSWORD", "HTTP_IP_CONNECT", "WALLET_NAME",
|
||||
"WALLET_DESCRIPTION", "USE_HARD_API_V2", "COUNT_VIEW_ROWS", "USE_HINT", "ALL_VIEW_ROWS", "ALL_LOG_TO_CLIENT", "USE_MINING",
|
||||
"MINING_START_TIME", "MINING_PERIOD_TIME", "POW_MAX_PERCENT", "COUNT_MINING_CPU", "SIZE_MINING_MEMORY", "POW_RUN_COUNT", "POW_RUN_COUNT_FIND",
|
||||
"USE_AUTO_UPDATE", "RESTART_PERIOD_SEC", "MAX_GRAY_CONNECTIONS_TO_SERVER", "TRANSACTION_PROOF_COUNT", "UPDATE_NUM_COMPLETE",
|
||||
"LIMIT_SEND_TRAFIC", "WATCHDOG_DEV", "ADDRLIST_MODE", "CheckPointDelta", "MIN_VER_STAT", "DEBUG_WALLET", "HTTP_HOSTING_PORT",
|
||||
"HTTPS_HOSTING_DOMAIN", "HTTP_MAX_COUNT_ROWS", "WATCHDOG_BADACCOUNT", "COREY_WATCH_DOG", "MAX_CONNECTIONS_COUNT", ];
|
||||
"WALLET_DESCRIPTION", "USE_HARD_API_V2", "COUNT_VIEW_ROWS", "USE_HINT", "ALL_VIEW_ROWS", "ALL_LOG_TO_CLIENT", "LOG_LEVEL",
|
||||
"USE_MINING", "MINING_START_TIME", "MINING_PERIOD_TIME", "POW_MAX_PERCENT", "COUNT_MINING_CPU", "SIZE_MINING_MEMORY", "POW_RUN_COUNT",
|
||||
"POW_RUN_COUNT_FIND", "USE_AUTO_UPDATE", "RESTART_PERIOD_SEC", "MAX_GRAY_CONNECTIONS_TO_SERVER", "TRANSACTION_PROOF_COUNT",
|
||||
"UPDATE_NUM_COMPLETE", "LIMIT_SEND_TRAFIC", "WATCHDOG_DEV", "ADDRLIST_MODE", "CheckPointDelta", "MIN_VER_STAT", "DEBUG_WALLET",
|
||||
"HTTP_HOSTING_PORT", "HTTPS_HOSTING_DOMAIN", "HTTP_MAX_COUNT_ROWS", "WATCHDOG_BADACCOUNT", "COREY_WATCH_DOG", "MAX_CONNECTIONS_COUNT",
|
||||
];
|
||||
global.USE_HARD_API_V2 = 0;
|
||||
global.USE_TICKET = 0;
|
||||
global.USE_CHECK_SENDING = 1;
|
||||
@ -50,6 +51,7 @@ global.POW_RUN_COUNT = 5000;
|
||||
global.POWRunPeriod = 1;
|
||||
global.CheckPointDelta = 20;
|
||||
global.ALL_LOG_TO_CLIENT = 1;
|
||||
global.LOG_LEVEL = 1;
|
||||
global.LIMIT_SEND_TRAFIC = 0;
|
||||
global.COUNT_VIEW_ROWS = 20;
|
||||
global.MIN_VER_STAT = 0;
|
||||
@ -97,7 +99,6 @@ global.GENERATE_BLOCK_ACCOUNT = 0;
|
||||
global.TOTAL_TER_MONEY = 1e9;
|
||||
global.TRANSACTION_PROOF_COUNT = 1000 * 1000;
|
||||
global.MIN_POWER_POW_ACC_CREATE = 16;
|
||||
global.MIN_POWER_POW_ACC_CREATE_LAST = MIN_POWER_POW_ACC_CREATE + 3;
|
||||
global.START_MINING = 2 * 1000 * 1000;
|
||||
global.REF_PERIOD_MINING = 1 * 1000 * 1000;
|
||||
global.DELTA_BLOCK_ACCOUNT_HASH = 1000;
|
||||
@ -134,7 +135,6 @@ if(global.LOCAL_RUN)
|
||||
global.TEST_TRANSACTION_GENERATE = 0;
|
||||
global.MIN_POWER_POW_TR = 8;
|
||||
global.MIN_POWER_POW_ACC_CREATE = 8;
|
||||
global.MIN_POWER_POW_ACC_CREATE_LAST = 8;
|
||||
NETWORK = "LOCAL";
|
||||
global.ALL_VIEW_ROWS = 1;
|
||||
}
|
||||
@ -149,7 +149,6 @@ else
|
||||
global.REF_PERIOD_MINING = 1000;
|
||||
global.MIN_POWER_POW_TR = 8;
|
||||
global.MIN_POWER_POW_ACC_CREATE = 8;
|
||||
global.MIN_POWER_POW_ACC_CREATE_LAST = 8;
|
||||
global.TRANSACTION_PROOF_COUNT = 200 * 1000;
|
||||
global.MAX_SIZE_LOG = 20 * 1024 * 1024;
|
||||
global.DELTA_BLOCK_ACCOUNT_HASH = 1000;
|
||||
|
@ -302,8 +302,8 @@ HTTPCaller.DappInfo = function (Params,responce,ObjectOnly)
|
||||
ArrLog.push(Item);
|
||||
}
|
||||
var Ret = {result:1, DELTA_CURRENT_TIME:DELTA_CURRENT_TIME, MIN_POWER_POW_TR:MIN_POWER_POW_TR, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK,
|
||||
CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, MIN_POWER_POW_ACC_CREATE:MIN_POWER_POW_ACC_CREATE_LAST, PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB),
|
||||
Smart:Smart, Account:Account, ArrWallet:WLData.arr, ArrEvent:EArr, ArrLog:ArrLog, };
|
||||
CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), Smart:Smart, Account:Account, ArrWallet:WLData.arr,
|
||||
ArrEvent:EArr, ArrLog:ArrLog, };
|
||||
if(global.WALLET)
|
||||
{
|
||||
Ret.WalletIsOpen = (WALLET.WalletOpen !== false);
|
||||
@ -456,12 +456,11 @@ HTTPCaller.GetWalletInfo = function (Params)
|
||||
ArrLog:ArrLogClient, MaxAccID:DApps.Accounts.GetMaxAccount(), MaxActNum:DApps.Accounts.GetActsMaxNum(), MaxDappsID:DApps.Smart.GetMaxNum(),
|
||||
NeedRestart:global.NeedRestart, ip:SERVER.ip, port:SERVER.port, NET_WORK_MODE:global.NET_WORK_MODE, INTERNET_IP_FROM_STUN:global.INTERNET_IP_FROM_STUN,
|
||||
HistoryMaxNum:MaxHistory, DELTA_CURRENT_TIME:DELTA_CURRENT_TIME, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK, CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME,
|
||||
MIN_POWER_POW_ACC_CREATE:MIN_POWER_POW_ACC_CREATE_LAST, DATA_PATH:(DATA_PATH.substr(1, 1) === ":" ? DATA_PATH : GetNormalPathString(process.cwd() + "/" + DATA_PATH)),
|
||||
NodeAddrStr:SERVER.addrStr, STAT_MODE:global.STAT_MODE, HTTPPort:global.HTTP_PORT_NUMBER, HTTPPassword:HTTP_PORT_PASSWORD,
|
||||
CONSTANTS:Constants, CheckPointBlockNum:CHECK_POINT.BlockNum, MiningAccount:global.GENERATE_BLOCK_ACCOUNT, CountMiningCPU:GetCountMiningCPU(),
|
||||
CountRunCPU:global.ArrMiningWrk.length, MiningPaused:global.MiningPaused, HashRate:HashRateOneSec, MIN_POWER_POW_TR:MIN_POWER_POW_TR,
|
||||
PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), NWMODE:global.NWMODE, PERIOD_ACCOUNT_HASH:PERIOD_ACCOUNT_HASH, MAX_ACCOUNT_HASH:DApps.Accounts.DBAccountsHash.GetMaxNum(),
|
||||
TXBlockNum:TXBlockNum, };
|
||||
DATA_PATH:(DATA_PATH.substr(1, 1) === ":" ? DATA_PATH : GetNormalPathString(process.cwd() + "/" + DATA_PATH)), NodeAddrStr:SERVER.addrStr,
|
||||
STAT_MODE:global.STAT_MODE, HTTPPort:global.HTTP_PORT_NUMBER, HTTPPassword:HTTP_PORT_PASSWORD, CONSTANTS:Constants, CheckPointBlockNum:CHECK_POINT.BlockNum,
|
||||
MiningAccount:global.GENERATE_BLOCK_ACCOUNT, CountMiningCPU:GetCountMiningCPU(), CountRunCPU:global.ArrMiningWrk.length, MiningPaused:global.MiningPaused,
|
||||
HashRate:HashRateOneSec, MIN_POWER_POW_TR:MIN_POWER_POW_TR, PRICE_DAO:PRICE_DAO(SERVER.BlockNumDB), NWMODE:global.NWMODE, PERIOD_ACCOUNT_HASH:PERIOD_ACCOUNT_HASH,
|
||||
MAX_ACCOUNT_HASH:DApps.Accounts.DBAccountsHash.GetMaxNum(), TXBlockNum:TXBlockNum, };
|
||||
if(Params.Account)
|
||||
Ret.PrivateKey = GetHexFromArr(WALLET.GetPrivateKey(WALLET.AccountMap[Params.Account]));
|
||||
else
|
||||
|
@ -27,9 +27,10 @@ function ToLogClient(t,e,r)
|
||||
{
|
||||
t && (ToLogFile(file_name_log, t), e || (e = ""), ArrLogClient.push({text:GetStrOnlyTime() + " " + t, key:e, final:r}), 13 < ArrLogClient.length && ArrLogClient.shift());
|
||||
};
|
||||
CheckSizeLogFile(file_name_error, file_name_errorPrev), global.ToLog = function (t)
|
||||
CheckSizeLogFile(file_name_error, file_name_errorPrev), global.ToLog = function (t,e)
|
||||
{
|
||||
global.ALL_LOG_TO_CLIENT ? ToLogClient(t, void 0, void 0) : ToLogFile(file_name_log, t);
|
||||
void 0 === e && (e = 1), e && e > global.LOG_LEVEL || (global.ALL_LOG_TO_CLIENT ? ToLogClient(t, void 0, void 0) : ToLogFile(file_name_log,
|
||||
t));
|
||||
}, global.SmallAddr = function (t)
|
||||
{
|
||||
return t.substr(0, 5);
|
||||
|
@ -357,16 +357,10 @@ module.exports = class CTransport extends require("./connect")
|
||||
ADD_TO_STAT("USEPACKET")
|
||||
var CurTime = GetCurrentTime();
|
||||
Meta.Node.LastTime = CurTime - 0
|
||||
if(Meta.MethodTiming.Process)
|
||||
if(Meta.MethodTiming.Process && Meta.MethodTiming.Process.Worker)
|
||||
{
|
||||
var Data = this.DataFromF(Meta);
|
||||
try
|
||||
{
|
||||
Meta.MethodTiming.Process.Worker.send({cmd:Meta.Method, Data:Data, addrStr:Meta.Node.addrStr, Context:Meta.Context})
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
Meta.MethodTiming.Process.Worker.send({cmd:Meta.Method, Data:Data, addrStr:Meta.Node.addrStr, Context:Meta.Context})
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,6 +234,7 @@ class CApp
|
||||
{
|
||||
if(IsZeroArr(this.PubKeyArr))
|
||||
return ;
|
||||
this.AccountMap = {}
|
||||
DApps.Accounts.FindAccounts([this.PubKeyArr], this.AccountMap, 0)
|
||||
}
|
||||
GetAccountKey(Num)
|
||||
|
@ -544,7 +544,7 @@ class AccountApp extends require("./dapp")
|
||||
if(BlockNum < 2800000)
|
||||
MinPower = MIN_POWER_POW_ACC_CREATE + 2
|
||||
else
|
||||
MinPower = MIN_POWER_POW_ACC_CREATE_LAST
|
||||
MinPower = MIN_POWER_POW_ACC_CREATE + 3
|
||||
if(power < MinPower)
|
||||
return "Error min power POW for create account (update client)";
|
||||
}
|
||||
|
@ -9,6 +9,14 @@
|
||||
*/
|
||||
|
||||
const crypto = require('crypto');
|
||||
WebApi2.GenerateKeys = function (Params)
|
||||
{
|
||||
var KeyPair = crypto.createECDH('secp256k1');
|
||||
var PrivKey = sha3(crypto.randomBytes(32));
|
||||
KeyPair.setPrivateKey(Buffer.from(PrivKey));
|
||||
var PubKey = KeyPair.getPublicKey('', 'compressed');
|
||||
return {result:1, PrivKey:GetHexFromArr(PrivKey), PubKey:GetHexFromArr(PubKey), Meta:Params ? Params.Meta : undefined};
|
||||
};
|
||||
WebApi2.CreateAccount = function (Params,response)
|
||||
{
|
||||
if(typeof Params === "object" && Params.Name && Params.PubKey)
|
||||
@ -17,7 +25,7 @@ WebApi2.CreateAccount = function (Params,response)
|
||||
};
|
||||
var Body = BufLib.GetBufferFromObject(TR, FORMAT_CREATE, 1000, {}, 1);
|
||||
Body = Body.slice(0, Body.len + 12);
|
||||
SendTransaction(Body, TR, MIN_POWER_POW_ACC_CREATE_LAST, function (result,TR,Body)
|
||||
SendTransaction(Body, TR, undefined, function (result,TR,Body)
|
||||
{
|
||||
var Result = {result:result < 1 ? 0 : 1, text:TR._text, TxID:GetHexFromArr(TR._TxID.slice(0, TR_TICKET_HASH_LENGTH + 6)), BlockNum:TR._BlockNum,
|
||||
Meta:Params.Meta, };
|
||||
@ -26,21 +34,7 @@ WebApi2.CreateAccount = function (Params,response)
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return {result:0, Meta:Params.Meta};
|
||||
};
|
||||
WebApi2.GetBalance = function (Params,response)
|
||||
{
|
||||
if(typeof Params === "object")
|
||||
{
|
||||
var arr = DApps.Accounts.GetRowsAccounts(ParseNum(Params.AccountID), 1);
|
||||
if(arr.length)
|
||||
{
|
||||
var Value = arr[0].Value;
|
||||
var Result = {result:1, SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, Meta:Params.Meta, };
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
return {result:0, Meta:Params.Meta};
|
||||
return {result:0, Meta:Params ? Params.Meta : undefined};
|
||||
};
|
||||
var MapSendID = {};
|
||||
WebApi2.Send = function (Params,response)
|
||||
@ -101,6 +95,20 @@ WebApi2.Send = function (Params,response)
|
||||
});
|
||||
return null;
|
||||
};
|
||||
WebApi2.GetBalance = function (Params,response)
|
||||
{
|
||||
if(typeof Params === "object")
|
||||
{
|
||||
var arr = DApps.Accounts.GetRowsAccounts(ParseNum(Params.AccountID), 1);
|
||||
if(arr.length)
|
||||
{
|
||||
var Value = arr[0].Value;
|
||||
var Result = {result:1, SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, Meta:Params.Meta, };
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
return {result:0, Meta:Params ? Params.Meta : undefined};
|
||||
};
|
||||
WebApi2.GetTransaction = function (Params)
|
||||
{
|
||||
if(typeof Params === "object" && Params.TxID)
|
||||
@ -131,19 +139,11 @@ WebApi2.GetTransaction = function (Params)
|
||||
}
|
||||
}
|
||||
}
|
||||
return {result:0, Meta:Params.Meta};
|
||||
return {result:0, Meta:Params ? Params.Meta : undefined};
|
||||
};
|
||||
WebApi2.GetHistoryTransactions = function (Params)
|
||||
{
|
||||
};
|
||||
WebApi2.GenerateKeys = function (Params)
|
||||
{
|
||||
var KeyPair = crypto.createECDH('secp256k1');
|
||||
var PrivKey = sha3(crypto.randomBytes(32));
|
||||
KeyPair.setPrivateKey(Buffer.from(PrivKey));
|
||||
var PubKey = KeyPair.getPublicKey('', 'compressed');
|
||||
return {result:1, PrivKey:GetHexFromArr(PrivKey), PubKey:GetHexFromArr(PubKey), Meta:Params.Meta};
|
||||
};
|
||||
var DELTA_FOR_TIME_TX = 1;
|
||||
|
||||
function CreateTxID(body,BlockNum,Nonce)
|
||||
|
@ -226,14 +226,6 @@ function StartChildProcess(Item)
|
||||
ITEM.Worker = undefined;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
ITEM.Worker.send({cmd:"Alive"});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
ITEM.Worker = undefined;
|
||||
}
|
||||
if(!ITEM.Worker)
|
||||
{
|
||||
ITEM.LastAlive = (Date.now()) + ITEM.PeriodAlive * 3;
|
||||
@ -290,6 +282,20 @@ function StartChildProcess(Item)
|
||||
break;
|
||||
}
|
||||
});
|
||||
ITEM.Worker.on('error', function (err)
|
||||
{
|
||||
ToError("ERROR IN " + ITEM.Name + " Err : " + err);
|
||||
ITEM.Worker = undefined;
|
||||
});
|
||||
ITEM.Worker.on('close', function (code)
|
||||
{
|
||||
ToError("CLOSE " + ITEM.Name);
|
||||
ITEM.Worker = undefined;
|
||||
});
|
||||
}
|
||||
if(ITEM.Worker)
|
||||
{
|
||||
ITEM.Worker.send({cmd:"Alive"});
|
||||
}
|
||||
}, 500);
|
||||
ITEM.RunRPC = function (Name,Params,F)
|
||||
|
@ -406,8 +406,7 @@ HostingCaller.GetCurrentInfo = function (Params)
|
||||
{
|
||||
var Ret = {result:1, VersionNum:global.UPDATE_CODE_VERSION_NUM, MaxNumBlockDB:SERVER.GetMaxNumBlockDB(), CurBlockNum:GetCurrentBlockNumByTime(),
|
||||
MaxAccID:DApps.Accounts.GetMaxAccount(), MaxDappsID:DApps.Smart.GetMaxNum(), NETWORK:global.NETWORK, CurTime:Date.now(), DELTA_CURRENT_TIME:DELTA_CURRENT_TIME,
|
||||
MIN_POWER_POW_TR:MIN_POWER_POW_TR, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK, CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, MIN_POWER_POW_ACC_CREATE:MIN_POWER_POW_ACC_CREATE_LAST,
|
||||
};
|
||||
MIN_POWER_POW_TR:MIN_POWER_POW_TR, FIRST_TIME_BLOCK:FIRST_TIME_BLOCK, CONSENSUS_PERIOD_TIME:CONSENSUS_PERIOD_TIME, };
|
||||
if(typeof Params === "object" && Params.Diagram == 1)
|
||||
{
|
||||
var arrNames = ["MAX:ALL_NODES", "MAX:HASH_RATE_G"];
|
||||
|
Loading…
Reference in New Issue
Block a user