Skip to content

Commit

Permalink
Receive addresses recovery fixed (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
levonpetrosyan93 authored Jun 25, 2021
1 parent 892c64e commit d5aa685
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6653,6 +6653,26 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
}
}
}

// recover addressbook
if (fFirstRun)
{
for (map<uint256, CWalletTx>::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));

{
Expand Down

0 comments on commit d5aa685

Please sign in to comment.