message: Fix potential deadlock during merkle root check
  We have to take the cs_main lock outside the section where we check
  the merkle root for an xthinblock otherwise we may deadlock.
diff: @@ -285,6 +285,7 @@ bool CXThinBlock::process(CNode *pfrom,
  map<uint64_t, uint256> mapPartialTxHash;
  vector<uint256> memPoolHashes;
  + bool fMerkleRootCorrect = true;
  {
  // Do the orphans first before taking the mempool.cs lock, so that we maintain correct locking order.
  LOCK(cs_orphancache);
  @@ -338,11 +339,10 @@ bool CXThinBlock::process(CNode *pfrom,
  uint256 merkleroot = ComputeMerkleRoot(fullTxHashes, &mutated);
  if (header.hashMerkleRoot != merkleroot)
  {
  - LOCK(cs_main);
  - Misbehaving(pfrom->GetId(), 100);
  - return error("Thinblock merkelroot does not match computed merkleroot, peer=%d", pfrom->GetId());
  + fMerkleRootCorrect = false;
  }
  -
  + else
  + {
  // Look for each transaction in our various pools and buffers.
  // With xThinBlocks the vTxHashes contains only the first 8 bytes of the tx hash.
  for (const uint256 hash : fullTxHashes)
  @@ -370,12 +370,22 @@ bool CXThinBlock::process(CNode *pfrom,
  }
  if (tx.IsNull())
  missingCount++;
  +
  // This will push an empty/invalid transaction if we don't have it yet
  pfrom->thinBlock.vtx.push_back(tx);
  }
  }
  + }
  } // End locking cs_orphancache, mempool.cs and cs_xval
  + // This must be checked outside the above section or a deadlock may occur
  + if (!fMerkleRootCorrect)
  + {
  + LOCK(cs_main);
  + Misbehaving(pfrom->GetId(), 100);
  + return error("Thinblock merkelroot does not match computed merkleroot, peer=%d", pfrom->GetId());
  + }
  +
  // There is a remote possiblity of a Tx hash collision therefore if it occurs we re-request a normal
  // thinblock which has the full Tx hash data rather than just the truncated hash.
  if (collision)
  