From 78e407ad0c26190a22de1bc8ed900164a44a36c3 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Mon, 29 Apr 2019 10:14:47 -0400 Subject: [PATCH] GetKeyBirthTimes should return key ids, not destinations --- src/wallet/rpcdump.cpp | 7 ++----- src/wallet/wallet.cpp | 8 ++++---- src/wallet/wallet.h | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 6d54522ad4..9ca47807c2 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -807,19 +807,16 @@ UniValue dumpwallet(const JSONRPCRequest& request) if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); - std::map mapKeyBirth; + std::map mapKeyBirth; const std::map& mapKeyPool = pwallet->GetAllReserveKeys(); pwallet->GetKeyBirthTimes(*locked_chain, mapKeyBirth); std::set scripts = pwallet->GetCScripts(); - // TODO: include scripts in GetKeyBirthTimes() output instead of separate // sort time/key pairs std::vector > vKeyBirth; for (const auto& entry : mapKeyBirth) { - if (const PKHash* keyID = boost::get(&entry.first)) { // set and test - vKeyBirth.push_back(std::make_pair(entry.second, CKeyID(*keyID))); - } + vKeyBirth.push_back(std::make_pair(entry.second, entry.first)); } mapKeyBirth.clear(); std::sort(vKeyBirth.begin(), vKeyBirth.end()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d18d33868a..b4eda10009 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3761,14 +3761,14 @@ void CWallet::ListLockedCoins(std::vector& vOutpts) const /** @} */ // end of Actions -void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map& mapKeyBirth) const { +void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map& mapKeyBirth) const { AssertLockHeld(cs_wallet); mapKeyBirth.clear(); // get birth times for keys with metadata for (const auto& entry : mapKeyMetadata) { if (entry.second.nCreateTime) { - mapKeyBirth[PKHash(entry.first)] = entry.second.nCreateTime; + mapKeyBirth[entry.first] = entry.second.nCreateTime; } } @@ -3777,7 +3777,7 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map 144 ? *tip_height - 144 : 0; // the tip can be reorganized; use a 144-block safety margin std::map mapKeyFirstBlock; for (const CKeyID &keyid : GetKeys()) { - if (mapKeyBirth.count(PKHash(keyid)) == 0) + if (mapKeyBirth.count(keyid) == 0) mapKeyFirstBlock[keyid] = max_height; } @@ -3805,7 +3805,7 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); unsigned int ComputeTimeSmart(const CWalletTx& wtx) const; /**