479 lines
9.3 KiB
Markdown
479 lines
9.3 KiB
Markdown
# 📦 Guide d'Installation - sdk_relay
|
|
|
|
Guide complet pour installer et configurer le service de relais sdk_relay pour les Silent Payments.
|
|
|
|
## 📋 Prérequis
|
|
|
|
### Système
|
|
|
|
- **OS** : Linux (Ubuntu 20.04+, Debian 11+, CentOS 8+), macOS 10.15+
|
|
- **Architecture** : x86_64, ARM64 (Apple Silicon)
|
|
- **RAM** : 2 Go minimum, 4 Go recommandés
|
|
- **Stockage** : 5 Go minimum, 10 Go recommandés
|
|
- **Réseau** : Connexion Internet stable
|
|
|
|
### Logiciels
|
|
|
|
- **Docker** : Version 20.10+ (recommandé)
|
|
- **Rust** : Version 1.70+ (pour compilation native)
|
|
- **Git** : Version 2.25+
|
|
- **Bitcoin Core** : Version 24.0+ (signet ou mainnet)
|
|
- **Blindbit** : Oracle accessible via HTTP
|
|
|
|
## 🚀 Installation
|
|
|
|
### 1. Installation de Docker (Recommandé)
|
|
|
|
#### Ubuntu/Debian
|
|
|
|
```bash
|
|
# Mettre à jour les paquets
|
|
sudo apt update
|
|
|
|
# Installer les dépendances
|
|
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
|
|
|
|
# Ajouter la clé GPG Docker
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
|
|
|
|
# Ajouter le repository Docker
|
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
# Installer Docker
|
|
sudo apt update
|
|
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
|
|
# Ajouter l'utilisateur au groupe docker
|
|
sudo usermod -aG docker $USER
|
|
|
|
# Démarrer Docker
|
|
sudo systemctl start docker
|
|
sudo systemctl enable docker
|
|
```
|
|
|
|
#### CentOS/RHEL
|
|
|
|
```bash
|
|
# Installer les dépendances
|
|
sudo yum install -y yum-utils
|
|
|
|
# Ajouter le repository Docker
|
|
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
|
|
|
# Installer Docker
|
|
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
|
|
# Démarrer Docker
|
|
sudo systemctl start docker
|
|
sudo systemctl enable docker
|
|
|
|
# Ajouter l'utilisateur au groupe docker
|
|
sudo usermod -aG docker $USER
|
|
```
|
|
|
|
#### macOS
|
|
|
|
```bash
|
|
# Installer via Homebrew
|
|
brew install --cask docker
|
|
|
|
# Ou télécharger Docker Desktop depuis
|
|
# https://www.docker.com/products/docker-desktop
|
|
```
|
|
|
|
### 2. Installation de Rust (Optionnel - pour compilation native)
|
|
|
|
#### Linux/macOS
|
|
|
|
```bash
|
|
# Installer Rust via rustup
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
|
|
# Recharger l'environnement
|
|
source ~/.cargo/env
|
|
|
|
# Vérifier l'installation
|
|
rustc --version
|
|
cargo --version
|
|
```
|
|
|
|
#### Windows
|
|
|
|
```bash
|
|
# Télécharger et installer rustup depuis
|
|
# https://rustup.rs/
|
|
```
|
|
|
|
### 3. Configuration SSH (Recommandé)
|
|
|
|
```bash
|
|
# Générer une clé SSH
|
|
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_sdk -C "sdk-relay-automation"
|
|
|
|
# Ajouter à l'agent SSH
|
|
ssh-add ~/.ssh/id_ed25519_sdk
|
|
|
|
# Configurer Git pour utiliser la clé
|
|
git config --global core.sshCommand "ssh -i ~/.ssh/id_ed25519_sdk"
|
|
|
|
# Afficher la clé publique pour Gitea
|
|
cat ~/.ssh/id_ed25519_sdk.pub
|
|
```
|
|
|
|
**Ajouter la clé publique à Gitea :**
|
|
1. Aller sur Gitea > Settings > SSH Keys
|
|
2. Coller la clé publique
|
|
3. Cliquer sur "Add key"
|
|
|
|
### 4. Clonage du Repository
|
|
|
|
```bash
|
|
# Cloner avec SSH (recommandé)
|
|
git clone git@git.4nkweb.com:4nk/sdk_relay.git
|
|
cd sdk_relay
|
|
|
|
# Ou cloner avec HTTPS
|
|
git clone https://git.4nkweb.com/4nk/sdk_relay.git
|
|
cd sdk_relay
|
|
```
|
|
|
|
## 🔧 Configuration
|
|
|
|
### Variables d'Environnement
|
|
|
|
Créer un fichier `.env` à la racine du projet :
|
|
|
|
```bash
|
|
# Configuration du service
|
|
RUST_LOG=info
|
|
RUST_BACKTRACE=1
|
|
|
|
# Configuration Bitcoin Core
|
|
BITCOIN_RPC_HOST=localhost
|
|
BITCOIN_RPC_PORT=18443
|
|
BITCOIN_RPC_USER=your_username
|
|
BITCOIN_RPC_PASS=your_password
|
|
BITCOIN_RPC_COOKIE_PATH=/path/to/.cookie
|
|
|
|
# Configuration Blindbit
|
|
BLINDBIT_URL=http://localhost:8000
|
|
BLINDBIT_API_KEY=your_api_key
|
|
|
|
# Configuration réseau
|
|
WS_PORT=8090
|
|
HTTP_PORT=8091
|
|
HOST=0.0.0.0
|
|
|
|
# Configuration de sécurité
|
|
ENABLE_TLS=false
|
|
CERT_PATH=/path/to/cert.pem
|
|
KEY_PATH=/path/to/key.pem
|
|
```
|
|
|
|
### Configuration Bitcoin Core
|
|
|
|
#### Installation Bitcoin Core
|
|
|
|
```bash
|
|
# Ubuntu/Debian
|
|
sudo apt update
|
|
sudo apt install -y bitcoin-core
|
|
|
|
# Ou télécharger depuis bitcoin.org
|
|
wget https://bitcoin.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
|
|
tar -xzf bitcoin-24.0.1-x86_64-linux-gnu.tar.gz
|
|
sudo cp bitcoin-24.0.1/bin/* /usr/local/bin/
|
|
```
|
|
|
|
#### Configuration Bitcoin Core
|
|
|
|
Créer le fichier `~/.bitcoin/bitcoin.conf` :
|
|
|
|
```ini
|
|
# Configuration réseau
|
|
network=signet
|
|
rpcuser=your_username
|
|
rpcpassword=your_password
|
|
rpcallowip=127.0.0.1
|
|
rpcbind=127.0.0.1:18443
|
|
|
|
# Configuration de sécurité
|
|
rpcssl=false
|
|
server=1
|
|
txindex=1
|
|
|
|
# Configuration de performance
|
|
dbcache=450
|
|
maxorphantx=10
|
|
maxmempool=50
|
|
mempoolexpiry=72
|
|
```
|
|
|
|
### Configuration Blindbit
|
|
|
|
#### Installation Blindbit
|
|
|
|
```bash
|
|
# Cloner le repository Blindbit
|
|
git clone https://github.com/4nk/blindbit.git
|
|
cd blindbit
|
|
|
|
# Installer les dépendances
|
|
pip install -r requirements.txt
|
|
|
|
# Configurer l'oracle
|
|
cp config.example.json config.json
|
|
# Éditer config.json avec vos paramètres
|
|
```
|
|
|
|
#### Configuration Blindbit
|
|
|
|
```json
|
|
{
|
|
"port": 8000,
|
|
"host": "0.0.0.0",
|
|
"api_key": "your_api_key",
|
|
"bitcoin_rpc": {
|
|
"host": "localhost",
|
|
"port": 18443,
|
|
"user": "your_username",
|
|
"password": "your_password"
|
|
}
|
|
}
|
|
```
|
|
|
|
## 🧪 Tests Post-Installation
|
|
|
|
### 1. Test de Compilation
|
|
|
|
#### Docker
|
|
|
|
```bash
|
|
# Build de l'image Docker
|
|
docker build -f Dockerfile -t sdk_relay .
|
|
|
|
# Vérifier que l'image a été créée
|
|
docker images | grep sdk_relay
|
|
```
|
|
|
|
#### Rust (Compilation native)
|
|
|
|
```bash
|
|
# Test de compilation
|
|
cargo build --release
|
|
|
|
# Vérifier le binaire
|
|
ls -la target/release/sdk_relay
|
|
```
|
|
|
|
### 2. Test de Configuration
|
|
|
|
```bash
|
|
# Vérifier la configuration
|
|
cargo run -- --config .conf --check
|
|
|
|
# Ou avec Docker
|
|
docker run --rm sdk_relay --config .conf --check
|
|
```
|
|
|
|
### 3. Test de Connexion
|
|
|
|
#### Test Bitcoin Core
|
|
|
|
```bash
|
|
# Test RPC Bitcoin Core
|
|
curl -u your_username:your_password \
|
|
-d '{"jsonrpc": "1.0", "id": "test", "method": "getblockchaininfo", "params": []}' \
|
|
-H 'content-type: text/plain;' \
|
|
http://localhost:18443/
|
|
```
|
|
|
|
#### Test Blindbit
|
|
|
|
```bash
|
|
# Test API Blindbit
|
|
curl -H "Authorization: Bearer your_api_key" \
|
|
http://localhost:8000/health
|
|
```
|
|
|
|
### 4. Test du Service
|
|
|
|
#### Démarrage du Service
|
|
|
|
```bash
|
|
# Avec Docker
|
|
docker run -d \
|
|
--name sdk_relay \
|
|
-p 8090:8090 \
|
|
-p 8091:8091 \
|
|
-v $(pwd)/.conf:/app/.conf \
|
|
sdk_relay
|
|
|
|
# Avec Rust
|
|
cargo run --release -- --config .conf
|
|
```
|
|
|
|
#### Tests de Connectivité
|
|
|
|
```bash
|
|
# Test HTTP Health
|
|
curl http://localhost:8091/health
|
|
|
|
# Test WebSocket
|
|
wscat -c ws://localhost:8090
|
|
|
|
# Test métriques
|
|
curl http://localhost:8091/metrics
|
|
```
|
|
|
|
## 🚨 Dépannage
|
|
|
|
### Problèmes Courants
|
|
|
|
#### Docker non trouvé
|
|
```bash
|
|
# Vérifier l'installation
|
|
which docker
|
|
docker --version
|
|
|
|
# Réinstaller si nécessaire
|
|
curl -fsSL https://get.docker.com | sh
|
|
sudo usermod -aG docker $USER
|
|
```
|
|
|
|
#### Rust non trouvé
|
|
```bash
|
|
# Vérifier l'installation
|
|
which rustc
|
|
rustc --version
|
|
|
|
# Réinstaller si nécessaire
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
source ~/.cargo/env
|
|
```
|
|
|
|
#### Erreurs de compilation
|
|
```bash
|
|
# Nettoyer et recompiler
|
|
cargo clean
|
|
cargo build --release
|
|
|
|
# Vérifier les dépendances
|
|
cargo update
|
|
cargo check
|
|
```
|
|
|
|
#### Erreurs de connexion Bitcoin Core
|
|
```bash
|
|
# Vérifier que Bitcoin Core est démarré
|
|
bitcoind -daemon
|
|
|
|
# Vérifier les logs
|
|
tail -f ~/.bitcoin/signet/debug.log
|
|
|
|
# Tester la connexion RPC
|
|
bitcoin-cli -signet getblockchaininfo
|
|
```
|
|
|
|
#### Erreurs de connexion Blindbit
|
|
```bash
|
|
# Vérifier que Blindbit est démarré
|
|
cd blindbit
|
|
python main.py
|
|
|
|
# Vérifier les logs
|
|
tail -f blindbit.log
|
|
|
|
# Tester l'API
|
|
curl http://localhost:8000/health
|
|
```
|
|
|
|
### Logs Détaillés
|
|
|
|
```bash
|
|
# Logs Docker
|
|
docker logs sdk_relay
|
|
|
|
# Logs Rust
|
|
RUST_LOG=debug cargo run -- --config .conf
|
|
|
|
# Logs Bitcoin Core
|
|
tail -f ~/.bitcoin/signet/debug.log
|
|
|
|
# Logs Blindbit
|
|
tail -f blindbit.log
|
|
```
|
|
|
|
## 🔒 Sécurité
|
|
|
|
### Vérifications de Sécurité
|
|
|
|
```bash
|
|
# Audit des dépendances Rust
|
|
cargo audit
|
|
|
|
# Vérification des vulnérabilités Docker
|
|
docker scan sdk_relay
|
|
|
|
# Test de sécurité réseau
|
|
nmap -p 8090,8091 localhost
|
|
```
|
|
|
|
### Bonnes Pratiques
|
|
|
|
- Utiliser HTTPS en production
|
|
- Configurer des pare-feu appropriés
|
|
- Maintenir les dépendances à jour
|
|
- Utiliser des variables d'environnement pour les secrets
|
|
- Tester régulièrement la sécurité
|
|
|
|
## 📊 Monitoring
|
|
|
|
### Métriques d'Installation
|
|
|
|
```bash
|
|
# Taille du projet
|
|
du -sh .
|
|
|
|
# Nombre de fichiers
|
|
find . -type f | wc -l
|
|
|
|
# Dépendances Rust
|
|
cargo tree | wc -l
|
|
|
|
# Taille du binaire
|
|
ls -lh target/release/sdk_relay
|
|
```
|
|
|
|
### Vérification de l'Installation
|
|
|
|
```bash
|
|
# Script de vérification
|
|
./scripts/verify-installation.sh
|
|
|
|
# Tests automatisés
|
|
cargo test --all
|
|
```
|
|
|
|
## 🎯 Prochaines Étapes
|
|
|
|
Après l'installation réussie :
|
|
|
|
1. **Lire le [Guide d'Utilisation](USAGE.md)** - Utiliser le service
|
|
2. **Consulter l'[Architecture](ARCHITECTURE.md)** - Comprendre le système
|
|
3. **Explorer les [APIs](API.md)** - Utiliser les fonctionnalités
|
|
4. **Configurer l'[Intégration 4NK_node](INTEGRATION_4NK_NODE.md)** - Déployer en production
|
|
|
|
## 📞 Support
|
|
|
|
En cas de problème :
|
|
|
|
1. Consulter la [documentation](INDEX.md)
|
|
2. Vérifier les [issues existantes](https://git.4nkweb.com/4nk/sdk_relay/issues)
|
|
3. Créer une nouvelle issue avec les détails du problème
|
|
4. Inclure les logs et la configuration utilisée
|
|
|
|
---
|
|
|
|
**🚀 Installation terminée ! sdk_relay est prêt à être utilisé.** ✨
|