mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-05 09:21:01 +02:00
wallet: Move MigrateToDescriptor and DeleteRecords to LegacyDataSPKM
This commit is contained in:
parent
b231f4d556
commit
61d872f1b3
@ -1753,7 +1753,7 @@ std::unordered_set<CScript, SaltedSipHasher> LegacyDataSPKM::GetScriptPubKeys()
|
|||||||
return spks;
|
return spks;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan::GetNotMineScriptPubKeys() const
|
std::unordered_set<CScript, SaltedSipHasher> LegacyDataSPKM::GetNotMineScriptPubKeys() const
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
std::unordered_set<CScript, SaltedSipHasher> spks;
|
std::unordered_set<CScript, SaltedSipHasher> spks;
|
||||||
@ -1763,7 +1763,7 @@ std::unordered_set<CScript, SaltedSipHasher> LegacyScriptPubKeyMan::GetNotMineSc
|
|||||||
return spks;
|
return spks;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
|
std::optional<MigrationData> LegacyDataSPKM::MigrateToDescriptor()
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
if (m_storage.IsLocked()) {
|
if (m_storage.IsLocked()) {
|
||||||
@ -1830,7 +1830,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
|
|||||||
WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0);
|
WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0);
|
||||||
|
|
||||||
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
|
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
|
||||||
auto desc_spk_man = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(m_storage, w_desc, m_keypool_size));
|
auto desc_spk_man = std::make_unique<DescriptorScriptPubKeyMan>(m_storage, w_desc, /*keypool_size=*/0);
|
||||||
desc_spk_man->AddDescriptorKey(key, key.GetPubKey());
|
desc_spk_man->AddDescriptorKey(key, key.GetPubKey());
|
||||||
desc_spk_man->TopUp();
|
desc_spk_man->TopUp();
|
||||||
auto desc_spks = desc_spk_man->GetScriptPubKeys();
|
auto desc_spks = desc_spk_man->GetScriptPubKeys();
|
||||||
@ -1875,7 +1875,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
|
|||||||
WalletDescriptor w_desc(std::move(desc), 0, 0, chain_counter, 0);
|
WalletDescriptor w_desc(std::move(desc), 0, 0, chain_counter, 0);
|
||||||
|
|
||||||
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
|
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
|
||||||
auto desc_spk_man = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(m_storage, w_desc, m_keypool_size));
|
auto desc_spk_man = std::make_unique<DescriptorScriptPubKeyMan>(m_storage, w_desc, /*keypool_size=*/0);
|
||||||
desc_spk_man->AddDescriptorKey(master_key.key, master_key.key.GetPubKey());
|
desc_spk_man->AddDescriptorKey(master_key.key, master_key.key.GetPubKey());
|
||||||
desc_spk_man->TopUp();
|
desc_spk_man->TopUp();
|
||||||
auto desc_spks = desc_spk_man->GetScriptPubKeys();
|
auto desc_spks = desc_spk_man->GetScriptPubKeys();
|
||||||
@ -1937,7 +1937,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
|
|||||||
} else {
|
} else {
|
||||||
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
|
// Make the DescriptorScriptPubKeyMan and get the scriptPubKeys
|
||||||
WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0);
|
WalletDescriptor w_desc(std::move(desc), creation_time, 0, 0, 0);
|
||||||
auto desc_spk_man = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(m_storage, w_desc, m_keypool_size));
|
auto desc_spk_man = std::make_unique<DescriptorScriptPubKeyMan>(m_storage, w_desc, /*keypool_size=*/0);
|
||||||
for (const auto& keyid : privkeyids) {
|
for (const auto& keyid : privkeyids) {
|
||||||
CKey key;
|
CKey key;
|
||||||
if (!GetKey(keyid, key)) {
|
if (!GetKey(keyid, key)) {
|
||||||
@ -2015,7 +2015,7 @@ std::optional<MigrationData> LegacyScriptPubKeyMan::MigrateToDescriptor()
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyScriptPubKeyMan::DeleteRecords()
|
bool LegacyDataSPKM::DeleteRecords()
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
WalletBatch batch(m_storage.GetDatabase());
|
WalletBatch batch(m_storage.GetDatabase());
|
||||||
|
@ -354,6 +354,18 @@ public:
|
|||||||
|
|
||||||
//! Fetches a pubkey from mapWatchKeys if it exists there
|
//! Fetches a pubkey from mapWatchKeys if it exists there
|
||||||
bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const;
|
bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves scripts that were imported by bugs into the legacy spkm and are
|
||||||
|
* simply invalid, such as a sh(sh(pkh())) script, or not watched.
|
||||||
|
*/
|
||||||
|
std::unordered_set<CScript, SaltedSipHasher> GetNotMineScriptPubKeys() const;
|
||||||
|
|
||||||
|
/** Get the DescriptorScriptPubKeyMans (with private keys) that have the same scriptPubKeys as this LegacyScriptPubKeyMan.
|
||||||
|
* Does not modify this ScriptPubKeyMan. */
|
||||||
|
std::optional<MigrationData> MigrateToDescriptor();
|
||||||
|
/** Delete all the records ofthis LegacyScriptPubKeyMan from disk*/
|
||||||
|
bool DeleteRecords();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Implements the full legacy wallet behavior
|
// Implements the full legacy wallet behavior
|
||||||
@ -548,18 +560,6 @@ public:
|
|||||||
const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
|
const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; }
|
||||||
|
|
||||||
std::set<CKeyID> GetKeys() const override;
|
std::set<CKeyID> GetKeys() const override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves scripts that were imported by bugs into the legacy spkm and are
|
|
||||||
* simply invalid, such as a sh(sh(pkh())) script, or not watched.
|
|
||||||
*/
|
|
||||||
std::unordered_set<CScript, SaltedSipHasher> GetNotMineScriptPubKeys() const;
|
|
||||||
|
|
||||||
/** Get the DescriptorScriptPubKeyMans (with private keys) that have the same scriptPubKeys as this LegacyScriptPubKeyMan.
|
|
||||||
* Does not modify this ScriptPubKeyMan. */
|
|
||||||
std::optional<MigrationData> MigrateToDescriptor();
|
|
||||||
/** Delete all the records ofthis LegacyScriptPubKeyMan from disk*/
|
|
||||||
bool DeleteRecords();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr. Does not provide privkeys */
|
/** Wraps a LegacyScriptPubKeyMan so that it can be returned in a new unique_ptr. Does not provide privkeys */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user