Overview
Description This PR changes the return format of -getinfo
Rationale
- make
-getinfomore user-friendly - uses less vertical screen space.
Fixes: Issue 17314(Not linking issue to prevent it from closing)
Alternative, more human-friendly, format besides JSON? Colors, progress bars
Return Format
// Data from getblockchaininfo
Chain: [getblockchaininfo.chain]
Blocks: [getblockchaininfo.blocks]
Headers: [getblockchaininfo.headers]
Verification progress: [getblockchaininfo.verificationprogress]
Difficulty: [getblockchaininfo.difficulty]
# Data from getnetworkinfo
Network: in [getnetworkinfo.connections_in], out [getnetworkinfo.connections_out], total [getnetworkinfo.connections]
Version: [getnetworkinfo.version]
Time offset (s): [getnetworkinfo.timeoffset]
Proxy: [getnetworkinfo.proxy] // "N/A" if no proxy
Min tx relay fee rate (BTC/kvB): [getnetworkinfo.relayfee]
# Data from getwalletinfo. Will only be present when a single wallet is loaded
Wallet: [getnetworkinfo.walletname] // "" if walletname is empty(default wallet)
Keypool size: [getnetworkinfo.keypoolsize]
Unlocked until: [getnetworkinfo.unlocked_until]
Transaction fee rate (-paytxfee) (BTC/kvB): [getnetworkinfo.paytxfee]
# Data from getbalances. Will only be present when a single wallet is loaded
Balance: [getbalances.mine.trusted]
# Data from listwallets then getbalances for each wallet. Will only be present for multiple wallets loaded
Balances
[getbalances.mine.trusted] [listwallets[i]] // Right justify on balance
Warnings: [getnetworkinfo.warnings]
Coloring
The following lines would be colored to better show the differences between the various -getinfo components. However, this will not apply for WIN32(ANSI code not supported) and users that connect the stdout to a non-terminal process.
Chain: ...: BLUE(\x1B[34m)Network: ...: GREEN(\x1B[32m)Wallet: ...: MAGENTA(\x1B[35m)Balance: ...CYAN(\x1B[36m)Balances: ...CYAN(\x1B[36m)Warnings: ...Yellow(\x1B[33m)
Screenshots
No wallet loaded:

Single wallet loaded

Multi wallet loaded

Reviewing Notes
Testing Scenarios
1. No wallet loaded
- When there no wallets are loaded(Unload wallet with
./src/bitcoin-cli unloadwallet "YOUR_WALLETNAME" - Test with
./src/bitcoin-cli -getinfo. - Should only display
chainandnetworksegment
2. Single wallet loaded
- When only a single wallet loaded or
-rpcwalletis set(Load wallet with./src/bitcoin-cli loadwallet "YOUR_WALLETNAME") - Test with
./src/bitcoin-cli -rpcwallet="YOUR_WALLETNAME" -getinfo(Load wallet with./src/bitcoin-cli loadwallet "YOUR_WALLETNAME") - Should only display
chain,network,walletandbalancesegment
3. Multiple wallet loaded
- When there are multiple wallets loaded(Load wallet with
./src/bitcoin-cli loadwallet "YOUR_WALLETNAME") - Test with
./src/bitcoin-cli -getinfo - Should only display
chain,networkandbalancessegment
Implementation
Current Flow
GetinfoRequestHandleris instantiatedConnectAndCallRPCis called withGetinfoRequestHandler. It returnsUniValue::VOBJ result- If
-rpcwalletwallet is not set,GetWalletBalancesis called with a pointer toresultas a parameter. It adds the balances for all the wallets toresult
New Flow
GetinfoRequestHandleris instantiatedConnectAndCallRPCis called withGetinfoRequestHandler. It returnsUniValue::VOBJ result- If
-rpcwalletwallet is not set,GetWalletBalancesis called with a pointer toresultas a parameter. It adds the balances for all the wallets toresult - New
ParseGetInfoResultis called withresultas parameter. It converts results type fromUniValue::VOBJtoUniValue::VSTRaccording to the format stated above.







Multi wallet

























</details>

