/api/health/check

GET ASYNC

Runs the full health check pipeline (detect, fix encryption, fix limbo, fix fracked, grade) on a specified wallet or all wallets. Returns a task ID for progress polling.

Description

The /api/health/check endpoint runs the complete health check pipeline on your wallet(s). This is a long-running operation that authenticates all coins, fixes encryption issues, heals fracked coins, and grades results. Because it can take 30 seconds or more for large wallets, it runs asynchronously in a background thread and returns a task_id immediately.

Health Check Pipeline

The full pipeline runs these steps in order:

  1. Detect: Authenticate all Bank and Fracked coins against 25 RAIDA servers
  2. Grade: Sort detected coins into Bank, Fracked, Counterfeit, or Limbo
  3. Fix Encryption: Repair any RAIDA servers with broken encryption keys
  4. Fix Limbo: Resolve coins with insufficient authentication data
  5. Fix Fracked: Heal coins that have 13+ passes but some failures using ticket-based repair
  6. Final Grade: Re-grade all fixed coins to their final folders
Boot Behavior

At startup, the server only runs a quick health check on the Mail wallet (typically 1 coin) for fast boot times. Use this endpoint to run a full health check on all wallets after the server is ready.

Parameters

Parameter Type Required Description
wallet_path string No The wallet name or path to check (e.g., Default). If omitted, all registered wallets are checked sequentially.

Response

Returns a JSON object with a task ID for polling progress. The health check runs in the background.

Response Properties

command string
Always "health_check".
success boolean
True if the background task was started successfully.
task_id string
Unique task identifier for polling progress via /api/system/tasks.
message string
Human-readable description of what is being checked.

Immediate Response (task started)

{
  "command": "health_check",
  "success": true,
  "task_id": "Mar-05-26_02-30-45-PM-A1B2",
  "message": "Health check: all wallets"
}

Completed Task Data (via /api/system/tasks)

{
  "task_id": "Mar-05-26_02-30-45-PM-A1B2",
  "status": "completed",
  "message": "Health check complete",
  "data": {
    "wallet": "E:\\Client1\\Client_Data\\Wallets\\Default",
    "detect_found": 179,
    "detect_fracked": 141,
    "enc_found": 0,
    "enc_fixed": 0,
    "fracked_found": 141,
    "fracked_fixed": 141,
    "elapsed_ms": 42000
  }
}

Polling for Progress

Since this is an async operation, use the /api/system/tasks endpoint to check progress:

Polling Workflow:
1. Call /api/health/check → receive task_id
2. Poll /api/system/tasks?id={task_id} every 3-5 seconds
3. Check "status" field:
   - "running"   → still in progress (check "progress" and "message")
   - "completed" → done (check "data" for results)
   - "failed"    → error occurred (check "message" for details)
Long-Running Operation

A full health check on a wallet with many coins (100+) can take 30-60 seconds or more. The operation includes:

  • Detect: ~2 seconds per batch of 100 coins (parallel RAIDA communication)
  • Fix Fracked: ~5-10 seconds (ticket acquisition + healing)
  • File I/O: Writing and moving coin files

Do not set HTTP client timeouts shorter than 60 seconds when polling.

Examples

JavaScript (fetch)

const API_HOST = 'http://localhost:8080';

// Run full health check on all wallets and poll to completion
async function runHealthCheck(walletPath = null) {
    // Start the health check
    let url = `${API_HOST}/api/health/check`;
    if (walletPath) {
        url += `?wallet_path=${encodeURIComponent(walletPath)}`;
    }

    const response = await fetch(url);
    const result = await response.json();

    if (!result.success) {
        console.error('Failed to start health check:', result.message);
        return;
    }

    console.log(`Health check started: ${result.message}`);
    const taskId = result.task_id;

    // Poll for completion
    while (true) {
        await new Promise(resolve => setTimeout(resolve, 3000)); // Wait 3 seconds

        const taskResp = await fetch(
            `${API_HOST}/api/system/tasks?id=${encodeURIComponent(taskId)}`
        );
        const task = await taskResp.json();

        if (task.status === 'completed') {
            console.log('Health check complete!');
            console.log('Results:', JSON.stringify(task.data, null, 2));
            return task.data;
        } else if (task.status === 'failed') {
            console.error('Health check failed:', task.message);
            return null;
        } else {
            console.log(`Progress: ${task.progress}% - ${task.message}`);
        }
    }
}

