/api/wallets/register

GET

Display a complete register of all denomination counts from 1,000,000 down to 0.00000001 CloudCoins.

Description

The `/api/wallets/register` endpoint provides a comprehensive inventory of all coin denominations in the active wallet's Bank and Fracked folders. It returns a complete register showing the count for every denomination from 1,000,000 down to 0.00000001, including denominations with zero coins.

This endpoint is useful for getting a quick overview of your wallet's coin distribution across all possible denominations.

Search Scope

This endpoint scans both the Bank (authenticated) and Fracked (partially authenticated) folders. Coins in other folders are not included in the register.

Complete Register

Unlike `/api/wallet/balance`, this endpoint shows all 15 denominations (metric powers of 10) including those with zero coins, providing a complete register view.

Parameters

This endpoint does not require any parameters. It automatically uses the active wallet.

Response

Returns a JSON object with a complete register of all denomination counts.

Response Properties

status string
Always "success" for successful requests.
operation string
Always "show-register".
register object
Object containing all denomination values as keys and coin counts as values.

Denomination Register

The register object contains the following denominations in descending order:

Denomination Example Count Denomination Example Count
"1000000" 0 "1" 50
"100000" 0 "0.1" 15
"10000" 1 "0.01" 8
"1000" 18 "0.001" 0
"100" 25 "0.0001" 14
"10" 30 "0.00001" 0
"0.000001" 0
"0.0000001" 0
"0.00000001" 0
"keys" 0 (NFT/Keys - only shown if count > 0)

Example Response

{
  "command": "show-register",
  "success": true,
  "register": {
    "1000000": 0,
    "100000": 0,
    "10000": 1,
    "1000": 18,
    "100": 25,
    "10": 30,
    "1": 50,
    "0.1": 15,
    "0.01": 8,
    "0.001": 0,
    "0.0001": 14,
    "0.00001": 0,
    "0.000001": 0,
    "0.0000001": 0,
    "0.00000001": 0
  }
}

Example Error Response (No Wallet)

{
  "error": "No active wallet set"
}

Examples

JavaScript (fetch)

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

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

        if (result.error) {
            console.error('Error:', result.error);
            return;
        }

        console.log('Wallet Register:');
        console.log('===============');

        // Calculate total coins and value
        let totalCoins = 0;
        let totalValue = 0;

        for (const [denom, count] of Object.entries(result.register)) {
            if (count > 0) {
                const denomValue = parseFloat(denom);
                totalCoins += count;
                totalValue += count * denomValue;
                console.log(`${denom.padEnd(12)} : ${count.toString().padStart(6)} coins`);
            }
        }

        console.log('===============');
        console.log(`Total Coins   : ${totalCoins}`);
        console.log(`Total Value   : ${totalValue.toLocaleString()} CC`);
    } catch (error) {
        console.error('Error fetching register:', error);
    }
}

// Usage - Windows
showRegister('E:\\Data\\Wallets\\Default');

// Usage - Linux/macOS
// showRegister('/home/user/CloudCoin/Wallets/Default');

cURL

# Windows - Get complete register
curl -X GET "http://localhost:8080/api/wallets/register?wallet_path=E:\Data\Wallets\Default"

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

# Pretty-print with jq
curl -X GET "http://localhost:8080/api/wallets/register?wallet_path=E:\Data\Wallets\Default" | jq

# Filter to show only non-zero denominations
curl -X GET "http://localhost:8080/api/wallets/register?wallet_path=E:\Data\Wallets\Default" | jq '.register | to_entries | map(select(.value > 0))'

Go

package main

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

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

type RegisterResponse struct {
    Status    string         `json:"status"`
    Operation string         `json:"operation"`
    Register  map[string]int `json:"register"`
}

func main() {
    // Windows path
    walletPath := "E:\\Data\\Wallets\\Default"
    // Linux/macOS path
    // walletPath := "/home/user/CloudCoin/Wallets/Default"

    url := fmt.Sprintf("%s/api/wallets/register?wallet_path=%s", ApiHost, url.QueryEscape(walletPath))
    resp, err := http.Get(url)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

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

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

    fmt.Println("Wallet Register:")
    fmt.Println("===============")

    totalCoins := 0
    totalValue := 0.0

    // Order by denomination (descending) - only metric powers of 10
    denoms := []string{
        "1000000", "100000", "10000", "1000", "100", "10", "1",
        "0.1", "0.01", "0.001", "0.0001", "0.00001",
        "0.000001", "0.0000001", "0.00000001",
    }

    for _, denom := range denoms {
        count := result.Register[denom]
        if count > 0 {
            denomValue, _ := strconv.ParseFloat(denom, 64)
            totalCoins += count
            totalValue += float64(count) * denomValue
            fmt.Printf("%-12s : %6d coins\n", denom, count)
        }
    }

    fmt.Println("===============")
    fmt.Printf("Total Coins   : %d\n", totalCoins)
    fmt.Printf("Total Value   : %.2f CC\n", totalValue)
}

Related Endpoints

/api/wallet/balance

Get wallet balance with total value - shows only denominations with non-zero counts.

/api/wallet/show-coins

List all coins in a specific folder with serial numbers and POWN strings.

/api/coins/grade

Sort coins into Bank, Fracked, or Counterfeit folders based on authentication status.