Merge pull request #5280 from nuttycom/bug/set_best_chain_wallet_lock

Lock the wallet in SetBestChainINTERNAL
This commit is contained in:
str4d 2021-08-31 21:46:09 +01:00 committed by GitHub
commit df6574b07d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -189,6 +189,10 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
SyncWithWallets(tx, NULL, pindexLastTip->nHeight);
}
// Update cached incremental witnesses
// This will take the cs_main lock in order to obtain the CBlockLocator
// used by `SetBestChain`, but as that write only occurs once every
// WRITE_WITNESS_INTERVAL * 1000000 microseconds this should not be
// exploitable as a timing channel.
GetMainSignals().ChainTip(pindexLastTip, &block, std::nullopt);
// On to the next block!
@ -220,6 +224,10 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
SyncWithWallets(tx, &block, blockData.pindex->nHeight);
}
// Update cached incremental witnesses
// This will take the cs_main lock in order to obtain the CBlockLocator
// used by `SetBestChain`, but as that write only occurs once every
// WRITE_WITNESS_INTERVAL * 1000000 microseconds this should not be
// exploitable as a timing channel.
GetMainSignals().ChainTip(blockData.pindex, &block, blockData.oldTrees);
// This block is done!

View File

@ -759,6 +759,7 @@ protected:
return;
}
try {
LOCK(cs_wallet);
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
auto wtx = wtxItem.second;
// We skip transactions for which mapSproutNoteData and mapSaplingNoteData