/api/wallet/fix-fracked
GETAutomatically heals fracked coins using the RAIDA ticket-based authentication system to repair partial authentication failures.
This endpoint is currently NOT IMPLEMENTED. It returns a placeholder response until integration is complete.
Current Status: Endpoint is registered in the API router but does not execute the healing workflow.
TODO: Call cmd_fix_coins() from commands.c and capture results for JSON response.
Description
The /api/wallet/fix-fracked endpoint is designed to automatically heal "fracked" coins - coins that have partial authentication (less than 13 out of 25 RAIDA servers passing, but not zero). The healing process uses a two-phase RAIDA protocol:
- Get Ticket Phase (0x0228): Request authentication tickets from RAIDAs that successfully authenticated the coin
- Fix Phase (0x0250): Present tickets to failing RAIDAs to prove coin authenticity and update their records
The process runs iteratively (up to 10 rounds) until all coins are either fully authenticated (moved to Bank), still partially failing (remain in Fracked), or determined to be counterfeit.
This endpoint will be useful for:
- Recovering coins that failed partial RAIDA authentication
- Automatic healing after network disruptions
- Batch repair of coins stuck in Fracked folder
- Scheduled maintenance to clear fracked coin backlog
RAIDA Healing Protocol
The Fix operation uses a sophisticated two-command protocol:
Phase 1: Get Ticket (Command 0x0228)
Request authentication tickets from RAIDAs with 'p' (pass) status:
- Request Format: Challenge(16 bytes) + [DN(1) + SN(4) + AN(16)] × N + Terminator(0x3E3E)
- Response Codes:
STATUS_ALL_PASS (241): Ticket(4 bytes) + 0x3E3ESTATUS_ALL_FAIL (242): 0x3E3E (no ticket)STATUS_MIXED (243): Bitfield(N) + Ticket(4 bytes) + 0x3E3E
- Ticket Validity: 60 seconds from issuance
Phase 2: Fix (Command 0x0250)
Present tickets to failing RAIDAs for verification:
- Request Format: Challenge(16 bytes) + [DN(1) + SN(4) + Ticket(4)] × N + Terminator(0x3E3E)
- Requirement: 13+ valid tickets needed for successful fix
- Outcome: Failing RAIDAs update their records with new authentication status
The algorithm iterates up to 10 rounds:
- Read all coins from Fracked folder
- For each RAIDA, identify coins needing fixes (non-'p' status)
- For each RAIDA, collect ticket requests (coins with 'p' status)
- Send Get Ticket requests to all 25 RAIDAs in parallel
- Send Fix requests with collected tickets to failing RAIDAs
- Update POWN strings based on fix results
- Write coins to Grade folder
- Run Grade command to sort: Bank (13+ passes), Fracked (<13 passes), Counterfeit (0 passes)
- Repeat until no changes or max rounds reached
Parameters
This endpoint does not require any parameters. It operates on all coins currently in the Fracked folder of the active wallet.
Response
Returns a JSON object with healing operation results.
The endpoint currently returns a placeholder response until implementation is complete.
Current Response Properties (Placeholder)
Current Example Response (Placeholder)
{
"status": "success",
"operation": "fix-fracked",
"message": "Fix fracked endpoint - implementation pending",
"fixed": 0,
"still_fracked": 0
}
Future Response Properties (After Implementation)
Future Example Response (After Implementation)
{
"status": "success",
"operation": "fix-fracked",
"message": "Fix operation completed",
"initial_fracked": 5,
"fixed": 3,
"still_fracked": 2,
"counterfeit": 0,
"rounds": 4
}
POWN String Updates
The Fix operation updates POWN (Proof of Ownership) strings to reflect authentication results:
| Character | Hex Value | Meaning | Fix Behavior |
|---|---|---|---|
p |
0x0A | Pass - Authenticated | RAIDA provides tickets |
f |
0x0F | Fail - Counterfeit | Receives Fix request with tickets |
n |
0x0C | No Reply - Timeout | Receives Fix request (may have network issues) |
e |
0x0E | Error - RAIDA Error | Receives Fix request (server had internal error) |
u |
0x00 | Untried - Not Checked | Should run Detect first |
b |
0x0B | Broken - Encryption Key Mismatch | Receives Fix request |
d |
0x0D | Dropped - Network Lost | Receives Fix request |
Authentication Threshold: 13+ 'p' characters out of 25 required for Bank status.
Examples
JavaScript (fetch)
const API_HOST = 'http://localhost:8080';
async function fixFrackedCoins() {
try {
const response = await fetch(`${API_HOST}/api/wallet/fix-fracked`);
const result = await response.json();
if (result.status === 'success') {
console.log('Fix Operation Results:');
console.log(`Initial Fracked: ${result.initial_fracked || 'N/A'}`);
console.log(`Fixed: ${result.fixed}`);
console.log(`Still Fracked: ${result.still_fracked}`);
console.log(`Counterfeit: ${result.counterfeit || 0}`);
console.log(`Rounds: ${result.rounds || 'N/A'}`);
console.log(`Message: ${result.message}`);
} else {
console.error('Fix operation failed:', result.message);
}
} catch (error) {
console.error('Error fixing fracked coins:', error);
}
}
fixFrackedCoins();
cURL
# Fix all fracked coins in active wallet
curl -X GET "http://localhost:8080/api/wallet/fix-fracked"
# Pretty print JSON output
curl -X GET "http://localhost:8080/api/wallet/fix-fracked" | jq
Go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
const ApiHost = "http://localhost:8080"
type FixFrackedResponse struct {
Status string `json:"status"`
Operation string `json:"operation"`
Message string `json:"message"`
InitialFracked int `json:"initial_fracked,omitempty"`
Fixed int `json:"fixed"`
StillFracked int `json:"still_fracked"`
Counterfeit int `json:"counterfeit,omitempty"`
Rounds int `json:"rounds,omitempty"`
}
func main() {
resp, err := http.Get(fmt.Sprintf("%s/api/wallet/fix-fracked", ApiHost))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
var result FixFrackedResponse
if err := json.Unmarshal(body, &result); err != nil {
panic(err)
}
if result.Status == "success" {
fmt.Printf("Fix Operation Results:\n")
fmt.Printf("Initial Fracked: %d\n", result.InitialFracked)
fmt.Printf("Fixed: %d\n", result.Fixed)
fmt.Printf("Still Fracked: %d\n", result.StillFracked)
fmt.Printf("Counterfeit: %d\n", result.Counterfeit)
fmt.Printf("Rounds: %d\n", result.Rounds)
fmt.Printf("Message: %s\n", result.Message)
} else {
fmt.Printf("Error: %s\n", result.Message)
}
}
Implementation Details
When this endpoint is fully implemented, it will execute the following workflow:
Workflow Steps
- Read Coins: Load all coins from the Fracked folder with POWN strings
- Build Fix Lists: For each RAIDA, identify coins needing fixes (non-'p' status)
- Build Ticket Lists: For each RAIDA, identify coins it can provide tickets for ('p' status)
- Get Tickets: Send parallel Get Ticket requests to all 25 RAIDAs
- Apply Fixes: Send Fix requests to failing RAIDAs with collected tickets
- Update POWN: Update coin POWN strings based on fix results
- Grade Coins: Write coins to Grade folder and run Grade command
- Iterate: Repeat until no changes or 10 rounds reached
- Generate Receipt: Create transaction receipt with task ID and results
- Timeout: 10 seconds per RAIDA request (configurable)
- Ticket Validity: Tickets expire after 60 seconds
- Minimum Tickets: 13+ tickets required for successful fix
- Max Rounds: 10 healing rounds maximum
- Threading: All 25 RAIDA requests execute in parallel using thread pool
- File Preservation: Original task IDs in filenames are preserved
Before running Fix, coins must already be authenticated:
- Coins should have POWN strings with at least some 'p' (pass) characters
- Coins with all 'u' (untried) should run Detect first
- Coins with 0 passes cannot be fixed (likely counterfeit)
Error Responses
Common error responses when the endpoint is fully implemented:
No Active Wallet
{
"status": "error",
"operation": "fix-fracked",
"message": "No active wallet set"
}
No Fracked Coins
{
"status": "success",
"operation": "fix-fracked",
"message": "No coins found in Fracked folder",
"initial_fracked": 0,
"fixed": 0,
"still_fracked": 0,
"counterfeit": 0,
"rounds": 0
}
Insufficient Ticket Sources
{
"status": "error",
"operation": "fix-fracked",
"message": "No RAIDAs have 'p' (pass) status - coins need authentication first",
"initial_fracked": 5,
"fixed": 0,
"still_fracked": 5,
"counterfeit": 0,
"rounds": 2
}
Related Endpoints
/api/wallet/show-coins
View all coins in the active wallet, including those in the Fracked folder with POWN strings.
/api/coins/grade
Sort coins into Bank, Fracked, and Counterfeit folders based on POWN authentication results.
/api/coins/detect
Authenticate coins with all 25 RAIDA servers to generate POWN strings.
CLI Implementation Reference
The Fix command is fully implemented in the CLI version (CloudCoinConsole):
// From commands.c - cmd_fix_coins()
// Location: D:\code\C Language\CloudCoinConsole\src\commands.c:6648
cc_result_t cmd_fix_coins(void) {
// 1. Read coins from Fracked folder
// 2. For each RAIDA, build "needs fixing" list (non-'p' status)
// 3. For each RAIDA, build "needs tickets" list ('p' status)
// 4. Send Get Ticket (0x0228) requests in parallel
// 5. Collect tickets from successful responses
// 6. Send Fix (0x0250) requests with tickets
// 7. Update POWN strings based on results
// 8. Write coins to Grade folder
// 9. Run Grade command to sort coins
// 10. Repeat up to 10 rounds or until no changes
// Returns: CC_SUCCESS or error code
}
Source File: D:\code\C Language\CloudCoinConsole\src\commands.c (line 6648)
API Handler: D:\code\C Language\CloudCoinConsole\src\api_handlers.c (line 693-704)