Overview
Description This PR changes the return format of -getinfo
Rationale
- make
-getinfo
more 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
0// Data from getblockchaininfo
1Chain: [getblockchaininfo.chain]
2Blocks: [getblockchaininfo.blocks]
3Headers: [getblockchaininfo.headers]
4Verification progress: [getblockchaininfo.verificationprogress]
5Difficulty: [getblockchaininfo.difficulty]
6
7# Data from getnetworkinfo
8Network: in [getnetworkinfo.connections_in], out [getnetworkinfo.connections_out], total [getnetworkinfo.connections]
9Version: [getnetworkinfo.version]
10Time offset (s): [getnetworkinfo.timeoffset]
11Proxy: [getnetworkinfo.proxy] // "N/A" if no proxy
12Min tx relay fee rate (BTC/kvB): [getnetworkinfo.relayfee]
13
14# Data from getwalletinfo. Will only be present when a single wallet is loaded
15Wallet: [getnetworkinfo.walletname] // "" if walletname is empty(default wallet)
16Keypool size: [getnetworkinfo.keypoolsize]
17Unlocked until: [getnetworkinfo.unlocked_until]
18Transaction fee rate (-paytxfee) (BTC/kvB): [getnetworkinfo.paytxfee]
19
20# Data from getbalances. Will only be present when a single wallet is loaded
21Balance: [getbalances.mine.trusted]
22
23# Data from listwallets then getbalances for each wallet. Will only be present for multiple wallets loaded
24Balances
25[getbalances.mine.trusted] [listwallets[i]] // Right justify on balance
26
27Warnings: [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
chain
andnetwork
segment
2. Single wallet loaded
- When only a single wallet loaded or
-rpcwallet
is 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
,wallet
andbalance
segment
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
,network
andbalances
segment
Implementation
Current Flow
GetinfoRequestHandler
is instantiatedConnectAndCallRPC
is called withGetinfoRequestHandler
. It returnsUniValue::VOBJ result
- If
-rpcwallet
wallet is not set,GetWalletBalances
is called with a pointer toresult
as a parameter. It adds the balances for all the wallets toresult
New Flow
GetinfoRequestHandler
is instantiatedConnectAndCallRPC
is called withGetinfoRequestHandler
. It returnsUniValue::VOBJ result
- If
-rpcwallet
wallet is not set,GetWalletBalances
is called with a pointer toresult
as a parameter. It adds the balances for all the wallets toresult
- New
ParseGetInfoResult
is called withresult
as parameter. It converts results type fromUniValue::VOBJ
toUniValue::VSTR
according to the format stated above.