feat: chain status command + wallet info + core/api SSE tracking
Some checks failed
Security Scan / security (push) Successful in 15s
Test / Test (push) Failing after 36s

chain status: live chain data from daemon RPC
  height, difficulty, aliases, sync state, HF5 countdown

wallet info: full wallet dump
  standard/integrated/auditable addresses, spend/view keys, seed

core/api now has WithSSEPath() for configurable SSE — ready for
go-blockchain integration when wiring as core/api service.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 03:04:05 +01:00
parent f8756c287b
commit b22eba2d45
No known key found for this signature in database
GPG key ID: AF404715446AEB41
3 changed files with 96 additions and 0 deletions

53
cmd_status.go Normal file
View file

@ -0,0 +1,53 @@
// Copyright (c) 2017-2026 Lethean (https://lt.hn)
//
// Licensed under the European Union Public Licence (EUPL) version 1.2.
// SPDX-License-Identifier: EUPL-1.2
package blockchain
import (
"dappco.re/go/core"
"dappco.re/go/core/blockchain/rpc"
"github.com/spf13/cobra"
)
func newStatusCmd(dataDir, seed *string, testnet *bool) *cobra.Command {
return &cobra.Command{
Use: "status",
Short: "Show chain and network status",
RunE: func(cmd *cobra.Command, args []string) error {
return runStatus(*seed, *testnet)
},
}
}
func runStatus(seed string, testnet bool) error {
rpcURL := seedToRPC(seed, testnet)
client := rpc.NewClient(rpcURL)
info, err := client.GetInfo()
if err != nil {
core.Print(nil, "Daemon unreachable at %s", rpcURL)
return err
}
core.Print(nil, "Lethean Chain Status")
core.Print(nil, " Height: %d", info.Height)
core.Print(nil, " Difficulty: %d", info.PowDifficulty)
core.Print(nil, " Aliases: %d", info.AliasCount)
core.Print(nil, " TX Pool: %d", info.TxPoolSize)
core.Print(nil, " PoS: %v", info.PosAllowed)
core.Print(nil, " Synced: %v", info.DaemonNetworkState == 2)
core.Print(nil, "")
// Hardfork status
hf5Remaining := int64(11500) - int64(info.Height)
if hf5Remaining > 0 {
core.Print(nil, "")
core.Print(nil, " HF5 in %d blocks (~%.1f hours)", hf5Remaining, float64(hf5Remaining)*2/60)
}
return nil
}

View file

@ -43,6 +43,7 @@ func AddWalletCommands(root *cobra.Command) {
newWalletScanCmd(&walletFile),
newWalletRestoreCmd(&walletFile),
newWalletTransferCmd(&walletFile),
newWalletInfoCmd(&walletFile),
)
root.AddCommand(walletCmd)
@ -431,3 +432,44 @@ func runWalletTransfer(walletRPC, destination string, amount float64, paymentID
return nil
}
func newWalletInfoCmd(walletFile *string) *cobra.Command {
return &cobra.Command{
Use: "info",
Short: "Show full wallet information",
RunE: func(cmd *cobra.Command, args []string) error {
return runWalletInfo(*walletFile)
},
}
}
func runWalletInfo(walletFile string) error {
if walletFile == "" {
walletFile = core.JoinPath(defaultDataDir(), "wallet.db")
}
s, err := store.New(walletFile)
if err != nil {
return coreerr.E("runWalletInfo", "open wallet store", err)
}
defer s.Close()
account, err := wallet.LoadAccount(s, "")
if err != nil {
return coreerr.E("runWalletInfo", "load wallet", err)
}
addr := account.Address()
seed, _ := account.ToSeed()
core.Print(nil, "Wallet Information")
core.Print(nil, " File: %s", walletFile)
core.Print(nil, " Address: %s", addr.Encode(0x1eaf7))
core.Print(nil, " Integrated: %s", addr.Encode(0xdeaf7))
core.Print(nil, " Auditable: %s", addr.Encode(0x3ceff7))
core.Print(nil, " Spend Key: %x", account.SpendPublicKey[:])
core.Print(nil, " View Key: %x", account.ViewPublicKey[:])
core.Print(nil, " Seed: %s", seed)
return nil
}

View file

@ -38,6 +38,7 @@ func AddChainCommands(root *cobra.Command) {
newExplorerCmd(&dataDir, &seed, &testnet),
newSyncCmd(&dataDir, &seed, &testnet),
newServeCmd(&dataDir, &seed, &testnet),
newStatusCmd(&dataDir, &seed, &testnet),
)
root.AddCommand(chainCmd)