knots-startos/actions/assumeutxo.sh

58 lines
1.9 KiB
Bash

#!/bin/sh
set -e
cat > input.json
URL=$(jq -r '.["location"]' input.json)
rm input.json
mkdir -p /tmp/snap
if [ -e "/tmp/snap/snapshot" ]; then
if [ $(sha256sum /tmp/snap/snapshot | awk '{ print $1 }') = "dc4bb43d58d6a25e91eae93eb052d72e3318bd98ec62a5d0c11817cefbba177b" ] || [ $(sha256sum /tmp/snap/snapshot | awk '{ print $1 }') = "43b3b1ad6e1005ffc0ff49514d0ffcc3e3ce671cc8d02da7fa7bac5405f89de4" ]; then
bitcoin-cli loadtxoutset /tmp/snap/snapshot &
result=" {
\"version\": \"0\",
\"message\": \"Consult the logs to see the progression of the snapshot loading. / DO NOT RESTART UNTIL THE SNAPSHOT IS LOADED.\",
\"value\": null,
\"copyable\": false,
\"qr\": false
}"
else
result=" {
\"version\": \"0\",
\"message\": \"The cached snapshot is not valid, deleting the cache, you can retry.\",
\"value\": null,
\"copyable\": false,
\"qr\": false
} "
rm /tmp/snap/snapshot
fi
else
wget -q $URL -O /tmp/snap/snapshot
if [ $(sha256sum /tmp/snap/snapshot | awk '{ print $1 }') = "dc4bb43d58d6a25e91eae93eb052d72e3318bd98ec62a5d0c11817cefbba177b" ] || [ $(sha256sum /tmp/snap/snapshot | awk '{ print $1 }') = "43b3b1ad6e1005ffc0ff49514d0ffcc3e3ce671cc8d02da7fa7bac5405f89de4" ]; then
bitcoin-cli loadtxoutset /tmp/snap/snapshot &
result=" {
\"version\": \"0\",
\"message\": \"Consult the logs to see the progression of the snapshot loading. / DO NOT RESTART UNTIL THE SNAPSHOT IS LOADED.\",
\"value\": null,
\"copyable\": false,
\"qr\": false
}"
else
result=" {
\"version\": \"0\",
\"message\": \"The download link is not a valid snapshot\",
\"value\": null,
\"copyable\": false,
\"qr\": false
}"
rm /tmp/snap/snapshot
fi
fi
echo $result