Skip to content

Commit 78e407a

Browse files
committed
GetKeyBirthTimes should return key ids, not destinations
1 parent 70946e7 commit 78e407a

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/wallet/rpcdump.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,19 +807,16 @@ UniValue dumpwallet(const JSONRPCRequest& request)
807807
if (!file.is_open())
808808
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
809809

810-
std::map<CTxDestination, int64_t> mapKeyBirth;
810+
std::map<CKeyID, int64_t> mapKeyBirth;
811811
const std::map<CKeyID, int64_t>& mapKeyPool = pwallet->GetAllReserveKeys();
812812
pwallet->GetKeyBirthTimes(*locked_chain, mapKeyBirth);
813813

814814
std::set<CScriptID> scripts = pwallet->GetCScripts();
815-
// TODO: include scripts in GetKeyBirthTimes() output instead of separate
816815

817816
// sort time/key pairs
818817
std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
819818
for (const auto& entry : mapKeyBirth) {
820-
if (const PKHash* keyID = boost::get<PKHash>(&entry.first)) { // set and test
821-
vKeyBirth.push_back(std::make_pair(entry.second, CKeyID(*keyID)));
822-
}
819+
vKeyBirth.push_back(std::make_pair(entry.second, entry.first));
823820
}
824821
mapKeyBirth.clear();
825822
std::sort(vKeyBirth.begin(), vKeyBirth.end());

src/wallet/wallet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,14 +3761,14 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const
37613761

37623762
/** @} */ // end of Actions
37633763

3764-
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t>& mapKeyBirth) const {
3764+
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CKeyID, int64_t>& mapKeyBirth) const {
37653765
AssertLockHeld(cs_wallet);
37663766
mapKeyBirth.clear();
37673767

37683768
// get birth times for keys with metadata
37693769
for (const auto& entry : mapKeyMetadata) {
37703770
if (entry.second.nCreateTime) {
3771-
mapKeyBirth[PKHash(entry.first)] = entry.second.nCreateTime;
3771+
mapKeyBirth[entry.first] = entry.second.nCreateTime;
37723772
}
37733773
}
37743774

@@ -3777,7 +3777,7 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<C
37773777
const int max_height = tip_height && *tip_height > 144 ? *tip_height - 144 : 0; // the tip can be reorganized; use a 144-block safety margin
37783778
std::map<CKeyID, int> mapKeyFirstBlock;
37793779
for (const CKeyID &keyid : GetKeys()) {
3780-
if (mapKeyBirth.count(PKHash(keyid)) == 0)
3780+
if (mapKeyBirth.count(keyid) == 0)
37813781
mapKeyFirstBlock[keyid] = max_height;
37823782
}
37833783

@@ -3805,7 +3805,7 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<C
38053805

38063806
// Extract block timestamps for those keys
38073807
for (const auto& entry : mapKeyFirstBlock)
3808-
mapKeyBirth[PKHash(entry.first)] = locked_chain.getBlockTime(entry.second) - TIMESTAMP_WINDOW; // block times can be 2h off
3808+
mapKeyBirth[entry.first] = locked_chain.getBlockTime(entry.second) - TIMESTAMP_WINDOW; // block times can be 2h off
38093809
}
38103810

38113811
/**

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific
898898
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
899899
bool EncryptWallet(const SecureString& strWalletPassphrase);
900900

901-
void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
901+
void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
902902
unsigned int ComputeTimeSmart(const CWalletTx& wtx) const;
903903

904904
/**

0 commit comments

Comments
 (0)