mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-18 21:25:06 +01:00
OTS API documentation
This commit is contained in:
113
doc/API.v0.md
113
doc/API.v0.md
@@ -957,3 +957,116 @@ Proxy response:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Stamp a hash on the Bitcoin blockchain using OTS (called by application)
|
||||||
|
|
||||||
|
Will stamp the supplied hash to the Bitcoin blockchain using OTS. Cyphernode will curl the callback when the OTS stamping is complete.
|
||||||
|
|
||||||
|
```http
|
||||||
|
POST http://cyphernode:8888/ots_stamp
|
||||||
|
with body...
|
||||||
|
{"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","callbackUrl":"192.168.111.233:1111/otscallback?id=1234567"}
|
||||||
|
```
|
||||||
|
|
||||||
|
Proxy response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"method": "ots_stamp",
|
||||||
|
"hash": "1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7",
|
||||||
|
"id": "422",
|
||||||
|
"result": "success"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"method": "ots_stamp",
|
||||||
|
"hash": "1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7",
|
||||||
|
"id": "422",
|
||||||
|
"result": "error",
|
||||||
|
"error": "Error message from OTS client."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get the OTS file of the supplied hash
|
||||||
|
|
||||||
|
Returns the binary OTS file of the supplied hash. If stamp is complete, will return a complete OTS file, or an incomplete OTS file otherwise.
|
||||||
|
|
||||||
|
```http
|
||||||
|
GET http://cyphernode:8888/ots_getfile/1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7
|
||||||
|
```
|
||||||
|
|
||||||
|
Proxy response:
|
||||||
|
|
||||||
|
Binary application/octet-stream content type.
|
||||||
|
|
||||||
|
### Verify an OTS file
|
||||||
|
|
||||||
|
Will verify the supplied OTS file, or verify the local OTS file named after the supplied hash suffixed with .ots.
|
||||||
|
|
||||||
|
```http
|
||||||
|
POST http://cyphernode:8888/ots_verify
|
||||||
|
with body...
|
||||||
|
{"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7"}
|
||||||
|
or
|
||||||
|
{"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
||||||
|
```
|
||||||
|
|
||||||
|
Proxy response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"method": "ots_verify",
|
||||||
|
"hash": "1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7",
|
||||||
|
"result": "success",
|
||||||
|
"message": "Message from OTS client."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"method": "ots_verify",
|
||||||
|
"hash": "1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7",
|
||||||
|
"result": "pending",
|
||||||
|
"message": "Message from OTS client."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"method": "ots_verify",
|
||||||
|
"hash": "1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7",
|
||||||
|
"result": "error",
|
||||||
|
"message": "Error message from OTS client."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
ots_info)
|
||||||
|
# POST http://192.168.111.152:8080/ots_info
|
||||||
|
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7"}
|
||||||
|
# BODY {"base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
||||||
|
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
||||||
|
|
||||||
|
### Get info an OTS file
|
||||||
|
|
||||||
|
Will return the base64 string of the detailed information of the supplied OTS file, or of the local OTS file named after the supplied hash suffixed with .ots.
|
||||||
|
|
||||||
|
```http
|
||||||
|
POST http://cyphernode:8888/ots_info
|
||||||
|
with body...
|
||||||
|
{"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7"}
|
||||||
|
or
|
||||||
|
{"base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
||||||
|
or
|
||||||
|
{"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
||||||
|
```
|
||||||
|
|
||||||
|
Proxy response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"method": "ots_info",
|
||||||
|
"result": "success",
|
||||||
|
"message": "Base64 string of the information text"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -1391,6 +1391,80 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
|
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
|
||||||
|
/ots_verify:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "ots"
|
||||||
|
- "optional features"
|
||||||
|
summary: "Verify an OTS file with hash"
|
||||||
|
description: "If base64 of the OTS file is not supplied, look for local OTS file named after the supplied hash suffixed with .ots."
|
||||||
|
operationId: "otsVerify"
|
||||||
|
requestBody:
|
||||||
|
description: "JSON object containing hash and base64otsfile."
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: "object"
|
||||||
|
required:
|
||||||
|
- "hash"
|
||||||
|
properties:
|
||||||
|
hash:
|
||||||
|
$ref: '#/components/schemas/TypeHashString'
|
||||||
|
base64otsfile:
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: "successful operation"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
# TODO: describe response
|
||||||
|
type: "object"
|
||||||
|
'403':
|
||||||
|
$ref: '#/components/schemas/ApiResponseNotAllowed'
|
||||||
|
'503':
|
||||||
|
description: "Resource temporarily unavailable"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
|
||||||
|
/ots_info:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- "ots"
|
||||||
|
- "optional features"
|
||||||
|
summary: "Get information about an OTS file"
|
||||||
|
description: "If base64 of the OTS file is not supplied, look for local OTS file named after the supplied hash suffixed with .ots."
|
||||||
|
operationId: "otsInfo"
|
||||||
|
requestBody:
|
||||||
|
description: "JSON object containing hash and/or base64otsfile."
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: "object"
|
||||||
|
properties:
|
||||||
|
hash:
|
||||||
|
$ref: '#/components/schemas/TypeHashString'
|
||||||
|
base64otsfile:
|
||||||
|
type: "string"
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: "successful operation"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
# TODO: describe response
|
||||||
|
type: "object"
|
||||||
|
'403':
|
||||||
|
$ref: '#/components/schemas/ApiResponseNotAllowed'
|
||||||
|
'503':
|
||||||
|
description: "Resource temporarily unavailable"
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ApiResponseTemporarilyUnavailable'
|
||||||
/ots_getfile/{hash}:
|
/ots_getfile/{hash}:
|
||||||
get:
|
get:
|
||||||
parameters:
|
parameters:
|
||||||
|
|||||||
@@ -252,11 +252,40 @@ serve_ots_verify() {
|
|||||||
trace "Entering serve_ots_verify()..."
|
trace "Entering serve_ots_verify()..."
|
||||||
|
|
||||||
local request=${1}
|
local request=${1}
|
||||||
local hash=$(echo "${request}" | jq ".hash" | tr -d '"')
|
local hash
|
||||||
|
hash=$(echo "${request}" | jq -e ".hash")
|
||||||
|
if [ "$?" -ne "0" ]; then
|
||||||
|
# Hash tag null, so there's no hash provided
|
||||||
|
trace "[serve_ots_verify] hash field missing!"
|
||||||
|
echo "{\"method\":\"ots_verify\",\"result\":\"error\",\"message\":\"hash must be provided\"}"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
hash=$(echo "${hash}" | tr -d '"')
|
||||||
|
fi
|
||||||
trace "[serve_ots_verify] hash=${hash}"
|
trace "[serve_ots_verify] hash=${hash}"
|
||||||
local base64otsfile=$(echo "${request}" | jq ".base64otsfile" | tr -d '"')
|
local base64otsfile
|
||||||
|
base64otsfile=$(echo "${request}" | jq -e ".base64otsfile")
|
||||||
|
if [ "$?" -ne "0" ]; then
|
||||||
|
# base64otsfile tag null, so there's no base64otsfile provided
|
||||||
|
base64otsfile=
|
||||||
|
else
|
||||||
|
base64otsfile=$(echo "${base64otsfile}" | tr -d '"')
|
||||||
|
fi
|
||||||
trace "[serve_ots_verify] base64otsfile=${base64otsfile}"
|
trace "[serve_ots_verify] base64otsfile=${base64otsfile}"
|
||||||
|
|
||||||
|
# If file is provided, we will execute info on it
|
||||||
|
# If file not provided, we will check for hash.ots in our folder and execute info on it
|
||||||
|
if [ -z "${base64otsfile}" ]; then
|
||||||
|
if [ -f otsfiles/${hash}.ots ]; then
|
||||||
|
trace "[serve_ots_verify] Constructing base64otsfile from provided hash, file otsfiles/${hash}.ots"
|
||||||
|
base64otsfile=$(cat otsfiles/${hash}.ots | base64 | tr -d '\n')
|
||||||
|
else
|
||||||
|
trace "[serve_ots_verify] File otsfiles/${hash}.ots does not exists!"
|
||||||
|
echo "{\"method\":\"ots_verify\",\"hash\":\"${hash}\",\"result\":\"error\",\"message\":\"OTS File not found\"}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
local result
|
local result
|
||||||
local message
|
local message
|
||||||
local returncode
|
local returncode
|
||||||
|
|||||||
@@ -399,8 +399,10 @@ main() {
|
|||||||
;;
|
;;
|
||||||
ots_verify)
|
ots_verify)
|
||||||
# POST http://192.168.111.152:8080/ots_verify
|
# POST http://192.168.111.152:8080/ots_verify
|
||||||
|
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7"}
|
||||||
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
|
||||||
|
|
||||||
|
# curl -v -d "{\"hash\":\"a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8\"}" localhost:8888/ots_verify
|
||||||
# curl -v -d "{\"hash\":\"a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8\",\"base64otsfile\":\"$(cat a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8.ots | base64 | tr -d '\n')\"}" localhost:8888/ots_verify
|
# curl -v -d "{\"hash\":\"a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8\",\"base64otsfile\":\"$(cat a6ea81a46fec3d02d40815b8667b388351edecedc1cc9f97aab55b566db7aac8.ots | base64 | tr -d '\n')\"}" localhost:8888/ots_verify
|
||||||
|
|
||||||
response=$(serve_ots_verify "${line}")
|
response=$(serve_ots_verify "${line}")
|
||||||
|
|||||||
Reference in New Issue
Block a user