diff options
author | Andrew Chow <achow101-github@achow101.com> | 2019-07-09 19:34:39 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2020-04-23 13:59:48 -0400 |
commit | 4cb9b69be031e1dc65d8964794781b347fd948f5 (patch) | |
tree | d8d3eef84d7e236aa175892e8e357f2436432ed9 /src/wallet/scriptpubkeyman.cpp | |
parent | d1ec3e4f19487b4b100f80ad02eac063c571777d (diff) |
Implement several simple functions in DescriptorScriptPubKeyMan
Implements a bunch of one liners: UpgradeKeyMetadata, IsFirstRun, HavePrivateKeys,
KeypoolCountExternalKeys, GetKeypoolSize, GetTimeFirstKey, CanGetAddresses,
RewriteDB
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index d651816e58..fbba42f50d 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -1561,12 +1561,18 @@ bool DescriptorScriptPubKeyMan::IsHDEnabled() const bool DescriptorScriptPubKeyMan::CanGetAddresses(bool internal) const { - return false; + // We can only give out addresses from descriptors that are single type (not combo), ranged, + // and either have cached keys or can generate more keys (ignoring encryption) + LOCK(cs_desc_man); + return m_wallet_descriptor.descriptor->IsSingleType() && + m_wallet_descriptor.descriptor->IsRange() && + (HavePrivateKeys() || m_wallet_descriptor.next_index < m_wallet_descriptor.range_end); } bool DescriptorScriptPubKeyMan::HavePrivateKeys() const { - return false; + LOCK(cs_desc_man); + return m_map_keys.size() > 0 || m_map_crypted_keys.size() > 0; } int64_t DescriptorScriptPubKeyMan::GetOldestKeyPoolTime() const @@ -1576,17 +1582,22 @@ int64_t DescriptorScriptPubKeyMan::GetOldestKeyPoolTime() const size_t DescriptorScriptPubKeyMan::KeypoolCountExternalKeys() const { - return 0; + if (m_internal) { + return 0; + } + return GetKeyPoolSize(); } unsigned int DescriptorScriptPubKeyMan::GetKeyPoolSize() const { - return 0; + LOCK(cs_desc_man); + return m_wallet_descriptor.range_end - m_wallet_descriptor.next_index; } int64_t DescriptorScriptPubKeyMan::GetTimeFirstKey() const { - return 0; + LOCK(cs_desc_man); + return m_wallet_descriptor.creation_time; } std::unique_ptr<SigningProvider> DescriptorScriptPubKeyMan::GetSolvingProvider(const CScript& script) const |