@@ -37,7 +37,8 @@ This project was originally implemented in
37
37
38
38
## Running the app
39
39
40
- ```
40
+ ### Locally
41
+ ``` sh
41
42
# install dependencies
42
43
npm install
43
44
@@ -51,6 +52,19 @@ npm run build
51
52
npm run start
52
53
```
53
54
55
+ ### In docker
56
+ ``` sh
57
+ docker run -d ghcr.io/rgb-tools/rgb-proxy-server
58
+ ```
59
+
60
+ For data persistence, mount a host path to ` /home/node/.rgb-proxy-server `
61
+ inside the container. The directory needs to be owned by user and group ` 1000 ` .
62
+
63
+ ### Data
64
+ Data is stored in ` $HOME/.rgb-proxy-server ` by default.
65
+
66
+ The default data path can be overridden via the ` APP_DATA ` environment variable.
67
+
54
68
## Example usage
55
69
56
70
The payee generates an RGB invoice and sends it to the payer (not covered
@@ -59,58 +73,65 @@ here). Let's assume the invoice contains the blinded UTXO `blindTest`.
59
73
The payer prepares the transfer, then sends the consignment file and the
60
74
related txid to the proxy server, using the blinded UTXO from the invoice as
61
75
identifier:
62
- ```
76
+ ``` sh
63
77
# let's create a fake consignment file and send it
64
- $ echo "consignment binary data" > consignment.rgb
65
- $ curl -X POST -H 'Content-Type: multipart/form-data' \
78
+ echo " consignment binary data" > consignment.rgb
79
+ curl -X POST -H ' Content-Type: multipart/form-data' \
66
80
-F ' jsonrpc=2.0' -F ' id="1"' -F ' method=consignment.post' \
67
81
-F
' params[recipient_id]=blindTest' -F
' params[txid]=527f2b2ebb81c873f128848d7226ecdb7cb4a4025222c54bfec7c358d51b9207' -F
' [email protected] ' \
68
82
localhost:3000/json-rpc
69
83
70
- {"jsonrpc":"2.0","id":"1","result":true}
84
+ # example output
85
+ # {"jsonrpc":"2.0","id":"1","result":true}
71
86
```
72
87
73
88
The payee requests the consignment for the blinded UTXO:
74
- ```
75
- $ curl -X POST -H 'Content-Type: application/json' \
89
+ ``` sh
90
+ curl -X POST -H ' Content-Type: application/json' \
76
91
-d ' {"jsonrpc": "2.0", "id": "2", "method": "consignment.get", "params": {"recipient_id": "blindTest"} }' \
77
92
localhost:3000/json-rpc
78
93
79
- {"jsonrpc":"2.0","id":"2","result": {"consignment": "Y29uc2lnbm1lbnQgYmluYXJ5IGRhdGEK", "txid": "527f2b2ebb81c873f128848d7226ecdb7cb4a4025222c54bfec7c358d51b9207"}}
94
+ # example output
95
+ # {"jsonrpc":"2.0","id":"2","result": {"consignment": "Y29uc2lnbm1lbnQgYmluYXJ5IGRhdGEK", "txid": "527f2b2ebb81c873f128848d7226ecdb7cb4a4025222c54bfec7c358d51b9207"}}
80
96
81
97
```
82
98
The file is returned as a base64-encoded string:
83
- ```
84
- $ echo 'Y29uc2lnbm1lbnQgYmluYXJ5IGRhdGEK' | base64 -d
85
- consignment binary data
99
+ ``` sh
100
+ echo ' Y29uc2lnbm1lbnQgYmluYXJ5IGRhdGEK' | base64 -d
101
+
102
+ # example output
103
+ # consignment binary data
86
104
```
87
105
88
106
If the consignment is valid, the payee ACKs it:
89
- ```
90
- $ curl -X POST -H 'Content-Type: application/json' \
107
+ ``` sh
108
+ curl -X POST -H ' Content-Type: application/json' \
91
109
-d ' {"jsonrpc": "2.0", "id": "3", "method": "ack.post", "params": {"recipient_id": "blindTest", "ack": true} }' \
92
110
localhost:3000/json-rpc
93
111
94
- {"jsonrpc":"2.0","id":"3","result":true}
112
+ # example output
113
+ # {"jsonrpc":"2.0","id":"3","result":true}
95
114
```
96
115
97
116
If the consignment is invalid, the payee NACKs it:
98
- ```
99
- $ curl -X POST -H 'Content-Type: application/json' \
117
+ ``` sh
118
+ curl -X POST -H ' Content-Type: application/json' \
100
119
-d ' {"jsonrpc": "2.0", "id": "4", "method": "ack.post", "params": {"recipient_id": "blindTest", "ack": false} }' \
101
120
localhost:3000/json-rpc
102
121
103
- {"jsonrpc":"2.0","id":"4","result":true}
122
+ # example output
123
+ # {"jsonrpc":"2.0","id":"4","result":true}
104
124
```
105
125
106
126
The payer requests the ` ack ` value (` null ` if payee has not called ` ack.post `
107
127
yet):
108
- ```
109
- $ curl -X POST -H 'Content-Type: application/json' \
128
+ ``` sh
129
+ curl -X POST -H ' Content-Type: application/json' \
110
130
-d ' {"jsonrpc": "2.0", "id": "5", "method": "ack.get", "params": {"recipient_id": "blindTest"} }' \
111
131
localhost:3000/json-rpc
112
132
113
- {"jsonrpc":"2.0","id":"5","result":true}
133
+ # example output
134
+ # {"jsonrpc":"2.0","id":"5","result":true}
114
135
```
115
136
116
137
In case of approval the transaction can be broadcast, otherwise the two parties
@@ -122,15 +143,17 @@ approval cannot be changed once submitted.
122
143
123
144
## Testing
124
145
125
- ### Jest with supertest
146
+ ``` sh
147
+ # install dependencies
148
+ npm run install
126
149
127
- ```
150
+ # run test suite
128
151
npm run test
129
152
```
130
153
131
154
## Linting
132
155
133
- ```
156
+ ``` sh
134
157
# run linter
135
158
npm run lint
136
159
0 commit comments