# Fix Web3Signer Key Path Issue

**Issue**: Web3Signer is looking for keys in `/opt/web3signer-23.10.0` instead of `/opt/web3signer/data/keys/`

**Root Cause**: The systemd service might be using the wrong path, or Web3Signer is defaulting to the installation directory.

---

## 🚀 Quick Fix

Run the automated fix script:

```bash
cd /home/intlc/projects/proxmox/rpc-translator-138
./scripts/fix-web3signer-path.sh
```

---

## 📋 Manual Fix Steps

### Step 1: Check Current Configuration

```bash
# Check systemd service
ssh root@192.168.11.11 "pct exec 107 -- cat /etc/systemd/system/web3signer.service"

# Check where keys are
ssh root@192.168.11.11 "pct exec 107 -- ls -la /opt/web3signer/data/keys/"
```

### Step 2: Update Systemd Service

The service should use `/opt/web3signer` as the installation directory and `/opt/web3signer/data` as the data path:

```bash
ssh root@192.168.11.11 "pct exec 107 -- bash -c 'cat > /etc/systemd/system/web3signer.service <<EOF
[Unit]
Description=Web3Signer - Ethereum Signing Service
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/web3signer
ExecStart=/opt/web3signer/bin/web3signer --http-listen-port=9000 --http-listen-host=192.168.11.111 --http-host-allowlist=* --data-path=/opt/web3signer/data eth1 --chain-id=138
Restart=always
RestartSec=5
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
EOF
'"
```

### Step 3: Reload and Restart

```bash
ssh root@192.168.11.11 "pct exec 107 -- systemctl daemon-reload && systemctl restart web3signer && sleep 5"
```

### Step 4: Verify Keys

```bash
# Check if keys are loaded
curl http://192.168.11.111:9000/api/v1/eth1/publicKeys

# Check logs if still not working
ssh root@192.168.11.11 "pct exec 107 -- journalctl -u web3signer.service -n 30 --no-pager"
```

---

## 🔍 Understanding the Issue

Web3Signer logs show:
```
Loading signer configuration metadata files from /opt/web3signer-23.10.0
Processing 0 metadata files
```

This suggests Web3Signer is looking in the installation directory instead of the data directory.

**For ETH1 keystore files**, Web3Signer should look in:
- `--data-path/keys/` (e.g., `/opt/web3signer/data/keys/`)

**The systemd service should specify:**
- `--data-path=/opt/web3signer/data` (where keys are stored)
- Installation directory: `/opt/web3signer` (where binary is)

---

## ✅ Expected Result

After fixing, Web3Signer logs should show:
```
Loading signer configuration metadata files from /opt/web3signer/data
Processing 3 metadata files
Total signers (keys) currently loaded in memory: 3
```

And the API should return:
```json
[
  "0x306290a09aefe8e7009c4fbd2662e1ee075255dc",
  "0x74b9ed9d5f37211128aec5b6de8ef5bb2762c68f",
  "0x7be3046f456a106d2ff8999ce90359dfc4c52f4c"
]
```

---

**Status**: Run `./scripts/fix-web3signer-path.sh` to fix the path issue!
