#include "console_command_reference.h"

#include <cstddef>

namespace dragonx {
namespace ui {

namespace {

template <size_t N>
constexpr int CountOf(const ConsoleCommandEntry (&)[N])
{
    return static_cast<int>(N);
}

const ConsoleCommandEntry kControlCommands[] = {
    {"help", "List all commands, or get help for a specified command", "[\"command\"]",
     "Lists every RPC command. Pass a command name to see the node's detailed help for just that one.",
     "help \"getinfo\"", "commands list documentation what available"},
    {"getinfo", "Get general info about the node", "",
     "A quick snapshot of the node: version, block height, connection count, difficulty and wallet balance.",
     "getinfo", "status version summary overview node health"},
    {"stop", "Stop the daemon", "",
     "Shuts the DragonX node down cleanly. The wallet stays disconnected until the node is started again.",
     "stop", "quit shutdown exit close halt turn off", true},
};

const ConsoleCommandEntry kNetworkCommands[] = {
    {"getnetworkinfo", "Return P2P network state info", "",
     "The node's networking state: protocol version, which networks are active, listening addresses and relay fee.",
     "getnetworkinfo", "network p2p connection status internet"},
    {"getpeerinfo", "Get data about each connected peer", "",
     "Detailed data for every peer you are connected to \xE2\x80\x94 address, version, ping time and bytes exchanged.",
     "getpeerinfo", "peers connections nodes who connected"},
    {"getconnectioncount", "Get number of peer connections", "",
     "How many peers the node is currently connected to. Zero usually means the node is still starting or offline.",
     "getconnectioncount", "peers connections count how many"},
    {"getnettotals", "Get network traffic statistics", "",
     "Shows the total number of bytes your node has sent and received over the peer-to-peer network since it started. Useful for monitoring how much bandwidth the wallet is using.",
     "getnettotals", "bandwidth usage data traffic upload download network stats"},
    {"addnode", "Add, remove, or connect to a node", "\"node\" \"add|remove|onetry\"",
     "Manually connects your node to a specific peer by host or IP. Use 'add' to keep it in your list permanently, 'onetry' for a single connection attempt, or 'remove' to drop it. Handy when auto-discovery is not finding peers.",
     "addnode \"node.dragonx.is\" \"add\"", "connect peer manual node ip host disconnect no peers not connecting"},
    {"setban", "Add or remove an IP/subnet from the ban list", "\"ip\" \"add|remove\" [bantime] [absolute]",
     "Bans or unbans an IP or subnet from connecting. bantime is in seconds (0 = the default 24h); absolute treats it as a Unix timestamp.",
     "setban \"192.168.0.6\" \"add\" 86400", "ban block ip peer firewall reject", true},
    {"listbanned", "List all banned IPs/subnets", "",
     "Lists the IP addresses and subnets your node has banned, usually for misbehaving. Check it to see who you have blocked or to confirm before unbanning a peer.",
     "listbanned", "banned blocked ip ban list blacklist peers rejected"},
    {"clearbanned", "Clear all banned IPs", "",
     "Removes every entry from the ban list, letting all previously-banned peers connect again.",
     "clearbanned", "unban reset bans allow clear", true},
    {"ping", "Ping all peers to measure round-trip time", "",
     "Queues a ping to every connected peer to measure round-trip latency. Results are not returned here but show up in getpeerinfo; use it to check how responsive your connections are.",
     "ping", "latency ping peers round trip connection speed responsive test"},
};

const ConsoleCommandEntry kBlockchainCommands[] = {
    {"getblockchaininfo", "Get current blockchain state", "",
     "State of the chain: height, best block hash, difficulty, verification progress and how far the node has synced.",
     "getblockchaininfo", "chain sync height status blockchain progress"},
    {"getblockcount", "Get number of blocks in longest chain", "",
     "The height of the longest chain \xE2\x80\x94 how many blocks the node has. Compare with the network to check sync.",
     "getblockcount", "height blocks how many chain length synced"},
    {"getbestblockhash", "Get hash of the tip block", "",
     "Shows the ID (hash) of the newest block at the very top of the blockchain. Handy to confirm your node is synced to the current chain tip.",
     "getbestblockhash", "latest block tip newest current top synced chain head"},
    {"getblock", "Get block data for a given hash or height", "\"hash|height\" [verbosity]",
     "Returns a block by its hash or height. verbosity 0 = raw hex, 1 = decoded header + txids, 2 = full transactions.",
     "getblock \"0000000000abc123\" 1", "block details transactions header"},
    {"getblockhash", "Get block hash at a given height", "height",
     "Looks up the unique ID (hash) of the block at a specific height (block number). Use it to find a block by its position, then feed the hash to other commands.",
     "getblockhash 1000000", "block by height number find block id lookup height hash"},
    {"getblockheader", "Get block header for a given hash", "\"hash\" [verbose]",
     "Returns the header (summary info) of a block, such as its time, difficulty, and links to neighboring blocks. Add true for readable fields instead of raw hex.",
     "getblockheader \"0000000000abc123\" true", "block summary header time difficulty inspect block metadata"},
    {"getdifficulty", "Get proof-of-work difficulty", "",
     "Shows how hard it currently is to mine a new block. A higher number means more mining power is competing on the network.",
     "getdifficulty", "mining difficulty how hard hashrate network pow proof of work"},
    {"getrawmempool", "Get all txids in mempool", "[verbose]",
     "Lists the transaction IDs waiting in the mempool (unconfirmed, not yet in a block). Pass true for extra details like fee and size per transaction.",
     "getrawmempool true", "pending unconfirmed transactions waiting mempool queue not confirmed"},
    {"getmempoolinfo", "Get mempool state info", "",
     "Reports the overall state of the waiting-transaction pool: how many transactions are pending and how much memory they use.",
     "getmempoolinfo", "mempool size pending count unconfirmed pool stats memory"},
    {"gettxout", "Get details about an unspent output", "\"txid\" n [includemempool]",
     "Checks a specific transaction output to see if it is still unspent and how many coins it holds. The last flag controls whether the mempool is also searched.",
     "gettxout \"0000000000abc123\" 0 true", "unspent output utxo check coins available spendable balance"},
    {"coinsupply", "Get coin supply information", "[height]",
     "Reports the coin supply at a block height (transparent, shielded, and total), or at the current tip if no height is given. Useful for checking total supply.",
     "coinsupply 1000000", "total supply circulating coins how many emission money supply shielded"},
    {"getchaintips", "Get all known chain tips", "",
     "Lists all block-chain branch tips the node knows about, including the main chain and any stale forks. Mostly useful for diagnosing chain forks or reorgs.",
     "getchaintips", "forks branches chain tips reorg orphan stale diagnose"},
    {"getchaintxstats", "Get chain transaction statistics", "[nblocks] [\"blockhash\"]",
     "Gives statistics about transactions over a window of recent blocks, like total count and average transactions per second. Useful for gauging network activity.",
     "getchaintxstats 2016", "transaction stats network activity tx rate throughput volume history"},
    {"verifychain", "Verify the blockchain database", "[checklevel] [numblocks]",
     "Runs an integrity check on your local blockchain database to confirm it is not corrupted. A higher checklevel and more blocks mean a deeper, slower check.",
     "verifychain 3 288", "check database integrity verify blockchain corruption validate"},
    {"kvsearch", "Search the blockchain key-value store", "\"key\"",
     "Advanced/developer command. Looks up a value previously stored on-chain under a given key in DragonX's key-value store.",
     "kvsearch \"mykey\"", "lookup key value store read on-chain data retrieve kv developer"},
    {"kvupdate", "Update a key-value pair on-chain", "\"key\" \"value\" days",
     "Advanced/developer command. Stores or updates a key-value entry on the blockchain for a number of days (costs a fee); an optional passphrase can protect the key. Rarely needed by wallet users.",
     "kvupdate \"mykey\" \"myvalue\" 30", "write key value store on-chain data set update kv developer publish"},
};

const ConsoleCommandEntry kMiningCommands[] = {
    {"getmininginfo", "Get mining-related information", "",
     "Mining status: current difficulty, estimated network hash rate and whether this node is generating blocks.",
     "getmininginfo", "mining hashrate difficulty generate"},
    {"setgenerate", "Turn mining on or off  (true/false [threads])", "generate [genproclimit]",
     "Turns built-in CPU mining on or off. Pass true or false, and optionally the number of threads (-1 = all cores).",
     "setgenerate true 4", "mine mining generate cpu start stop", true},
    {"getgenerate", "Check if the node is mining", "",
     "Tells you whether the node's built-in CPU miner is currently turned on and trying to mine blocks. Handy to confirm mining is running or stopped.",
     "getgenerate", "mining on off status check am i mining is mining running generate"},
    {"getnetworkhashps", "Get estimated network hash rate", "[blocks] [height]",
     "Estimates the whole network's total mining power (solutions per second) over recent blocks. A higher number means more miners competing to find each block.",
     "getnetworkhashps 120 -1", "network hashrate mining power total speed solutions per second competition"},
    {"getblocksubsidy", "Get block reward at a given height", "[height]",
     "Shows the block reward (newly minted DRGX) paid for mining the block at a given height. Useful for checking current or future rewards; omit the height to use the current tip.",
     "getblocksubsidy 250000", "block reward mining payout coins subsidy how much earn per block"},
    {"getblocktemplate", "Get block template for mining", "[\"jsonrequestobject\"]",
     "Advanced/developer command: returns the raw data a mining program needs to assemble and work on a candidate block. Normal users mine via a pool or the built-in miner instead.",
     "getblocktemplate {\"capabilities\":[\"coinbasetxn\",\"workid\"]}", "mining template block work developer pool solo advanced candidate"},
    {"submitblock", "Submit a mined block to the network", "\"hexdata\"",
     "Advanced/developer command: submits a fully mined block (as raw hex) to the network. Only used by external mining software that built the block itself.",
     "submitblock \"0000000000abc123\"", "submit block mined broadcast solo mining developer advanced send block"},
};

const ConsoleCommandEntry kWalletCommands[] = {
    {"getbalance", "Get wallet transparent balance", "[\"account\"] [minconf]",
     "Your confirmed transparent (t-address) balance in DRGX. Shielded funds are NOT included \xE2\x80\x94 use z_gettotalbalance for everything.",
     "getbalance", "balance money funds how much transparent"},
    {"z_gettotalbalance", "Get total transparent + shielded balance", "[minconf]",
     "Your complete balance in DRGX \xE2\x80\x94 transparent plus shielded (private) funds together.",
     "z_gettotalbalance", "balance total money funds shielded private how much"},
    {"z_getbalances", "Get all balances (transparent + shielded)", "",
     "Breaks your balance down across each transparent and shielded address the wallet holds.",
     "z_getbalances", "balance breakdown addresses funds per address"},
    {"getnewaddress", "Generate a new transparent address", "",
     "Creates a fresh transparent (t-) address you can share to receive DRGX.",
     "getnewaddress", "receive new address deposit transparent create get paid"},
    {"z_getnewaddress", "Generate a new shielded address", "[\"type\"]",
     "Creates a fresh shielded (z-) address for receiving DRGX privately.",
     "z_getnewaddress", "receive new address private shielded create"},
    {"listaddresses", "List all transparent addresses", "",
     "Lists the transparent (t-) addresses in your wallet.",
     "listaddresses", "addresses list my accounts transparent"},
    {"z_listaddresses", "List all z-addresses", "",
     "Lists the shielded (z-) addresses in your wallet.",
     "z_listaddresses", "addresses list my shielded private"},
    {"sendtoaddress", "Send to a specific address", "\"address\" amount",
     "Sends DRGX to a transparent address. amount is in DRGX. Double-check the address \xE2\x80\x94 sent transactions cannot be reversed.",
     "sendtoaddress \"RyourRecipientAddr\" 1.5", "send pay transfer money spend", true},
    {"z_sendmany", "Send to multiple z/t-addresses with shielded support", "\"fromaddress\" [{\"address\":\"...\",\"amount\":...}]",
     "Sends DRGX from one address to one or more recipients, with shielded (private) support. Amounts are in DRGX.",
     "z_sendmany \"RfromAddr\" [{\"address\":\"zs1toAddr\",\"amount\":1.0}]", "send pay private shielded transfer money", true},
    {"z_shieldcoinbase", "Shield transparent coinbase funds to a z-address", "\"fromaddress\" \"tozaddress\" [fee] [limit]",
     "Moves newly mined (coinbase) transparent funds into a private shielded z-address, since mined rewards must be shielded before they can be spent normally. Runs in the background and returns an operation id.",
     "z_shieldcoinbase \"RyourMiningAddr\" \"zs1yourShieldedAddr\"", "shield mining rewards coinbase private hide mined funds move to shielded", true},
    {"z_mergetoaddress", "Merge multiple UTXOs/notes to one address", "[\"fromaddress\",...] \"toaddress\" [fee] [limit]",
     "Combines many small balances (from transparent and/or shielded addresses) into a single destination address in one transaction, to consolidate funds. Runs in the background and returns an operation id.",
     "z_mergetoaddress [\"RyourAddr\",\"zs1yourShieldedAddr\"] \"zs1destShieldedAddr\"", "merge combine consolidate funds sweep small balances into one address", true},
    {"listtransactions", "List recent wallet transactions", "[\"account\"] [count] [from]",
     "Your most recent wallet transactions, newest first \xE2\x80\x94 amounts, addresses and confirmations.",
     "listtransactions", "transactions history recent payments received sent"},
    {"listunspent", "List unspent transaction outputs", "[minconf] [maxconf]",
     "Lists your spendable transparent coins (unspent outputs), showing which addresses hold funds and how many confirmations each has. Useful to see exactly what's available to spend.",
     "listunspent 1", "unspent coins utxo available balance spendable transparent outputs"},
    {"z_listunspent", "List unspent shielded notes", "[minconf] [maxconf]",
     "Lists your spendable shielded notes (private z-address funds), showing amounts and confirmations. The private-address counterpart to listunspent.",
     "z_listunspent 1", "unspent shielded notes private balance available zaddr spendable notes"},
    {"z_getoperationstatus", "Get status of async z operations", "[\"operationid\",...]",
     "Checks whether a background shielded operation (like sending or shielding from a z-address) is still running, has succeeded, or has failed. Use the operation id returned when you started it.",
     "z_getoperationstatus [\"opid-00000000-abc1-2345-6789-000000000abc\"]", "check status pending operation progress is my send done async job"},
    {"z_getoperationresult", "Get result of completed z operations", "[\"operationid\",...]",
     "Fetches the final result (transaction id or any error) of a finished background shielded operation and then removes it from memory. Use after the status shows it completed.",
     "z_getoperationresult [\"opid-00000000-abc1-2345-6789-000000000abc\"]", "operation result txid outcome finished completed error async send"},
    {"z_listoperationids", "List all async z operation IDs", "",
     "Lists the ids of all your background shielded operations known to the node, so you can look up their status or results. Takes no arguments.",
     "z_listoperationids", "list operations pending jobs opids background async queue"},
    {"getwalletinfo", "Get wallet state info", "",
     "Wallet summary: balances, transaction count, key-pool size and whether the wallet is encrypted and locked.",
     "getwalletinfo", "wallet status info balance encrypted locked"},
    {"backupwallet", "Back up wallet to a file", "\"destination\"",
     "Saves a copy of your wallet.dat to the given path. Keep the backup somewhere safe and private.",
     "backupwallet \"/home/you/drgx-backup.dat\"", "backup save wallet copy protect"},
    {"dumpprivkey", "Dump private key for an address", "\"address\"",
     "Reveals the private key for an address. Anyone with this key can spend from the address \xE2\x80\x94 never share it.",
     "dumpprivkey \"RyourAddr\"", "private key export reveal secret spend", true},
    {"importprivkey", "Import a private key into the wallet", "\"privkey\" [\"label\"] [rescan]",
     "Imports a private key so the wallet can spend from its address, then rescans the chain for its history (can be slow).",
     "importprivkey \"Uxxxxxxxxxxxx\"", "import private key restore recover add", true},
    {"dumpwallet", "Dump all wallet keys to a file", "\"filename\"",
     "Writes a human-readable text file of your wallet's transparent private keys for backup. The file is saved into the daemon's configured -exportdir folder. Anyone with it can spend your funds, so store it securely.",
     "dumpwallet \"wallet-backup\"", "backup export private keys save wallet dump keys to file", true},
    {"importwallet", "Import wallet from a dump file", "\"filename\"",
     "Loads keys from a dumpwallet text file back into your wallet and rescans the chain for their funds. Use to restore a backup or add keys from another wallet. Advanced/recovery use.",
     "importwallet \"/home/you/wallet-backup.txt\"", "restore import keys recover load wallet backup from file", true},
    {"z_exportkey", "Export spending key for a z-address", "\"zaddr\"",
     "Reveals the spending key for a shielded address. Anyone with it can spend your private funds \xE2\x80\x94 keep it secret.",
     "z_exportkey \"zs1yourAddr\"", "private key export shielded secret spend", true},
    {"z_importkey", "Import a z-address spending key", "\"zkey\" [rescan] [startheight]",
     "Adds a shielded (z-address) spending key from another wallet so you can see and spend its private funds here. By default it rescans the chain, which can take a while. Advanced/recovery use.",
     "z_importkey \"secret-extended-key-main1yourZKeyHere\"", "import shielded key restore zaddr spending key recover private funds", true},
    {"z_exportviewingkey", "Export viewing key for a z-address", "\"zaddr\"",
     "Exports a view-only key for a shielded address, letting someone see its incoming funds and balance without being able to spend. Safe to share for auditing/monitoring.",
     "z_exportviewingkey \"zs1yourShieldedAddr\"", "export viewing key watch only audit read only shielded balance"},
    {"z_importviewingkey", "Import a z-address viewing key", "\"vkey\" [rescan] [startheight]",
     "Imports a view-only key so your wallet can watch a shielded address's incoming funds without being able to spend them. By default it rescans the chain. For monitoring/auditing.",
     "z_importviewingkey \"zviews1yourViewingKeyHere\"", "import viewing key watch only monitor shielded address audit read only", true},
    {"z_exportwallet", "Export all wallet keys (including z-keys) to file", "\"filename\"",
     "Writes a text-file backup of all your keys including shielded (z-address) spending keys, unlike dumpwallet which is transparent-only. Saved into the daemon's -exportdir folder; anyone with it can spend your funds.",
     "z_exportwallet \"full-wallet-backup\"", "backup export all keys shielded zkeys save wallet full to file", true},
    {"signmessage", "Sign a message with an address key", "\"address\" \"message\"",
     "Signs a message with the private key of one of your addresses, proving you control that address.",
     "signmessage \"RyourAddr\" \"hello world\"", "sign message prove ownership"},
    {"settxfee", "Set the transaction fee per kB", "amount",
     "Sets the fee you pay per kilobyte on transparent transactions, in DRGX. A higher fee can speed confirmation; set 0 to use the default. Applies until you change it or restart.",
     "settxfee 0.0001", "set fee transaction cost per kb miner fee change fee rate"},
    {"walletpassphrase", "Unlock the wallet with passphrase", "\"passphrase\" timeout",
     "Unlocks an encrypted wallet for the given number of seconds so you can send funds. Your passphrase is typed in plain text \xE2\x80\x94 be sure no one is watching.",
     "walletpassphrase \"your passphrase\" 60", "unlock passphrase password encrypted open", true},
    {"walletlock", "Lock the wallet", "",
     "Removes the encryption key from memory, locking the wallet so its keys can't spend until you unlock it again with your passphrase. Only works on an encrypted wallet.",
     "walletlock", "lock wallet secure re-lock protect passphrase disable spending"},
    {"encryptwallet", "Encrypt the wallet with a passphrase", "\"passphrase\"",
     "Encrypts the wallet with a passphrase. The node shuts down afterward and you will need the passphrase to send. Encryption cannot be undone \xE2\x80\x94 keep the passphrase safe.",
     "encryptwallet \"a strong passphrase\"", "encrypt password protect secure lock", true},
};

const ConsoleCommandEntry kRawTransactionCommands[] = {
    {"createrawtransaction", "Create a raw transaction spending given inputs", "[{\"txid\":\"...\",\"vout\":n},...] {\"address\":amount,...}",
     "Advanced/developer command. Builds an unsigned raw transaction from transparent inputs (txid+vout) you pick and transparent outputs you specify; returns only hex that you must still sign and broadcast. Cannot spend to or from shielded (zs1) addresses. Most users should just use the Send tab.",
     "createrawtransaction [{\"txid\":\"0000000000abc123\",\"vout\":0}] {\"RyourAddr\":1.0}", "build unsigned transaction manually craft raw tx construct spend inputs outputs advanced"},
    {"decoderawtransaction", "Decode raw transaction hex string", "\"hexstring\"",
     "Developer tool. Takes a raw transaction hex string and shows its contents in readable JSON (inputs, outputs, amounts, addresses, scripts). Useful for inspecting a transaction before you sign or broadcast it.",
     "decoderawtransaction \"0100000001abc123...\"", "inspect raw transaction hex read decode view contents parse tx examine"},
    {"decodescript", "Decode a hex-encoded script", "\"hex\"",
     "Developer tool. Turns a hex-encoded script into readable form and shows the address or spending condition it represents. Rarely needed unless you are debugging scripts, redeem scripts, or multisig setups.",
     "decodescript \"76a914abc123...88ac\"", "decode script hex readable inspect multisig p2sh redeemscript debug advanced"},
    {"getrawtransaction", "Get raw transaction data by txid", "\"txid\" [verbose]",
     "Look up a transaction by its txid and return its raw hex, or a decoded readable view if you pass 1 for verbose. Only finds a tx that is in the mempool, has an unspent output, or when the node runs with -txindex.",
     "getrawtransaction \"0000000000abc123\" 1", "lookup transaction by id fetch tx details verbose inspect view raw txindex"},
    {"sendrawtransaction", "Submit raw transaction to the network", "\"hexstring\" [allowhighfees]",
     "Advanced command. Broadcasts an already-signed raw transaction hex to the network so miners can include it in a block. This is the final step after building and signing a transaction by hand.",
     "sendrawtransaction \"0100000001abc123...\"", "broadcast submit signed transaction publish push to network relay send hex"},
    {"signrawtransaction", "Sign a raw transaction with private keys", "\"hexstring\"",
     "Advanced command. Signs a raw transaction using the private keys in your wallet so it becomes valid to broadcast. Returns the signed hex plus a 'complete' flag telling you whether it is fully signed and ready to send.",
     "signrawtransaction \"0100000001abc123...\"", "sign raw transaction authorize private key finalize validate ready to broadcast"},
    {"fundrawtransaction", "Add inputs to meet output value", "\"hexstring\"",
     "Advanced wallet command. Adds enough of your wallet's inputs (plus one change output) to a partial raw transaction so it covers its outputs and fee. The added inputs are unsigned, so you still need to sign and send it afterward.",
     "fundrawtransaction \"0100000000010000000000...\"", "add inputs fund coins cover amount select utxos change fee complete transaction"},
};

const ConsoleCommandEntry kUtilityCommands[] = {
    {"validateaddress", "Validate a transparent address", "\"address\"",
     "Checks whether a transparent address is well-formed and whether it belongs to your wallet.",
     "validateaddress \"RsomeAddr\"", "validate check address valid mine"},
    {"z_validateaddress", "Validate a z-address", "\"zaddr\"",
     "Checks whether a shielded (zs1...) address is valid and reports its type (sapling) and, if your wallet is loaded, whether the address belongs to you. Handy for double-checking a private address before sending to it.",
     "z_validateaddress \"zs1someAddr\"", "check shielded address valid private zaddr is this address mine verify z-address sapling"},
    {"estimatefee", "Estimate fee for a transaction", "nblocks",
     "Estimates the fee (per kilobyte) a transaction likely needs to start confirming within the given number of blocks. Returns -1 if the node hasn't seen enough activity to make a guess.",
     "estimatefee 6", "estimate fee cost transaction how much confirmation speed fee per kb suggested network fee"},
    {"verifymessage", "Verify a signed message", "\"address\" \"signature\" \"message\"",
     "Confirms that a signed message really came from the owner of a transparent (R...) address. You supply the address, its base64 signature, and the exact original message; it returns true or false.",
     "verifymessage \"RyourAddr\" \"H1234base64signature==\" \"the exact signed message\"", "verify signed message check signature prove ownership authenticate confirm sender validate proof"},
    {"createmultisig", "Create a multisig address", "nrequired [\"key\",...]",
     "Advanced: builds a multi-signature address that needs several keys to approve spending (e.g. 2-of-3). Returns the address and a redeem script you must keep in order to spend from it.",
     "createmultisig 2 [\"RfirstAddr\",\"RsecondAddr\",\"RthirdAddr\"]", "multisig shared wallet multiple signatures joint account m of n co-sign approval redeem script"},
    {"invalidateblock", "Mark a block as invalid", "\"hash\"",
     "Advanced/developer: forces your node to mark a specific block (and everything built on it) as invalid, rolling your local chain back to before it. Only for troubleshooting or testing; reversible with reconsiderblock.",
     "invalidateblock \"0000000000abc123\"", "reject block roll back chain reorg force invalid remove block undo block troubleshoot fork", true},
    {"reconsiderblock", "Reconsider a previously invalidated block", "\"hash\"",
     "Advanced/developer: clears the invalid mark on a block and its descendants so your node accepts them again and rejoins the normal chain. Used to reverse a previous invalidateblock.",
     "reconsiderblock \"0000000000abc123\"", "undo invalidate accept block again re-enable block restore chain reconsider fix rollback fork", true},
};

// ============================================================================
// Lite backend command set — the verbs the SDXL lite backend accepts (see its
// commands.rs get_commands()). Unlike the full node these are NOT JSON-RPC: the
// backend takes plain, space-separated tokens (no quoting), so the reference
// modal inserts them bare. clear/help/quit are intentionally omitted — the C++
// console tab intercepts those before they reach the backend.
// ============================================================================

const ConsoleCommandEntry kLiteWalletCommands[] = {
    {"balance", "Show your DRGX balance", "",
     "Shows the DRGX balance held in this wallet across all its shielded and transparent addresses.",
     "balance", "money funds amount total holdings"},
    {"addresses", "List all addresses in the wallet", "",
     "Lists every address this wallet owns \xE2\x80\x94 shielded (zs1...) and transparent (R.../t...) \xE2\x80\x94 so you can pick one to receive to.",
     "addresses", "receive address list wallet mine deposit"},
    {"new", "Create a new address in this wallet", "type",
     "Creates a fresh receive address. Pass zs for a shielded (private) sapling address, or R (a capital R) for a transparent one \xE2\x80\x94 those exact tokens (case-sensitive).",
     "new zs", "create address receive generate new shielded transparent zs"},
    {"list", "List all transactions in the wallet", "",
     "Shows the wallet's transaction history \xE2\x80\x94 sends, receives and shields \xE2\x80\x94 with amounts, addresses and confirmations.",
     "list", "history transactions txs payments activity sent received"},
    {"notes", "List sapling notes and UTXOs", "[all]",
     "Lists the individual shielded notes and transparent UTXOs that make up your balance. Pass all to include spent ones.",
     "notes", "utxo notes unspent coins inputs sapling"},
    {"info", "Get the lightwalletd server's info", "",
     "Reports the lightwalletd server the wallet is connected to \xE2\x80\x94 its version, chain and block height.",
     "info", "server node lightwalletd version connection status"},
};

const ConsoleCommandEntry kLiteSyncCommands[] = {
    {"sync", "Download compact blocks and sync to the server", "",
     "Fetches new compact blocks from the lightwalletd server and scans them for transactions belonging to this wallet.",
     "sync", "update refresh scan blocks download catch up"},
    {"syncstatus", "Get the sync status of the wallet", "",
     "Reports how far the wallet has synced \xE2\x80\x94 whether a sync is in progress and the block it has reached.",
     "syncstatus", "progress status syncing scanning percent blocks"},
    {"height", "Get the latest block height the wallet is at", "",
     "Shows the block height the wallet has scanned up to. Compare with the network height to gauge sync.",
     "height", "block height number chain tip synced"},
    {"rescan", "Rescan the wallet from scratch", "",
     "Discards the scanned state and re-downloads/re-scans every block from the wallet's birthday. Slow, but fixes a stuck or incomplete balance.",
     "rescan", "rescan resync repair fix balance rebuild from scratch"},
    {"save", "Save the wallet file to disk", "",
     "Writes the current wallet state to disk. The wallet also saves automatically after a sync or send.",
     "save", "save persist write disk store"},
};

const ConsoleCommandEntry kLiteSendCommands[] = {
    {"send", "Send DRGX to an address", "[{\"address\":\"zs1...\",\"amount\":0}]",
     "Sends DRGX from the console using a JSON array of recipients (the Send tab is the easy way; this is the power-user form). amount is in puposhis (the base unit); memo is optional and delivered privately to shielded recipients.",
     "send [{\"address\":\"zs1exampleaddress\",\"amount\":100000000,\"memo\":\"thanks\"}]",
     "pay transfer send spend money transaction json", true},
    {"shield", "Shield transparent DRGX into a sapling address", "[address]",
     "Moves your transparent (public) DRGX into a shielded sapling address for privacy. With no address it shields to the wallet's own sapling address.",
     "shield", "shield private sapling transparent move protect", true},
};

const ConsoleCommandEntry kLiteKeyCommands[] = {
    {"seed", "Display the wallet seed phrase", "",
     "Reveals the seed phrase that backs up this wallet. Anyone who sees it can spend your funds \xE2\x80\x94 keep it secret and offline.",
     "seed", "seed phrase mnemonic backup recovery words secret", true},
    {"export", "Export the private key for an address", "[address]",
     "Prints the private/spending key for a wallet address \xE2\x80\x94 anyone with it controls the funds. With no address it exports every key.",
     "export zs1exampleaddress", "export private key spending backup secret", true},
    {"import", "Import a spending or viewing key", "key",
     "Imports a shielded spending or viewing key (pass just the key). The wallet rescans from the sapling activation height to find the key's transactions.",
     "import somekey", "import restore key spending viewing add watch"},
    {"timport", "Import a transparent WIF private key", "wif",
     "Imports a transparent private key in WIF format (begins with U, 5, K or L) so the wallet can spend its funds.",
     "timport somewifkey", "import transparent wif private key taddr"},
    {"encrypt", "Encrypt the wallet with a password", "password",
     "Encrypts the wallet with a password and locks it immediately. You will need the password to send or reveal keys afterwards. If you forget it, only the seed phrase can recover the wallet.",
     "encrypt strongpassword", "encrypt password protect lock secure passphrase", true},
    {"decrypt", "Completely remove wallet encryption", "password",
     "Permanently removes the wallet's password encryption, leaving it unprotected on disk. Requires the current password.",
     "decrypt strongpassword", "decrypt remove encryption password unprotect", true},
    {"unlock", "Unlock the wallet for spending", "password",
     "Temporarily unlocks an encrypted wallet so it can send or reveal keys. Use lock to re-lock it.",
     "unlock strongpassword", "unlock password spend open temporarily"},
    {"lock", "Lock a temporarily-unlocked wallet", "",
     "Re-locks a wallet that was unlocked for spending, without removing its encryption.",
     "lock", "lock secure re-lock protect close"},
    {"encryptionstatus", "Check if the wallet is encrypted and locked", "",
     "Reports whether the wallet is encrypted and, if so, whether it is currently locked or unlocked.",
     "encryptionstatus", "encryption status locked unlocked encrypted state"},
};

const ConsoleCommandEntry kLiteAdvancedCommands[] = {
    {"sietch", "Create a Sietch address", "[type]",
     "Creates a Sietch address, used for enhanced-privacy sends. Pass zs for a sapling Sietch address.",
     "sietch zs", "sietch privacy address decoy sapling advanced"},
    {"saplingtree", "Dump the latest Sapling commitment tree (debug)", "",
     "Prints the latest Sapling commitment tree state \xE2\x80\x94 a debugging aid, not needed for everyday use.",
     "saplingtree", "sapling tree commitment debug advanced merkle"},
    {"coinsupply", "Get the coin supply info", "",
     "Reports coin-supply figures for the chain as seen by the wallet's server.",
     "coinsupply", "supply coins total emission circulating amount"},
};

} // namespace

const std::vector<ConsoleCommandCategory>& consoleCommandCategories()
{
    static const std::vector<ConsoleCommandCategory> categories = {
        {"Control",          kControlCommands,        CountOf(kControlCommands)},
        {"Network",          kNetworkCommands,        CountOf(kNetworkCommands)},
        {"Blockchain",       kBlockchainCommands,     CountOf(kBlockchainCommands)},
        {"Mining",           kMiningCommands,         CountOf(kMiningCommands)},
        {"Wallet",           kWalletCommands,         CountOf(kWalletCommands)},
        {"Raw Transactions", kRawTransactionCommands, CountOf(kRawTransactionCommands)},
        {"Utility",          kUtilityCommands,        CountOf(kUtilityCommands)},
    };
    return categories;
}

const std::vector<ConsoleCommandCategory>& liteConsoleCommandCategories()
{
    static const std::vector<ConsoleCommandCategory> categories = {
        {"Wallet",          kLiteWalletCommands,   CountOf(kLiteWalletCommands)},
        {"Sync",            kLiteSyncCommands,     CountOf(kLiteSyncCommands)},
        {"Send",            kLiteSendCommands,     CountOf(kLiteSendCommands)},
        {"Keys & Security", kLiteKeyCommands,      CountOf(kLiteKeyCommands)},
        {"Advanced",        kLiteAdvancedCommands, CountOf(kLiteAdvancedCommands)},
    };
    return categories;
}

} // namespace ui
} // namespace dragonx
