This commit is contained in:
progr76@gmail.com 2019-03-16 19:10:33 +03:00
parent 5af6a818a0
commit 2de9ccec4d
2 changed files with 150 additions and 0 deletions

Binary file not shown.

View File

@ -304,3 +304,153 @@ http://127.0.0.1/api/v2/GetHistoryTransactions
"NextPos": 439090
}
```
=Добавочная часть к API2=
Вариант использования:
1. Computer A (has public keys) creates a raw unsigned transaction
2. Computer B (has secret keys) grabs and signs the raw transaction
3. computer A grabs the signed transaction and transmits it.
7)**/api/v2/CreateRawTransaction** - create json payment tx without a signature
#### Parameters:
* FromID - номер счета отправителя
* FromPrivKey - приватный ключ отправителя в hex-формате
* ToID - номер счета получателя, число или публичный ключ в hex-формате (в этом случае будет создан новый счет с именем заданным в первой строке описания платежа и в качестве оплаты создания счета спишется 10 Тера)
* Amount - сумма, число с плавающей точкой или объект в формате {SumCOIN,SumCENT}
* Description - описание платежка (необязательный параметр)
example:
```js
http://127.0.0.1/api/v2/CreateRawTransaction
{
"FromID": 187004,
"ToID":190650,
"Amount":10.5,
"Description":"Тест"
}
```
return:
```js
{
"result": 1,
"Tx": {
"Type": 111,
"Version": 3,
"FromID": 187004,
"OperationID": 118,
"To": [
{
"PubKey": "",
"ID": 190650,
"SumCOIN": 10,
"SumCENT": 500000000
}
],
"Description": "Тест",
"Sign": ""
}
}
```
8)**/api/v2/SignRawTransaction** - sign tx
#### Parameters:
* Tx - JSON object
* FromPrivKey - sender private key in hex format
example:
```js
http://127.0.0.1/api/v2/SignRawTransaction
{
"Tx": {
"Type": 111,
"Version": 3,
"FromID": 187004,
"OperationID": 118,
"To": [
{
"PubKey": "",
"ID": 190650,
"SumCOIN": 10,
"SumCENT": 500000000
}
],
"Description": "Тест",
"Sign": ""
},
"FromPrivKey": "98765432108AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033"
}
```
return:
```js
{
"result": 1,
"Tx": {
"Type": 111,
"Version": 3,
"FromID": 187004,
"OperationID": 118,
"To": [
{
"PubKey": "",
"ID": 190650,
"SumCOIN": 10,
"SumCENT": 500000000
}
],
"Description": "Тест",
"Sign": "123456789ABCD931F3A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C0332480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033"
}
}
```
9)**/api/v2/SendRawTransaction** - send tx to TERA network
#### Parameters:
* Tx -JSON object
* Wait - if the number 1 is set, the response to the request is not returned until the transaction is written to the blockchain (the response time to the request is increased to 8 seconds)
example:
```js
http://127.0.0.1/api/v2/SendRawTransaction
{
"Tx": {
"Type": 111,
"Version": 3,
"FromID": 187004,
"OperationID": 118,
"To": [
{
"PubKey": "",
"ID": 190650,
"SumCOIN": 10,
"SumCENT": 500000000
}
],
"Description": "Тест",
"Sign": "123456789ABCD931F3A2D45610FE8AC931F32480BFE3E78D26E45B0A4F88045D6518263DA12FA9C0332480BFE3E78D26E45B0A4F88045D6518263DA12FA9C033"
},
"Wait":1
}
```
return:
```js
{
"result": 1,
"text": "Add to blockchain",
"TxID": "1234567891ABF4062B149B7C2F010000",
"BlockNum": 22222900
}
```