From 2f7ceb68ecc05a600f76a7ba5dfdffde9e990723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Haf?= Date: Wed, 26 Mar 2025 13:33:14 +0100 Subject: [PATCH 1/2] add assume UTXO support --- Dockerfile | 1 + actions/assumeutxo.sh | 28 ++++++++++++++++++++++++++++ manifest.yaml | 23 ++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 actions/assumeutxo.sh diff --git a/Dockerfile b/Dockerfile index 9dfe582..59ca264 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,6 +88,7 @@ COPY ./manager/target/${ARCH}-unknown-linux-musl/release/bitcoind-manager \ ./actions/sendcoin.sh \ ./actions/sendall.sh \ ./actions/signmessage.sh \ + /actions/assumeutxo.sh \ ./actions/reindex_chainstate.sh \ ./actions/prioritise-transaction.sh \ ./check-rpc.sh \ diff --git a/actions/assumeutxo.sh b/actions/assumeutxo.sh new file mode 100644 index 0000000..42d8882 --- /dev/null +++ b/actions/assumeutxo.sh @@ -0,0 +1,28 @@ +#!/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 + bitcoin-cli loadtxoutset /tmp/snap/snapshot & +else + wget -q $URL -O /tmp/snap/snapshot + bitcoin-cli loadtxoutset /tmp/snap/snapshot & +fi + +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 +}" + +echo $result diff --git a/manifest.yaml b/manifest.yaml index 52028b6..fbbeba3 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -351,7 +351,28 @@ actions: description: "The message to sign." placeholder: "" nullable: false - + assumeutxo: + name: "Assume UTXO" + description: "Use an UTXO snapshot for instant use of your node." + allowed-statuses: + - running + implementation: + type: docker + image: main + system: false + entrypoint: assumeutxo.sh + args: [] + io-format: json + mounts: + main: /root/.bitcoin + inject: true + input-spec: + location: + type: string + name: "Snapshot URL" + description: "The URL where we download the snapshot" + placeholder: "" + nullable: false migrations: from: "*": From 90d7acaa39111be5a10dbbbbf06091972b28cbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Haf?= Date: Wed, 2 Apr 2025 18:25:25 +0200 Subject: [PATCH 2/2] fix path + add more explicit error and check --- Dockerfile | 2 +- actions/assumeutxo.sh | 49 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 59ca264..c942e2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,7 +88,7 @@ COPY ./manager/target/${ARCH}-unknown-linux-musl/release/bitcoind-manager \ ./actions/sendcoin.sh \ ./actions/sendall.sh \ ./actions/signmessage.sh \ - /actions/assumeutxo.sh \ + ./actions/assumeutxo.sh \ ./actions/reindex_chainstate.sh \ ./actions/prioritise-transaction.sh \ ./check-rpc.sh \ diff --git a/actions/assumeutxo.sh b/actions/assumeutxo.sh index 42d8882..a93bd54 100644 --- a/actions/assumeutxo.sh +++ b/actions/assumeutxo.sh @@ -11,18 +11,47 @@ rm input.json mkdir -p /tmp/snap if [ -e "/tmp/snap/snapshot" ]; then - bitcoin-cli loadtxoutset /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 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 - bitcoin-cli loadtxoutset /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 -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 -}" - echo $result