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>
76 lines
2.3 KiB
Bash
76 lines
2.3 KiB
Bash
#!/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 "$@"
|