Skip to content

Commit 6cb888b

Browse files
Empactachow101
authored andcommitted
Apply the batch treatment to CWallet::SetAddressBook via ImportScriptPubKeys
1 parent 6154a09 commit 6cb888b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/wallet/wallet.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
16931693
CTxDestination dest;
16941694
ExtractDestination(script, dest);
16951695
if (!internal && IsValidDestination(dest)) {
1696-
SetAddressBook(dest, label, "receive");
1696+
SetAddressBookWithDB(batch, dest, label, "receive");
16971697
}
16981698
}
16991699
return true;
@@ -3280,8 +3280,7 @@ DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx)
32803280
return DBErrors::LOAD_OK;
32813281
}
32823282

3283-
3284-
bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
3283+
bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
32853284
{
32863285
bool fUpdated = false;
32873286
{
@@ -3294,9 +3293,15 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s
32943293
}
32953294
NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != ISMINE_NO,
32963295
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
3297-
if (!strPurpose.empty() && !WalletBatch(*database).WritePurpose(EncodeDestination(address), strPurpose))
3296+
if (!strPurpose.empty() && !batch.WritePurpose(EncodeDestination(address), strPurpose))
32983297
return false;
3299-
return WalletBatch(*database).WriteName(EncodeDestination(address), strName);
3298+
return batch.WriteName(EncodeDestination(address), strName);
3299+
}
3300+
3301+
bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
3302+
{
3303+
WalletBatch batch(*database);
3304+
return SetAddressBookWithDB(batch, address, strName, strPurpose);
33003305
}
33013306

33023307
bool CWallet::DelAddressBook(const CTxDestination& address)

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,8 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific
715715

716716
void AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const bool internal, WalletBatch& batch);
717717

718+
bool SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose);
719+
718720
//! Adds a script to the store and saves it to disk
719721
bool AddCScriptWithDB(WalletBatch& batch, const CScript& script);
720722

0 commit comments

Comments
 (0)