/api/wallets/delete

GET

Removes a wallet from the configuration without deleting the wallet directory from the filesystem.

Real Example

Click the link below to test deleting a wallet (WARNING: This will actually delete the wallet if it exists and has no coins):

Description

The `/api/wallets/delete` endpoint removes a wallet from the CloudCoin Console configuration by deleting its entry from wallet-locations.csv. The wallet directory and all its contents remain on disk and can be re-added later if needed.

⚠️ Default Wallet Protection

The Default wallet in the Default location cannot be deleted. This is a safety feature to ensure the system always has at least one accessible wallet.

💡 Important Note

This operation only removes the wallet from the configuration file. The wallet directory, including all coins and data, remains untouched on the filesystem. If you need to re-add the wallet later, use `/api/wallet/add-location` with the same path.

📝 Use Cases
  • Temporarily hide a wallet from the wallet list
  • Clean up wallet configuration without losing data
  • Remove duplicate or misconfigured wallet entries
  • Reorganize wallet management without file operations

Parameters

Query Parameters

wallet_path string required
Absolute path to the wallet directory to delete (e.g., E:DataWalletsMyWallet). The wallet must have zero balance in Bank and Fracked folders.

Response

Returns a JSON object indicating the result of the delete operation.

Success Response Properties

command string
Always "success" when the wallet is removed from configuration.
success string
Always "wallet-delete".
wallet_path string
The wallet index that was deleted.
wallet string
Name of the wallet that was removed from configuration.
message string
Confirmation message: "Wallet deleted from configuration".
note string
Reminder that "The wallet directory still exists on disk".

Success Response Example

{
  "command": "wallet-delete",
  "success": true,
  "index": 0,
  "wallet": "TestWallet",
  "message": "Wallet deleted from configuration",
  "note": "The wallet directory still exists on disk"
}

Error Responses

The endpoint returns different error codes depending on the failure reason.

HTTP 400 - Missing Parameter

{
  "status": "error",
  "success": true,
  "error_code": 400,
  "message": "Missing 'index' parameter"
}

HTTP 403 - Cannot Delete Default Wallet

{
  "status": "error",
  "success": true,
  "error_code": 403,
  "message": "Cannot delete the Default wallet"
}

HTTP 400 - Invalid Wallet Index

{
  "status": "error",
  "success": true,
  "error_code": 400,
  "message": "Invalid wallet index"
}

HTTP 500 - Configuration Save Failed

{
  "status": "error",
  "success": true,
  "error_code": 500,
  "message": "Failed to save wallet configuration"
}

Examples

JavaScript (fetch)

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

async function deleteWallet(walletPath) {
    try {
        const url = `${API_HOST}/api/wallets/delete?wallet_path=${encodeURIComponent(walletPath)}`;
        const response = await fetch(url);
        const result = await response.json();

        if (result.status === 'success') {
            console.log(`✓ ${result.message}`);
            console.log(`Index: ${result.index}`);
            console.log(`Wallet: ${result.wallet}`);
            console.log(`Note: ${result.note}`);
        } else {
            console.error(`Error: ${result.message}`);
        }
    } catch (error) {
        console.error('Request failed:', error);
    }
}

// Delete wallet at index 0 from configuration
deleteWallet(0);

cURL

# Delete wallet from configuration - Windows
curl -X DELETE "http://localhost:8080/api/wallets/delete?wallet_path=E:\Data\Wallets\Default"

# Linux/macOS
# curl -X DELETE "http://localhost:8080/api/wallets/delete?wallet_path=/home/user/CloudCoin/Wallets/Default"

# With verbose output
curl -v -X DELETE "http://localhost:8080/api/wallets/delete?wallet_path=E:\Data\Wallets\Default"

# Note: This only removes from config - directory remains on disk

Go

package main

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

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

type DeleteWalletResponse struct {
    Status    string `json:"status"`
    Operation string `json:"operation"`
    Index     int    `json:"index"`
    Wallet    string `json:"wallet"`
    Message   string `json:"message"`
    Note      string `json:"note"`
}

type ErrorResponse struct {
    Status    string `json:"status"`
    Operation string `json:"operation"`
    ErrorCode int    `json:"error_code"`
    Message   string `json:"message"`
}

func deleteWallet(walletPath string) error {
    // Build URL with query parameter
    apiUrl := fmt.Sprintf("%s/api/wallets/delete?wallet_path=%s",
        ApiHost, url.QueryEscape(walletPath))

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

    body, _ := ioutil.ReadAll(resp.Body)

    // Check for success
    if resp.StatusCode == http.StatusOK {
        var result DeleteWalletResponse
        if err := json.Unmarshal(body, &result); err != nil {
            return err
        }

        fmt.Printf("✓ %s\n", result.Message)
        fmt.Printf("Index: %d\n", result.Index)
        fmt.Printf("Wallet: %s\n", result.Wallet)
        fmt.Printf("Note: %s\n", result.Note)
        return nil
    }

    // Handle error response
    var errResult ErrorResponse
    if err := json.Unmarshal(body, &errResult); err != nil {
        return err
    }

    return fmt.Errorf("error %d: %s", errResult.ErrorCode, errResult.Message)
}

func main() {
    if err := deleteWallet(0); err != nil {
        fmt.Printf("Failed: %v\n", err)
    }
}

Implementation Details

Understanding how the delete operation works internally:

  1. Parameter Validation: Checks that the 'index' parameter is provided in the query string.
  2. Index Validation: Validates that the wallet index is within valid range (0 to wallet count - 1).
  3. Wallet Retrieval: Retrieves the wallet at the specified index from wallet-locations.csv.
  4. Default Protection: Returns HTTP 403 if attempting to delete the "Default" wallet in the Default location.
  5. Config Update: Removes the wallet entry from the configuration array and shifts remaining entries.
  6. Count Decrement: Decreases the wallet_location_count by 1.
  7. Save Changes: Persists the updated configuration to wallet-locations.csv.
  8. Filesystem Untouched: The wallet directory and all its contents remain on disk.
💡 Pro Tip

If you accidentally delete a wallet from configuration, you can easily restore it using `/api/wallet/add-location` with the original path. All your coins and data will still be there since the directory was never deleted.

Related Endpoints

/api/wallet/list

View all configured wallets to see which ones are available for deletion.

/api/wallet/create

Create a new wallet with proper directory structure.

/api/wallet/add-location

Re-add a wallet to the configuration by specifying its filesystem path.