Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 2,925 Lines • ▼ Show 20 Lines | const RPCHelpMan help{ | ||||
"outputs that the wallet can sign\n" | "outputs that the wallet can sign\n" | ||||
" \"trusted\": xxx (numeric) trusted balance " | " \"trusted\": xxx (numeric) trusted balance " | ||||
"(outputs created by the wallet or confirmed outputs)\n" | "(outputs created by the wallet or confirmed outputs)\n" | ||||
" \"untrusted_pending\": xxx (numeric) untrusted " | " \"untrusted_pending\": xxx (numeric) untrusted " | ||||
"pending balance (outputs created by others that are in the " | "pending balance (outputs created by others that are in the " | ||||
"mempool)\n" | "mempool)\n" | ||||
" \"immature\": xxx (numeric) balance from " | " \"immature\": xxx (numeric) balance from " | ||||
"immature coinbase outputs\n" | "immature coinbase outputs\n" | ||||
" \"used\": xxx (numeric) (only present if " | |||||
"avoid_reuse is set) balance from coins sent to addresses that " | |||||
"were previously spent from (potentially privacy violating)\n" | |||||
" },\n" | " },\n" | ||||
" \"watchonly\": { (object) watchonly " | " \"watchonly\": { (object) watchonly " | ||||
"balances (not present if wallet does not watch anything)\n" | "balances (not present if wallet does not watch anything)\n" | ||||
" \"trusted\": xxx (numeric) trusted balance " | " \"trusted\": xxx (numeric) trusted balance " | ||||
"(outputs created by the wallet or confirmed outputs)\n" | "(outputs created by the wallet or confirmed outputs)\n" | ||||
" \"untrusted_pending\": xxx (numeric) untrusted " | " \"untrusted_pending\": xxx (numeric) untrusted " | ||||
"pending balance (outputs created by others that are in the " | "pending balance (outputs created by others that are in the " | ||||
"mempool)\n" | "mempool)\n" | ||||
Show All 21 Lines | static UniValue getbalances(const Config &config, | ||||
const auto bal = wallet.GetBalance(); | const auto bal = wallet.GetBalance(); | ||||
UniValue balances{UniValue::VOBJ}; | UniValue balances{UniValue::VOBJ}; | ||||
{ | { | ||||
UniValue balances_mine{UniValue::VOBJ}; | UniValue balances_mine{UniValue::VOBJ}; | ||||
balances_mine.pushKV("trusted", ValueFromAmount(bal.m_mine_trusted)); | balances_mine.pushKV("trusted", ValueFromAmount(bal.m_mine_trusted)); | ||||
balances_mine.pushKV("untrusted_pending", | balances_mine.pushKV("untrusted_pending", | ||||
ValueFromAmount(bal.m_mine_untrusted_pending)); | ValueFromAmount(bal.m_mine_untrusted_pending)); | ||||
balances_mine.pushKV("immature", ValueFromAmount(bal.m_mine_immature)); | balances_mine.pushKV("immature", ValueFromAmount(bal.m_mine_immature)); | ||||
if (wallet.IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE)) { | |||||
// If the AVOID_REUSE flag is set, bal has been set to just the | |||||
// un-reused address balance. Get the total balance, and then | |||||
// subtract bal to get the reused address balance. | |||||
const auto full_bal = wallet.GetBalance(0, false); | |||||
balances_mine.pushKV( | |||||
"used", ValueFromAmount(full_bal.m_mine_trusted + | |||||
full_bal.m_mine_untrusted_pending - | |||||
bal.m_mine_trusted - | |||||
bal.m_mine_untrusted_pending)); | |||||
} | |||||
balances.pushKV("mine", balances_mine); | balances.pushKV("mine", balances_mine); | ||||
} | } | ||||
if (wallet.HaveWatchOnly()) { | if (wallet.HaveWatchOnly()) { | ||||
UniValue balances_watchonly{UniValue::VOBJ}; | UniValue balances_watchonly{UniValue::VOBJ}; | ||||
balances_watchonly.pushKV("trusted", | balances_watchonly.pushKV("trusted", | ||||
ValueFromAmount(bal.m_watchonly_trusted)); | ValueFromAmount(bal.m_watchonly_trusted)); | ||||
balances_watchonly.pushKV( | balances_watchonly.pushKV( | ||||
"untrusted_pending", | "untrusted_pending", | ||||
▲ Show 20 Lines • Show All 2,026 Lines • Show Last 20 Lines |