Skip to content

Commit fc2867f

Browse files
committed
refactor: Replace UnsetWalletFlagWithDB with UnsetBlankWalletFlag in ScriptPubKeyMan
ScriptPubKeyMan is only using UnsetWalletFlagWithDB to unset the blank wallet flag. Just make that it's own function and not expose the flag writing directly. This does not change behavior.
1 parent 78e7cbc commit fc2867f

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ bool LegacyScriptPubKeyMan::AddKeyPubKeyWithDB(WalletBatch& batch, const CKey& s
440440
secret.GetPrivKey(),
441441
mapKeyMetadata[pubkey.GetID()]);
442442
}
443-
m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
443+
m_storage.UnsetBlankWalletFlag(batch);
444444
return true;
445445
}
446446

@@ -597,7 +597,7 @@ bool LegacyScriptPubKeyMan::AddWatchOnlyWithDB(WalletBatch &batch, const CScript
597597
UpdateTimeFirstKey(meta.nCreateTime);
598598
NotifyWatchonlyChanged(true);
599599
if (batch.WriteWatchOnly(dest, meta)) {
600-
m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
600+
m_storage.UnsetBlankWalletFlag(batch);
601601
return true;
602602
}
603603
return false;
@@ -876,7 +876,7 @@ void LegacyScriptPubKeyMan::SetHDSeed(const CPubKey& seed)
876876
SetHDChain(newHdChain, false);
877877
NotifyCanGetAddressesChanged();
878878
WalletBatch batch(m_storage.GetDatabase());
879-
m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
879+
m_storage.UnsetBlankWalletFlag(batch);
880880
}
881881

882882
/**
@@ -1155,7 +1155,7 @@ bool LegacyScriptPubKeyMan::AddCScriptWithDB(WalletBatch& batch, const CScript&
11551155
if (!FillableSigningProvider::AddCScript(redeemScript))
11561156
return false;
11571157
if (batch.WriteCScript(Hash160(redeemScript), redeemScript)) {
1158-
m_storage.UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
1158+
m_storage.UnsetBlankWalletFlag(batch);
11591159
return true;
11601160
}
11611161
return false;

src/wallet/scriptpubkeyman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class WalletStorage
2828
virtual const std::string GetDisplayName() const = 0;
2929
virtual WalletDatabase& GetDatabase() = 0;
3030
virtual bool IsWalletFlagSet(uint64_t) const = 0;
31-
virtual void UnsetWalletFlagWithDB(WalletBatch&, uint64_t) = 0;
31+
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
3232
virtual bool CanSupportFeature(enum WalletFeature) const = 0;
3333
virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr, bool = false) = 0;
3434
virtual bool IsLocked() const = 0;

src/wallet/wallet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,11 @@ void CWallet::UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag)
13091309
throw std::runtime_error(std::string(__func__) + ": writing wallet flags failed");
13101310
}
13111311

1312+
void CWallet::UnsetBlankWalletFlag(WalletBatch& batch)
1313+
{
1314+
UnsetWalletFlagWithDB(batch, WALLET_FLAG_BLANK_WALLET);
1315+
}
1316+
13121317
bool CWallet::IsWalletFlagSet(uint64_t flag) const
13131318
{
13141319
return (m_wallet_flags & flag);

src/wallet/wallet.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,10 @@ class CWallet final : public WalletStorage, private interfaces::Chain::Notificat
660660
bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
661661

662662
//! Unsets a wallet flag and saves it to disk
663-
void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag) override;
663+
void UnsetWalletFlagWithDB(WalletBatch& batch, uint64_t flag);
664+
665+
//! Unset the blank wallet flag and saves it to disk
666+
void UnsetBlankWalletFlag(WalletBatch& batch) override;
664667

665668
/** Interface for accessing chain state. */
666669
interfaces::Chain* m_chain;

0 commit comments

Comments
 (0)