HTTP_API.md 40.3 KB
Newer Older
Cédric Moreau's avatar
Cédric Moreau committed
1
# uCoin HTTP API
Cédric Moreau's avatar
Cédric Moreau committed
2

Cédric Moreau's avatar
Cédric Moreau committed
3
4
5
## Contents

* [Contents](#contents)
Cédric Moreau's avatar
Cédric Moreau committed
6
7
8
9
10
11
* [Overview](#overview)
* [Merkle URLs](#merkle-urls)
* [API](#api)
  * [pks/](#pks)
      * [add](#pksadd)
      * [lookup](#pkslookup)
12
      * [all](#pksall)
13
  * [keychain/](#keychain)
14
      * [parameters](#parameters)
15
16
      * [membership](#keychainmembership)
      * [keyblock](#keychainkeyblock)
17
      * [keyblock/[number]](#keychainkeyblocknumber)
18
      * [current](#keychaincurrent)
19
20
21
22
23
24
25
26
27
28
29
  * [network/](#network)
      * [pubkey](#networkpubkey)
      * [peering](#networkpeering)
      * [peering/peers (GET)](#networkpeeringpeers-get)
      * [peering/peers (POST)](#networkpeeringpeers-post)
      * [peering/peers/upstream](#networkpeeringpeersupstream)
      * [peering/peers/upstream/[PGP_FINGERPRINT]](#networkpeeringpeersupstreampgp_fingerprint)
      * [peering/peers/downstream](#networkpeeringpeersdownstream)
      * [peering/peers/downstream/[PGP_FINGERPRINT]](#networkpeeringpeersdownstreampgp_fingerprint)
      * [peering/forward](#networkpeeringforward)
      * [peering/status](#networkpeeringstatus)
30
31
32
      * [wallet (GET)](#networkwallet-get)
      * [wallet (POST)](#networkwallet-post)
      * [wallet/[PGP_FINGERPRINT]](#networkwalletpgp_fingerprint)
33
  * [contract/](#contract)
34
      * [parameters](#parameters1)
35
36
37
38
39
40
41
42
43
      * [am/[AMENDMENT_NUMBER]](#amamendment_number)
  * [tx/](#tx)
      * [process](#process)
      * [last/[count]](#lastcount)
      * [sender/[PGP_FINGERPRINT]](#senderpgp_fingerprint)
      * [sender/[PGP_FINGERPRINT]/view/[TX_NUMBER]](#senderpgp_fingerprintviewtx_number)
      * [sender/[PGP_FINGERPRINT]/last/[count]/[from]](#senderpgp_fingerprintlastcountfrom)
      * [recipient/[PGP_FINGERPRINT]](#recipientpgp_fingerprint)
      * [refering/[PGP_FINGERPRINT]/[TX_NUMBER]](#referingpgp_fingerprinttx_number)
44
      * [coins/list/[PGP_FINGERPRINT]](#coinslistpgp_fingerprint)
45
46
      * [coins/view/[COIN_ID]/owner](#coinsviewcoin_idowner)
      * [coins/view/[COIN_ID]/history](#coinsviewcoin_idhistory)
Cédric Moreau's avatar
Cédric Moreau committed
47
48

## Overview
49

Cédric Moreau's avatar
Cédric Moreau committed
50
Data is made accessible through an HTTP API mainly inspired from [OpenUDC_exchange_formats draft](https://github.com/Open-UDC/open-udc/blob/master/docs/OpenUDC_exchange_formats.draft.txt), and has been adapted to fit uCoin specificities.
51
52
53
54

    http[s]://Node[:port]/...
    |-- pks/
    |   |-- add
55
    |   |-- all
56
    |   `-- lookup
57
58
59
    |-- keychain/
    |   |-- membership
    |   |-- keyblock
60
    |   |       `-- [NUMBER]
61
    |   `-- current
62
    |-- network/
63
    |   |-- parameters
64
    |   |-- pubkey
65
    |   |-- peering
66
    |   |   |-- forward
Cédric Moreau's avatar
Cédric Moreau committed
67
68
69
70
71
72
    |   |   |-- status
    |   |   `-- peers/
    |   |       |-- upstream/
    |   |       |   `-- [PGP_FINGERPRINT]
    |   |       `-- downstream/
    |   |           `-- [PGP_FINGERPRINT]
73
    |   `-- wallet/
74
    |       `-- [PGP_FINGERPRINT]
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    |-- contract/
    |   |-- parameters
    |   `-- amendments/
    |       `-- am/
    |           `-- [AMENDMENT_NUMBER]
    `-- tx/
        |-- process
        |-- last/
        |   `-- [count]
        |-- sender/
        |   `-- [PGP_FINGERPRINT]/
        |       |-- view/
        |       |   `-- [TX_NUMBER]
        |       `-- last/
        |           `-- [count]/
        |               `-- [from]
        |-- recipient/
        |   `-- [PGP_FINGERPRINT]
        |-- refering/    
        |   `-- [PGP_FINGERPRINT]/
        |       `-- [TX_NUMBER]
        `-- coins/
            |-- list/
            |   `-- [PGP_FINGERPRINT]
            `-- view/
Cédric Moreau's avatar
Cédric Moreau committed
100
                `-- [COIN_ID]/
101
102
                    |-- history
                    `-- owner
103
104
105
106
107

## Merkle URLs

Merkle URL is a special kind of URL applicable for resources:

108
* `pks/all`
109
* `network/peering/peers (GET)`
110
* `network/wallet (GET)`
111
112
* `hdc/transactions/sender/[PGP_FINGERPRINT]`
* `hdc/transactions/recipient/[PGP_FINGERPRINT]`
113

114
Such kind of URL returns Merkle tree hashes informations. In uCoin, Merkle trees are an easy way to detect unsynced data and where the differences come from. For example, `network/peers` is a Merkle tree whose leaves are peers' key fingerprint sorted ascending way. Thus, if any new peer is added, a branch of the tree will see its hash modified and propagated to the root hash. Change is then easy to detect.
115

Cédric Moreau's avatar
Cédric Moreau committed
116
For commodity issues, this URL uses query parameters to retrieve partial data of the tree, as most of the time all the data is not required. uCoin Merkle tree has a determined number of parent nodes (given a number of leaves), which allows to ask only for interval of them.
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

Here is an example of members Merkle tree with 5 members (taken from [Tree Hash EXchange format (THEX)](http://web.archive.org/web/20080316033726/http://www.open-content.net/specs/draft-jchapweske-thex-02.html)):

                       ROOT=H(H+E)
                        /        \
                       /          \
                 H=H(F+G)          E
                /       \           \
               /         \           \
        F=H(A+B)         G=H(C+D)     E
        /     \           /     \      \
       /       \         /       \      \
      A         B       C         D      E


    Note: H() is some hash function

Where A,B,C,D,E are already hashed data.

Cédric Moreau's avatar
Cédric Moreau committed
136
With such a tree structure, uCoin consider the tree has exactly 6 nodes: `[ROOT,H,E,F,G,E]`. Nodes are just an array, and for a Lambda Server LS1, it is easy to ask for the values of another server LS2 for level 1 (`H` and `E`, the second level): it requires nodes interval `[1;2]`.
137

Cédric Moreau's avatar
Cédric Moreau committed
138
Hence it is quite easy for anyone who wants to check if a `Z` member joined the uCoin community as it would alter the `E` branch of the tree:
139
140
141
142
143
144
145
146
147
148
149
150
151
152

                        ROOT'=H(H+E')
                        /            \
                       /              \
                 H=H(F+G)              E'
                /       \               \
               /         \               \
        F=H(A+B)          G=H(C+D)       E'=H(E+Z)
        /     \           /     \         /     \
       /       \         /       \       /       \
      A         B       C         D     E         Z

`ROOT` changed to `ROOT'`, `E` to `E'`, but `H` did not. The whole `E'` branch should be updated with the proper new data.

153
For that purpose, Merkle URL defines different parameters and results:
154

155
**Parameters**
156
157
158

Parameter | Description
--------- | -----------
159
160
`leaves`  | Defines wether or not leaves hashes should be returned too. Defaults to `false`.
`leaf`    | Hash of a leaf whose content should be returned. Ignore `leaves` parameter.
161

162
163
**Returns**

164
Merkle URL result with `leaves=false`.
165
166
```json
{
167
168
169
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
170
  "root": "6513D6A1582DAE614D8A3B364BF3C64C513D236B"
171
172
173
}
```

174
Merkle URL result with `leaves=true`.
175
176
```json
{
177
178
179
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
  "root": "6513D6A1582DAE614D8A3B364BF3C64C513D236B",
  "leaves": [
    "32096C2E0EFF33D844EE6D675407ACE18289357D",
    "50C9E8D5FC98727B4BBC93CF5D64A68DB647F04F",
    "6DCD4CE23D88E2EE9568BA546C007C63D9131C1B",
    "AE4F281DF5A5D0FF3CAD6371F76D5C29B6D953EC",
    "E0184ADEDF913B076626646D3F52C3B49C39AD6D"
  ]
}
```

Merkle URL result with `leaf=AE4F281DF5A5D0FF3CAD6371F76D5C29B6D953EC`.
```json
{
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
  "root": "6513D6A1582DAE614D8A3B364BF3C64C513D236B",
  "leaf": {
    "hash": "AE4F281DF5A5D0FF3CAD6371F76D5C29B6D953EC",
    "value": // JSON value (object, string, int, ...)
201
  }
202
203
204
}
```

Cédric Moreau's avatar
Cédric Moreau committed
205
206
207
208
209
210
### uCoin Merkle trees leaves

Each tree manages different data, and has a different goal. Hence, each tree has its own rules on how are generated and sorted tree leaves.
Here is a summup of such rules:


211
212
213
Merkle URL                                                                | Leaf                                    | Sort
------------------------------------------------------------------------- | ----------------------------------------| ---------------------------------------
`pks/all`                                                                 | Fingerprint of the key                  | By fingerprint string sort, ascending.
214
215
216
217
218
219
220
221
222
223
`network/peers (GET)`                                                     | Fingerprint of the peer                 | By fingerprint string sort, ascending.
`network/wallet (GET)`                                                    | Fingerprint of the wallet               | By fingerprint string sort, ascending.
`hdc/transactions/sender/[PGP_FINGERPRINT]`                               | Hash of (transaction + signature)       | By hash string sort, ascending.
`hdc/transactions/recipient/[PGP_FINGERPRINT]`                            | Hash of (transaction + signature)       | By hash string sort, ascending.

#### Unicity

It has to be noted that the first four Merkle URLs, there is **no possible conflict** for leaves, as every leaf is represents a OpenPGP key whose fingerprint is unique according to [uCoin protocol](./Protocol.md). Indeed: *nodes are responsible for the concrete key stored under a fingerprint*.

However for the 2 last URLs, conflicts are possible even if largely improbable. Such conflicts would not be a huge problem however: it would lead to hide one of the conflicted transactions, but those 2 URLs are not here for exhaustive inventory of transactions, only for quick synchronization checking. So the goal is still reached.
Cédric Moreau's avatar
Cédric Moreau committed
224

Cédric Moreau's avatar
Cédric Moreau committed
225
## API
226
227
228

### pks/*

Cédric Moreau's avatar
Cédric Moreau committed
229
This URL is used to manage OpenPGP certificates, making uCoin acting **like** an SKS server.
230

Cédric Moreau's avatar
Cédric Moreau committed
231
232
233
234
235
236
237
#### `pks/add`
**Goal**

POST ASCII-armored OpenPGP certificates.

**Parameters**

238
239
240
Name      | Value                                     | Method
--------- | ----------------------------------------- | ------
`keytext` | The raw certificate, ASCII-armored.       | POST
Cédric Moreau's avatar
Cédric Moreau committed
241
242
243
244

**Returns**

The sent PGP Public Key and signature.
245
```json
Cédric Moreau's avatar
Cédric Moreau committed
246
{
247
248
249
250
251
  "email":"cem.moreau@gmail.com",
  "comment":"udid2;c;CAT;LOL;2000-04-19;e+43.70-079.42;0;",
  "name":"LoL Cat",
  "fingerprint":"C73882B64B7E72237A2F460CE9CAB76D19A8651E",
  "raw":"-----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----\r\n"
Cédric Moreau's avatar
Cédric Moreau committed
252
253
254
255
256
257
258
259
260
261
}
```

#### `pks/lookup`
**Goal**

Allows to search for OpenPGP certificates, according to [HKP draft](http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#page-3).

**Parameters**

262
263
Name     | Value                                                                                                         | Method
-------- | ------------------------------------------------------------------------------------------------------------- | ------
Cédric Moreau's avatar
Cédric Moreau committed
264
`search` | A value for searching in PGP certificates database. May start with '0x' for direct search on PGP fingerprint. | GET
265
`op`     | Operation: may be either 'index' or 'get'.                                                                    | GET
Cédric Moreau's avatar
Cédric Moreau committed
266
267
268

**Returns**

Cédric Moreau's avatar
Cédric Moreau committed
269
270
271
272
273
274
A list of matching PGP keys in json format if `op=index`, a single ASCII-armored key if `op=get`.

```json
{
  "keys": [
    {
Cédric Moreau's avatar
Cédric Moreau committed
275
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
276
277
278
279
280
281
      "key":
      {
        "email":"cem.moreau@gmail.com",
        "comment":"udid2;c;CAT;LOL;2000-04-19;e+43.70-079.42;0;",
        "name":"LoL Cat",
        "fingerprint":"C73882B64B7E72237A2F460CE9CAB76D19A8651E",
Cédric Moreau's avatar
Cédric Moreau committed
282
        "raw":"-----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----\r\n"
Cédric Moreau's avatar
Cédric Moreau committed
283
284
      }
    },{
Cédric Moreau's avatar
Cédric Moreau committed
285
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
286
287
288
289
290
291
      "key":
      {
        "email":"cem.moreau@gmail.com",
        "comment":"udid2;c;CAT;LOL;2000-04-19;e+43.70-079.42;0;",
        "name":"LoL Cat",
        "fingerprint":"C73882B64B7E72237A2F460CE9CAB76D19A8651E",
Cédric Moreau's avatar
Cédric Moreau committed
292
        "raw":"-----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----\r\n"
Cédric Moreau's avatar
Cédric Moreau committed
293
294
295
296
      }
    }
  ]
```
297

298
299
300
301
302
303
304
305
306
307
308
309
310
311
#### `pks/all`
**Goal**

Merkle URL refering all the received public keys.

**Parameters**

*None*.

**Returns**

Merkle URL result.
```json
{
312
313
314
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
315
  "root": "114B6E61CB5BB93D862CA3C1DFA8B99E313E66E9"
316
317
318
319
320
321
322
}
```

Merkle URL leaf: public key
```json
{
  "hash": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
323
324
  "value": {
    "fingerprint": "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
Cédric Moreau's avatar
Cédric Moreau committed
325
    "pubkey": "-----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----\r\n"
326
  }
327
328
329
}
```

330
331
### keychain/*

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#### `parameters`

**Goal**

GET the keychain parameters used by this node.

**Parameters**

*None*.

**Returns**

The synchronization parameters.
```json
{
    "sigDelay": 157680000,
    "sigValidity": 31536000,
    "sigQty": 5,
    "stepMax": 3,
    "powZeroMin": 4,
    "powPeriod": 10
}
```

Parameters meaning is described under [Protocol parameters](./Protocol.md#protocol-parameters).

358
359
#### `keychain/membership`

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387

**Goal**

POST a [Membership](./Protocol.md#membership) document.

**Parameters**

Name | Value | Method
---- | ----- | ------
`membership` | The raw membership structure. | POST
`signature` | The signature of the `membership` parameter. | POST

**Returns**

The posted membership request + posted signature.
```json
{
  "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
  "membership": {
    "version": "1",
    "currency": "beta_brousouf",
    "issuer": "FD17FECBAF731658EDEB60CF8700174B1D585861",
    "membership": "IN",
    "sigDate": 1390739944,
    "raw": "Version: 1\r\n...Membership: IN\r\n"
  }
}
```
388
389
390

#### `keychain/keyblock`

391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
**Goal**

POST a new keyblock to add to the keychain.

**Parameters**

Name               | Value                          | Method
------------------ | ------------------------------ | ------
`keyblock`           | The raw keyblock to be added  | POST
`signature`          | Signature of the raw keyblock | POST

**Returns**

The promoted keyblock if successfuly added to the keychain (see [keyblock/[number]](#keychainkeyblocknumber) return object).

#### `keychain/keyblock/[NUMBER]`

**Goal**

GET the promoted keyblock whose number `NUMBER`.

**Parameters**

Name               | Value                                                         | Method
------------------ | ------------------------------------------------------------- | ------
`NUMBER`           | The promoted keyblock number (integer value) we want to see.  | URL

**Returns**

The promoted keyblock if it exists (otherwise return HTTP 404).
```json
{
  "version": 1,
  "nonce": 28,
  "number": 1,
  "timestamp": 1408996317,
  "membersCount": 4,
  "currency": "beta_brousouf",
  "membersRoot": "E9A2E7146E00CF407CE7C837CD83430327928CA9",
  "signature": "-----BEGIN PGP SIGNATURE-----...-----END PGP SIGNATURE-----\r\n",
  "hash": "0000F40BDC0399F2E84000468628F50A122B5F16",
  "previousHash": "0009A7A62703F976F683BBA500FC0CB832B8220D",
  "previousIssuer": "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
  "membersChanges": [],
  "keysChanges": [
    {
      "membership": {
        "signature": "iQGcBAABCAA...J8/UODEA==\n=t2S+\n",
        "membership": "1:33BBFC0C67078D72AF128B5BA296CC530126F372:IN:1408995911:Snowy (udid2;c;SNOW;JOHN;1980-07-13;e+40.71-074.01;0;) 
<john.snow@got.com>"
      },
      "certpackets": "wsBfBBAB...LWPztzla5vwADMow==\n",
      "keypackets": "xsDNBFH...oEA=\n",
      "fingerprint": "33BBFC0C67078D72AF128B5BA296CC530126F372",
      "type": "N"
    },
    {
      "membership": {
        "signature": "iQEcBAAB...3NGiw=\n=2nmK\n",
        "membership": "1:663A65AC3CE8F36DCBBCAF7ABD4367024C29635E:IN:1408995912:Superman (udid2;c;KENT;CLARK-JOSEPH;1950-04-07;e+37.31-083.34;0;) 
    <superman@krypton.com>"
      },
      "certpackets": "wsBfB...aWdNJL1VaYk=\n",
      "fingerprint": "663A65AC3CE8F36DCBBCAF7ABD4367024C29635E",
      "type": "N"
    },
    {
      "keypackets": "",
      "certpackets": "wsDfBBAB...zcBmO\n",
      "fingerprint": "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
      "type": "U"
    },
    {
      "keypackets": "",
      "certpackets": "wsDfBBAB...KyKG5SymM7YQ==\n",
      "fingerprint": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
      "type": "U"
    }
  ]
}
```
472
473
474

#### `keychain/current`

475
Same as [keyblock/[number]](#keychainkeyblocknumber), but return last accepted keyblock.
476

477
### network/*
478

479
This URL is used for uCoin Gossip protocol (exchanging UCG messages).
480

481
#### `network/pubkey`
Cédric Moreau's avatar
Cédric Moreau committed
482
483
484
485
486
487
488
489
490
491
492
493
**Goal**

GET the public key of the peer.

**Parameters**

*None*.

**Returns**

The public key in ASCII-armored format.
```
Cédric Moreau's avatar
Cédric Moreau committed
494
-----BEGIN PGP PUBLIC KEY BLOCK-----
Cédric Moreau's avatar
Cédric Moreau committed
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
Version: GnuPG v1.4.12 (GNU/Linux)

mQENBFHHC/EBCADWTLSN7EGP+n30snndS3ZNcB02foL+0opcS6LK2coPDJLg2noo
keJRHZxF3THmZQrKwZOjiuDBinOc5DWlzIS/gD/RaXwntgPFlGKBlBU+g255fr28
ziSb5Y1lW4N//nUFdPZzoMmPgRj0b17T0UPCoMR8ZZ/Smk5LINbQwt+A+LEoxEdE
Vcq+Tyc0OlEabqO6RFqiKDRiPhGPiCwVQA3yPjb6iCp5gTchObCxCnDbxA0Mfj9F
mHrGbepNHGXxStO4xT0woCb7y02S1E8K08kOc5Bq9e1Yj5I/mdaw4Hn/Wp28lZl1
mnO1u1z9ZU/rcglhEyaEOTwasheb44QcdGSfABEBAAG0TUxvTCBDYXQgKHVkaWQy
O2M7Q0FUO0xPTDsyMDAwLTA0LTE5O2UrNDMuNzAtMDc5LjQyOzA7KSA8Y2VtLm1v
cmVhdUBnbWFpbC5jb20+iQE9BBMBCAAnBQJRxwvxAhsDBQkLR5jvBQsJCAcDBRUK
CQgLBRYCAwEAAh4BAheAAAoJEOnKt20ZqGUeZYcH/0ItH4b/O0y7V1Jzc1DZAdn4
iDiI7/SF3fN4f6cJCu/SOVb+ERFIb6JK+HNHdVAcMHKaPW625R0FahHUkcXWkkGm
Q6+sLIsVZwVN1oeZtlD12cq9A4UJyfJUXkinMKkI8xpdV8J7s5wFRavOS/qaF5be
ah0Z+IGwQK0nuXxWpT6UZWbpUfXPQB2Mz2/rpjSWKwO3X4FwwOfDiuZExyH2JPDY
shdPcj/x+gnzYW9XfWCJw3rOK42vtM+aLtUpJO0Jh6X/sj/iqyS4rPB4DVCmEgSX
Px1P+kqnsz3aNTOIujXS8Faz+TC+eNhn+z3SoTl5gBlNNM171fWFr0BR3nIfIu65
AQ0EUccL8QEIAPAQaxK6s4DjDHiOwrMotvb479QD5PsHU6S0VG0+naoPlNJb2d5w
YhnFAn4aYLiXx4IIl38rHnV+yWATOUe2rdCe4enTXkxyWJVaxIcNJLFpUjHYGbrC
nNwiXpuQfSDuRN/wcVNSBKXhWNUPY9IsbgERWhS5YTFnuQcBjMqDwF6JImQ8O4nZ
wno811nqK1XaMuLVvXZAsO1Vi1k3NArM5+jdlq9e3BA0NcHJmGEcQdTw0Tk5Oq6r
mE8ux7pS0bn6OUkkseR5DyRlFtzqi4wp30GeggeFExx7ZCVuctpJX9ZoC3cJoZT0
s3LuUtV0EW50yCtP+3Vpkek2WtjfVbM6kDkAEQEAAYkBJQQYAQgADwUCUccL8QIb
DAUJC0eY7wAKCRDpyrdtGahlHg7+B/95xEoSrFQ7/mc7g6sbisvx3s547gUXXYSu
FHS03IMDWJrfGKqXtBf9ETBx4OLeBXY7z1lL4WCN6/xtrL+mSQ9dbDqdXv/1EhkS
v0s+IvJ34KYGAkFXSCoTE7rnkPwQjoMYVSFkf5e8g9adyKvndq/QSPNuv+FPL6sH
m1N9nmus5Ebr0zTVDmmfoqzokuDfHm5h6YrkFscMGjrCKWuXSiTaGj9Hm3MqeZ3T
Kva5isa/h0h7Ai3wJ5XJpMrFNN6BU/wIt7fM2hsNAOwaG+WUfgjYEkOua8gPPtpL
ZJJPb/89yrs9F7JkLi/oiAl5VpItm+hlFpLe1TE7oa6k53eZ2a+V
=rOj9
Cédric Moreau's avatar
Cédric Moreau committed
524
-----END PGP PUBLIC KEY BLOCK-----
Cédric Moreau's avatar
Cédric Moreau committed
525
526
```

527
#### `network/peering`
528
529
**Goal**

Cédric Moreau's avatar
Cédric Moreau committed
530
531
532
533
534
535
536
537
538
539
540
541
542
543
GET the peering informations of this node.

**Parameters**

*None*.

**Returns**

Peering entry of the node.
```json
{
  "version": "1",
  "currency": "beta_brousouf",
  "fingerprint": "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
Cédric Moreau's avatar
Cédric Moreau committed
544
545
546
547
548
  "endpoints": [
    "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9001",
    "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9002",
    "OTHER_PROTOCOL 88.77.66.55 9001",
  ],
Cédric Moreau's avatar
Cédric Moreau committed
549
  "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n"
Cédric Moreau's avatar
Cédric Moreau committed
550
551
552
}
```

553
#### `network/peering/peers (GET)`
554
555
556
557
558
559
560
561
562
563
564
565
566
**Goal**

Merkle URL refering to peering entries of every node inside the currency network.

**Parameters**

*None*.

**Returns**

Merkle URL result.
```json
{
567
568
569
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
570
  "root": "114B6E61CB5BB93D862CA3C1DFA8B99E313E66E9"
571
572
573
574
575
576
577
578
579
580
581
}
```

Merkle URL leaf: peering entry
```json
{
  "hash": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
  "value": {
    "version": "1",
    "currency": "beta_brousouf",
    "fingerprint": "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
Cédric Moreau's avatar
Cédric Moreau committed
582
583
584
585
586
    "endpoints": [
      "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9001",
      "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9002",
      "OTHER_PROTOCOL 88.77.66.55 9001"
    ],
Cédric Moreau's avatar
Cédric Moreau committed
587
    "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n"
588
589
590
591
  }
}
```

592
#### `network/peering/peers (POST)`
593
594
595
596
597
598
**Goal**

POST a UCG peering entry document to this node in order to alter UCG peering table.

**Parameters**

599
600
601
Name        | Value                               | Method
----------- | ----------------------------------- | ------
`entry`     | UCG peering entry document.         | POST
602
603
604
605
606
607
608
609
610
611
`signature` | Signature of the UCG entry's value. | POST

**Returns**

The posted entry.
```json
{
  "version": "1",
  "currency": "beta_brousouf",
  "fingerprint": "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
Cédric Moreau's avatar
Cédric Moreau committed
612
613
614
615
616
  "endpoints": [
    "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9001",
    "BASIC_MERKLED_API some.dns.name 88.77.66.55 2001:0db8:0000:85a3:0000:0000:ac1f 9002",
    "OTHER_PROTOCOL 88.77.66.55 9001"
  ],
Cédric Moreau's avatar
Cédric Moreau committed
617
  "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n"
618
619
620
}
```

621
#### `network/peering/peers/upstream`
Cédric Moreau's avatar
Cédric Moreau committed
622
623
624
625
626
627
628
629
630
631
**Goal**

GET a list of peers this node is **listening to** for ANY incoming transaction.

**Parameters**

*None*.

**Returns**

632
The corresponding peer list's fingerprints.
Cédric Moreau's avatar
Cédric Moreau committed
633
634
635

```json
{
636
637
638
639
  "peers": [
    "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
    "B356F8A6AD4A0431AF047AA204511A9F8A51ED37"
  ]
Cédric Moreau's avatar
Cédric Moreau committed
640
641
642
}
```

643
#### `network/peering/peers/upstream/[PGP_FINGERPRINT]`
Cédric Moreau's avatar
Cédric Moreau committed
644
645
646
647
648
649
**Goal**

GET a list of peers this node is **listening to** for incoming transactions of `PGP_FINGERPRINT`.

**Parameters**

650
651
Name              | Value                                                                        | Method
----------------- | ---------------------------------------------------------------------------- | ------
Cédric Moreau's avatar
Cédric Moreau committed
652
653
654
655
656
657
658
659
`PGP_FINGERPRINT` | PGP key's fingerprint whose incoming transactions are listened by this node. | URL

**Returns**

The corresponding peer list.

```json
{
660
661
662
663
  "peers": [
    "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
    "B356F8A6AD4A0431AF047AA204511A9F8A51ED37"
  ]
Cédric Moreau's avatar
Cédric Moreau committed
664
665
666
}
```

667
#### `network/peering/peers/downstream`
Cédric Moreau's avatar
Cédric Moreau committed
668
669
670
671
672
673
674
675
676
677
678
679
680
681
**Goal**

GET a list of peers this node is **listened by** for ANY incoming transaction.

**Parameters**

*None*.

**Returns**

The corresponding peer list.

```json
{
682
683
684
685
  "peers": [
    "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
    "B356F8A6AD4A0431AF047AA204511A9F8A51ED37"
  ]
Cédric Moreau's avatar
Cédric Moreau committed
686
687
688
}
```

689
#### `network/peering/peers/downstream/[PGP_FINGERPRINT]`
Cédric Moreau's avatar
Cédric Moreau committed
690
691
692
693
694
695
**Goal**

GET a list of peers this node is **listened by** for incoming transactions of `PGP_FINGERPRINT`.

**Parameters**

696
697
Name              | Value                                                                          | Method
----------------- | ------------------------------------------------------------------------------ | ------
Cédric Moreau's avatar
Cédric Moreau committed
698
699
700
701
702
703
704
705
`PGP_FINGERPRINT` | PGP key's fingerprint whose incoming transactions are listened by other nodes. | URL

**Returns**

The corresponding peer list.

```json
{
706
707
708
709
  "peers": [
    "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
    "B356F8A6AD4A0431AF047AA204511A9F8A51ED37"
  ]
Cédric Moreau's avatar
Cédric Moreau committed
710
711
712
}
```

713
#### `network/peering/forward`
Cédric Moreau's avatar
Cédric Moreau committed
714
715
**Goal**

716
POST a UCG forward document to this node in order to be sent back incoming transactions.
717
718
719

**Parameters**

720
721
722
Name        | Value                                  | Method
----------- | -------------------------------------- | ------
`forward`   | UCG forward document.                  | POST
723
`signature` | Signature of the UCG forward document. | POST
724
725
726

**Returns**

727
The posted forward.
728
729
730
731
```json
{
  "version": "1",
  "currency": "beta_brousouf",
Cédric Moreau's avatar
Cédric Moreau committed
732
733
  "from": "A70B8E8E16F91909B6A06DFB7EEF1651D9CCF468",
  "to": "CC5AE6DA4307AD2339FB52013119E9704EDE0802",
734
735
736
737
738
739
740
741
  "forward": "KEYS",
  "keys": [
    "395DF8F7C51F007019CB30201C49E884B46B92FA",
    "58E6B3A414A1E090DFC6029ADD0F3555CCBA127F",
    "4DC7C9EC434ED06502767136789763EC11D2C4B7",
    "8EFD86FB78A56A5145ED7739DCB00C78581C5375",
    "95CB0BFD2977C761298D9624E4B4D4C72A39974A"
  ]
742
743
744
}
```

745
#### `network/peering/status`
746
747
**Goal**

748
POST a UCG status document to this node in order notify of its status.
Cédric Moreau's avatar
Cédric Moreau committed
749
750
751

**Parameters**

752
753
754
755
Name        | Value                                  | Method
----------- | -------------------------------------- | ------
`status`    | UCG status document.                   | POST
`signature` | Signature of the UCG entry's value.    | POST
Cédric Moreau's avatar
Cédric Moreau committed
756
757
758

**Returns**

759
The posted status.
Cédric Moreau's avatar
Cédric Moreau committed
760
761
762
763
```json
{
  "version": "1",
  "currency": "beta_brousouf",
Cédric Moreau's avatar
Cédric Moreau committed
764
  "status": "UP"
Cédric Moreau's avatar
Cédric Moreau committed
765
766
767
}
```

768
#### `network/wallet (GET)`
Cédric Moreau's avatar
Cédric Moreau committed
769
770
**Goal**

771
Merkle URL refering to WHT (Wallets Hash Table).
Cédric Moreau's avatar
Cédric Moreau committed
772
773
774
775
776
777
778
779
780
781
782
783
784

**Parameters**

*None*.

**Returns**

Merkle URL result.
```json
{
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
785
  "root": "114B6E61CB5BB93D862CA3C1DFA8B99E313E66E9"
Cédric Moreau's avatar
Cédric Moreau committed
786
787
788
}
```

789
Merkle URL leaf: Wallet
Cédric Moreau's avatar
Cédric Moreau committed
790
791
792
793
```json
{
  "hash": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
  "value": {
Cédric Moreau's avatar
Cédric Moreau committed
794
    "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
795
796
    "entry": {
      "version": "1",
Cédric Moreau's avatar
Cédric Moreau committed
797
      "currency": "beta_brousouf",
Cédric Moreau's avatar
Cédric Moreau committed
798
      "issuer": "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
799
      "requiredTrusts": 3,
Cédric Moreau's avatar
Cédric Moreau committed
800
801
802
803
804
805
806
807
808
809
810
811
812
      "hosters": [
        "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
        "D049002A6724D35F867F64CC087BA351C0AEB6DF"
      ],
      "trusts": [
        "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
        "D049002A6724D35F867F64CC087BA351C0AEB6DF"
      ]
    }
  }
}
```

813
#### `network/wallet (POST)`
Cédric Moreau's avatar
Cédric Moreau committed
814
815
**Goal**

816
POST a Wallet.
Cédric Moreau's avatar
Cédric Moreau committed
817
818
819

**Parameters**

820
821
822
Name        | Value                                  | Method
----------- | -------------------------------------- | ------
`entry`     | Entry data.                            | POST
823
`signature` | Signature of the Wallet value.         | POST
Cédric Moreau's avatar
Cédric Moreau committed
824
825
826

**Returns**

827
The posted Wallet.
828
829
```json
{
Cédric Moreau's avatar
Cédric Moreau committed
830
  "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
831
  "entry": {
832
    "version": "1",
Cédric Moreau's avatar
Cédric Moreau committed
833
834
    "currency": "beta_brousouf",
    "fingerprint": "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
835
    "requiredTrusts": 3,
836
    "hosters": [
Cédric Moreau's avatar
Cédric Moreau committed
837
838
      "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
      "D049002A6724D35F867F64CC087BA351C0AEB6DF"
839
840
    ],
    "trusts": [
Cédric Moreau's avatar
Cédric Moreau committed
841
842
843
      "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
      "D049002A6724D35F867F64CC087BA351C0AEB6DF"
    ]
844
845
846
847
  }
}
```

848
#### `network/wallet/[PGP_FINGERPRINT]`
849
850
**Goal**

851
GET a unique Wallet.
852
853
854

**Parameters**

855
856
Name              | Value                                           | Method
----------------- | ----------------------------------------------- | ------
857
858
859
860
`PGP_FINGERPRINT` | The key fingerprint we want Trust informations. | URL

**Returns**

861
The requested Wallet.
862
863
```json
{
Cédric Moreau's avatar
Cédric Moreau committed
864
  "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
865
866
  "entry": {
    "version": "1",
Cédric Moreau's avatar
Cédric Moreau committed
867
868
    "currency": "beta_brousouf",
    "fingerprint": "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
869
    "requiredTrusts": 3,
Cédric Moreau's avatar
Cédric Moreau committed
870
871
872
873
874
875
876
877
878
    "hosters": [
      "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
      "D049002A6724D35F867F64CC087BA351C0AEB6DF"
    ],
    "trusts": [
      "C73882B64B7E72237A2F460CE9CAB76D19A8651E",
      "D049002A6724D35F867F64CC087BA351C0AEB6DF"
    ]
  }
879
880
881
}
```

882
### contract/*
883
884
885
886
887

This URL pattern manages all the data used by uCoin based on the PKS.

In a general way, those URLs return HTTP **200** code on success, HTTP **501** if not implemented and any HTTP error code on error.

888
889
#### `parameters`

890
891
**Goal**

892
GET the monetary parameters used by this node.
893
894
895
896
897
898
899

**Parameters**

*None*.

**Returns**

900
The monetary parameters.
901
```json
902
{
903
904
905
    "c": 0.737826,
    "dt": 2629800,
    "ud0": 100
906
907
908
}
```

909
Parameters meaning is described under [Protocol parameters](./Protocol.md#protocol-parameters).
910
911

#### `am/[AMENDMENT_NUMBER]`
912
913
**Goal**

914
GET the promoted amendment with number `AMENDMENT_NUMBER`.
915
916
917

**Parameters**

918
919
Name               | Value                                                         | Method
------------------ | ------------------------------------------------------------- | ------
920
921
922
923
924
925
`AMENDMENT_NUMBER` | The promoted amendment number (integer value) we want to see. | URL

**Returns**

The promoted amendment if it exists (otherwise return HTTP 404).
```json
Cédric Moreau's avatar
Cédric Moreau committed
926
927
{
  "version": "1",
928
  "currency": "beta_brousouf",
Cédric Moreau's avatar
Cédric Moreau committed
929
  "number": "2",
930
  "generated": 1400588975,
Cédric Moreau's avatar
Cédric Moreau committed
931
932
933
934
935
936
937
  "previousHash": "0F45DFDA214005250D4D2CBE4C7B91E60227B0E5",
  "dividend": "100",
  "membersRoot": "F92B6F81C85200250EE51783F5F9F6ACA57A9AFF",
  "membersCount": "4",
  "membersChanges": [
    "+31A6302161AC8F5938969E85399EB3415C237F93"
  ],
938
  "raw": "Version: 1\r\n...+31A6302161AC8F5938969E85399EB3415C237F93\r\n"
Cédric Moreau's avatar
Cédric Moreau committed
939
940
941
}
```

942
### tx/*
Cédric Moreau's avatar
Cédric Moreau committed
943

944
#### `tx/process`
945
946
**Goal**

Cédric Moreau's avatar
Cédric Moreau committed
947
POST a transaction.
948
949
950

**Parameters**

951
952
953
954
Name              | Value                                                         | Method
----------------- | ------------------------------------------------------------- | ------
`transaction`     | The raw transaction.                                          | POST
`signature`       | The signature of the `transaction`.                           | POST
955
956
957

**Returns**

Cédric Moreau's avatar
Cédric Moreau committed
958
The recorded transaction and its signature.
959
```json
960
{
Cédric Moreau's avatar
Cédric Moreau committed
961
  "raw": "Version: 1\r\n...\r\n",
962
963
  "transaction":
  {
Cédric Moreau's avatar
Cédric Moreau committed
964
    "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
965
    "version": 1,
Cédric Moreau's avatar
Cédric Moreau committed
966
    "currency": "beta_brousouf",
967
968
    "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
    "number": 1,
Cédric Moreau's avatar
Cédric Moreau committed
969
    "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
970
    "recipient": "A9571447F4B6B477F1037D85C6211FB059C561C7",
971
972
973
    "amounts": [
      "9EE7ABA9EE7A15F57319B6BFC21FA08E821ABEAA-0:100",
      "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-1:110",
974
    ],
975
    "comment": "Buying something"
976
977
978
979
  }
}
```

980
#### `tx/last/[COUNT]`
981
982
**Goal**

Cédric Moreau's avatar
Cédric Moreau committed
983
Get the last `n` received transactions.
984
985
986

**Parameters**

Cédric Moreau's avatar
Cédric Moreau committed
987
988
989
990
991
992
993
994
995
996
997
Name              | Value                                                                        | Method
----------------- | ---------------------------------------------------------------------------- | ------
`COUNT`           | Integer indicating to retrieve the last [COUNT] transactions. Defaults to 1. | URL

**Returns**

The last [COUNT] transactions received.
```json
{
  "transactions": [
    {
Cédric Moreau's avatar
Cédric Moreau committed
998
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
999
1000
1001
1002
1003
      "version": 1,
      "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
      "number": 92,
      "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
      "recipient": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
1004
1005
1006
      "amounts": [
        "70C881D4A26984DDCE795F6F71817C9CF4480E79-92:66",
        "503A586FE6F7819A18A38426A7C2C1D0880F99CB-122:988",
Cédric Moreau's avatar
Cédric Moreau committed
1007
1008
1009
      ],
      "comment": "Paying LoLCat's food."
    },{
Cédric Moreau's avatar
Cédric Moreau committed
1010
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
1011
      "version": 1,
1012
      "currency": "beta_brousouf",
Cédric Moreau's avatar
Cédric Moreau committed
1013
      "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
1014
1015
      "number": 91,
      "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
1016
      "recipient": "A9571447F4B6B477F1037D85C6211FB059C561C7",
1017
1018
1019
      "amounts": [
        "9EE7ABA9EE7A15F57319B6BFC21FA08E821ABEAA-0:100",
        "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-1:110",
Cédric Moreau's avatar
Cédric Moreau committed
1020
      ],
1021
      "comment": "Buying something"
Cédric Moreau's avatar
Cédric Moreau committed
1022
1023
1024
1025
1026
    }
  ]
}
```

1027
#### `tx/sender/[PGP_FINGERPRINT]`
Cédric Moreau's avatar
Cédric Moreau committed
1028
1029
1030
1031
1032
1033
1034
1035
1036
**Goal**

Merkle URL referencing all the transactions sent by this sender and stored by this node (should contain all transactions of the sender).

**Parameters**

Name              | Value                                                         | Method
----------------- | ------------------------------------------------------------- | ------
`PGP_FINGERPRINT` | PGP fingerprint of the key we want to see sent transactions.  | URL
1037
1038
1039
1040
1041
1042

**Returns**

Merkle URL result.
```json
{
1043
1044
1045
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
1046
  "root": "114B6E61CB5BB93D862CA3C1DFA8B99E313E66E9"
1047
1048
1049
1050
1051
1052
}
```

Merkle URL leaf: transaction
```json
{
1053
1054
  "hash": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
  "value": {
1055
1056
    "transaction":
    {
Cédric Moreau's avatar
Cédric Moreau committed
1057
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1058
      "version": 1,
1059
      "sender": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
1060
      "number": 14,
Cédric Moreau's avatar
Cédric Moreau committed
1061
      "recipient": "31A6302161AC8F5938969E85399EB3415C237F93",
1062
      "coins": [
1063
1064
1065
        "2E69197FAB029D8669EF85E82457A1587CA0ED9C-10-1",
        "2E69197FAB029D8669EF85E82457A1587CA0ED9C-2-4:31A6302161AC8F5938969E85399EB3415C237F93-1",
        "2E69197FAB029D8669EF85E82457A1587CA0ED9C-3-6:31A6302161AC8F5938969E85399EB3415C237F93-1",
1066
      ],
1067
      "comment": "Giving back some coins"
1068
1069
1070
1071
1072
    }
  }
}
```

1073
#### `tx/sender/[PGP_FINGERPRINT]/view/[TX_NUMBER]`
1074
1075
**Goal**

Cédric Moreau's avatar
Cédric Moreau committed
1076
GET the transaction of given `TRANSACTION_ID`.
1077
1078
1079

**Parameters**

Cédric Moreau's avatar
Cédric Moreau committed
1080
1081
1082
1083
Name              | Value                                                                                                                | Method
----------------- | -------------------------------------------------------------------------------------------------------------------- | ------
`PGP_FINGERPRINT` | PGP fingerprint of the key we want to see transaction.                                                               | URL
`TX_NUMBER`       | The transaction [unique identifier](https://github.com/c-geek/ucoin/blob/master/doc/HDC.md#transaction) number part. | URL
1084
1085
1086

**Returns**

Cédric Moreau's avatar
Cédric Moreau committed
1087
The transaction and its signature.
1088
1089
```json
{
1090
1091
1092
  "raw": "Version: 1\r\n...\r\n",
  "transaction":
  {
Cédric Moreau's avatar
Cédric Moreau committed
1093
    "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1094
    "version": 1,
1095
    "sender": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
Cédric Moreau's avatar
Cédric Moreau committed
1096
    "number": 14,
1097
1098
    "recipient": "31A6302161AC8F5938969E85399EB3415C237F93",
    "coins": [
1099
1100
1101
      "2E69197FAB029D8669EF85E82457A1587CA0ED9C-10-1",
      "2E69197FAB029D8669EF85E82457A1587CA0ED9C-2-4:31A6302161AC8F5938969E85399EB3415C237F93-1",
      "2E69197FAB029D8669EF85E82457A1587CA0ED9C-3-6:31A6302161AC8F5938969E85399EB3415C237F93-1",
1102
    ],
1103
    "comment": "Giving back some coins"
1104
1105
1106
1107
  }
}
```

1108
#### `tx/sender/[PGP_FINGERPRINT]/last/[COUNT]/[FROM]`
1109
1110
**Goal**

Cédric Moreau's avatar
Cédric Moreau committed
1111
Get the last `n` received transactions of a PGP key.
1112
1113
1114

**Parameters**

Cédric Moreau's avatar
Cédric Moreau committed
1115
1116
1117
1118
1119
Name              | Value                                                                                      | Method
----------------- | ------------------------------------------------------------------------------------------ | ------
`PGP_FINGERPRINT` | PGP fingerprint of the key we want to see last transaction.                                | URL
`COUNT`           | Integer indicating to retrieve the last [COUNT] transactions. Defaults to 1.               | URL
`FROM`            | Integer indicating to retrieve [COUNT] transactions starting from [FROM] number. Optional. | URL
1120
1121
1122

**Returns**

Cédric Moreau's avatar
Cédric Moreau committed
1123
The last [COUNT] transactions of given PGP key.
1124
1125
```json
{
Cédric Moreau's avatar
Cédric Moreau committed
1126
  "transactions": [
1127
    {
Cédric Moreau's avatar
Cédric Moreau committed
1128
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1129
      "version": 1,
Cédric Moreau's avatar
Cédric Moreau committed
1130
1131
1132
1133
      "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
      "number": 92,
      "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
      "recipient": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
1134
1135
1136
      "amounts": [
        "70C881D4A26984DDCE795F6F71817C9CF4480E79-92:66",
        "503A586FE6F7819A18A38426A7C2C1D0880F99CB-122:988",
Cédric Moreau's avatar
Cédric Moreau committed
1137
1138
1139
      ],
      "comment": "Paying LoLCat's food."
    },{
Cédric Moreau's avatar
Cédric Moreau committed
1140
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
Cédric Moreau's avatar
Cédric Moreau committed
1141
      "version": 1,
1142
      "currency": "beta_brousouf",
Cédric Moreau's avatar
Cédric Moreau committed
1143
      "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
1144
1145
      "number": 91,
      "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
1146
      "recipient": "A9571447F4B6B477F1037D85C6211FB059C561C7",
1147
1148
1149
      "amounts": [
        "9EE7ABA9EE7A15F57319B6BFC21FA08E821ABEAA-0:100",
        "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-1:110",
1150
      ],
1151
      "comment": "Buying something"
1152
    }
Cédric Moreau's avatar
Cédric Moreau committed
1153
  ]
1154
1155
1156
}
```

1157
#### `tx/recipient/[PGP_FINGERPRINT]`
1158
1159
1160
1161
1162
1163
**Goal**

Merkle URL referencing all the transactions received for this recipient stored by this node.

**Parameters**

1164
1165
Name              | Value                                                            | Method
----------------- | ---------------------------------------------------------------- | ------
1166
1167
1168
1169
1170
1171
1172
`PGP_FINGERPRINT` | PGP fingerprint of the key we want to see received transactions. | URL

**Returns**

Merkle URL result.
```json
{
1173
1174
1175
  "depth": 3,
  "nodesCount": 6,
  "leavesCount": 5,
1176
  "root": "114B6E61CB5BB93D862CA3C1DFA8B99E313E66E9"
1177
1178
1179
1180
1181
1182
}
```

Merkle URL leaf: transaction
```json
{
1183
1184
  "hash": "2E69197FAB029D8669EF85E82457A1587CA0ED9C",
  "value": {
1185
1186
    "transaction":
    {
Cédric Moreau's avatar
Cédric Moreau committed
1187
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1188
1189
      "version": 1,
      "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
1190
1191
1192
1193
1194
1195
      "number": 92,
      "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
      "recipient": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
      "amounts": [
        "70C881D4A26984DDCE795F6F71817C9CF4480E79-92:66",
        "503A586FE6F7819A18A38426A7C2C1D0880F99CB-122:988",
1196
      ],
1197
      "comment": "Paying LoLCat's food."
1198
1199
1200
1201
1202
    }
  }
}
```

1203
#### `tx/refering/[PGP_FINGERPRINT]/[TX_NUMBER]`
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
**Goal**

GET all the transactions refering to source transaction #`[TX_NUMBER]` issued by `[PGP_FINGERPRINT]`.

**Parameters**

Name              | Value                                                         | Method
----------------- | ------------------------------------------------------------- | ------
`PGP_FINGERPRINT` | PGP fingerprint of the key we want to see sent transactions.  | URL
`TX_NUMBER`       | Transaction number of given PGP key                           | URL

**Returns**

A list of transactions pointing to this source transaction.
```json
{
  "transactions": [
    {
Cédric Moreau's avatar
Cédric Moreau committed
1222
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
      "version": 1,
      "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
      "number": 92,
      "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
      "recipient": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
      "amounts": [
        "70C881D4A26984DDCE795F6F71817C9CF4480E79-92:66",
        "503A586FE6F7819A18A38426A7C2C1D0880F99CB-122:988",
      ],
      "comment": "Paying LoLCat's food."
    },{
Cédric Moreau's avatar
Cédric Moreau committed
1234
      "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1235
1236
1237
1238
1239
      "version": 1,
      "currency": "beta_brousouf",
      "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
      "number": 91,
      "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
1240
      "recipient": "A9571447F4B6B477F1037D85C6211FB059C561C7",
1241
1242
1243
1244
      "amounts": [
        "9EE7ABA9EE7A15F57319B6BFC21FA08E821ABEAA-0:100",
        "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-1:110",
      ],
1245
      "comment": "Buying something"
1246
1247
1248
1249
1250
    }
  ]
}
```

1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
#### `coins/list/[PGP_FINGERPRINT]`
**Goal**

GET all the coins owned by `[PGP_FINGERPRINT]`.

**Parameters**

Name              | Value                                                         | Method
----------------- | ------------------------------------------------------------- | ------
`PGP_FINGERPRINT` | PGP fingerprint of the key we want to see sent owned coins.   | URL

**Returns**

A list of coins owned by this key.
```json
{
  "coins": [
    "31A6302161AC8F5938969E85399EB3415C237F93-0-1",
    "31A6302161AC8F5938969E85399EB3415C237F93-0-2",
    "31A6302161AC8F5938969E85399EB3415C237F93-0-3",
    "31A6302161AC8F5938969E85399EB3415C237F93-0-4",
    "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-0-1",
    "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-0-2",
    "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-0-3",
    "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-0-4",
    "D02B0466F3F9B7B0C9C8E926700379AEF0DD1E5B-0-5"
    ...
  ]
}
```

#### `coins/view/[COIN_ID]/owner`
**Goal**

GET a coin owner + justifying transaction if it exists.

**Parameters**

Name              | Value                                                         | Method
----------------- | ------------------------------------------------------------- | ------
`COIN_ID`         | ID of the coin to be checked.                                 | URL

**Returns**

A coin's ownership.
```json
{
1298
  "coinid": "70C881D4A26984DDCE795F6F71817C9CF4480E79-92-66",
1299
1300
  "owner": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
  "transaction": {
Cédric Moreau's avatar
Cédric Moreau committed
1301
    "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
    "version": 1,
    "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
    "number": 92,
    "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
    "recipient": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
    "amounts": [
      "31A6302161AC8F5938969E85399EB3415C237F93-92-25",
      "31A6302161AC8F5938969E85399EB3415C237F93-122-1",
    ],
    "comment": "Paying LoLCat's food."
  }
}
```

#### `coins/view/[COIN_ID]/history`
**Goal**

GET a coin owner + justifying transaction for each state a coin has gone trough.

**Parameters**

Name              | Value                                                         | Method
----------------- | ------------------------------------------------------------- | ------
`COIN_ID`         | ID of the coin to be checked.                                 | URL

**Returns**

A coin's list of ownerships in time.
```json
{
1332
  "history": [{
1333
      "coinid": "70C881D4A26984DDCE795F6F71817C9CF4480E79-92-66",
1334
1335
      "owner": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
      "transaction": {
Cédric Moreau's avatar
Cédric Moreau committed
1336
        "signature": "-----BEGIN PGP SIGNATURE-----\r\n ... -----END PGP SIGNATURE-----\r\n",
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
        "version": 1,
        "sender": "31A6302161AC8F5938969E85399EB3415C237F93",
        "number": 92,
        "previousHash": "BE522363749E62BA1034C7B1358B01C75289DA48",
        "recipient": "86F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8",
        "amounts": [
          "31A6302161AC8F5938969E85399EB3415C237F93-92-25",
          "31A6302161AC8F5938969E85399EB3415C237F93-122-1",
        ],
        "comment": "Paying LoLCat's food."
      }
    },{
    ...
    }
  ]
}
```