aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorS3RK <1466284+S3RK@users.noreply.github.com>2021-06-28 21:37:47 +0200
committerS3RK <1466284+S3RK@users.noreply.github.com>2021-06-28 21:44:50 +0200
commit586f1d53d60880ea2873d860f95e3390016620d1 (patch)
treec866e742a241e117498c5986e3247d46e293a4df /src/wallet
parentf1b7db14748d9ee04735b4968366d33bc89aea23 (diff)
downloadbitcoin-586f1d53d60880ea2873d860f95e3390016620d1.tar.xz
wallet: maintain SPK consistency on internal flag change
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8750f508a7..5ae490d5cc 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3153,12 +3153,21 @@ void CWallet::AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool interna
void CWallet::LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
{
+ // Activating ScriptPubKeyManager for a given output and change type is incompatible with legacy wallets.
+ // Legacy wallets have only one ScriptPubKeyManager and it's active for all output and change types.
+ Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
+
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;
+ auto& spk_mans_other = internal ? m_external_spk_managers : m_internal_spk_managers;
auto spk_man = m_spk_managers.at(id).get();
spk_man->SetInternal(internal);
spk_mans[type] = spk_man;
+ if (spk_mans_other[type] == spk_man) {
+ spk_mans_other[type] = nullptr;
+ }
+
NotifyCanGetAddressesChanged();
}