/api/wallet/delete
GETRemoves a wallet from the configuration without deleting the wallet directory from the filesystem.
Description
The `/api/wallet/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 using `/api/wallet/add-location`.
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.
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.
- 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
Response
Returns a JSON object indicating the result of the delete operation.
Success Response Properties
Success Response Example
{
"status": "success",
"operation": "wallet-delete",
"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",
"operation": "wallet-delete",
"error_code": 400,
"message": "Missing required parameter: name"
}
HTTP 403 - Cannot Delete Default Wallet
{
"status": "error",
"operation": "wallet-delete",
"error_code": 403,
"message": "Cannot delete the Default wallet"
}
HTTP 404 - Wallet Not Found
{
"status": "error",
"operation": "wallet-delete",
"error_code": 404,
"message": "Wallet 'TestWallet' not found"
}
HTTP 500 - Configuration Save Failed
{
"status": "error",
"operation": "wallet-delete",
"error_code": 500,
"message": "Failed to save wallet configuration"
}
Examples
JavaScript (fetch)
const API_HOST = 'http://localhost:8080';
async function deleteWallet(walletName) {
try {
const url = `${API_HOST}/api/wallet/delete?name=${encodeURIComponent(walletName)}`;
const response = await fetch(url);
const result = await response.json();
if (result.status === 'success') {
console.log(`✓ ${result.message}`);
console.log(`Wallet: ${result.wallet}`);
console.log(`Note: ${result.note}`);
} else {
console.error(`Error: ${result.message}`);
}
} catch (error) {
console.error('Request failed:', error);
}
}
// Delete a wallet from configuration
deleteWallet('TestWallet');
cURL
# Delete a wallet from configuration
curl -X GET "http://localhost:8080/api/wallet/delete?name=TestWallet"
# With verbose output
curl -v -X GET "http://localhost:8080/api/wallet/delete?name=TestWallet"
# 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"`
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(walletName string) error {
// Build URL with query parameter
apiUrl := fmt.Sprintf("%s/api/wallet/delete?name=%s",
ApiHost, url.QueryEscape(walletName))
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("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("TestWallet"); err != nil {
fmt.Printf("Failed: %v\n", err)
}
}
Implementation Details
Understanding how the delete operation works internally:
- Parameter Validation: Checks that the 'name' parameter is provided in the query string.
- Wallet Search: Searches for the wallet in the wallet-locations.csv configuration file.
- Not Found Check: Returns HTTP 404 if the wallet name doesn't exist in the configuration.
- Default Protection: Returns HTTP 403 if attempting to delete the "Default" wallet in the Default location.
- Config Update: Removes the wallet entry from the configuration array and shifts remaining entries.
- Count Decrement: Decreases the wallet_location_count by 1.
- Save Changes: Persists the updated configuration to wallet-locations.csv.
- Filesystem Untouched: The wallet directory and all its contents remain on disk.
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/add-location
Re-add a wallet to the configuration by specifying its filesystem path.