mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge b1a46b212f into merged_master (Bitcoin PR bitcoin/bitcoin#26008)
This commit is contained in:
commit
1bc20d7011
7 changed files with 157 additions and 21 deletions
|
|
@ -1293,6 +1293,9 @@ bool LegacyScriptPubKeyMan::TopUp(unsigned int kpSize)
|
|||
}
|
||||
if (!batch.TxnCommit()) throw std::runtime_error(strprintf("Error during keypool top up. Cannot commit changes for wallet %s", m_storage.GetDisplayName()));
|
||||
NotifyCanGetAddressesChanged();
|
||||
// Note: Unlike with DescriptorSPKM, LegacySPKM does not need to call
|
||||
// m_storage.TopUpCallback() as we do not know what new scripts the LegacySPKM is
|
||||
// watching for. CWallet's scriptPubKey cache is not used for LegacySPKMs.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2157,6 +2160,7 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size)
|
|||
bool DescriptorScriptPubKeyMan::TopUpWithDB(WalletBatch& batch, unsigned int size)
|
||||
{
|
||||
LOCK(cs_desc_man);
|
||||
std::set<CScript> new_spks;
|
||||
unsigned int target_size;
|
||||
if (size > 0) {
|
||||
target_size = size;
|
||||
|
|
@ -2187,6 +2191,7 @@ bool DescriptorScriptPubKeyMan::TopUpWithDB(WalletBatch& batch, unsigned int siz
|
|||
if (!m_wallet_descriptor.descriptor->Expand(i, provider, scripts_temp, out_keys, &temp_cache)) return false;
|
||||
}
|
||||
// Add all of the scriptPubKeys to the scriptPubKey set
|
||||
new_spks.insert(scripts_temp.begin(), scripts_temp.end());
|
||||
for (const CScript& script : scripts_temp) {
|
||||
m_map_script_pub_keys[script] = i;
|
||||
}
|
||||
|
|
@ -2212,6 +2217,7 @@ bool DescriptorScriptPubKeyMan::TopUpWithDB(WalletBatch& batch, unsigned int siz
|
|||
// By this point, the cache size should be the size of the entire range
|
||||
assert(m_wallet_descriptor.range_end - 1 == m_max_cached_index);
|
||||
|
||||
m_storage.TopUpCallback(new_spks, this);
|
||||
NotifyCanGetAddressesChanged();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2627,6 +2633,7 @@ uint256 DescriptorScriptPubKeyMan::GetID() const
|
|||
void DescriptorScriptPubKeyMan::SetCache(const DescriptorCache& cache)
|
||||
{
|
||||
LOCK(cs_desc_man);
|
||||
std::set<CScript> new_spks;
|
||||
m_wallet_descriptor.cache = cache;
|
||||
for (int32_t i = m_wallet_descriptor.range_start; i < m_wallet_descriptor.range_end; ++i) {
|
||||
FlatSigningProvider out_keys;
|
||||
|
|
@ -2635,6 +2642,7 @@ void DescriptorScriptPubKeyMan::SetCache(const DescriptorCache& cache)
|
|||
throw std::runtime_error("Error: Unable to expand wallet descriptor from cache");
|
||||
}
|
||||
// Add all of the scriptPubKeys to the scriptPubKey set
|
||||
new_spks.insert(scripts_temp.begin(), scripts_temp.end());
|
||||
for (const CScript& script : scripts_temp) {
|
||||
if (m_map_script_pub_keys.count(script) != 0) {
|
||||
throw std::runtime_error(strprintf("Error: Already loaded script at index %d as being at index %d", i, m_map_script_pub_keys[script]));
|
||||
|
|
@ -2652,6 +2660,8 @@ void DescriptorScriptPubKeyMan::SetCache(const DescriptorCache& cache)
|
|||
}
|
||||
m_max_cached_index++;
|
||||
}
|
||||
// Make sure the wallet knows about our new spks
|
||||
m_storage.TopUpCallback(new_spks, this);
|
||||
}
|
||||
|
||||
bool DescriptorScriptPubKeyMan::AddKey(const CKeyID& key_id, const CKey& key)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue