Skip to content

Commit b5795a7

Browse files
committed
Wallet: Add warning comments and assert to CWallet::DelAddressBook
1 parent 6d2905f commit b5795a7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/wallet/wallet.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,6 +3213,11 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s
32133213

32143214
bool CWallet::DelAddressBook(const CTxDestination& address)
32153215
{
3216+
// If we want to delete receiving addresses, we need to take care that DestData "used" (and possibly newer DestData) gets preserved (and the "deleted" address transformed into a change entry instead of actually being deleted)
3217+
// NOTE: This isn't a problem for sending addresses because they never have any DestData yet!
3218+
// When adding new DestData, it should be considered here whether to retain or delete it (or move it?).
3219+
assert(!IsMine(address));
3220+
32163221
{
32173222
LOCK(cs_wallet);
32183223

src/wallet/wallet.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,10 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
852852

853853
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
854854

855-
//! Adds a destination data tuple to the store, and saves it to disk
855+
/**
856+
* Adds a destination data tuple to the store, and saves it to disk
857+
* When adding new fields, take care to consider how DelAddressBook should handle it!
858+
*/
856859
bool AddDestData(WalletBatch& batch, const CTxDestination& dest, const std::string& key, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
857860
//! Erases a destination data tuple in the store and on disk
858861
bool EraseDestData(WalletBatch& batch, const CTxDestination& dest, const std::string& key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);

0 commit comments

Comments
 (0)