Skip to content

Commit 0c0977a

Browse files
committed
specify protocol v0.1
0 parents  commit 0c0977a

File tree

1 file changed

+314
-0
lines changed

1 file changed

+314
-0
lines changed

README.md

Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
# RGB HTTP JSON-RPC
2+
3+
In order to operate an RGB transfer it is necessary to exchange special files,
4+
called consignments, that represent the offline data used to move asset rights.
5+
Moreover, with NFTs and collectibles there could also be the need to exchange
6+
media files.
7+
8+
While this can be achieved using the [Storm
9+
protocol](https://github.com/Storm-WG/storm-spec), which is a powerful protocol
10+
for distributed storage, we believe users shouldn't need to rely on a single
11+
file exchange medium, in order for the RGB ecosystem to be as resilient as
12+
possible.
13+
14+
To provide a simple alternative, we defined this protocol. It can be easily
15+
implemented in almost any programming language and can use any storage system.
16+
17+
The protocol uses a [JSON-RPC 2.0] interface over HTTP(s).
18+
In order to be compliant with the protocol, an implementation must support all
19+
the [protocol methods](#protocol-methods).
20+
21+
The protocol is intended to be included as a possible consignment endpoint
22+
type in the [LNP/BP Invoice Library](https://github.com/LNP-BP/invoices).
23+
24+
Protocol version is `0.1`.
25+
26+
27+
## Protocol methods
28+
29+
### server.info
30+
31+
#### request
32+
33+
```json
34+
{ "id": 0, "method": "server.info" }
35+
```
36+
37+
#### response
38+
39+
```json
40+
{ "id": 0, "result": { "protocol_version": "0.1", "version": "0.1.0", "uptime": 42069 } }
41+
```
42+
43+
### consignment.post
44+
45+
#### request
46+
47+
In addition to the parameters, the consignment file needs to be attached under
48+
the `file` name via multipart form.
49+
50+
```json
51+
{ "id": 9, "method": "consignment.post", "params": { "blinded_utxo": "txob1nt9ee42dczeu3s0447txykxnqwq2w98ps2c4k8vd9fry903rud7q2wymt7" } }
52+
```
53+
54+
Params:
55+
- `blinded_utxo`: the blinded UTXO for which we want to upload a consignment file
56+
57+
#### response
58+
59+
On first successful upload:
60+
```json
61+
{ "id": 9, "result": true }
62+
```
63+
64+
On successive successful uploads (of the same consignment file):
65+
```json
66+
{ "id": 9, "result": false }
67+
```
68+
69+
Errors:
70+
- [`-101`](#change-uploaded-file--101)
71+
- [`-202`](#blinded-utxo--202)
72+
- [`-302`](#blinded-utxo--302)
73+
- [`-303`](#file--303)
74+
75+
### consignment.get
76+
77+
#### request
78+
79+
```json
80+
{ "id": 3, "method": "consignment.get", "params": { "blinded_utxo": "txob1nt9ee42dczeu3s0447txykxnqwq2w98ps2c4k8vd9fry903rud7q2wymt7" } }
81+
```
82+
83+
Params:
84+
- `blinded_utxo`: the blinded UTXO for which we want to get a consignment file
85+
86+
#### response
87+
88+
When a consignment is available, it is returned in base64-encoded form:
89+
```json
90+
{ "id": 3, "result": "0f001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000" }
91+
```
92+
93+
Errors:
94+
- [`-202`](#blinded-utxo--202)
95+
- [`-302`](#blinded-utxo--302)
96+
- [`-400`](#consignment-file--400)
97+
98+
### media.post
99+
100+
#### request
101+
102+
In addition to the parameters, the media file needs to be attached under
103+
the `file` name via multipart form.
104+
105+
```json
106+
{ "id": 8, "method": "media.post", "params": { "attachment_id": "94667ec87b3c3280b712edba44c7bddb5c23c988dbe3fd40c1079eb913f63bfc" } }
107+
```
108+
109+
Params:
110+
- `attachment_id`: the attachment ID for which we want to upload a media file
111+
112+
#### response
113+
114+
```json
115+
{ "id": 8, "result": null }
116+
```
117+
118+
Errors:
119+
- [`-101`](#change-uploaded-file--101)
120+
- [`-201`](#attachment-id--201)
121+
- [`-301`](#attachment-id--301)
122+
- [`-303`](#file--303)
123+
124+
### media.get
125+
126+
#### request
127+
128+
```json
129+
{ "id": 4, "method": "media.get", "params": { "attachment_id": "94667ec87b3c3280b712edba44c7bddb5c23c988dbe3fd40c1079eb913f63bfc" } }
130+
```
131+
132+
Params:
133+
- `attachment_id`: the attachment ID for which we want to get a media file
134+
135+
#### response
136+
137+
When a media is available, it is returned in base64-encoded form:
138+
```json
139+
{ "id": 4, "result": "0b001dr104fjff7fff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000" }
140+
```
141+
142+
Errors:
143+
- [`-201`](#attachment-id--201)
144+
- [`-301`](#attachment-id--301)
145+
- [`-401`](#media-file--401)
146+
147+
### ack.post
148+
149+
#### request
150+
151+
To accept a consignment:
152+
153+
```json
154+
{ "id": 7, "method": "ack.post", "params": {
155+
"blinded_utxo": "txob1nt9ee42dczeu3s0447txykxnqwq2w98ps2c4k8vd9fry903rud7q2wymt7",
156+
"ack": true
157+
} }
158+
```
159+
160+
To reject a consignment:
161+
162+
```json
163+
{ "id": 7, "method": "ack.post", "params": {
164+
"blinded_utxo": "txob1nt9ee42dczeu3s0447txykxnqwq2w98ps2c4k8vd9fry903rud7q2wymt7",
165+
"ack": false
166+
} }
167+
```
168+
169+
Params:
170+
- `blinded_utxo`: the blinded UTXO for which we want to ACK or NACK its associated consignment file
171+
- `ack`: whether the consignment is accepted (`true`) or rejected (`false`)
172+
173+
#### response
174+
175+
```json
176+
{ "id": 7, "result": null }
177+
```
178+
179+
Errors:
180+
- [`-100`](#ack-again--100)
181+
- [`-200`](#ack--200)
182+
- [`-202`](#blinded-utxo--202)
183+
- [`-300`](#ack--300)
184+
- [`-302`](#blinded-utxo--302)
185+
- [`-400`](#consignment-file--400)
186+
187+
### ack.get
188+
189+
#### request
190+
191+
```json
192+
{ "id": 9, "method": "ack.get", "params": { "blinded_utxo": "txob1nt9ee42dczeu3s0447txykxnqwq2w98ps2c4k8vd9fry903rud7q2wymt7" } }
193+
```
194+
195+
Params:
196+
- `blinded_utxo`: the blinded UTXO for which we want to know if the associated
197+
consignment file has been ACKed or NACKed
198+
199+
#### response
200+
201+
When counterparty has positively acknowledged (ACK) the consignment:
202+
203+
```json
204+
{ "id": 9, "result": true }
205+
```
206+
207+
When counterparty has negatively acknowledged (NACK) the consignment:
208+
209+
```json
210+
{ "id": 9, "result": false }
211+
```
212+
213+
When counterparty has not (yet) acknowledged the consignment:
214+
215+
```json
216+
{ "id": 9, "result": null }
217+
```
218+
219+
Errors:
220+
- [`-202`](#blinded-utxo--202)
221+
- [`-302`](#blinded-utxo--302)
222+
- [`-400`](#consignment-file--400)
223+
224+
225+
## Protocol errors
226+
227+
Errors follow [JSON-RPC 2.0] rules and their codes are divided in 4 categories:
228+
[Cannot](#cannot), [Invalid](#invalid), [Missing](#missing) and
229+
[Not found](#not-found).
230+
231+
In the error examples `<req_params>` (`error.data`) will contain the client
232+
request body.
233+
234+
### Cannot
235+
236+
#### ACK again (-100)
237+
238+
```json
239+
{ "id": 2, "error": "{ \"code\": -100, \"message\": \"Cannot ACK again\", \"data\": <req_params> }" }
240+
```
241+
242+
#### Change uploaded file (-101)
243+
244+
```json
245+
{ "id": 1, "error": "{ \"code\": -101, \"message\": \"Cannot change uploaded file\", \"data\": <req_params> }" }
246+
```
247+
248+
### Invalid
249+
250+
#### Ack (-200)
251+
252+
```json
253+
{ "id": 1, "error": "{ \"code\": -200, \"message\": \"Invalid ACK\", \"data\": <req_params> }" }
254+
```
255+
256+
#### Attachment ID (-201)
257+
258+
```json
259+
{ "id": 1, "error": "{ \"code\": -201, \"message\": \"Invalid attachment ID\", \"data\": <req_params> }" }
260+
```
261+
262+
#### Blinded UTXO (-202)
263+
264+
```json
265+
{ "id": 1, "error": "{ \"code\": -202, \"message\": \"Invalid blinded UTXO\", \"data\": <req_params> }" }
266+
```
267+
268+
### Missing
269+
270+
#### Ack (-300)
271+
272+
```json
273+
{ "id": 1, "error": "{ \"code\": -300, \"message\": \"Missing ACK\", \"data\": <req_params> }" }
274+
```
275+
276+
#### Attachment ID (-301)
277+
278+
```json
279+
{ "id": 1, "error": "{ \"code\": -301, \"message\": \"Missing attachment ID\", \"data\": <req_params> }" }
280+
```
281+
282+
#### Blinded UTXO (-302)
283+
284+
```json
285+
{ "id": 1, "error": "{ \"code\": -302, \"message\": \"Missing blinded UTXO\", \"data\": <req_params> }" }
286+
```
287+
288+
#### File (-303)
289+
290+
```json
291+
{ "id": 1, "error": "{ \"code\": -303, \"message\": \"Missing file\", \"data\": <req_params> }" }
292+
```
293+
294+
### Not found
295+
296+
#### Consignment file (-400)
297+
298+
```json
299+
{ "id": 1, "error": "{ \"code\": -400, \"message\": \"Consignment file not found\", \"data\": <req_params> }" }
300+
```
301+
302+
#### Media file (-401)
303+
304+
```json
305+
{ "id": 1, "error": "{ \"code\": -401, \"message\": \"Media file not found\", \"data\": <req_params> }" }
306+
```
307+
308+
309+
## Known implementations
310+
311+
- [rgb-proxy-server](https://github.com/grunch/rgb-proxy-server)
312+
313+
314+
[JSON-RPC 2.0]: https://www.jsonrpc.org/specification

0 commit comments

Comments
 (0)