added staked totals to getwalletinfo
This commit is contained in:
parent
3ab7b8dc69
commit
4b5ff04114
2 changed files with 25 additions and 4 deletions
|
@ -2952,8 +2952,11 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
|
||||||
" \"walletname\": xxxxx, (string) the wallet name\n"
|
" \"walletname\": xxxxx, (string) the wallet name\n"
|
||||||
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
|
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
|
||||||
" \"balance\": xxxxxxx, (numeric) DEPRECATED. Identical to getbalances().mine.trusted\n"
|
" \"balance\": xxxxxxx, (numeric) DEPRECATED. Identical to getbalances().mine.trusted\n"
|
||||||
|
" \"available_balance\": xxxxxxx, (numeric) balance minus stakes in " + CURRENCY_UNIT + "\n"
|
||||||
|
" \"staked_claim_balance\": xxxxxxx, (numeric) total in claim reservations in " + CURRENCY_UNIT + "\n"
|
||||||
" \"unconfirmed_balance\": xxx, (numeric) DEPRECATED. Identical to getbalances().mine.untrusted_pending\n"
|
" \"unconfirmed_balance\": xxx, (numeric) DEPRECATED. Identical to getbalances().mine.untrusted_pending\n"
|
||||||
" \"immature_balance\": xxxxxx, (numeric) DEPRECATED. Identical to getbalances().mine.immature\n"
|
" \"immature_balance\": xxxxxx, (numeric) DEPRECATED. Identical to getbalances().mine.immature\n"
|
||||||
|
" \"staked_support_balance\": xxxxxxx, (numeric) total in support reservations in " + CURRENCY_UNIT + "\n"
|
||||||
" \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
|
" \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
|
||||||
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n"
|
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n"
|
||||||
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n"
|
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n"
|
||||||
|
@ -2986,12 +2989,17 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
|
|
||||||
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
|
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
|
||||||
const auto bal = pwallet->GetBalance();
|
|
||||||
obj.pushKV("walletname", pwallet->GetName());
|
obj.pushKV("walletname", pwallet->GetName());
|
||||||
obj.pushKV("walletversion", pwallet->GetVersion());
|
obj.pushKV("walletversion", pwallet->GetVersion());
|
||||||
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
|
auto balance = pwallet->GetBalance();
|
||||||
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
|
auto claims = pwallet->GetBalance(ISMINE_CLAIM);
|
||||||
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
|
auto supports = pwallet->GetBalance(ISMINE_SUPPORT);
|
||||||
|
obj.pushKV("balance", ValueFromAmount(balance.m_mine_trusted));
|
||||||
|
obj.pushKV("available_balance", ValueFromAmount(balance.m_mine_trusted - claims.m_mine_trusted - supports.m_mine_trusted));
|
||||||
|
obj.pushKV("staked_claim_balance", ValueFromAmount(claims));
|
||||||
|
obj.pushKV("staked_support_balance", ValueFromAmount(supports));
|
||||||
|
obj.pushKV("unconfirmed_balance", ValueFromAmount(balance.m_mine_untrusted_pending));
|
||||||
|
obj.pushKV("immature_balance", ValueFromAmount(balance.m_mine_immature));
|
||||||
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
|
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
|
||||||
obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime());
|
obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime());
|
||||||
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
|
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
|
||||||
|
|
|
@ -151,6 +151,17 @@ uint256 AbandonAClaim(const uint256& txid, bool isSupport = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ValidateBalance(double claims, double supports) {
|
||||||
|
rpcfn_type rpc_method = tableRPC["getwalletinfo"]->actor;
|
||||||
|
JSONRPCRequest req;
|
||||||
|
req.URI = "/wallet/tester_wallet";
|
||||||
|
req.params = UniValue(UniValue::VARR);
|
||||||
|
UniValue results = rpc_method(req);
|
||||||
|
BOOST_CHECK_EQUAL(claims, results["staked_claim_balance"].get_real());
|
||||||
|
BOOST_CHECK_EQUAL(supports, results["staked_support_balance"].get_real());
|
||||||
|
BOOST_CHECK_EQUAL(claims + supports, results["balance"].get_real() - results["available_balance"].get_real());
|
||||||
|
}
|
||||||
|
|
||||||
void AddClaimSupportThenRemove() {
|
void AddClaimSupportThenRemove() {
|
||||||
generateBlock(155);
|
generateBlock(155);
|
||||||
BOOST_CHECK_EQUAL(AvailableBalance(), 55.0);
|
BOOST_CHECK_EQUAL(AvailableBalance(), 55.0);
|
||||||
|
@ -190,6 +201,8 @@ void AddClaimSupportThenRemove() {
|
||||||
BOOST_CHECK_EQUAL(looked[1]["txid"].get_str(), spid.GetHex());
|
BOOST_CHECK_EQUAL(looked[1]["txid"].get_str(), spid.GetHex());
|
||||||
BOOST_CHECK_EQUAL(looked[1]["supported_claimid"].get_str(), clid);
|
BOOST_CHECK_EQUAL(looked[1]["supported_claimid"].get_str(), clid);
|
||||||
|
|
||||||
|
ValidateBalance(1.0, 0.5);
|
||||||
|
|
||||||
// abandon support
|
// abandon support
|
||||||
auto aid1 = AbandonAClaim(spid, true);
|
auto aid1 = AbandonAClaim(spid, true);
|
||||||
BOOST_CHECK(!aid1.IsNull());
|
BOOST_CHECK(!aid1.IsNull());
|
||||||
|
|
Loading…
Add table
Reference in a new issue