Skip to content

Commit

Permalink
Implement GetKeypoolOldestTime and only display it if greater than 0
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Apr 23, 2020
1 parent 586b57a commit f1ca5fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2439,7 +2439,7 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
{RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
{RPCResult::Type::STR_AMOUNT, "immature_balance", "DEPRECATED. Identical to getbalances().mine.immature"},
{RPCResult::Type::NUM, "txcount", "the total number of transactions in the wallet"},
{RPCResult::Type::NUM_TIME, "keypoololdest", "the " + UNIX_EPOCH_TIME + " of the oldest pre-generated key in the key pool"},
{RPCResult::Type::NUM_TIME, "keypoololdest", "the " + UNIX_EPOCH_TIME + " of the oldest pre-generated key in the key pool. Legacy wallets only."},
{RPCResult::Type::NUM, "keypoolsize", "how many new keys are pre-generated (only counts external keys)"},
{RPCResult::Type::NUM, "keypoolsize_hd_internal", "how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)"},
{RPCResult::Type::NUM_TIME, "unlocked_until", "the " + UNIX_EPOCH_TIME + " until which the wallet is unlocked for transfers, or 0 if the wallet is locked"},
Expand Down Expand Up @@ -2472,13 +2472,16 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)

size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
const auto bal = pwallet->GetBalance();
int64_t kp_oldest = pwallet->GetOldestKeyPoolTime();
obj.pushKV("walletname", pwallet->GetName());
obj.pushKV("walletversion", pwallet->GetVersion());
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime());
if (kp_oldest > 0) {
obj.pushKV("keypoololdest", kp_oldest);
}
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);

LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan();
Expand Down
4 changes: 3 additions & 1 deletion src/wallet/scriptpubkeyman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,9 @@ bool DescriptorScriptPubKeyMan::HavePrivateKeys() const

int64_t DescriptorScriptPubKeyMan::GetOldestKeyPoolTime() const
{
return GetTime();
// This is only used for getwalletinfo output and isn't relevant to descriptor wallets.
// The magic number 0 indicates that it shouldn't be displayed so that's what we return.
return 0;
}

size_t DescriptorScriptPubKeyMan::KeypoolCountExternalKeys() const
Expand Down

0 comments on commit f1ca5fe

Please sign in to comment.