/api/wallets/delete

GET

Deletes an empty wallet folder and removes it from the wallet registry.

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 deletes the wallet directory from disk, removes the matching entry from wallet_paths.txt, and saves the updated registry.

⚠️ 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

The wallet must be empty before it can be deleted. If the Bank or Fracked folder still contains coin files, the API returns an error telling the caller to empty the wallet first.

📝 Use Cases
  • Remove an unused empty wallet completely
  • Clean up a stale wallet registry entry and folder together
  • Delete test wallets after validation
  • Prevent accidental deletion of wallets that still contain coins

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 "wallet-delete".
success boolean
True when the wallet folder was deleted and the registry was updated.
wallet_path string
Normalized path of the wallet that was deleted.
message string
Confirmation message: "Wallet deleted successfully".

Success Response Example

{
  "command": "wallet-delete",
  "success": true,
  "wallet_path": "E:/Client_Data/Wallets/TestWallet",
  "message": "Wallet deleted successfully"
}

Error Responses

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

HTTP 400 - Missing Parameter

{
  "error": true,
  "message": "Missing required parameter: wallet_path",
  "code": 400
}

HTTP 400 - Cannot Delete Default Wallet

{
  "error": true,
  "message": "Cannot delete the Default wallet",
  "code": 400
}

HTTP 400 - Wallet Not Empty

{
  "error": true,
  "message": "Wallet is not empty. Empty the Bank and Fracked folders before deleting it.",
  "code": 400
}

HTTP 404 - Wallet Not Found In Registry

{
  "error": true,
  "message": "Wallet not found in registry",
  "code": 404
}

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.success) {
            console.log(`✓ ${result.message}`);
            console.log(`Deleted: ${result.wallet_path}`);
        } else {
            console.error(`Error: ${result.message}`);
        }
    } catch (error) {
        console.error('Request failed:', error);
    }
}

// Delete an empty wallet by path
deleteWallet('E:/Client_Data/Wallets/TestWallet');

cURL

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

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

# With verbose output
curl -v -X DELETE "http://localhost:8080/api/wallets/delete?wallet_path=E:\Client_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. Path Validation: Resolves and normalizes the supplied wallet_path.
  2. Registry Check: Confirms the wallet exists in the registry loaded from wallet_paths.txt.
  3. Default Protection: Refuses to delete the Default wallet.
  4. Empty Wallet Guard: Refuses deletion if Bank or Fracked still contains coin files.
  5. Filesystem Delete: Removes the wallet directory tree from disk.
  6. Registry Save: Removes the matching entry and writes the updated wallet_paths.txt.
💡 Pro Tip

Call `/api/wallets/balance` or `/api/wallets/show-coins` first if you want to confirm the wallet is empty before deleting it.

Related Endpoints

/api/wallets/list

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

/api/wallets/create

Create a new wallet with proper directory structure.

/api/wallets/locations

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