Add Monero (XMR) payment support
This commit is contained in:
parent
0c8e1b4f89
commit
f3cd1e7116
45 changed files with 7200 additions and 759 deletions
226
Makefile
226
Makefile
|
|
@ -13,8 +13,51 @@ PSERVE = $(VENV_DIR)/bin/pserve
|
|||
ALEMBIC = $(VENV_DIR)/bin/alembic
|
||||
MPS_INIT = $(VENV_DIR)/bin/initialize_make_post_sell_db
|
||||
|
||||
# Default target: install from PyPI and then start the server.
|
||||
all: install-from-pypi serve
|
||||
# Default target: show help
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
|
||||
# Help target - shows all available commands
|
||||
help:
|
||||
@echo "Make Post Sell - Available Commands"
|
||||
@echo "==================================="
|
||||
@echo ""
|
||||
@echo "SETUP & INSTALLATION:"
|
||||
@echo " make venv - Create Python virtual environment"
|
||||
@echo " make config - Download configuration file"
|
||||
@echo " make install-from-pypi - Complete setup using PyPI packages"
|
||||
@echo " make install-from-source - Complete setup from source (dev mode)"
|
||||
@echo " make install-from-source-prod - Production install from source"
|
||||
@echo ""
|
||||
@echo "DATABASE:"
|
||||
@echo " make init-db - Initialize the database"
|
||||
@echo ""
|
||||
@echo "DEVELOPMENT:"
|
||||
@echo " make serve - Start development server with auto-reload"
|
||||
@echo " make test - Run test suite"
|
||||
@echo " make test-coverage - Run tests with coverage report"
|
||||
@echo " make http - Start simple HTTP server on port 8000"
|
||||
@echo " make activate - Show how to activate virtual environment"
|
||||
@echo ""
|
||||
@echo "CRYPTOCURRENCY (MONERO):"
|
||||
@echo " make check-monero - Check if Monero tools are installed"
|
||||
@echo " make install-monero - Install Monero tools automatically"
|
||||
@echo " make monero-wallet-create - Create new Monero wallet (first time)"
|
||||
@echo " make monero-node - Start local Monero node (150GB required)"
|
||||
@echo " make monero-wallet - Start wallet RPC with local node"
|
||||
@echo " make monero-wallet-remote - Start wallet RPC with remote node (dev)"
|
||||
@echo " make monero-full-stack - Show instructions for complete setup"
|
||||
@echo " make crypto-watcher - Start payment monitoring service"
|
||||
@echo " make crypto-watcher-once - Run payment check once (testing)"
|
||||
@echo ""
|
||||
@echo "WALLET MANAGEMENT:"
|
||||
@echo " make sweep-check - Check hot wallet balances (dry run)"
|
||||
@echo " make sweep - Sweep funds to cold storage"
|
||||
@echo ""
|
||||
@echo "CLEANUP:"
|
||||
@echo " make clean - Remove virtual environment"
|
||||
@echo ""
|
||||
@echo "For more info, see README.md and CRYPTO.rst"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Environment Setup Targets
|
||||
|
|
@ -123,6 +166,185 @@ http: venv
|
|||
@echo "Starting simple HTTP server on port 8000..."
|
||||
$(PYTHON) -m http.server 8000
|
||||
|
||||
# Run the crypto watcher service for monitoring Monero payments.
|
||||
crypto-watcher: venv config
|
||||
@echo "Starting crypto payment watcher..."
|
||||
$(VENV_DIR)/bin/crypto_watcher $(DATA_DIR)/$(CONFIG_FILE)
|
||||
|
||||
# Run the crypto watcher once (for testing or manual processing).
|
||||
crypto-watcher-once: venv config
|
||||
@echo "Running crypto payment watcher once..."
|
||||
$(VENV_DIR)/bin/crypto_watcher $(DATA_DIR)/$(CONFIG_FILE) --once
|
||||
|
||||
# Check hot wallet balance (dry run).
|
||||
sweep-check: venv config
|
||||
@echo "Checking hot wallet balance..."
|
||||
@echo "IMPORTANT: Set COLD_WALLET_ADDRESS environment variable first!"
|
||||
$(VENV_DIR)/bin/sweep_to_cold $(DATA_DIR)/$(CONFIG_FILE) $${COLD_WALLET_ADDRESS:-ADDRESS_NOT_SET} --dry-run
|
||||
|
||||
# Sweep excess funds to cold storage.
|
||||
sweep: venv config
|
||||
@echo "Sweeping excess funds to cold storage..."
|
||||
@echo "IMPORTANT: Set COLD_WALLET_ADDRESS environment variable first!"
|
||||
$(VENV_DIR)/bin/sweep_to_cold $(DATA_DIR)/$(CONFIG_FILE) $${COLD_WALLET_ADDRESS:-ADDRESS_NOT_SET}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Monero Infrastructure Targets
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Start the Monero daemon (blockchain node) - requires ~150GB disk space
|
||||
monero-node: venv config check-monero
|
||||
@echo "Starting Monero daemon (monerod)..."
|
||||
@echo "This will download ~150GB blockchain data and may take 1-2 days to sync"
|
||||
@mkdir -p $(DATA_DIR)/monero-blockchain
|
||||
@echo "Checking available disk space..."
|
||||
@available=$$(df -BG $(DATA_DIR) | tail -1 | awk '{print $$4}' | sed 's/G//'); \
|
||||
if [ $$available -lt 200 ]; then \
|
||||
echo "ERROR: Insufficient disk space!"; \
|
||||
echo "Available: $${available}GB"; \
|
||||
echo "Required: 200GB+ (150GB blockchain + growth)"; \
|
||||
exit 1; \
|
||||
else \
|
||||
echo "Disk space OK: $${available}GB available"; \
|
||||
fi
|
||||
@echo "Check sync status at: http://127.0.0.1:18081/get_info"
|
||||
@echo "Press Ctrl+C to stop"
|
||||
monerod --data-dir=$(DATA_DIR)/monero-blockchain \
|
||||
--rpc-bind-ip=127.0.0.1 \
|
||||
--rpc-bind-port=18081 \
|
||||
--confirm-external-bind \
|
||||
--log-level=1
|
||||
|
||||
# Start the Monero wallet RPC (requires monerod or remote node)
|
||||
monero-wallet: venv config check-monero
|
||||
@echo "Starting Monero wallet RPC..."
|
||||
@echo "Make sure monerod is running and synced first!"
|
||||
@echo "Wallet file: $(DATA_DIR)/mps-wallet"
|
||||
@echo "RPC will be available at: http://127.0.0.1:18083"
|
||||
monero-wallet-rpc \
|
||||
--wallet-file=$(DATA_DIR)/mps-wallet \
|
||||
--password-file=$(DATA_DIR)/wallet-password.txt \
|
||||
--rpc-bind-ip=127.0.0.1 \
|
||||
--rpc-bind-port=18083 \
|
||||
--disable-rpc-login \
|
||||
--daemon-address=127.0.0.1:18081 \
|
||||
--trusted-daemon \
|
||||
--log-level=1
|
||||
|
||||
# Development mode - use remote node (no blockchain download needed)
|
||||
monero-wallet-remote: venv config check-monero
|
||||
@echo "Starting wallet with REMOTE node (development/testing only)..."
|
||||
@echo "Using public node - less private but no blockchain download"
|
||||
@echo "Wallet file: $(DATA_DIR)/mps-wallet"
|
||||
@echo "RPC will be available at: http://127.0.0.1:18083"
|
||||
@echo ""
|
||||
@echo "Trying primary node: opennode.xmr-tw.org:18089"
|
||||
monero-wallet-rpc \
|
||||
--wallet-file=$(DATA_DIR)/mps-wallet \
|
||||
--password-file=$(DATA_DIR)/wallet-password.txt \
|
||||
--rpc-bind-ip=127.0.0.1 \
|
||||
--rpc-bind-port=18083 \
|
||||
--disable-rpc-login \
|
||||
--daemon-address=opennode.xmr-tw.org:18089 \
|
||||
--trusted-daemon \
|
||||
--log-level=1
|
||||
|
||||
|
||||
# Install Monero tools automatically
|
||||
install-monero:
|
||||
@echo "Installing Monero tools..."
|
||||
@if [ "$$(uname)" = "Linux" ]; then \
|
||||
mkdir -p $(HOME)/.local/bin && \
|
||||
cd /tmp && \
|
||||
wget -q --show-progress https://downloads.getmonero.org/cli/linux64 && \
|
||||
tar -xf linux64 && \
|
||||
cp monero-x*/monero* $(HOME)/.local/bin/ && \
|
||||
rm -rf monero-x* linux64 && \
|
||||
echo "✓ Monero tools installed to $(HOME)/.local/bin/" && \
|
||||
echo "" && \
|
||||
echo "Add to your PATH by running:" && \
|
||||
echo " export PATH=\"$(HOME)/.local/bin:\$$PATH\"" && \
|
||||
echo "Or add that line to your ~/.bashrc or ~/.zshrc" && \
|
||||
echo "" && \
|
||||
echo "Then run 'make monero-wallet-create' to create a wallet"; \
|
||||
elif [ "$$(uname)" = "Darwin" ]; then \
|
||||
if command -v brew >/dev/null 2>&1; then \
|
||||
brew install monero; \
|
||||
else \
|
||||
echo "Please install Homebrew first: https://brew.sh"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
else \
|
||||
echo "Unsupported OS. Please download manually from:"; \
|
||||
echo "https://www.getmonero.org/downloads/"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Check if Monero tools are installed and provide install instructions
|
||||
check-monero:
|
||||
@if command -v monero-wallet-rpc >/dev/null 2>&1; then \
|
||||
echo "✓ Monero tools found: $$(monero-wallet-rpc --version | head -1)"; \
|
||||
else \
|
||||
echo "❌ Monero tools not found!"; \
|
||||
echo ""; \
|
||||
if [ "$$(uname)" = "Linux" ]; then \
|
||||
echo "Install on Linux:"; \
|
||||
echo "Download latest official release (recommended):"; \
|
||||
echo " wget https://downloads.getmonero.org/cli/linux64"; \
|
||||
echo " tar -xf linux64 && sudo cp monero-x*/monero* /usr/local/bin/"; \
|
||||
echo ""; \
|
||||
echo "Or install to user directory (no sudo):"; \
|
||||
echo " mkdir -p $$HOME/.local/bin"; \
|
||||
echo " wget https://downloads.getmonero.org/cli/linux64"; \
|
||||
echo " tar -xf linux64 && cp monero-x*/monero* $$HOME/.local/bin/"; \
|
||||
echo " export PATH=\"$$HOME/.local/bin:$$PATH\""; \
|
||||
elif [ "$$(uname)" = "Darwin" ]; then \
|
||||
echo "Install on macOS:"; \
|
||||
echo " brew install monero"; \
|
||||
echo ""; \
|
||||
echo "Or download latest official release:"; \
|
||||
echo " wget https://downloads.getmonero.org/cli/mac64"; \
|
||||
echo " tar -xf mac64 && sudo cp monero-x*/monero* /usr/local/bin/"; \
|
||||
else \
|
||||
echo "Download latest official Monero CLI tools:"; \
|
||||
echo " https://www.getmonero.org/downloads/"; \
|
||||
echo " Extract and copy monero-* binaries to /usr/local/bin/"; \
|
||||
fi; \
|
||||
echo ""; \
|
||||
echo "Package managers may have older versions. Official downloads are recommended."; \
|
||||
echo "After installing, run this command again."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Create a new Monero wallet for the shop
|
||||
monero-wallet-create: check-monero
|
||||
@echo "Creating new Monero wallet..."
|
||||
@echo "IMPORTANT: Save the 25-word mnemonic seed that will be displayed!"
|
||||
@echo "Enter a password for the wallet (or leave empty):"
|
||||
@read -s password; echo $$password > $(DATA_DIR)/wallet-password.txt
|
||||
monero-wallet-cli --generate-new-wallet=$(DATA_DIR)/mps-wallet \
|
||||
--password-file=$(DATA_DIR)/wallet-password.txt
|
||||
@echo "Wallet created at: $(DATA_DIR)/mps-wallet"
|
||||
@echo "Password saved in: $(DATA_DIR)/wallet-password.txt"
|
||||
@echo "Now run 'make monero-wallet' or 'make monero-wallet-remote' to start the RPC server"
|
||||
|
||||
# Instructions for running the full Monero stack
|
||||
monero-full-stack:
|
||||
@echo "=== Running Full Monero Payment Stack ==="
|
||||
@echo ""
|
||||
@echo "For PRODUCTION (most secure, requires ~150GB):"
|
||||
@echo " Terminal 1: make monero-node # Start blockchain node"
|
||||
@echo " Terminal 2: make monero-wallet # Start wallet RPC (after node syncs)"
|
||||
@echo " Terminal 3: make crypto-watcher # Start payment watcher"
|
||||
@echo " Terminal 4: make serve # Start web application"
|
||||
@echo ""
|
||||
@echo "For DEVELOPMENT (quick start, uses public node):"
|
||||
@echo " Terminal 1: make monero-wallet-remote # Start wallet with remote node"
|
||||
@echo " Terminal 2: make crypto-watcher # Start payment watcher"
|
||||
@echo " Terminal 3: make serve # Start web application"
|
||||
@echo ""
|
||||
@echo "First time? Run 'make monero-wallet-create' to create a wallet"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Cleanup Target
|
||||
# -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue