Small fixes to make it work, using fixed javascript-opentimestamps

This commit is contained in:
kexkey
2019-08-14 15:44:16 -04:00
committed by kexkey
parent 8fc7d0f708
commit 8168bed0d5
4 changed files with 26 additions and 6 deletions

View File

@@ -4,7 +4,9 @@ RUN apk add --update --no-cache \
git \
jq \
su-exec \
&& yarn global add javascript-opentimestamps
&& git clone --branch bitcoinconf_props https://github.com/Kexkey/javascript-opentimestamps.git \
&& cd javascript-opentimestamps \
&& npm install -g
WORKDIR /script

View File

@@ -91,6 +91,7 @@ verify() {
local result
local returncode
local message
local data
# Let's create the OTS file locally from the base64
@@ -147,13 +148,25 @@ verify() {
trace_rc ${returncode}
if [ "${returncode}" -eq "0" ]; then
# String found
data="${data}success\"}"
# "Success!" found
data="${data}success"
else
# String not found
data="${data}error\",\"error\":\"${result}\"}"
# "Success!" not found
echo "${result}" | grep "Pending" > /dev/null
returncode=$?
trace_rc ${returncode}
if [ "${returncode}" -eq "0" ]; then
# "Pending" found
data="${data}pending"
else
# "Pending" not found
data="${data}error"
fi
fi
data="${data}\",\"message\":\"${result}\"}"
trace "[verify] data=${data}"
echo "${data}"

View File

@@ -242,6 +242,7 @@ serve_ots_verify() {
trace "[serve_ots_verify] base64otsfile=${base64otsfile}"
local result
local message
local returncode
trace "[serve_ots_verify] request_ots_verify \"${hash}\" \"${base64otsfile}\""
@@ -249,7 +250,9 @@ serve_ots_verify() {
returncode=$?
trace_rc ${returncode}
result="{\"method\":\"ots_verify\",\"hash\":\"${hash}\",\"result\":\"${result}\"}"
message=$(echo ${result} | jq ".message")
result=$(echo ${result} | jq ".result")
result="{\"method\":\"ots_verify\",\"hash\":\"${hash}\",\"result\":${result},\"message\":${message}}"
trace "[serve_ots_verify] result=${result}"

View File

@@ -399,6 +399,8 @@ main() {
# POST http://192.168.111.152:8080/ots_verify
# BODY {"hash":"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7","base64otsfile":"AE9wZW5UaW1lc3RhbXBzAABQcm9vZ...gABYiWDXPXGQEDxNch"}
# curl -v -d "{\"hash\":\"1ddfb769eb0b8876bc570e25580e6a53afcf973362ee1ee4b54a807da2e5eed7\",\"base64otsfile\":\"$(cat 1dd.ots.base64)\"}" localhost:8888/ots_verify
response=$(serve_ots_verify "${line}")
response_to_client "${response}" ${?}
break