From 7eba1d1e7b995064c13a0bfc249b99b63b6ed76b Mon Sep 17 00:00:00 2001 From: Levon Petrosyan Date: Mon, 10 May 2021 01:46:57 +0400 Subject: [PATCH] Receive addresses recovery fixed --- src/wallet/wallet.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9c39aae3bc..5c6d0f04e5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -6621,6 +6621,26 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile) } } } + + // recover addressbook + if (fFirstRun) + { + for (map::iterator it = walletInstance->mapWallet.begin(); it != walletInstance->mapWallet.end(); ++it) { + for (uint32_t i = 0; i < (*it).second.tx->vout.size(); i++) { + const auto& txout = (*it).second.tx->vout[i]; + if(txout.scriptPubKey.IsMint() || (*it).second.changes.count(i)) + continue; + if (!walletInstance->IsMine(txout)) + continue; + CTxDestination addr; + if(!ExtractDestination(txout.scriptPubKey, addr)) + continue; + if (walletInstance->mapAddressBook.count(addr) == 0) + walletInstance->SetAddressBook(addr, "", "receive"); + } + } + } + walletInstance->SetBroadcastTransactions(GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST)); {