mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
refactor: rename FirstKeyTimeChanged to MaybeUpdateBirthTime
In the following-up commit, the wallet birth time will also
be modified by the transactions scanning process. When a tx
older than all descriptor's timestamp is detected.
Github-Pull: #28920
Rebased-From: b4306e3c8d
This commit is contained in:
parent
35039ac3cc
commit
074296dd60
2 changed files with 9 additions and 7 deletions
|
@ -1763,11 +1763,11 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::FirstKeyTimeChanged(const ScriptPubKeyMan* spkm, int64_t new_birth_time)
|
void CWallet::MaybeUpdateBirthTime(int64_t time)
|
||||||
{
|
{
|
||||||
int64_t birthtime = m_birth_time.load();
|
int64_t birthtime = m_birth_time.load();
|
||||||
if (new_birth_time < birthtime) {
|
if (time < birthtime) {
|
||||||
m_birth_time = new_birth_time;
|
m_birth_time = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3494,10 +3494,12 @@ LegacyScriptPubKeyMan* CWallet::GetOrCreateLegacyScriptPubKeyMan()
|
||||||
|
|
||||||
void CWallet::AddScriptPubKeyMan(const uint256& id, std::unique_ptr<ScriptPubKeyMan> spkm_man)
|
void CWallet::AddScriptPubKeyMan(const uint256& id, std::unique_ptr<ScriptPubKeyMan> spkm_man)
|
||||||
{
|
{
|
||||||
|
// Add spkm_man to m_spk_managers before calling any method
|
||||||
|
// that might access it.
|
||||||
const auto& spkm = m_spk_managers[id] = std::move(spkm_man);
|
const auto& spkm = m_spk_managers[id] = std::move(spkm_man);
|
||||||
|
|
||||||
// Update birth time if needed
|
// Update birth time if needed
|
||||||
FirstKeyTimeChanged(spkm.get(), spkm->GetTimeFirstKey());
|
MaybeUpdateBirthTime(spkm->GetTimeFirstKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::SetupLegacyScriptPubKeyMan()
|
void CWallet::SetupLegacyScriptPubKeyMan()
|
||||||
|
@ -3530,7 +3532,7 @@ void CWallet::ConnectScriptPubKeyManNotifiers()
|
||||||
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
|
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
|
||||||
spk_man->NotifyWatchonlyChanged.connect(NotifyWatchonlyChanged);
|
spk_man->NotifyWatchonlyChanged.connect(NotifyWatchonlyChanged);
|
||||||
spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged);
|
spk_man->NotifyCanGetAddressesChanged.connect(NotifyCanGetAddressesChanged);
|
||||||
spk_man->NotifyFirstKeyTimeChanged.connect(std::bind(&CWallet::FirstKeyTimeChanged, this, std::placeholders::_1, std::placeholders::_2));
|
spk_man->NotifyFirstKeyTimeChanged.connect(std::bind(&CWallet::MaybeUpdateBirthTime, this, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -678,8 +678,8 @@ public:
|
||||||
bool ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const std::map<CKeyID, CPubKey>& pubkey_map, const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
bool ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const std::map<CKeyID, CPubKey>& pubkey_map, const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
bool ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
bool ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
/** Updates wallet birth time if 'new_birth_time' is below it */
|
/** Updates wallet birth time if 'time' is below it */
|
||||||
void FirstKeyTimeChanged(const ScriptPubKeyMan* spkm, int64_t new_birth_time);
|
void MaybeUpdateBirthTime(int64_t time);
|
||||||
|
|
||||||
CFeeRate m_pay_tx_fee{DEFAULT_PAY_TX_FEE};
|
CFeeRate m_pay_tx_fee{DEFAULT_PAY_TX_FEE};
|
||||||
unsigned int m_confirm_target{DEFAULT_TX_CONFIRM_TARGET};
|
unsigned int m_confirm_target{DEFAULT_TX_CONFIRM_TARGET};
|
||||||
|
|
Loading…
Add table
Reference in a new issue