Skip to content

Commit f1ca5fe

Browse files
committed
Implement GetKeypoolOldestTime and only display it if greater than 0
1 parent 586b57a commit f1ca5fe

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,7 +2439,7 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
24392439
{RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
24402440
{RPCResult::Type::STR_AMOUNT, "immature_balance", "DEPRECATED. Identical to getbalances().mine.immature"},
24412441
{RPCResult::Type::NUM, "txcount", "the total number of transactions in the wallet"},
2442-
{RPCResult::Type::NUM_TIME, "keypoololdest", "the " + UNIX_EPOCH_TIME + " of the oldest pre-generated key in the key pool"},
2442+
{RPCResult::Type::NUM_TIME, "keypoololdest", "the " + UNIX_EPOCH_TIME + " of the oldest pre-generated key in the key pool. Legacy wallets only."},
24432443
{RPCResult::Type::NUM, "keypoolsize", "how many new keys are pre-generated (only counts external keys)"},
24442444
{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)"},
24452445
{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"},
@@ -2472,13 +2472,16 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
24722472

24732473
size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
24742474
const auto bal = pwallet->GetBalance();
2475+
int64_t kp_oldest = pwallet->GetOldestKeyPoolTime();
24752476
obj.pushKV("walletname", pwallet->GetName());
24762477
obj.pushKV("walletversion", pwallet->GetVersion());
24772478
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
24782479
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
24792480
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
24802481
obj.pushKV("txcount", (int)pwallet->mapWallet.size());
2481-
obj.pushKV("keypoololdest", pwallet->GetOldestKeyPoolTime());
2482+
if (kp_oldest > 0) {
2483+
obj.pushKV("keypoololdest", kp_oldest);
2484+
}
24822485
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
24832486

24842487
LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan();

src/wallet/scriptpubkeyman.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,9 @@ bool DescriptorScriptPubKeyMan::HavePrivateKeys() const
18511851

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

18571859
size_t DescriptorScriptPubKeyMan::KeypoolCountExternalKeys() const

0 commit comments

Comments
 (0)