GetKeyBirthTimes should return key ids, not destinations
This commit is contained in:
parent
70946e7fee
commit
78e407ad0c
3 changed files with 7 additions and 10 deletions
|
@ -807,19 +807,16 @@ UniValue dumpwallet(const JSONRPCRequest& request)
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
||||||
|
|
||||||
std::map<CTxDestination, int64_t> mapKeyBirth;
|
std::map<CKeyID, int64_t> mapKeyBirth;
|
||||||
const std::map<CKeyID, int64_t>& mapKeyPool = pwallet->GetAllReserveKeys();
|
const std::map<CKeyID, int64_t>& mapKeyPool = pwallet->GetAllReserveKeys();
|
||||||
pwallet->GetKeyBirthTimes(*locked_chain, mapKeyBirth);
|
pwallet->GetKeyBirthTimes(*locked_chain, mapKeyBirth);
|
||||||
|
|
||||||
std::set<CScriptID> scripts = pwallet->GetCScripts();
|
std::set<CScriptID> scripts = pwallet->GetCScripts();
|
||||||
// TODO: include scripts in GetKeyBirthTimes() output instead of separate
|
|
||||||
|
|
||||||
// sort time/key pairs
|
// sort time/key pairs
|
||||||
std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
|
std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
|
||||||
for (const auto& entry : mapKeyBirth) {
|
for (const auto& entry : mapKeyBirth) {
|
||||||
if (const PKHash* keyID = boost::get<PKHash>(&entry.first)) { // set and test
|
vKeyBirth.push_back(std::make_pair(entry.second, entry.first));
|
||||||
vKeyBirth.push_back(std::make_pair(entry.second, CKeyID(*keyID)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mapKeyBirth.clear();
|
mapKeyBirth.clear();
|
||||||
std::sort(vKeyBirth.begin(), vKeyBirth.end());
|
std::sort(vKeyBirth.begin(), vKeyBirth.end());
|
||||||
|
|
|
@ -3761,14 +3761,14 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const
|
||||||
|
|
||||||
/** @} */ // end of Actions
|
/** @} */ // end of Actions
|
||||||
|
|
||||||
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t>& mapKeyBirth) const {
|
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CKeyID, int64_t>& mapKeyBirth) const {
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
mapKeyBirth.clear();
|
mapKeyBirth.clear();
|
||||||
|
|
||||||
// get birth times for keys with metadata
|
// get birth times for keys with metadata
|
||||||
for (const auto& entry : mapKeyMetadata) {
|
for (const auto& entry : mapKeyMetadata) {
|
||||||
if (entry.second.nCreateTime) {
|
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<C
|
||||||
const int max_height = tip_height && *tip_height > 144 ? *tip_height - 144 : 0; // the tip can be reorganized; use a 144-block safety margin
|
const int max_height = tip_height && *tip_height > 144 ? *tip_height - 144 : 0; // the tip can be reorganized; use a 144-block safety margin
|
||||||
std::map<CKeyID, int> mapKeyFirstBlock;
|
std::map<CKeyID, int> mapKeyFirstBlock;
|
||||||
for (const CKeyID &keyid : GetKeys()) {
|
for (const CKeyID &keyid : GetKeys()) {
|
||||||
if (mapKeyBirth.count(PKHash(keyid)) == 0)
|
if (mapKeyBirth.count(keyid) == 0)
|
||||||
mapKeyFirstBlock[keyid] = max_height;
|
mapKeyFirstBlock[keyid] = max_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3805,7 +3805,7 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<C
|
||||||
|
|
||||||
// Extract block timestamps for those keys
|
// Extract block timestamps for those keys
|
||||||
for (const auto& entry : mapKeyFirstBlock)
|
for (const auto& entry : mapKeyFirstBlock)
|
||||||
mapKeyBirth[PKHash(entry.first)] = locked_chain.getBlockTime(entry.second) - TIMESTAMP_WINDOW; // block times can be 2h off
|
mapKeyBirth[entry.first] = locked_chain.getBlockTime(entry.second) - TIMESTAMP_WINDOW; // block times can be 2h off
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -898,7 +898,7 @@ public:
|
||||||
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
|
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
|
||||||
bool EncryptWallet(const SecureString& strWalletPassphrase);
|
bool EncryptWallet(const SecureString& strWalletPassphrase);
|
||||||
|
|
||||||
void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
unsigned int ComputeTimeSmart(const CWalletTx& wtx) const;
|
unsigned int ComputeTimeSmart(const CWalletTx& wtx) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue