Initial commit: VaultMesh Skills collection
Collection of operational skills for VaultMesh infrastructure including: - backup-sovereign: Backup and recovery operations - btc-anchor: Bitcoin anchoring - cloudflare-tunnel-manager: Cloudflare tunnel management - container-registry: Container registry operations - disaster-recovery: Disaster recovery procedures - dns-sovereign: DNS management - eth-anchor: Ethereum anchoring - gitea-bootstrap: Gitea setup and configuration - hetzner-bootstrap: Hetzner server provisioning - merkle-forest: Merkle tree operations - node-hardening: Node security hardening - operator-bootstrap: Operator initialization - proof-verifier: Cryptographic proof verification - rfc3161-anchor: RFC3161 timestamping - secrets-vault: Secrets management 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
66
btc-anchor/SKILL.md
Normal file
66
btc-anchor/SKILL.md
Normal file
@@ -0,0 +1,66 @@
|
||||
---
|
||||
name: btc-anchor
|
||||
description: >
|
||||
Anchor a Merkle root (root_hex) to Bitcoin testnet or mainnet using OP_RETURN via bitcoin-cli.
|
||||
Emits PROOF.json + tx metadata with plan/apply/rollback and verification.
|
||||
Consumes merkle-forest ROOT.txt (or explicit ROOT_HEX). Triggers: 'btc anchor',
|
||||
'anchor root on bitcoin', 'op_return', 'taproot proof', 'bitcoin-cli'.
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
# BTC Anchor (OP_RETURN via bitcoin-cli)
|
||||
|
||||
This skill anchors a **root_hex** on Bitcoin by creating a transaction
|
||||
with an **OP_RETURN** output containing the root bytes.
|
||||
|
||||
## Requirements
|
||||
- `bitcoin-cli` connected to a synced node (mainnet/testnet/signet)
|
||||
- Wallet loaded + funded (UTXOs)
|
||||
- Network parameters set (v1 uses `bitcoin-cli -testnet` / `-signet` flags)
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
cd ~/.claude/skills/btc-anchor
|
||||
|
||||
export ROOT_FILE="$HOME/.claude/skills/merkle-forest/outputs/runs/<run>/ROOT.txt"
|
||||
export BTC_NETWORK="testnet" # mainnet|testnet|signet
|
||||
export BTC_FEE_RATE="5" # sat/vB (rough)
|
||||
export OP_RETURN_PREFIX="VM" # 2-byte ascii prefix
|
||||
|
||||
./scripts/00_preflight.sh
|
||||
./scripts/10_plan.sh
|
||||
|
||||
export DRY_RUN=0
|
||||
./scripts/11_apply.sh
|
||||
|
||||
./scripts/90_verify.sh
|
||||
./scripts/99_report.sh
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
| Parameter | Required | Default | Description |
|
||||
|---|---:|---|---|
|
||||
| ROOT_FILE | No | (empty) | ROOT.txt path |
|
||||
| ROOT_HEX | No | (empty) | Explicit root hex (overrides ROOT_FILE) |
|
||||
| BTC_NETWORK | No | testnet | mainnet/testnet/signet |
|
||||
| BTC_FEE_RATE | No | 5 | sat/vB (passed to walletcreatefundedpsbt) |
|
||||
| OP_RETURN_PREFIX | No | VM | ASCII prefix (helps identify payloads) |
|
||||
| DRY_RUN | No | 1 | Apply refuses unless DRY_RUN=0 |
|
||||
| REQUIRE_CONFIRM | No | 1 | Require confirmation phrase |
|
||||
| CONFIRM_PHRASE | No | I UNDERSTAND THIS WILL BROADCAST A BITCOIN TX | Safety phrase |
|
||||
|
||||
## Outputs
|
||||
`outputs/runs/<label>_<timestamp>/`
|
||||
- root_hex.txt
|
||||
- op_return_hex.txt
|
||||
- txid.txt
|
||||
- rawtx.hex
|
||||
- PROOF.json
|
||||
- status_matrix.json
|
||||
- audit_report.md
|
||||
|
||||
## Notes
|
||||
- Payload format: `<prefix-as-hex><root-bytes>` truncated to fit OP_RETURN.
|
||||
- v1 uses OP_RETURN and the node wallet RPCs: create raw tx → fund → sign → send.
|
||||
40
btc-anchor/config.json
Normal file
40
btc-anchor/config.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "btc-anchor",
|
||||
"version": "1.0.0",
|
||||
"defaults": {
|
||||
"BTC_NETWORK": "testnet",
|
||||
"BTC_FEE_RATE": "5",
|
||||
"OP_RETURN_PREFIX": "VM",
|
||||
"LABEL": "btc-anchor",
|
||||
"DRY_RUN": "1",
|
||||
"REQUIRE_CONFIRM": "1",
|
||||
"CONFIRM_PHRASE": "I UNDERSTAND THIS WILL BROADCAST A BITCOIN TX"
|
||||
},
|
||||
"phases": {
|
||||
"preflight": [
|
||||
"00_preflight.sh"
|
||||
],
|
||||
"btc": {
|
||||
"plan": [
|
||||
"10_plan.sh"
|
||||
],
|
||||
"apply": [
|
||||
"11_apply.sh"
|
||||
],
|
||||
"rollback": [
|
||||
"rollback/undo_last_run.sh"
|
||||
]
|
||||
},
|
||||
"verify": [
|
||||
"90_verify.sh"
|
||||
],
|
||||
"report": [
|
||||
"99_report.sh"
|
||||
]
|
||||
},
|
||||
"eu_compliance": {
|
||||
"data_residency": "EU",
|
||||
"jurisdiction": "Ireland",
|
||||
"gdpr_applicable": true
|
||||
}
|
||||
}
|
||||
14
btc-anchor/references/btc_anchor_notes.md
Normal file
14
btc-anchor/references/btc_anchor_notes.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# BTC Anchor Notes
|
||||
|
||||
## Method
|
||||
v1 anchors via OP_RETURN using the node wallet RPC flow:
|
||||
- walletcreatefundedpsbt
|
||||
- walletprocesspsbt
|
||||
- finalizepsbt
|
||||
- sendrawtransaction
|
||||
|
||||
## Payload
|
||||
ASCII prefix (default "VM") + root bytes, truncated to standard OP_RETURN limits.
|
||||
|
||||
## Ops
|
||||
Prefer testnet/signet during development, then mainnet with tight fee control.
|
||||
15
btc-anchor/scripts/00_preflight.sh
Normal file
15
btc-anchor/scripts/00_preflight.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
source "$SCRIPT_DIR/_common.sh"
|
||||
|
||||
main() {
|
||||
need bitcoin-cli
|
||||
need xxd
|
||||
need jq
|
||||
# connectivity
|
||||
flag="$(net_flag)"
|
||||
bitcoin-cli $flag getblockchaininfo >/dev/null 2>&1 || die "bitcoin-cli cannot reach node (check RPC creds, network)."
|
||||
log_info "Preflight OK. Network=$BTC_NETWORK"
|
||||
}
|
||||
main "$@"
|
||||
26
btc-anchor/scripts/10_plan.sh
Normal file
26
btc-anchor/scripts/10_plan.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
source "$SCRIPT_DIR/_common.sh"
|
||||
|
||||
: "${BTC_NETWORK:=testnet}"
|
||||
: "${BTC_FEE_RATE:=5}"
|
||||
: "${OP_RETURN_PREFIX:=VM}"
|
||||
|
||||
main() {
|
||||
root_hex="$(read_root_hex)"
|
||||
prefix_hex="$(ascii_to_hex "$OP_RETURN_PREFIX")"
|
||||
payload="${prefix_hex}${root_hex}"
|
||||
# OP_RETURN payload max is 80 bytes standard; we keep under 80 bytes (160 hex chars)
|
||||
payload="${payload:0:160}"
|
||||
|
||||
echo "[PLAN] $(date -Iseconds) BTC Anchor"
|
||||
echo "[PLAN] Network: $BTC_NETWORK"
|
||||
echo "[PLAN] Fee rate (sat/vB): $BTC_FEE_RATE"
|
||||
echo "[PLAN] Prefix: $OP_RETURN_PREFIX (hex: $prefix_hex)"
|
||||
echo "[PLAN] Root hex (raw): $root_hex"
|
||||
echo "[PLAN] OP_RETURN payload hex: $payload"
|
||||
echo "[PLAN] Will create OP_RETURN tx via wallet RPCs: createrawtransaction -> walletcreatefundedpsbt -> walletprocesspsbt -> finalizepsbt -> sendrawtransaction"
|
||||
echo "[PLAN] Next: export DRY_RUN=0 && ./scripts/11_apply.sh"
|
||||
}
|
||||
main "$@"
|
||||
75
btc-anchor/scripts/11_apply.sh
Normal file
75
btc-anchor/scripts/11_apply.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
SKILL_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
source "$SCRIPT_DIR/_common.sh"
|
||||
|
||||
: "${BTC_NETWORK:=testnet}"
|
||||
: "${BTC_FEE_RATE:=5}"
|
||||
: "${OP_RETURN_PREFIX:=VM}"
|
||||
: "${LABEL:=btc-anchor}"
|
||||
|
||||
main() {
|
||||
confirm_gate
|
||||
flag="$(net_flag)"
|
||||
mkdir -p "$SKILL_ROOT/outputs/runs"
|
||||
ts="$(date -Iseconds | tr ':' '-')"
|
||||
run_dir="$SKILL_ROOT/outputs/runs/${LABEL}_${ts}"
|
||||
mkdir -p "$run_dir"
|
||||
|
||||
root_hex="$(read_root_hex)"
|
||||
echo "$root_hex" > "$run_dir/root_hex.txt"
|
||||
prefix_hex="$(ascii_to_hex "$OP_RETURN_PREFIX")"
|
||||
payload="${prefix_hex}${root_hex}"
|
||||
payload="${payload:0:160}"
|
||||
echo "$payload" > "$run_dir/op_return_hex.txt"
|
||||
|
||||
# 1) create raw tx with single OP_RETURN output (no inputs yet)
|
||||
raw="$(bitcoin-cli $flag createrawtransaction "[]" "{\"data\":\"$payload\"}")"
|
||||
# 2) fund via PSBT
|
||||
funded="$(bitcoin-cli $flag walletcreatefundedpsbt "[]" "{\"data\":\"$payload\"}" 0 "{\"fee_rate\":$BTC_FEE_RATE}")"
|
||||
psbt="$(echo "$funded" | jq -r '.psbt')"
|
||||
[[ -n "$psbt" && "$psbt" != "null" ]] || die "walletcreatefundedpsbt did not return psbt"
|
||||
|
||||
# 3) process (sign) psbt
|
||||
processed="$(bitcoin-cli $flag walletprocesspsbt "$psbt")"
|
||||
psbt2="$(echo "$processed" | jq -r '.psbt')"
|
||||
|
||||
# 4) finalize
|
||||
finalized="$(bitcoin-cli $flag finalizepsbt "$psbt2")"
|
||||
hex="$(echo "$finalized" | jq -r '.hex')"
|
||||
complete="$(echo "$finalized" | jq -r '.complete')"
|
||||
[[ "$complete" == "true" ]] || die "finalizepsbt not complete"
|
||||
echo "$hex" > "$run_dir/rawtx.hex"
|
||||
|
||||
# 5) send
|
||||
txid="$(bitcoin-cli $flag sendrawtransaction "$hex")"
|
||||
[[ -n "$txid" ]] || die "Failed to send tx"
|
||||
echo "$txid" > "$run_dir/txid.txt"
|
||||
|
||||
# proof
|
||||
cat > "$run_dir/PROOF.json" <<EOF
|
||||
{
|
||||
"skill": "btc-anchor",
|
||||
"version": "1.0.0",
|
||||
"timestamp": "$(date -Iseconds)",
|
||||
"network": "$BTC_NETWORK",
|
||||
"fee_rate_sat_vb": "$BTC_FEE_RATE",
|
||||
"op_return_prefix": "$(json_escape "$OP_RETURN_PREFIX")",
|
||||
"op_return_hex": "$(json_escape "$payload")",
|
||||
"root_hex": "$(json_escape "$root_hex")",
|
||||
"txid": "$(json_escape "$txid")",
|
||||
"artifacts": {
|
||||
"root_hex_file": "root_hex.txt",
|
||||
"op_return_hex_file": "op_return_hex.txt",
|
||||
"rawtx": "rawtx.hex",
|
||||
"txid_file": "txid.txt"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "$run_dir" > "$SKILL_ROOT/outputs/last_run_dir.txt"
|
||||
log_info "Anchored on BTC ($BTC_NETWORK). txid=$txid"
|
||||
log_info "Run dir: $run_dir"
|
||||
}
|
||||
main "$@"
|
||||
48
btc-anchor/scripts/90_verify.sh
Normal file
48
btc-anchor/scripts/90_verify.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
SKILL_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
source "$SCRIPT_DIR/_common.sh"
|
||||
|
||||
: "${BTC_NETWORK:=testnet}"
|
||||
|
||||
main() {
|
||||
[[ -f "$SKILL_ROOT/outputs/last_run_dir.txt" ]] || die "No last run."
|
||||
run_dir="$(cat "$SKILL_ROOT/outputs/last_run_dir.txt")"
|
||||
status="$run_dir/status_matrix.json"
|
||||
flag="$(net_flag)"
|
||||
|
||||
ok_proof=false; ok_txid=false; ok_seen=false
|
||||
[[ -f "$run_dir/PROOF.json" ]] && ok_proof=true
|
||||
if [[ -f "$run_dir/txid.txt" ]]; then
|
||||
txid="$(cat "$run_dir/txid.txt")"
|
||||
[[ -n "$txid" ]] && ok_txid=true
|
||||
if bitcoin-cli $flag getrawtransaction "$txid" >/dev/null 2>&1; then
|
||||
ok_seen=true
|
||||
fi
|
||||
fi
|
||||
|
||||
blockers="[]"
|
||||
if [[ "$ok_txid" != "true" ]]; then blockers='["missing_txid"]'
|
||||
elif [[ "$ok_seen" != "true" ]]; then blockers='["tx_not_found_yet_mempool_or_index"]'
|
||||
fi
|
||||
|
||||
cat > "$status" <<EOF
|
||||
{
|
||||
"skill": "btc-anchor",
|
||||
"timestamp": "$(date -Iseconds)",
|
||||
"run_dir": "$(json_escape "$run_dir")",
|
||||
"checks": [
|
||||
{"name":"proof_present", "ok": $ok_proof},
|
||||
{"name":"txid_present", "ok": $ok_txid},
|
||||
{"name":"tx_seen_by_node", "ok": $ok_seen}
|
||||
],
|
||||
"blockers": $blockers,
|
||||
"warnings": [],
|
||||
"next_steps": ["proof-verifier"]
|
||||
}
|
||||
EOF
|
||||
log_info "Wrote $status"
|
||||
cat "$status"
|
||||
}
|
||||
main "$@"
|
||||
36
btc-anchor/scripts/99_report.sh
Normal file
36
btc-anchor/scripts/99_report.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
SKILL_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
source "$SCRIPT_DIR/_common.sh"
|
||||
|
||||
main() {
|
||||
[[ -f "$SKILL_ROOT/outputs/last_run_dir.txt" ]] || die "No last run."
|
||||
run_dir="$(cat "$SKILL_ROOT/outputs/last_run_dir.txt")"
|
||||
report="$run_dir/audit_report.md"
|
||||
status="$run_dir/status_matrix.json"
|
||||
txid="$(cat "$run_dir/txid.txt" 2>/dev/null || true)"
|
||||
root_hex="$(cat "$run_dir/root_hex.txt" 2>/dev/null || true)"
|
||||
|
||||
cat > "$report" <<EOF
|
||||
# BTC Anchor Audit Report
|
||||
|
||||
**Generated:** $(date -Iseconds)
|
||||
**Run Dir:** \`$run_dir\`
|
||||
**TXID:** \`$txid\`
|
||||
**Root Hex:** \`$root_hex\`
|
||||
**Skill Version:** 1.0.0
|
||||
|
||||
## Status Matrix
|
||||
|
||||
$(if [[ -f "$status" ]]; then echo '```json'; cat "$status"; echo '```'; else echo "_Missing status_matrix.json_"; fi)
|
||||
|
||||
## EU Compliance
|
||||
|
||||
EU (Ireland - Dublin), Irish jurisdiction. Anchors are public chain data.
|
||||
EOF
|
||||
|
||||
log_info "Wrote $report"
|
||||
cat "$report"
|
||||
}
|
||||
main "$@"
|
||||
55
btc-anchor/scripts/_common.sh
Normal file
55
btc-anchor/scripts/_common.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
log_info(){ echo "[INFO] $(date -Iseconds) $*"; }
|
||||
log_warn(){ echo "[WARN] $(date -Iseconds) $*" >&2; }
|
||||
log_error(){ echo "[ERROR] $(date -Iseconds) $*" >&2; }
|
||||
die(){ log_error "$*"; exit 1; }
|
||||
need(){ command -v "$1" >/dev/null 2>&1 || die "Missing required tool: $1"; }
|
||||
|
||||
confirm_gate() {
|
||||
: "${DRY_RUN:=1}"
|
||||
: "${REQUIRE_CONFIRM:=1}"
|
||||
: "${CONFIRM_PHRASE:=I UNDERSTAND THIS WILL BROADCAST A BITCOIN TX}"
|
||||
[[ "$DRY_RUN" == "0" ]] || die "DRY_RUN=$DRY_RUN (set DRY_RUN=0)."
|
||||
if [[ "$REQUIRE_CONFIRM" == "1" ]]; then
|
||||
echo "Type to confirm:"
|
||||
echo " $CONFIRM_PHRASE"
|
||||
read -r input
|
||||
[[ "$input" == "$CONFIRM_PHRASE" ]] || die "Confirmation phrase mismatch."
|
||||
fi
|
||||
}
|
||||
|
||||
json_escape() {
|
||||
local s="$1"
|
||||
s="${s//\\/\\\\}"; s="${s//\"/\\\"}"; s="${s//$'\n'/\\n}"
|
||||
printf "%s" "$s"
|
||||
}
|
||||
|
||||
read_root_hex() {
|
||||
: "${ROOT_HEX:=}"
|
||||
: "${ROOT_FILE:=}"
|
||||
if [[ -n "$ROOT_HEX" ]]; then
|
||||
echo "${ROOT_HEX#0x}"
|
||||
return 0
|
||||
fi
|
||||
[[ -n "$ROOT_FILE" ]] || die "Set ROOT_HEX or ROOT_FILE."
|
||||
[[ -f "$ROOT_FILE" ]] || die "ROOT_FILE not found: $ROOT_FILE"
|
||||
rh="$(grep '^root_hex=' "$ROOT_FILE" | head -n1 | cut -d= -f2)"
|
||||
[[ -n "$rh" ]] || die "Could not parse root_hex from ROOT_FILE."
|
||||
echo "${rh#0x}"
|
||||
}
|
||||
|
||||
net_flag() {
|
||||
: "${BTC_NETWORK:=testnet}"
|
||||
case "$BTC_NETWORK" in
|
||||
mainnet) echo "" ;;
|
||||
testnet) echo "-testnet" ;;
|
||||
signet) echo "-signet" ;;
|
||||
*) die "BTC_NETWORK must be mainnet|testnet|signet" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
ascii_to_hex() {
|
||||
# portable: use xxd
|
||||
echo -n "$1" | xxd -p -c 256 | tr -d '\n'
|
||||
}
|
||||
19
btc-anchor/scripts/rollback/undo_last_run.sh
Normal file
19
btc-anchor/scripts/rollback/undo_last_run.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
SKILL_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
|
||||
source "$SKILL_ROOT/scripts/_common.sh"
|
||||
|
||||
main() {
|
||||
confirm_gate
|
||||
if [[ ! -f "$SKILL_ROOT/outputs/last_run_dir.txt" ]]; then
|
||||
log_warn "No last run; nothing to undo."
|
||||
exit 0
|
||||
fi
|
||||
run_dir="$(cat "$SKILL_ROOT/outputs/last_run_dir.txt")"
|
||||
log_warn "Removing last run artifacts (cannot undo broadcast tx): $run_dir"
|
||||
rm -rf "$run_dir" || true
|
||||
rm -f "$SKILL_ROOT/outputs/last_run_dir.txt" || true
|
||||
log_info "Local rollback complete (chain tx remains)."
|
||||
}
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user