Lock cs_main for accesses to chainActive in GetPaymentAddressForRecipient.

This commit is contained in:
Kris Nuttycombe 2022-03-21 14:06:25 -06:00
parent 758852b281
commit a8bae004b1
1 changed files with 6 additions and 2 deletions

View File

@ -862,14 +862,18 @@ std::pair<PaymentAddress, RecipientType> CWallet::GetPaymentAddressForRecipient(
const uint256& txid,
const libzcash::RecipientAddress& recipient) const
{
AssertLockHeld(cs_main);
AssertLockHeld(cs_wallet);
auto self = this;
auto nHeight = chainActive.Height();
int nHeight = chainActive.Height();
auto wtxPtr = mapWallet.find(txid);
if (wtxPtr != mapWallet.end()) {
nHeight = wtxPtr->second.GetDepthInMainChain();
const CBlockIndex* pTxIndex{nullptr};
if (wtxPtr->second.GetDepthInMainChain(pTxIndex) > 0) {
nHeight = pTxIndex->nHeight;
}
}
auto ufvk = self->GetUFVKForReceiver(RecipientAddressToReceiver(recipient));