Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
# Build the crates as part of `nix flake check` for convenience
inherit minipool;

# Run tests on the workspace source
minipool-test = craneLib.cargoTest (commonArgs // {
inherit cargoArtifacts;
});

# Run clippy (and deny all warnings) on the workspace source,
# again, reusing the dependency artifacts from above.
minipool-clippy = craneLib.cargoClippy (commonArgs // {
Expand Down Expand Up @@ -117,12 +122,13 @@
# Build dependencies
pkg-config
openssl

# Development tools
cargo-watch
cargo-audit
cargo-outdated
cargo-edit
just
];

# Set up rust-analyzer for the project
Expand Down
54 changes: 54 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Minipool development commands

# List available commands (default)
default:
@just --list

# Run minipool locally using Bitcoin Core cookie auth
run *args:
./scripts/run-local.sh {{args}}

# Run endpoint tests against minipool
test url:
./scripts/test-endpoints.sh {{url}}

# Build the project
build:
cargo build

# Build release
build-release:
cargo build --release

# Run clippy
lint:
cargo clippy

# Format code
fmt:
cargo fmt

# Check formatting
fmt-check:
cargo fmt --check

# Run all checks (build, lint, format)
check: build lint fmt-check

# Start minipool and run tests
run-and-test:
#!/usr/bin/env bash
cleanup() {
echo "Stopping minipool..."
kill $pid 2>/dev/null || true
wait $pid 2>/dev/null || true
}
trap cleanup EXIT
echo "Starting minipool..."
./scripts/run-local.sh &
pid=$!
sleep 5
echo "Running tests..."
./scripts/test-endpoints.sh
test_result=$?
exit $test_result
121 changes: 121 additions & 0 deletions scripts/run-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env bash
# Run minipool locally using Bitcoin Core cookie authentication
# Usage: ./run-local.sh [options]
#
# Options:
# --bind-addr ADDR Address to bind to (default: 127.0.0.1:9090)
# --bitcoin-dir DIR Bitcoin data directory (default: ~/.bitcoin)
# --testnet Use testnet
# --signet Use signet
# --regtest Use regtest
# --release Run release build
# --build Build before running
# -h, --help Show this help

set -e

BIND_ADDR="127.0.0.1:9090"
PROMETHEUS_ADDR="[::]:9091"
BITCOIN_DIR="$HOME/.bitcoin"
NETWORK=""
RELEASE=""
BUILD=""
RPC_PORT=8332

show_help() {
head -14 "$0" | tail -13 | sed 's/^# //' | sed 's/^#//'
exit 0
}

while [[ $# -gt 0 ]]; do
case $1 in
--bind-addr)
BIND_ADDR="$2"
shift 2
;;
--bitcoin-dir)
BITCOIN_DIR="$2"
shift 2
;;
--testnet)
NETWORK="testnet3"
RPC_PORT=18332
shift
;;
--signet)
NETWORK="signet"
RPC_PORT=38332
shift
;;
--regtest)
NETWORK="regtest"
RPC_PORT=18443
shift
;;
--release)
RELEASE="--release"
shift
;;
--build)
BUILD="1"
shift
;;
-h|--help)
show_help
;;
*)
echo "Unknown option: $1"
show_help
;;
esac
done

# Determine cookie file location
if [ -n "$NETWORK" ]; then
COOKIE_FILE="$BITCOIN_DIR/$NETWORK/.cookie"
else
COOKIE_FILE="$BITCOIN_DIR/.cookie"
fi

# Check if cookie file exists
if [ ! -f "$COOKIE_FILE" ]; then
echo "Error: Cookie file not found at $COOKIE_FILE"
echo ""
echo "Make sure Bitcoin Core is running."
if [ -n "$NETWORK" ]; then
echo " bitcoind -$NETWORK"
else
echo " bitcoind"
fi
exit 1
fi

# Read cookie credentials
COOKIE=$(cat "$COOKIE_FILE")
RPC_USER="${COOKIE%%:*}"
RPC_PASS="${COOKIE#*:}"

# Determine RPC URL
RPC_URL="http://127.0.0.1:$RPC_PORT"

echo "Starting minipool..."
echo " Bitcoin RPC: $RPC_URL"
echo " Cookie file: $COOKIE_FILE"
echo " Bind address: $BIND_ADDR"
[ -n "$NETWORK" ] && echo " Network: $NETWORK"
echo ""

# Build if requested
if [ -n "$BUILD" ]; then
echo "Building..."
cargo build $RELEASE
echo ""
fi

# Run minipool
exec cargo run $RELEASE -- \
--bitcoin-rpc-url "$RPC_URL" \
--bitcoin-rpc-user "$RPC_USER" \
--bitcoin-rpc-pass "$RPC_PASS" \
--bind-addr "$BIND_ADDR" \
--prometheus-bind-addr "$PROMETHEUS_ADDR"
Loading