// Check all wallets
runHealthCheck();

// Or check a specific wallet
runHealthCheck('Default');

cURL

# Run health check on all wallets
curl "http://localhost:8080/api/health/check"

# Run health check on a specific wallet
curl "http://localhost:8080/api/health/check?wallet_path=Default"

# Poll for task completion (replace TASK_ID with actual ID)
curl "http://localhost:8080/api/system/tasks?id=TASK_ID"

# One-liner: start check and poll until done (bash)
TASK_ID=$(curl -s "http://localhost:8080/api/health/check" | python3 -c "import sys,json; print(json.load(sys.stdin)['task_id'])")
echo "Task: $TASK_ID"
while true; do
    STATUS=$(curl -s "http://localhost:8080/api/system/tasks?id=$TASK_ID")
    echo "$STATUS" | python3 -c "import sys,json; d=json.load(sys.stdin); print(f'{d.get(\"status\")}: {d.get(\"message\",\"\")}')"
    echo "$STATUS" | python3 -c "import sys,json; exit(0 if json.load(sys.stdin).get('status') in ('completed','failed') else 1)" && break
    sleep 3
done

Go

package main

import (
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
    "net/url"
    "time"
)

const ApiHost = "http://localhost:8080"

type HealthCheckResponse struct {
    Success bool   `json:"success"`
    TaskID  string `json:"task_id"`
    Message string `json:"message"`
}

type TaskStatus struct {
    TaskID   string                 `json:"task_id"`
    Status   string                 `json:"status"`
    Progress int                    `json:"progress"`
    Message  string                 `json:"message"`
    Data     map[string]interface{} `json:"data"`
}

func runHealthCheck(walletPath string) error {
    // Start health check
    reqURL := fmt.Sprintf("%s/api/health/check", ApiHost)
    if walletPath != "" {
        reqURL += "?wallet_path=" + url.QueryEscape(walletPath)
    }

    resp, err := http.Get(reqURL)
    if err != nil {
        return fmt.Errorf("request failed: %v", err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    var result HealthCheckResponse
    json.Unmarshal(body, &result)

    if !result.Success {
        return fmt.Errorf("failed to start: %s", result.Message)
    }

    fmt.Printf("Started: %s (task: %s)\n", result.Message, result.TaskID)

    // Poll for completion
    for {
        time.Sleep(3 * time.Second)

        taskURL := fmt.Sprintf("%s/api/system/tasks?id=%s",
            ApiHost, url.QueryEscape(result.TaskID))
        taskResp, err := http.Get(taskURL)
        if err != nil {
            continue
        }

        taskBody, _ := ioutil.ReadAll(taskResp.Body)
        taskResp.Body.Close()

        var task TaskStatus
        json.Unmarshal(taskBody, &task)

        switch task.Status {
        case "completed":
            fmt.Println("Health check complete!")
            data, _ := json.MarshalIndent(task.Data, "", "  ")
            fmt.Println(string(data))
            return nil
        case "failed":
            return fmt.Errorf("health check failed: %s", task.Message)
        default:
            fmt.Printf("Progress: %d%% - %s\n", task.Progress, task.Message)
        }
    }
}

func main() {
    if err := runHealthCheck("Default"); err != nil {
        panic(err)
    }
}

Related Endpoints

/api/health/authenticate

Run only the Detect step to authenticate coins without fixing or healing.

/api/health/fix

Run only the Fix Fracked step to heal coins with partial authentication.

/api/health/encryption-repair

Run only the Fix Encryption step to repair broken encryption keys on RAIDA servers.

/api/system/tasks

Poll task status and progress for any async operation.