/api/program/detect-lost-encryption
GETScans the active wallet for encrypted coin files and detects which RAIDA servers have lost encryption keys.
Description
The `/api/program/detect-lost-encryption` endpoint analyzes all encrypted coin files in the Bank and Fracked folders of the active wallet. For each coin, it examines the POWN string to determine which of the 25 RAIDA servers have valid encryption keys ('p' status) versus those that have lost keys (any non-'p' status).
This diagnostic endpoint is critical for identifying encryption key loss situations where coins are encrypted but the client-server shared secrets have been corrupted or lost. Without valid encryption keys, encrypted operations with those RAIDAs will fail.
If 13 or more RAIDAs (out of 25) have lost encryption keys, your encrypted coins may become inaccessible. The threshold for CloudCoin authenticity is 13+ passes, so losing 13+ RAIDA connections is considered critical.
This endpoint is essential for:
- Recovery workflows: Pre-flight check before attempting encrypted operations
- Encryption key management: Identify which RAIDAs need key restoration
- Wallet health checks: Periodic diagnostics to detect encryption degradation
- Troubleshooting: Diagnose why encrypted operations are failing
- Migration planning: Assess encryption status before moving wallets
How It Works
- Folder Scan: Reads all `.bin` files from Bank and Fracked folders
- Coin Analysis: For each coin file, reads the header including the POWN string
- POWN String Parsing: Examines all 25 characters (one per RAIDA) in the POWN string
- Key Detection: A RAIDA has a valid key if its POWN character is 'p' (pass/authenticated)
- Lost Key Identification: RAIDAs with any non-'p' status ('f', 'e', 'n', 'u', etc.) are considered to have lost keys
- Summary Generation: Counts total coins, lost RAIDAs, and provides recommendations
The POWN string uses these status codes:
p- Pass (valid encryption key)f- Fail (counterfeit/rejected)e- Error (RAIDA error response)n- No reply (timeout)u- Untried (never authenticated)b- Broken encryption keyd- Dropped (network error)
Parameters
This endpoint does not require any parameters. It automatically analyzes the currently active wallet.
An active wallet must be set. If no wallet is active, the endpoint returns an error. Use /api/program/login to set the active wallet first.
Response
Returns a JSON object with detailed encryption key status information.
Response Properties
Example Response - Healthy Wallet
{
"status": "success",
"operation": "detect-lost-encryption",
"summary": {
"bank_coins": 42,
"fracked_coins": 3,
"total_coins": 45,
"lost_raida_count": 0
},
"lost_raidas": [],
"raida_status": [
{ "raida_id": 0, "has_key": true },
{ "raida_id": 1, "has_key": true },
{ "raida_id": 2, "has_key": true },
// ... all 25 RAIDAs have keys
{ "raida_id": 24, "has_key": true }
],
"recommendation": "All RAIDAs have encryption keys available."
}
Example Response - Lost Connections Detected
{
"status": "success",
"operation": "detect-lost-encryption",
"summary": {
"bank_coins": 42,
"fracked_coins": 3,
"total_coins": 45,
"lost_raida_count": 5
},
"lost_raidas": [3, 7, 12, 18, 22],
"raida_status": [
{ "raida_id": 0, "has_key": true },
{ "raida_id": 1, "has_key": true },
{ "raida_id": 2, "has_key": true },
{ "raida_id": 3, "has_key": false },
// ...
{ "raida_id": 7, "has_key": false },
// ...
{ "raida_id": 24, "has_key": true }
],
"recommendation": "Lost connections detected. Run /api/fix-encryption to restore."
}
Example Response - Critical Status
{
"status": "success",
"operation": "detect-lost-encryption",
"summary": {
"bank_coins": 42,
"fracked_coins": 3,
"total_coins": 45,
"lost_raida_count": 15
},
"lost_raidas": [0, 1, 3, 4, 7, 9, 11, 12, 14, 15, 16, 18, 20, 22, 23],
"raida_status": [
{ "raida_id": 0, "has_key": false },
{ "raida_id": 1, "has_key": false },
{ "raida_id": 2, "has_key": true },
// ... 15 RAIDAs have lost keys
{ "raida_id": 24, "has_key": true }
],
"recommendation": "CRITICAL: Lost connections exceed threshold. Run /api/fix-encryption immediately."
}
Error Responses
Error: No Active Wallet
{
"status": "error",
"message": "No active wallet",
"error_code": 501
}
Examples
JavaScript (fetch)
const API_HOST = 'http://localhost:8080';
async function detectLostEncryption() {
try {
const response = await fetch(`${API_HOST}/api/program/detect-lost-encryption`);
const result = await response.json();
if (result.status === 'success') {
console.log('Encryption Status Report:');
console.log(`Total Coins Scanned: ${result.summary.total_coins}`);
console.log(` - Bank: ${result.summary.bank_coins}`);
console.log(` - Fracked: ${result.summary.fracked_coins}`);
console.log(`\nLost RAIDAs: ${result.summary.lost_raida_count}/25`);
if (result.lost_raidas.length > 0) {
console.log('RAIDAs with lost keys:', result.lost_raidas.join(', '));
}
console.log(`\nRecommendation: ${result.recommendation}`);
// Check if critical
if (result.summary.lost_raida_count >= 13) {
console.warn('⚠️ CRITICAL: Immediate action required!');
}
} else {
console.error('Error:', result.message);
}
} catch (error) {
console.error('Request failed:', error);
}
}
detectLostEncryption();
cURL
# Detect lost encryption connections
curl -X GET "http://localhost:8080/api/program/detect-lost-encryption"
# Pretty print with jq (if installed)
curl -s "http://localhost:8080/api/program/detect-lost-encryption" | jq .
# Check only the lost RAIDA count
curl -s "http://localhost:8080/api/program/detect-lost-encryption" | jq '.summary.lost_raida_count'
# List which RAIDAs have lost keys
curl -s "http://localhost:8080/api/program/detect-lost-encryption" | jq '.lost_raidas'
Go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
const ApiHost = "http://localhost:8080"
type Summary struct {
BankCoins int `json:"bank_coins"`
FrackedCoins int `json:"fracked_coins"`
TotalCoins int `json:"total_coins"`
LostRaidaCount int `json:"lost_raida_count"`
}
type RaidaStatus struct {
RaidaID int `json:"raida_id"`
HasKey bool `json:"has_key"`
}
type DetectResponse struct {
Status string `json:"status"`
Operation string `json:"operation"`
Summary Summary `json:"summary"`
LostRaidas []int `json:"lost_raidas"`
RaidaStatus []RaidaStatus `json:"raida_status"`
Recommendation string `json:"recommendation"`
}
func main() {
resp, err := http.Get(fmt.Sprintf("%s/api/program/detect-lost-encryption", ApiHost))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
var result DetectResponse
if err := json.Unmarshal(body, &result); err != nil {
panic(err)
}
fmt.Println("Encryption Status Report:")
fmt.Printf("Total Coins Scanned: %d\n", result.Summary.TotalCoins)
fmt.Printf(" - Bank: %d\n", result.Summary.BankCoins)
fmt.Printf(" - Fracked: %d\n", result.Summary.FrackedCoins)
fmt.Printf("\nLost RAIDAs: %d/25\n", result.Summary.LostRaidaCount)
if len(result.LostRaidas) > 0 {
fmt.Print("RAIDAs with lost keys: ")
for i, id := range result.LostRaidas {
if i > 0 {
fmt.Print(", ")
}
fmt.Printf("%d", id)
}
fmt.Println()
}
fmt.Printf("\nRecommendation: %s\n", result.Recommendation)
if result.Summary.LostRaidaCount >= 13 {
fmt.Println("⚠️ CRITICAL: Immediate action required!")
}
}
Understanding the Results
Severity Levels
What Causes Lost Encryption Keys?
- Database corruption: RAIDA server database corruption can lose stored shared secrets
- Network timeouts: Failed encryption handshakes during key establishment
- Server restarts: Non-persistent memory storage being cleared
- Manual key changes: Administrative changes to RAIDA encryption data
- Coin imports: Importing coins from another wallet with different encryption keys
Recovery Process
If lost encryption connections are detected, follow this recovery workflow:
- Detect: Run this endpoint to identify which RAIDAs have lost keys
- Fix: Use /api/program/fix-encryption to restore connections
- Verify: Run this endpoint again to confirm all keys are restored
- Monitor: Periodically check encryption health to catch issues early
The /api/program/fix-encryption endpoint uses the CloudCoin healing protocol (Get Ticket + Fix) to recover lost encryption connections. It collects authentication tickets from RAIDAs with valid keys and uses them to restore keys on RAIDAs that lost them.
Related Endpoints
/api/program/login
Set the active wallet for operations. Required before running detect-lost-encryption.
/api/program/fix-encryption
Recover lost encryption connections by running the healing protocol to restore RAIDA keys.
/api/coins/detect
Authenticate coins with RAIDA servers. Updates POWN strings that this endpoint analyzes.