diff --git a/Bin/Light/Tera-light.zip b/Bin/Light/Tera-light.zip
index 6203589..f9e1ac7 100644
Binary files a/Bin/Light/Tera-light.zip and b/Bin/Light/Tera-light.zip differ
diff --git a/Bin/Light/tera_light_setup.exe b/Bin/Light/tera_light_setup.exe
index 0d84875..d57a566 100644
Binary files a/Bin/Light/tera_light_setup.exe and b/Bin/Light/tera_light_setup.exe differ
diff --git a/Doc/Eng/API2.md b/Doc/Eng/API2.md
index 0aececf..fe3d3c3 100644
--- a/Doc/Eng/API2.md
+++ b/Doc/Eng/API2.md
@@ -1,5 +1,5 @@
# API v2 (for exchanges)
-
+Works with update version 0.895
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.
@@ -223,7 +223,74 @@ return:
6)**/api/v2/GetHistoryTransactions** - to get the transaction history of the account
-#### **TODO**
+#### Parameters:
+* AccountID - account (account) number)
+* Count - maximum number of rows returned - history depth (default 100)
+
+option to set parameters for organizing page navigation:
+* NextPos - history line ID number (this value is taken from the last line of the previous result)
+* Count - number of rows returned
+
+Advanced setting:
+* GetTxID - if set to 1, the transaction ID in hex-format is returned in the TxID field
+
+
+example1:
+```js
+http://127.0.0.1/api/v2/GetHistoryTransactions
+{
+ "AccountID": 190480
+}
+```
+return:
+```js
+
+{
+ "result": 1,
+ "History": [
+ {
+ "Type": 1,
+ "BlockNum": 19994502,
+ "TrNum": 0,
+ "Pos": 498190,
+ "NextPos": 439090,
+ "Direct": "+",
+ "CorrID": 190478,
+ "SumCOIN": 1,
+ "SumCENT": 0
+ },
+ {
+ "Type": 1,
+ "BlockNum": 19993514,
+ "TrNum": 0,
+ "Pos": 439090,
+ "NextPos": 0,
+ "Direct": "+",
+ "CorrID": 190478,
+ "SumCOIN": 1,
+ "SumCENT": 0
+ }
+ ],
+ "Tail": {
+ "NextPos": 498190,
+ "Reserv": {
+ "type": "Buffer",
+ "data": [
+ 0,
+ 0
+ ]
+ },
+ "Num": 190480
+ }
+}
+```
+example2:
+```js
+http://127.0.0.1/api/v2/GetHistoryTransactions
+{
+ "NextPos": 439090
+}
+```
diff --git a/Doc/Rus/API2.md b/Doc/Rus/API2.md
index 62f985c..611477a 100644
--- a/Doc/Rus/API2.md
+++ b/Doc/Rus/API2.md
@@ -1,4 +1,6 @@
# API v2 (для бирж и обменников)
+Работает с версии обновления 0.895
+
API предназначено для облегчения написания сторонних приложений. На стороне сервера выполняется криптография и операции POW. Поэтому оно не рекомендуется для публичного доступа, т.к. нет защиты от DDOS атак. Используйте его, если приложения такие как сервер биржи находятся в одной приватной сети.
@@ -167,6 +169,10 @@ return:
#### Параметры:
* TxID - ИД транзакции в hex-формате
+альтернативный вариант задания параметров:
+* BlockNum - номер блока
+* TrNum - номер транзакции в блоке
+
example1:
```js
http://127.0.0.1/api/v2/GetTransaction
@@ -193,7 +199,9 @@ return:
"OperationID": 41,
"Body": "",
"Sign": "8C761F539A6A24427CF810A49140CA1FFBF0F3A48DCF58AEE0DD9E4A4E631E1A1B6DA86ED6E2EF92DBF537270AA02B5EAE3A7C822B3F70628CAD78525ED9E0F7",
- "result": 1
+ "result": 1,
+ "BlockNum": 19781201,
+ "TrNum": 0
}
```
@@ -214,15 +222,83 @@ return:
"Adviser": 0,
"Smart": 0,
"Reserve": "000000",
- "result": 190552
+ "result": 190552,
+ "BlockNum": 19889100,
+ "TrNum": 1
}
+
```
+
## GetHistoryTransactions
6)**/api/v2/GetHistoryTransactions** - получить историю транзакций счета
-#### **TODO**
+#### Параметры:
+* AccountID - номер счета (аккаунта)
+* Count - максимальное число возвращаемых строк - глубина истории (по умолчанию 100)
+
+вариант задания параметров для организации постраничной навигации:
+* NextPos - номер ид строки истории (это значение берется из последней строки предыдущего результата)
+* Count - число возвращаемых строк
+
+Дополнительные параметры:
+* GetTxID - если стоит 1 - то возвращается в поле TxID возвращается ID транзакции в 16 формате
+example1:
+```js
+http://127.0.0.1/api/v2/GetHistoryTransactions
+{
+ "AccountID": 190480
+}
+```
+return:
+```js
+{
+ "result": 1,
+ "History": [
+ {
+ "Type": 1,
+ "BlockNum": 19994502,
+ "TrNum": 0,
+ "Pos": 498190,
+ "NextPos": 439090,
+ "Direct": "+",
+ "CorrID": 190478,
+ "SumCOIN": 1,
+ "SumCENT": 0
+ },
+ {
+ "Type": 1,
+ "BlockNum": 19993514,
+ "TrNum": 0,
+ "Pos": 439090,
+ "NextPos": 0,
+ "Direct": "+",
+ "CorrID": 190478,
+ "SumCOIN": 1,
+ "SumCENT": 0
+ }
+ ],
+ "Tail": {
+ "NextPos": 498190,
+ "Reserv": {
+ "type": "Buffer",
+ "data": [
+ 0,
+ 0
+ ]
+ },
+ "Num": 190480
+ }
+}
+```
+example2:
+```js
+http://127.0.0.1/api/v2/GetHistoryTransactions
+{
+ "NextPos": 439090
+}
+```
diff --git a/Doc/Rus/README.md b/Doc/Rus/README.md
index 4b94c7f..f67d6fe 100644
--- a/Doc/Rus/README.md
+++ b/Doc/Rus/README.md
@@ -269,6 +269,7 @@ Version = 3 - поддержка переводов на счета со сма
* [Техническое WP - черновик](https://docs.google.com/document/d/1B6_qlAp2xs4aHkqOwyvRMCDJTjgeNiOJiGpIeT0VAzY/edit?usp=sharing)
* [Торрент блокчейна (каталог DATA/DB)](https://sourceforge.net/p/tera/code/ci/master/tree/Torrent/Tera-folder-DB.torrent?format=raw)
* [API](https://sourceforge.net/p/tera/code/ci/master/tree/Doc/Rus/API.md)
+* [API2](https://sourceforge.net/p/tera/code/ci/master/tree/Doc/Rus/API2.md)
* [CONSTANTS](https://sourceforge.net/p/tera/code/ci/master/tree/Doc/Rus/CONSTANTS.MD)
* [Презентация - Проблематика блокчейна и пути решения](https://docs.google.com/presentation/d/1NvaGQTUpeP3y7CmHpaqFmaqWlCEMMoPdvCyylFVJ3lk/edit?usp=sharing)
diff --git a/Source/HTML/wallet.html b/Source/HTML/wallet.html
index 0a46f60..23d2f08 100644
--- a/Source/HTML/wallet.html
+++ b/Source/HTML/wallet.html
@@ -1513,7 +1513,7 @@
{
var Item=MapAccounts[$("idAccount").value];
if(Item)
- $("idSumSend").value=FLOAT_FROM_COIN(Item.Value);
+ $("idSumSend").value=FLOAT_FROM_COIN(Item.Value).toStringF();
}
@@ -1694,6 +1694,7 @@
Prev. Operation |
Prev. amount |
+ Prev. History |
diff --git a/Source/HTML/web-wallet.html b/Source/HTML/web-wallet.html
index 521c405..29ee18c 100644
--- a/Source/HTML/web-wallet.html
+++ b/Source/HTML/web-wallet.html
@@ -955,7 +955,7 @@
{
var Item=MapAccounts[$("idAccount").value];
if(Item)
- $("idSumSend").value=FLOAT_FROM_COIN(Item.Value);
+ $("idSumSend").value=FLOAT_FROM_COIN(Item.Value).toStringF();
}
diff --git a/Source/core/constant.js b/Source/core/constant.js
index 29fbc66..ae424f4 100644
--- a/Source/core/constant.js
+++ b/Source/core/constant.js
@@ -8,7 +8,7 @@
* Telegram: https://web.telegram.org/#/im?p=@terafoundation
*/
-global.UPDATE_CODE_VERSION_NUM = 893;
+global.UPDATE_CODE_VERSION_NUM = 895;
global.MIN_CODE_VERSION_NUM = 884;
global.MINING_VERSION_NUM = 3;
global.InitParamsArg = InitParamsArg;
diff --git a/Source/core/db/db-row.js b/Source/core/db/db-row.js
index 427ce36..97f9da3 100644
--- a/Source/core/db/db-row.js
+++ b/Source/core/db/db-row.js
@@ -52,7 +52,7 @@ module.exports = class CDBState extends require("./db")
var written = fs.writeSync(FI.fd, BufWrite, 0, BufWrite.length, Position);
if(written !== BufWrite.length)
{
- TO_ERROR_LOG("DB-STATE", 10, "Error write to file:" + written + " <> " + BufWrite.length)
+ TO_ERROR_LOG("DB-ROW", 10, "Error write to file:" + written + " <> " + BufWrite.length)
return false;
}
if(RetBuf)
diff --git a/Source/core/html-server.js b/Source/core/html-server.js
index cfb36d2..c706d76 100644
--- a/Source/core/html-server.js
+++ b/Source/core/html-server.js
@@ -952,7 +952,7 @@ HTTPCaller.TruncateBlockChain = function (Param)
var MinBlock = DApps.Accounts.GetMinBlockAct();
if(MinBlock > StartNum)
{
- ToLog("Cant Truncate BlockChain. Very long length. Max length=" + (SERVER.BlockNumDB - MinBlock));
+ ToLog("Cant Truncate BlockChain. Very long length. Max length=" + (SERVER.BlockNumDB - MinBlock), 0);
return {result:0, sessionid:sessionid};
}
SERVER.TruncateBlockDB(StartNum);
@@ -1359,8 +1359,8 @@ if(global.HTTP_PORT_NUMBER)
if(!ClientIPMap[remoteAddress])
{
ClientIPMap[remoteAddress] = 1;
- ToLog("CONNECT TO HTTP ACCESS FROM: " + remoteAddress);
- ToLog("Path: " + Path);
+ ToLog("CONNECT TO HTTP ACCESS FROM: " + remoteAddress, 0);
+ ToLog("Path: " + Path, 0);
}
if(CheckPassword && global.HTTP_PORT_PASSWORD)
{
diff --git a/Source/dapp/accounts.js b/Source/dapp/accounts.js
index bcea28e..56b99b1 100644
--- a/Source/dapp/accounts.js
+++ b/Source/dapp/accounts.js
@@ -13,6 +13,10 @@ const fs = require('fs');
const DBRow = require("../core/db/db-row");
const MAX_SUM_TER = 1e9;
const MAX_SUM_CENT = 1e9;
+const DBLib = require("../core/db/db");
+global.HistoryDB = new DBLib();
+const FILE_NAME_HISTORY = "history-body";
+var WorkStructHistory = {};
global.TYPE_TRANSACTION_CREATE = 100;
const TYPE_TRANSACTION_TRANSFER = 105;
const TYPE_TRANSACTION_TRANSFER2 = 110;
@@ -141,9 +145,13 @@ class AccountApp extends require("./dapp")
}"
this.ACCOUNT_ROW_SIZE = 6 + 33 + 40 + (6 + 4 + 6 + 84) + 6 + 6 + 9
this.DBState = new MerkleDBRow("accounts-state", this.ACCOUNT_ROW_SIZE, this.FORMAT_ACCOUNT_ROW, bReadOnly)
- this.DBAct = new DBRow("accounts-act", 6 + 6 + (6 + 4 + 6 + 6 + 84) + 1 + 11, "{ID:uint, BlockNum:uint,PrevValue:{SumCOIN:uint,SumCENT:uint32, Reserve0:uint, OperationID:uint,Smart:uint32,Data:arr80}, Mode:byte, TrNum:uint16, Reserve: arr9}",
+ this.DBAct = new DBRow("accounts-act", 6 + 6 + (6 + 4 + 6 + 6 + 84) + 1 + 11, "{ID:uint, BlockNum:uint,PrevValue:{SumCOIN:uint,SumCENT:uint32, NextPos:uint, OperationID:uint,Smart:uint32,Data:arr80}, Mode:byte, TrNum:uint16, Reserve: arr9}",
bReadOnly)
this.DBActPrev = new DBRow("accounts-act-prev", this.DBAct.DataSize, this.DBAct.Format, bReadOnly)
+ this.FORMAT_STATE_HISTORY = "{NextPos:uint,Reserv:arr2}"
+ this.DBStateHistory = new DBRow("history-state", 8, this.FORMAT_STATE_HISTORY, bReadOnly)
+ HistoryDB.OpenDBFile(FILE_NAME_HISTORY, !bReadOnly)
+ this.HistoryFormatArr = ["{Type:byte, BlockNum:uint32,TrNum:uint16, NextPos:uint}", "{Type:byte, BlockNum:uint32,TrNum:uint16, NextPos:uint, Direct:str1,CorrID:uint, SumCOIN:uint,SumCENT:uint32}"]
if(global.READ_ONLY_DB)
return ;
this.DBAccountsHash = new DBRow("accounts-hash2", 6 + 32 + 32 + 10, "{BlockNum:uint, Hash:hash, SumHash:hash, Reserve: arr10}",
@@ -163,6 +171,7 @@ class AccountApp extends require("./dapp")
return ;
this.DBState.MerkleTree = undefined
this.DBState.Truncate( - 1)
+ this.DBStateHistory.Truncate( - 1)
this.DBAct.Truncate( - 1)
this.DBActPrev.Truncate( - 1)
this.DBAccountsHash.Truncate( - 1)
@@ -187,6 +196,8 @@ class AccountApp extends require("./dapp")
this.DBAccountsHash.Close()
if(this.DBStateTX)
this.DBStateTX.Close()
+ if(this.DBStateHistory)
+ this.DBStateHistory.Close()
}
ClearDataBase()
{
@@ -829,6 +840,12 @@ class AccountApp extends require("./dapp")
var Data = this.DBState.Read(Item.ID);
Data.Value = Item.PrevValue
this.DBState.Write(Data)
+ var History = this.DBStateHistory.Read(Item.ID);
+ if(History)
+ {
+ History.NextPos = Item.PrevValue.NextPos
+ this.DBStateHistory.Write(History)
+ }
}
}
if(bWas)
@@ -836,6 +853,7 @@ class AccountApp extends require("./dapp")
if(NumTruncateState)
{
this.DBState.Truncate(NumTruncateState - 1)
+ this.DBStateHistory.Truncate(NumTruncateState - 1)
}
DBAct.Truncate(StartNum - 1)
}
@@ -1126,6 +1144,16 @@ class AccountApp extends require("./dapp")
{
var BlockNum = Block.BlockNum;
var DBChanges = this.DBChanges;
+ for(var i = 0; i < DBChanges.BlockHistory.length; i++)
+ {
+ var Data = DBChanges.BlockHistory[i];
+ var Account = DBChanges.BlockMap[Data.CurID];
+ Data.Type = 1
+ Data.NextPos = Account.Value.NextPos
+ Account.Value.NextPos = this.SaveHistory(Data)
+ if(WALLET.AccountMap[Data.CurID] !== undefined)
+ WALLET.OnDoHistoryAct(Data, BlockNum)
+ }
var arr = [];
for(var key in DBChanges.BlockMap)
{
@@ -1146,10 +1174,18 @@ class AccountApp extends require("./dapp")
var BackLog = {Num:undefined, ID:Account.Num, BlockNum:BlockNum, PrevValue:Account.BackupValue, TrNum:Account.ChangeTrNum,
Mode:Account.New};
this.DBAct.Write(BackLog)
+ }
+ for(var i = 0; i < arr.length; i++)
+ {
+ var Account = arr[i];
this.DBState.Write(Account)
}
- for(var i = 0; i < DBChanges.BlockHistory.length; i++)
- WALLET.OnDoHistoryAct(DBChanges.BlockHistory[i], BlockNum)
+ for(var i = 0; i < arr.length; i++)
+ {
+ var Account = arr[i];
+ var History = {Num:Account.Num, NextPos:Account.Value.NextPos};
+ this.DBStateHistory.Write(History)
+ }
for(var i = 0; i < DBChanges.BlockEvent.length; i++)
{
var Data = DBChanges.BlockEvent[i];
@@ -1240,13 +1276,17 @@ class AccountApp extends require("./dapp")
return undefined;
BData.Num = Num
Value = BData.Value
- BData.BackupValue = {SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:Value.Data}
+ var BHistory = this.DBStateHistory.Read(Num);
+ if(BHistory)
+ Value.NextPos = BHistory.NextPos
+ BData.BackupValue = {SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:Value.Data,
+ NextPos:Value.NextPos}
BlockMap[Num] = BData
}
Value = BData.Value
Data = {Num:Num, Currency:BData.Currency, PubKey:BData.PubKey, Name:BData.Name, BlockNumCreate:BData.BlockNumCreate, Adviser:BData.Adviser,
- Value:{SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:CopyArr(Value.Data)},
- BackupValue:BData.BackupValue}
+ Value:{SumCOIN:Value.SumCOIN, SumCENT:Value.SumCENT, OperationID:Value.OperationID, Smart:Value.Smart, Data:CopyArr(Value.Data),
+ NextPos:Value.NextPos}, BackupValue:BData.BackupValue}
TRMap[Num] = Data
}
return Data;
@@ -1274,10 +1314,11 @@ class AccountApp extends require("./dapp")
throw "Not enough money on the account ID:" + FromID;
}
this.WriteStateTR(FromData, TrNum)
- if(WALLET.AccountMap[FromID] !== undefined)
+ if(FromID > 15)
{
- this.DBChanges.TRHistory.push({Direct:"-", FromID:FromID, ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionFrom,
- FromOperationID:FromData.Value.OperationID, Currency:FromData.Currency})
+ this.DBChanges.TRHistory.push({Direct:"-", Receive:0, CurID:FromID, CorrID:ToID, BlockNum:BlockNum, TrNum:TrNum, FromID:FromID,
+ ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionFrom, FromOperationID:FromData.Value.OperationID,
+ Currency:FromData.Currency})
}
var ToData = this.ReadStateTR(ToID);
if(!ToData)
@@ -1286,10 +1327,11 @@ class AccountApp extends require("./dapp")
}
ADD(ToData.Value, CoinSum)
this.WriteStateTR(ToData, TrNum)
- if(WALLET.AccountMap[ToID] !== undefined)
+ if(ToID > 15)
{
- this.DBChanges.TRHistory.push({Direct:"+", FromID:FromID, ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionTo,
- FromOperationID:FromData.Value.OperationID, Currency:ToData.Currency})
+ this.DBChanges.TRHistory.push({Direct:"+", Receive:1, CurID:ToID, CorrID:FromID, BlockNum:BlockNum, TrNum:TrNum, FromID:FromID,
+ ToID:ToID, SumCOIN:CoinSum.SumCOIN, SumCENT:CoinSum.SumCENT, Description:DescriptionTo, FromOperationID:FromData.Value.OperationID,
+ Currency:ToData.Currency})
}
FromData.Value.OperationID += OperationCount
if(FromData.Value.Smart)
@@ -1336,6 +1378,66 @@ class AccountApp extends require("./dapp")
var sigObj = secp256k1.sign(hash, Buffer.from(PrivKey));
return sigObj.signature;
}
+ SaveHistory(Data)
+ {
+ var FileItem = HistoryDB.OpenDBFile(FILE_NAME_HISTORY, 1);
+ var FD = FileItem.fd;
+ var Position = FileItem.size;
+ if(!Position)
+ Position = 100
+ var BufWrite = BufLib.GetBufferFromObject(Data, this.HistoryFormatArr[Data.Type], 100, WorkStructHistory);
+ var written = fs.writeSync(FD, BufWrite, 0, BufWrite.length, Position);
+ if(written !== BufWrite.length)
+ {
+ TO_ERROR_LOG("DB-HISTORY", 10, "Error write to file:" + written + " <> " + BufWrite.length)
+ throw "Error write to FILE_NAME_HISTORY";
+ return false;
+ }
+ if(Position >= FileItem.size)
+ {
+ FileItem.size = Position + written
+ }
+ return Position;
+ }
+ GetHistory(Num, Count, StartPos)
+ {
+ var Position = StartPos;
+ var FileItem = HistoryDB.OpenDBFile(FILE_NAME_HISTORY, 0);
+ var FD = FileItem.fd;
+ if(Position === undefined)
+ {
+ var Account = this.DBStateHistory.Read(Num);
+ if(!Account)
+ {
+ return [];
+ }
+ Position = Account.NextPos
+ }
+ var arr = [];
+ while(Count > 0 && Position)
+ {
+ Count--
+ var BufRead = BufLib.GetNewBuffer(100);
+ var bytesRead = fs.readSync(FD, BufRead, 0, BufRead.length, Position);
+ if(bytesRead < 13)
+ {
+ ToLog("bytesRead<13 Position=" + Position)
+ break;
+ }
+ var Type = BufRead[0];
+ var format = this.HistoryFormatArr[Type];
+ if(!format)
+ {
+ ToLog("Error from history, type = " + Type)
+ break;
+ }
+ var Item = BufLib.GetObjectFromBuffer(BufRead, format, WorkStructHistory);
+ Item.Pos = Position
+ Position = Item.NextPos
+ arr.push(Item)
+ }
+ return arr;
+ }
};
module.exports = AccountApp;
var App = new AccountApp;
diff --git a/Source/process/api-exchange.js b/Source/process/api-exchange.js
index 40ee488..b6e332d 100644
--- a/Source/process/api-exchange.js
+++ b/Source/process/api-exchange.js
@@ -119,29 +119,30 @@ WebApi2.GetTransaction = function (Params)
var Arr = GetArrFromHex(Params.TxID);
var BlockNum = ReadUintFromArr(Arr, TR_TICKET_HASH_LENGTH);
var Block = SERVER.ReadBlockDB(BlockNum);
- if(Block)
+ if(Block && Block.arrContent)
{
- Arr = Arr.slice(0, TR_TICKET_HASH_LENGTH);
for(var i = 0; i < Block.arrContent.length; i++)
{
var Body = Block.arrContent[i];
- var Nonce = ReadUintFromArr(Body, Body.length - 6);
- var Arr2 = CreateTxID(Body, BlockNum, Nonce);
- Arr2 = Arr2.slice(0, TR_TICKET_HASH_LENGTH);
+ var Arr2 = GetTxID(BlockNum, Body);
if(CompareArr(Arr2, Arr) === 0)
{
- var TR = DApps.Accounts.GetObjectTransaction(Body);
- if(TR)
- {
- ConvertBufferToStr(TR);
- TR.result = 1;
- TR.Meta = Params.Meta;
- if(Block.VersionBody === 1 && Block.arrContentResult)
- {
- TR.result = Block.arrContentResult[i];
- }
- return TR;
- }
+ return GetTransactionFromBody(Params, Block, i, Body);
+ }
+ }
+ }
+ }
+ else
+ {
+ if(typeof Params === "object" && Params.BlockNum && Params.TrNum !== undefined)
+ {
+ var Block = SERVER.ReadBlockDB(Params.BlockNum);
+ if(Block && Block.arrContent)
+ {
+ var Body = Block.arrContent[Params.TrNum];
+ if(Body)
+ {
+ return GetTransactionFromBody(Params, Block, Params.TrNum, Body);
}
}
}
@@ -150,9 +151,39 @@ WebApi2.GetTransaction = function (Params)
};
WebApi2.GetHistoryTransactions = function (Params)
{
+ if(typeof Params === "object" && Params.AccountID)
+ {
+ if(!Params.Count)
+ Params.Count = 100;
+ var arr = DApps.Accounts.GetHistory(Params.AccountID, Params.Count, Params.NextPos);
+ if(Params.GetTxID)
+ {
+ for(var i = 0; i < arr.length; i++)
+ {
+ var Item = arr[i];
+ var Block = SERVER.ReadBlockDB(Item.BlockNum);
+ if(!Block || (!Block.arrContent))
+ continue;
+ var Body = Block.arrContent[Item.TrNum];
+ if(!Body)
+ continue;
+ Item.TxID = GetHexFromArr(GetTxID(Item.BlockNum, Body));
+ }
+ }
+ var Result = {result:arr.length > 0 ? 1 : 0, History:arr, Tail:DApps.Accounts.DBStateHistory.Read(Params.AccountID), Meta:Params ? Params.Meta : undefined};
+ return Result;
+ }
+ return {result:0, Meta:Params ? Params.Meta : undefined};
};
var DELTA_FOR_TIME_TX = 1;
+function GetTxID(BlockNum,Body)
+{
+ var Nonce = ReadUintFromArr(Body, Body.length - 6);
+ var Arr2 = CreateTxID(Body, BlockNum, Nonce);
+ return Arr2.slice(0, TR_TICKET_HASH_LENGTH + 6);
+};
+
function CreateTxID(body,BlockNum,Nonce)
{
body.writeUIntLE(BlockNum, body.length - 12, 6);
@@ -259,3 +290,22 @@ function CreateNonceAndSend(startnonce,NumNext)
});
};
};
+
+function GetTransactionFromBody(Params,Block,TrNum,Body)
+{
+ var TR = DApps.Accounts.GetObjectTransaction(Body);
+ if(TR)
+ {
+ ConvertBufferToStr(TR);
+ TR.result = 1;
+ TR.Meta = Params.Meta;
+ if(Block.VersionBody === 1 && Block.arrContentResult)
+ {
+ TR.result = Block.arrContentResult[TrNum];
+ }
+ TR.BlockNum = Block.BlockNum;
+ TR.TrNum = TrNum;
+ return TR;
+ }
+ return {result:0, Meta:Params ? Params.Meta : undefined};
+};
diff --git a/Source/process/main-process.js b/Source/process/main-process.js
index e9ba711..9861a0e 100644
--- a/Source/process/main-process.js
+++ b/Source/process/main-process.js
@@ -896,7 +896,7 @@ function TestSignLib(MaxTime)
{
ToLog("*************** WARNING: VERY SLOW LIBRARY: secp256k1 ***************");
ToLog("You can only process: " + Num + " transactions");
- ToLog("Install all dependent packages and run the installation command:\ncd Source/node_modules/secp256k1 \nnode-gyp build");
+ ToLog("Install all dependent packages, see detail: https://www.npmjs.com/package/secp256k1");
return 0;
}
}
diff --git a/Source/process/web-process.js b/Source/process/web-process.js
index 6f20e76..497cd81 100644
--- a/Source/process/web-process.js
+++ b/Source/process/web-process.js
@@ -111,7 +111,7 @@ function CheckAlive()
var Delta = Date.now() - LastAlive;
if(Delta > CHECK_STOP_CHILD_PROCESS)
{
- ToLog("HOSTING: ALIVE TIMEOUT Stop and exit: " + Delta + "/" + global.CHECK_STOP_CHILD_PROCESS);
+ ToLog("HOSTING: ALIVE TIMEOUT Stop and exit: " + Delta + "/" + global.CHECK_STOP_CHILD_PROCESS, 0);
process.exit(0);
return ;
}
@@ -121,7 +121,7 @@ process.on('uncaughtException', function (err)
ToError(err.stack);
ToLog(err.stack);
TO_ERROR_LOG("HOSTING", 777, err);
- ToLog("-----------------HOSTING EXIT------------------");
+ ToLog("-----------------HOSTING EXIT------------------", 0);
process.exit();
});
process.on('error', function (err)
@@ -169,7 +169,7 @@ if(global.HTTPS_HOSTING_DOMAIN)
}
if(GetNewSert)
{
- ToLog("Start get new SERT");
+ ToLog("Start get new SERT", 0);
var opts = {domains:[global.HTTPS_HOSTING_DOMAIN], email:'progr76@gmail.com', agreeTos:true, communityMember:true, };
greenlock.register(opts).then(function (certs)
{
@@ -209,7 +209,7 @@ function MainHTTPFunction(request,response)
else
{
var Str = "Error postDataChunk.length=" + postDataChunk.length;
- ToLog(Str);
+ ToLog(Str, 0);
Response.writeHead(405, {'Content-Type':'text/html'});
Response.end(Str);
}