diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -338,22 +338,6 @@ pwallet->SetAddressBook(dest, label, "send"); } - // Detect when there are no addresses using this label. - // If so, delete the account record for it. Labels, unlike addresses, can be - // deleted, and if we wouldn't do this, the record would stick around - // forever. - bool found_address = false; - for (const std::pair &item : - pwallet->mapAddressBook) { - if (item.second.name == label) { - found_address = true; - break; - } - } - if (!found_address) { - pwallet->DeleteLabel(old_label); - } - return NullUniValue; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1052,9 +1052,6 @@ int64_t IncOrderPosNext(WalletBatch *batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); DBErrors ReorderTransactions(); - bool GetLabelDestination(CTxDestination &dest, const std::string &label, - bool bForceNew = false) - EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void MarkDirty(); bool AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose = true); @@ -1191,7 +1188,6 @@ GetAddressBalances(interfaces::Chain::Lock &locked_chain); std::set GetLabelAddresses(const std::string &label) const; - void DeleteLabel(const std::string &label); isminetype IsMine(const CTxIn &txin) const; /** diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -937,50 +937,6 @@ return nRet; } -bool CWallet::GetLabelDestination(CTxDestination &dest, - const std::string &label, bool bForceNew) { - WalletBatch batch(*database); - - CAccount account; - batch.ReadAccount(label, account); - - if (!bForceNew) { - if (!account.vchPubKey.IsValid()) { - bForceNew = true; - } else { - // Check if the current key has been used (TODO: check other - // addresses with the same key) - CScript scriptPubKey = GetScriptForDestination(GetDestinationForKey( - account.vchPubKey, m_default_address_type)); - for (std::map::iterator it = mapWallet.begin(); - it != mapWallet.end() && account.vchPubKey.IsValid(); ++it) { - for (const CTxOut &txout : (*it).second.tx->vout) { - if (txout.scriptPubKey == scriptPubKey) { - bForceNew = true; - break; - } - } - } - } - } - - // Generate a new key - if (bForceNew) { - if (!GetKeyFromPool(account.vchPubKey, false)) { - return false; - } - - LearnRelatedScripts(account.vchPubKey, m_default_address_type); - dest = GetDestinationForKey(account.vchPubKey, m_default_address_type); - SetAddressBook(dest, label, "receive"); - batch.WriteAccount(label, account); - } else { - dest = GetDestinationForKey(account.vchPubKey, m_default_address_type); - } - - return true; -} - void CWallet::MarkDirty() { LOCK(cs_wallet); for (std::pair &item : mapWallet) { @@ -4050,11 +4006,6 @@ return result; } -void CWallet::DeleteLabel(const std::string &label) { - WalletBatch batch(*database); - batch.EraseAccount(label); -} - bool CReserveKey::GetReservedKey(CPubKey &pubkey, bool internal) { if (!pwallet->CanGetAddresses(internal)) { return false; diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -194,10 +194,6 @@ bool WriteMinVersion(int nVersion); - bool ReadAccount(const std::string &strAccount, CAccount &account); - bool WriteAccount(const std::string &strAccount, const CAccount &account); - bool EraseAccount(const std::string &strAccount); - /// Write destination data key,value tuple to database. bool WriteDestData(const CTxDestination &address, const std::string &key, const std::string &value); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -166,22 +166,6 @@ return WriteIC(std::string("minversion"), nVersion); } -bool WalletBatch::ReadAccount(const std::string &strAccount, - CAccount &account) { - account.SetNull(); - return m_batch.Read(std::make_pair(std::string("acc"), strAccount), - account); -} - -bool WalletBatch::WriteAccount(const std::string &strAccount, - const CAccount &account) { - return WriteIC(std::make_pair(std::string("acc"), strAccount), account); -} - -bool WalletBatch::EraseAccount(const std::string &strAccount) { - return EraseIC(std::make_pair(std::string("acc"), strAccount)); -} - class CWalletScanState { public: unsigned int nKeys{0};