mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
wallet: fix legacy spkm default birth time
To avoid scanning blocks, as assumed by a wallet with no generated keys or imported scripts, the default value for the birth time needs to be set to the maximum int64_t value. Once the first key is generated or the first script is imported, the legacy SPKM will update the birth time automatically.
This commit is contained in:
parent
75fbf444c1
commit
6f497377aa
2 changed files with 6 additions and 2 deletions
|
@ -709,7 +709,7 @@ void LegacyScriptPubKeyMan::UpdateTimeFirstKey(int64_t nCreateTime)
|
||||||
// Cannot determine birthday information, so set the wallet birthday to
|
// Cannot determine birthday information, so set the wallet birthday to
|
||||||
// the beginning of time.
|
// the beginning of time.
|
||||||
nTimeFirstKey = 1;
|
nTimeFirstKey = 1;
|
||||||
} else if (!nTimeFirstKey || nCreateTime < nTimeFirstKey) {
|
} else if (nTimeFirstKey == UNKNOWN_TIME || nCreateTime < nTimeFirstKey) {
|
||||||
nTimeFirstKey = nCreateTime;
|
nTimeFirstKey = nCreateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,9 @@ public:
|
||||||
virtual bool IsLocked() const = 0;
|
virtual bool IsLocked() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Constant representing an unknown spkm creation time
|
||||||
|
static constexpr int64_t UNKNOWN_TIME = std::numeric_limits<int64_t>::max();
|
||||||
|
|
||||||
//! Default for -keypool
|
//! Default for -keypool
|
||||||
static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
|
static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
|
||||||
|
|
||||||
|
@ -286,7 +289,8 @@ private:
|
||||||
WatchOnlySet setWatchOnly GUARDED_BY(cs_KeyStore);
|
WatchOnlySet setWatchOnly GUARDED_BY(cs_KeyStore);
|
||||||
WatchKeyMap mapWatchKeys GUARDED_BY(cs_KeyStore);
|
WatchKeyMap mapWatchKeys GUARDED_BY(cs_KeyStore);
|
||||||
|
|
||||||
int64_t nTimeFirstKey GUARDED_BY(cs_KeyStore) = 0;
|
// By default, do not scan any block until keys/scripts are generated/imported
|
||||||
|
int64_t nTimeFirstKey GUARDED_BY(cs_KeyStore) = UNKNOWN_TIME;
|
||||||
|
|
||||||
//! Number of pre-generated keys/scripts (part of the look-ahead process, used to detect payments)
|
//! Number of pre-generated keys/scripts (part of the look-ahead process, used to detect payments)
|
||||||
int64_t m_keypool_size GUARDED_BY(cs_KeyStore){DEFAULT_KEYPOOL_SIZE};
|
int64_t m_keypool_size GUARDED_BY(cs_KeyStore){DEFAULT_KEYPOOL_SIZE};
|
||||||
|
|
Loading…
Add table
Reference in a new issue