mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-26 15:36:19 +01:00
Split SetActiveScriptPubKeyMan into Add/LoadActiveScriptPubKeyMan
Remove the memonly bool and follow the Add and Load pattern we use everywhere else.
This commit is contained in:
@@ -4374,12 +4374,21 @@ void CWallet::SetupDescriptorScriptPubKeyMans()
|
||||
spk_manager->SetupDescriptorGeneration(master_key, t);
|
||||
uint256 id = spk_manager->GetID();
|
||||
m_spk_managers[id] = std::move(spk_manager);
|
||||
SetActiveScriptPubKeyMan(id, t, internal);
|
||||
AddActiveScriptPubKeyMan(id, t, internal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::SetActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal, bool memonly)
|
||||
void CWallet::AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
|
||||
{
|
||||
WalletBatch batch(*database);
|
||||
if (!batch.WriteActiveScriptPubKeyMan(static_cast<uint8_t>(type), id, internal)) {
|
||||
throw std::runtime_error(std::string(__func__) + ": writing active ScriptPubKeyMan id failed");
|
||||
}
|
||||
LoadActiveScriptPubKeyMan(id, type, internal);
|
||||
}
|
||||
|
||||
void CWallet::LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
|
||||
{
|
||||
WalletLogPrintf("Setting spkMan to active: id = %s, type = %d, internal = %d\n", id.ToString(), static_cast<int>(type), static_cast<int>(internal));
|
||||
auto& spk_mans = internal ? m_internal_spk_managers : m_external_spk_managers;
|
||||
@@ -4387,12 +4396,6 @@ void CWallet::SetActiveScriptPubKeyMan(uint256 id, OutputType type, bool interna
|
||||
spk_man->SetInternal(internal);
|
||||
spk_mans[type] = spk_man;
|
||||
|
||||
if (!memonly) {
|
||||
WalletBatch batch(*database);
|
||||
if (!batch.WriteActiveScriptPubKeyMan(static_cast<uint8_t>(type), id, internal)) {
|
||||
throw std::runtime_error(std::string(__func__) + ": writing active ScriptPubKeyMan id failed");
|
||||
}
|
||||
}
|
||||
NotifyCanGetAddressesChanged();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user