/api/wallet/list

GET

Lists all configured wallets and their locations on the system.

Description

The `/api/wallet/list` endpoint returns information about all wallets configured in the CloudCoin Console system. Wallets are grouped by their location path, and the active wallet is indicated in the response.

💡 Active Wallet

The active wallet is marked with `"active": true` in the response. This is the wallet that will be used for all coin operations (import, export, balance checks, etc.).

📁 Wallet Organization

Wallets are organized by location (directory path). Multiple wallets can exist in the same location, and you can have wallets in different locations on the file system.

Parameters

This endpoint does not require any parameters.

Response

Returns a JSON object containing the list of wallets grouped by location.

Response Properties

status string
Always "success" if the request was processed.
operation string
The operation type - "wallet-list".
locations array
Array of location objects, each containing a path and array of wallets.
locations[].path string
The directory path where the wallets are located.
locations[].wallets array
Array of wallet objects at this location.
wallets[].index integer
The wallet's index in the global wallet list.
wallets[].name string
The wallet's name.
wallets[].active boolean
True if this is the currently active wallet.

Example Response (Success)

{
  "status": "success",
  "operation": "wallet-list",
  "locations": [
    {
      "path": "C:\\Users\\User\\MyWallet3",
      "wallets": [
        {
          "index": 0,
          "name": "Default",
          "active": true
        },
        {
          "index": 1,
          "name": "Savings",
          "active": false
        }
      ]
    },
    {
      "path": "D:\\CloudCoin\\Backup",
      "wallets": [
        {
          "index": 2,
          "name": "Archive",
          "active": false
        }
      ]
    }
  ]
}

Example Response (No Wallets)

{
  "status": "success",
  "operation": "wallet-list",
  "message": "No wallets configured",
  "count": 0,
  "locations": []
}

Examples

JavaScript (fetch)

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

async function listWallets() {
    try {
        const response = await fetch(`${API_HOST}/api/wallet/list`);
        const result = await response.json();

        if (result.status === 'success') {
            console.log('Wallets by location:');

            result.locations.forEach(location => {
                console.log(`\nLocation: ${location.path}`);
                location.wallets.forEach(wallet => {
                    const activeMarker = wallet.active ? ' (ACTIVE)' : '';
                    console.log(`  [${wallet.index}] ${wallet.name}${activeMarker}`);
                });
            });
        } else {
            console.error('Failed to list wallets:', result.error);
        }
    } catch (error) {
        console.error('Error listing wallets:', error);
    }
}

listWallets();

cURL

# List all configured wallets
curl -X GET "http://localhost:8080/api/wallet/list"

Go

package main

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

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

type Wallet struct {
    Index  int    `json:"index"`
    Name   string `json:"name"`
    Active bool   `json:"active"`
}

type Location struct {
    Path    string   `json:"path"`
    Wallets []Wallet `json:"wallets"`
}

type WalletListResponse struct {
    Status    string     `json:"status"`
    Operation string     `json:"operation"`
    Locations []Location `json:"locations"`
}

func main() {
    resp, err := http.Get(fmt.Sprintf("%s/api/wallet/list", ApiHost))
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

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

    var result WalletListResponse
    if err := json.Unmarshal(body, &result); err != nil {
        panic(err)
    }

    fmt.Println("Wallets by location:")
    for _, location := range result.Locations {
        fmt.Printf("\nLocation: %s\n", location.Path)
        for _, wallet := range location.Wallets {
            activeMarker := ""
            if wallet.Active {
                activeMarker = " (ACTIVE)"
            }
            fmt.Printf("  [%d] %s%s\n", wallet.Index, wallet.Name, activeMarker)
        }
    }
}

Related Endpoints

/api/wallet/balance

Check the balance of the active wallet to see total coin value.

/api/wallet/switch

Switch the active wallet to a different wallet from the list.

/api/wallet/create

Create a new wallet at a specified location.