/fix

POST ASYNC

Fix fracked coins and recover limbo coins in a wallet.

POST /api/v1/fix

Description

This endpoint launches two processes: fixing fracked coins and recovering limbo coins in the specified wallet. Fracked coins are those with authentication issues on some RAIDA servers, while limbo coins are those with more serious authentication problems. This operation attempts to repair these coins and restore them to full functionality.

Note

This is an asynchronous API call. It creates a task and returns its ID. You can query the task status until it completes, showing a progress indicator to the user.

Understanding Asynchronous API Calls

This endpoint is asynchronous, which means:

  1. When you call this endpoint, it immediately returns a task ID rather than waiting for the full operation to complete.
  2. You then need to periodically check the task status using the /api/v1/task/{task_id} endpoint.
  3. Once the task is complete, the task status endpoint will return the full results.
Task Status Response Structure

When checking a task's status, you'll get a JSON response with the following structure:

{
    "id": "task123",              // The task identifier
    "status": "running",          // Status can be "running", "completed", or "error"
    "progress": 60,               // Progress percentage (0-100)
    "message": "...",             // Optional status message or error details
    "data": { ... }               // Only present when status is "completed"
}
Task Status Types

running The task is still in progress. Continue to check the status.

completed The task is finished successfully. The response will include the full result data.

error The task encountered an error. The response will include an error message.

Tip

When displaying task progress to users, consider implementing a progress bar that updates based on the progress value returned by the task status API.

Request

This endpoint accepts a JSON object with the following properties:

Request Body Parameters

Parameter Type Required Description
name string Yes The name of the wallet containing coins to fix.

Example Request

{
    "name": "Default"
}

Response

Returns a 200 OK response with a JSON object containing details about the fix operation results.

Response Properties

total_fracked integer
Total value of fracked coins that were found.
total_limbo integer
Total value of coins in limbo state that were found.
total_fixed integer
Total value of fracked coins that were successfully fixed.
total_skipped integer
Total value of coins that were skipped during the fix process.
total_errors integer
Number of errors encountered during the fix process.
total_limbo_recovered integer
Total value of limbo coins that were successfully recovered.

Example Response

{
  "total_fracked": 7000,
  "total_limbo": 1000,
  "total_fixed": 6000,
  "total_skipped": 1000,
  "total_errors": 0,
  "total_limbo_recovered": 1000
}

Examples

JavaScript Example

// Using Fetch API to make the asynchronous call and check task status
const apiHost = 'http://localhost:8004';

// Step 1: Call the fix endpoint to create a task
fetch(`${apiHost}/api/v1/fix`, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        name: 'Default'
    })
})
.then(response => response.json())
.then(task => {
    console.log('Task created:', task);
    
    // Step 2: Monitor task status
    const taskId = task.id;
    const checkTaskInterval = setInterval(() => {
        fetch(`${apiHost}/api/v1/task/${taskId}`)
            .then(response => response.json())
            .then(taskStatus => {
                console.log(`Task progress: ${taskStatus.progress}%`);
                
                // Update progress bar in UI
                document.getElementById('progressBar').value = taskStatus.progress;
                document.getElementById('progressText').textContent = `${taskStatus.progress}%`;
                
                // Step 3: Check if the task is complete
                if (taskStatus.status === 'completed') {
                    clearInterval(checkTaskInterval);
                    const result = taskStatus.data;
                    
                    console.log('Fix operation results:');
                    console.log(`Total fracked coins: ${result.total_fracked}`);
                    console.log(`Total limbo coins: ${result.total_limbo}`);
                    console.log(`Successfully fixed: ${result.total_fixed}`);
                    console.log(`Limbo coins recovered: ${result.total_limbo_recovered}`);
                    console.log(`Skipped: ${result.total_skipped}`);
                    console.log(`Errors: ${result.total_errors}`);
                    
                    // Display a success message to the user
                    const successRate = result.total_fixed + result.total_limbo_recovered;
                    const totalIssues = result.total_fracked + result.total_limbo;
                    const message = `Fix operation completed: ${successRate} out of ${totalIssues} coins with issues were repaired successfully.`;
                    
                    document.getElementById('resultContainer').textContent = message;
                } else if (taskStatus.status === 'error') {
                    clearInterval(checkTaskInterval);
                    console.error('Task error:', taskStatus.message);
                    document.getElementById('resultContainer').textContent = `Error: ${taskStatus.message}`;
                }
            })
            .catch(error => {
                clearInterval(checkTaskInterval);
                console.error('Error checking task status:', error);
            });
    }, 1000); // Check every second
})
.catch(error => {
    console.error('Error initiating fix task:', error);
});

cURL Example

# Step 1: Call the fix endpoint to create a task
curl -X POST "http://localhost:8004/api/v1/fix" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Default"
  }'

# Example response:
# {"id":"task123","status":"running","progress":0}

# Step 2: Check the task status (replace 'task123' with your actual task ID)
curl -X GET "http://localhost:8004/api/v1/task/task123" -H "accept: application/json"

# Example response while in progress:
# {"id":"task123","status":"running","progress":60}

# Example response when complete:
# {"id":"task123","status":"completed","progress":100,"data":{"total_fracked":7000,"total_limbo":1000,"total_fixed":6000,"total_skipped":1000,"total_errors":0,"total_limbo_recovered":1000}}

Related Endpoints

/health

Perform a health check on all coins in the Bank to identify fracked or counterfeit coins.