Commit 04732769 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Details HTTP API: transactions

parent 2c4bd174
......@@ -179,6 +179,10 @@ Field | Description
`Coins` | a list of coins that are to be sent. Each line starts with a `COIN_ID` identifying the coin, eventually followed by a comma and a `TRANSACTION_ID` justifying the ownership of the coin.
`Comment` | comment for transaction. May be used for any future purpose. Multiline field, ends at the end of the transaction message.
And `TRANSACTION_ID` has the following format:
SENDER_FINGERPRINT-INCREMENT
### Coins format
A `COIN_ID` has the following format:
......@@ -229,6 +233,33 @@ Such a transaction is used to *create* new money, i.e. new coins. To be a valid
#### Example
Version: 1
Sender: 31A6302161AC8F5938969E85399EB3415C237F93
Number: 1
Recipient: 31A6302161AC8F5938969E85399EB3415C237F93
Type: ISSUANCE
Coins:
31A6302161AC8F5938969E85399EB3415C237F93-1-5-2-A-1
31A6302161AC8F5938969E85399EB3415C237F93-2-2-2-A-1
31A6302161AC8F5938969E85399EB3415C237F93-3-1-2-A-1
31A6302161AC8F5938969E85399EB3415C237F93-4-1-2-A-1
31A6302161AC8F5938969E85399EB3415C237F93-5-5-1-A-1
31A6302161AC8F5938969E85399EB3415C237F93-6-3-1-A-1
31A6302161AC8F5938969E85399EB3415C237F93-7-1-1-A-1
31A6302161AC8F5938969E85399EB3415C237F93-8-1-1-A-1
Comment:
Creating 8 new coins according to Amendment 1
(imaginary one, with Universal Dividend 1000)
Coins are:
- 1 value 500
- 1 value 200
- 2 value 100
- 1 value 50
- 1 value 30
- 2 value 10
Note that this comment is part of transaction thus
il also signed.
### Transfert transaction
Transfert transaction is identified by having `Type: TRANSFERT` value. Such a transaction alter the ownership of one or more coins from `Sender` to `Recipient`. Ownership can be proved by the `Recipient` simply by showing this transaction.
......@@ -237,12 +268,37 @@ Thereafter, when `Recipient` wants to send those coins to someone else, he will
#### Example
Version: 1
Sender: 31A6302161AC8F5938969E85399EB3415C237F93
Number: 92
Recipient: 86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8
Type: TRANSFERT
Coins:
31A6302161AC8F5938969E85399EB3415C237F93-1-5-2-A-1, 31A6302161AC8F5938969E85399EB3415C237F93-1
31A6302161AC8F5938969E85399EB3415C237F93-2-2-2-A-1, 31A6302161AC8F5938969E85399EB3415C237F93-1
Comment:
Here I am sending coins 500 and 200 to someone else (either an individual or organization).
### Fusion transaction
Fusion transaction is identified by having `Type: FUSION` value. Such a transaction allows to fusion *existing* coins into a *new* one with a value equals to the sum of the material coins.
#### Example
Version: 1
Sender: 31A6302161AC8F5938969E85399EB3415C237F93
Number: 92
Recipient: 31A6302161AC8F5938969E85399EB3415C237F93
Type: FUSION
Coins:
31A6302161AC8F5938969E85399EB3415C237F93-9-5-1-F-92
31A6302161AC8F5938969E85399EB3415C237F93-6-3-1-A-1, 31A6302161AC8F5938969E85399EB3415C237F93-1
31A6302161AC8F5938969E85399EB3415C237F93-7-1-1-A-1, 31A6302161AC8F5938969E85399EB3415C237F93-1
31A6302161AC8F5938969E85399EB3415C237F93-8-1-1-A-1, 31A6302161AC8F5938969E85399EB3415C237F93-1
Comment:
Here I am fusioning my coins 6,7,8 (of respective value 30,10,10) to make a new coin of value 50.
Of course, coins 6,7,8 are therefore unusable as they are no more part of monetary mass.
### Validity
In HDC, a Transaction structure is considered *valid* if:
......
......@@ -359,7 +359,8 @@ Transaction chain.
},{
// ...
}
]
],
"comment": "Paying LoLCat's food."
},{
"version": 1,
"sender": "31A6302161AC8F5938969E85399EB3415C237F93",
......@@ -368,13 +369,17 @@ Transaction chain.
"type": "FUSION",
"coins": [
{
"id": "10-1-2-F-14",
"transaction_id": ""
},{
"id": "2-4-1-A-1",
"transaction_id": "31A6302161AC8F5938969E85399EB3415C237F93-1"
},{
"id": "3-6-1-A-1",
"transaction_id": "31A6302161AC8F5938969E85399EB3415C237F93-1"
}
]
],
"comment": "Too much coins ! Making big one."
}
]
}
......@@ -441,11 +446,165 @@ The new THT entry.
}
```
#### transactions/*
#### `transactions/process/issuance`
**Goal**
POST an issuance transaction.
**Parameters**
Name | Value | Method
---- | ----- | ------
`transaction` | The raw transaction. | POST
`signature` | The signature of the `transaction`. | POST
**Returns**
The issuance transaction and its signature.
```js
{
"signature": "-----BEGIN PGP SIGNATURE ... END PGP SIGNATURE-----",
"transaction":
{
"version": 1,
"sender": "31A6302161AC8F5938969E85399EB3415C237F93",
"number": 1,
"recipient": "31A6302161AC8F5938969E85399EB3415C237F93",
"type": "ISSUANCE",
"coins": [
{
"id": "1-5-2-A-1",
"transaction_id": ""
},{
// Other coin
},{
// ...
}
],
"comment": "Universal Dividend"
}
}
```
#### `transactions/process/transfert`
**Goal**
POST a transfert transaction.
**Parameters**
Name | Value | Method
---- | ----- | ------
`transaction` | The raw transaction. | POST
`signature` | The signature of the `transaction`. | POST
**Returns**
The transfert transaction and its signature.
```js
{
"signature": "-----BEGIN PGP SIGNATURE ... END PGP SIGNATURE-----",
"transaction":
{
"version": 1,
"sender": "31A6302161AC8F5938969E85399EB3415C237F93",
"number": 92,
"recipient": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
"type": "TRANSFERT",
"coins": [
{
"id": "10-1-2-F-14",
"transaction_id": "31A6302161AC8F5938969E85399EB3415C237F93-14"
},{
// Other coin
},{
// ...
}
],
"comment": "Paying LoLCat's food."
}
}
```
#### `transactions/process/fusion`
**Goal**
POST a fusion transaction.
**Parameters**
Name | Value | Method
---- | ----- | ------
`transaction` | The raw transaction. | POST
`signature` | The signature of the `transaction`. | POST
**Returns**
The fusion transaction and its signature.
```js
{
"signature": "-----BEGIN PGP SIGNATURE ... END PGP SIGNATURE-----",
"transaction":
{
"version": 1,
"sender": "31A6302161AC8F5938969E85399EB3415C237F93",
"number": 14,
"recipient": "31A6302161AC8F5938969E85399EB3415C237F93",
"type": "FUSION",
"coins": [
{
"id": "10-1-2-F-14",
"transaction_id": ""
},{
"id": "2-4-1-A-1",
"transaction_id": "31A6302161AC8F5938969E85399EB3415C237F93-1"
},{
"id": "3-6-1-A-1",
"transaction_id": "31A6302161AC8F5938969E85399EB3415C237F93-1"
}
],
"comment": "Too much coins ! Making big one."
}
}
```
#### `transactions/view/[TRANSACTION_ID]`
**Goal**
GET the transaction of given `TRANSACTION_ID`.
**Parameters**
Name | Value | Method
---- | ----- | ------
`TRANSACTION_ID` | The transaction [unique identifier](https://github.com/c-geek/nodecoind/blob/master/doc/HDC.md#transaction). | URL
**Returns**
URL | Description | Result
--- | ----------- | ------
`process/issuance` | is a URL to POST an issuance transaction. | The issuance transaction.
`process/transfert` | is a URL to POST a transfert transaction. | The transfert transaction.
`process/transfert` | is a URL to POST a fusion transaction. | The fusion transaction.
`view/[TRANSACTION_ID]` | displays detailed informations about a transaction. | The asked transaction.
\ No newline at end of file
The transaction and its signature.
```js
{
"signature": "-----BEGIN PGP SIGNATURE ... END PGP SIGNATURE-----",
"transaction":
{
"version": 1,
"sender": "31A6302161AC8F5938969E85399EB3415C237F93",
"number": 14,
"recipient": "31A6302161AC8F5938969E85399EB3415C237F93",
"type": "FUSION",
"coins": [
{
"id": "10-1-2-F-14",
"transaction_id": ""
},{
"id": "2-4-1-A-1",
"transaction_id": "31A6302161AC8F5938969E85399EB3415C237F93-1"
},{
"id": "3-6-1-A-1",
"transaction_id": "31A6302161AC8F5938969E85399EB3415C237F93-1"
}
],
"comment": "Too much coins ! Making big one."
}
}
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment