8 – How to check Drupal Node Access Permissions in Custom Module

I am building a custom module , where my company employees only needs to access website without login. They will enter their employee id in one form and will store that employee id in one of the cookie. When ever cookie is set or valid then employees will access my website.

I built a form and cookie is also set but in my test.module file I’ve written like this and none of the functions calling while accessing a node by anonymous users. For first time it is calling hook_node_view , when I refresh second time its opening node normally.

here is my .module file

use SymfonyComponentHttpFoundationRedirectResponse;
use DrupalCoreUrl;

 * @file
 * Contains test.module.

function test_node_view($node, $view_mode, $langcode)  {
global $base_url;

    if (!isset($_COOKIE('empid'))) {
            $response = new RedirectResponse($base_url.'/mylogin');


function test_entity_view(array &$build, DrupalCoreEntityEntityInterface $entity, DrupalCoreEntityDisplayEntityViewDisplayInterface $display, $view_mode) {

    if (!isset($_COOKIE('empid'))) {
            echo 'Entity'; exit;
            $host = Drupal::request()->getHost();
            $response = new RedirectResponse($host.'/mylogin');


function test_theme($existing, $type, $theme, $path) {

echo 'Theme'; exit;
  return array(
    'relatedlinks' => array(
      'template' => 'templates/relatedlinks',
      'variables' => array('viewresult' => NULL, 'tags' => NULL),

function test_entity_access(DrupalCoreEntityEntityInterface $entity, $operation, DrupalCoreSessionAccountInterface $account) {
    echo 'Theme'; exit;
  // No opinion.
  return AccessResult::neutral();

function test_node_view_alter(array &$build, DrupalCoreEntityEntityInterface $entity, DrupalCoreEntityDisplayEntityViewDisplayInterface $display) {

echo 'Theme'; exit;
  if ($build('#view_mode') == 'full' && isset($build('an_additional_field'))) {

    // Change its weight.
    $build('an_additional_field')('#weight') = -10;

    // Add a #post_render callback to act on the rendered HTML of the entity.
    $build('#post_render')() = 'my_module_node_post_render';

 * Implements hook_preprocess_node().
function test_preprocess_node(&$variables) {

echo 'Themedsfsdfsdf'; exit;
  // Get the node's content type
  $type = $variables('node')->getType();

  // Get its view mode
  $mode = $variables('view_mode');

  // Make sure we have a class array
  if (!isset($variables('attributes')('class'))) {
    $variables('attributes')('class') = ();

  // Add our classes
  $variables('attributes')('class')() = 'node--type-' . $type; // ex: node--type-article
  $variables('attributes')('class')() = 'node--mode-' . $mode; // ex: node--mode-teaser
  $variables('attributes')('class')() = 'node--type-' . $type . '--mode-' . $mode; // ex: node--type-article--mode-teaser

None of the above functions worked for me.

bitcoin core – Is it possible to query a node for all addresses containing value?

Bitcoin-core (the full node implementation that makes up the majority of the network) does not keep an index of all addresses and balances, so without writing additional code to do the job, it is not possible. Bitcoin-core keeps track of coins via the UTXO model– the idea of ‘an address with a balance’ is just an abstraction of this that makes for a more user-friendly interface.

Of course, you could write some code to create an index of addresses and their respective balances, or perhaps find an already-existing open-source block explorer project that accomplishes this.

Is it possible to query a node for all addresses?

For instance, can I run a query on a bitcoin node, that returns all addresses with more than 1 bitcoin on them?

javascript – Retornar valor de uma função NODE


Estou iniciando com NODE. Tenho a função abaixo e gostaria que ela retornasse o texto traduzido. Hoje ela joga o texto para o console. Como faço para ela retornar o texto? Como ficaria? Obrigado.

function traduzirTexto() {
  // ==> Aqui vamos configurar os requests
  let options = {
    method: 'POST',
    baseUrl: endpoint,
    url: 'translate',
    qs: {
      'api-version': '3.0',
      'to': ('en', 'es')
    headers: {
      'Ocp-Apim-Subscription-Key': subscriptionKey,
      'Content-type': 'application/json',
      'X-ClientTraceId': uuidv4().toString()
    body: ({
      'text': 'Olá Desenvolvedor!'
    json: true,

  // ==> Aqui vamos imprimir a nossa requisição
  request(options, (err, res, body) => {
    console.log(JSON.stringify(body, null, 4));

8 – Can’t get referenced node to appear in view block

I have recipe and food nodes, and recipe nodes (e.g. My Favourite Cake Recipe) link to parent food types (e.g. Cake). This link is done via a Parent Food content reference field on the recipe node type.

Now I’d like to display a block titled Linked Food next to all recipes. To do this I created a food content view with the following:

  • Add a relationship with item Content referenced from field_parent_food so that I can display the content of the food node referenced from the recipe page I’m viewing.
  • Add a contextual ID filter, and set WHEN THE FILTER VALUE IS NOT AVAILABLE to Provide Default -> Content ID from URL so that I only look at nodes with an ID equal to the current page.
  • Add a field with ID Parent Food so that I display the content of the referenced food.

I then set up this block to display on the recipe content type. When I navigate to a recipe I was now expecting to see the parent food node detailed in the block, but instead I just see the same recipe repeated in the block. What am I doing wrong here?

I’ve had a look at a view tutorials and I’m as someone who is familiar with relational databases I find the concept of views (or at least the documentation) really impenetrable, so I’m just going to ask…

Which is a correct definition and interpretation of “increased node density” after a transformation

After transforming a set of points in $(0,1)times(0,1)subseteqmathbb{R}^2$ (see the 1st image) as $begin{cases}x’=frac{1}{xsqrt{x^2+y^2}}\y’=frac{1}{ysqrt{x^2+y^2}}end{cases}$ (see the 2nd image). I noticed that the node distribution appears to be “more dense”, i.e. the nodes originally near (1,1) are now more densely distributed than the nodes originally near (0,0). Is there a way to mathematically name this “change in density” and which is the proper way to show it less informally? Can this be related to the statistical “density function”?

original points
transformed points

Oracle RAC Node 1 is in mount mode, How to open?

I’m new to Oracle RAC, today I found out that Node 1 is down, but don’t know how to fix. Please help

from SQL*Plus

SQL> select status from v$instance;



from ./crsctl stat res -t

      1        ONLINE  INTERMEDIATE ibmbdb01                 Mounted (Closed)    
      2        ONLINE  ONLINE       ibmbdb02                 Open    

from srvctl status database -d ibmbdb -v

(oracle@ibmbdb01 ~)$ srvctl status database -d ibmbdb -v
Instance ibmbdb1 is running on node ibmbdb01. Instance status: Mounted (Closed).
Instance ibmbdb2 is running on node ibmbdb02. Instance status: Open.

bitcoinjs – Elements Regtest Node LBTC Asset Hash Inconsistency

I’m having a strange problem that I can’t seem to wrap my head around; having started over from scratch now numerous times, I just can’t figure this out.

I have followed the tutorial on the Elements Project website (https://elementsproject.org/elements-code-tutorial/overview) to setup a Regtest Bitcoin node along with a Regtest Elements node. It’s Regtest, so I don’t mind sharing my bitcoin.conf and elements.conf:





I did simplify the environment a little bit, removing the second Elements node from the equation. I proceeded to follow the tutorial to claim the anyone-can-spend coins, and generate 101 blocks to make them spendable:

ADDRGEN1=$(e1-cli getnewaddress)
e1-cli sendtoaddress $(e1-cli getnewaddress) 21000000 "" "" true
e1-cli generatetoaddress 101 $ADDRGEN1

Then I created an address offline using elementsjs-lib.

const bip39 = require("bip39")
const bip32 = require("bip32")
const slip77 = require("slip77")
const liquid = require('liquidjs-lib')

const regtest = liquid.networks.regtest
const mnemonic = bip39.generateMnemonic()
const seed = await bip39.mnemonicToSeed(mnemonic)

const node = bip32.fromSeed(seed, regtest)
const nodeBlinding = slip77.fromSeed(seed)

const addressIndex = 0
const child = node.derivePath(`m/1776'/0'/0'/0/${addressIndex}`)

let p2pkh = liquid.payments.p2pkh({ pubkey: child.publicKey, network:regtest })
const blindingKeyPair = nodeBlinding.derive(p2pkh.output)
p2pkh = liquid.payments.p2pkh({ pubkey: child.publicKey, blindkey: blindingKeyPair.publicKey, network: regtest })

console.log("address", p2pkh.address)
console.log("private key:", child.toWIF())
console.log("public key:", p2pkh.pubkey.toString('hex'))
console.log("output:", p2pkh.output.toString('hex'))
console.log("confidential address:", p2pkh.confidentialAddress)

console.log("blindingKeyPair masterKey", blindingKeyPair.masterKey.toString('hex'))
console.log("blindingKeyPair privateKey:", blindingKeyPair.privateKey.toString('hex'))
console.log("blindingKeyPair publicKey:", blindingKeyPair.publicKey.toString('hex'))
console.log("blindingKeyPair extra:", blindingKeyPair.extra.toString('hex'))
console.log("blindingKeyPair script:", blindingKeyPair.extra.toString('hex'))

Then I sent some LBTC to the confidential address I created, and generated one more block on my elements node to mine it.

e1-cli sendtoaddress CTEneiZiqsxx9mV9cbk3J8V14zC8jJrnWXqvpWYzjSF4J2D38rE49c4EEKZhmC7ito3TKdxCHmstzmZZ 100 "" "" false
e1-cli generatetoaddress 1 $ADDRGEN1

I was doing this so I can test the unblinding of transactions using liquidjs-lib, which I was successful. The problem I am writing about was observed when I began testing my transaction building code using liquidjs-lib’s psbt, specifically regarding asset hashes.

According to liquidjs-lib.networks.regtest.assetHash, the standard asset hash for liquid bitcoin is 5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225.

In liquidjs-lib’s transaction examples, it is understood that the asset hash should be formatted for psbt as the concatenation of the buffer for 01 in hex and the reversed buffer of liquid.networks.regtest.assetHash in hex. This resulting buffer is <Buffer 01 25 b2 51 07 0e 29 ca 19 04 3c f3 3c cd 73 24 e2 dd ab 03 ec c4 ae 0b 5e 77 c4 fc 0e 5c f6 c9 5a>.

When I started working with psbt, and inspecting values along the way, I noticed something odd. The asset hash in the outputs of the transaction representing the LBTC I sent from my elements node to my offline address did not match either of the asset values above. I sent regtest LBTC, but the asset hash of the output does not match the standard regtest LBTC asset hash.

On my node, when I check the transaction e1-cli gettransaction 2179604703e75d761cde9fa04ef06c4b63e1f3d9954e843a7c536c0e2aa82456` the output shows:

"details": (
        "address": "2dgdgpvJv8P779i5r2i8YHkAgyvZZi6B8GX",
        "category": "send",
        "amount": -100.00000000,
        "amountblinder": "da05a84bcfd65ff7c59c5fc56577c6af324f3e15cce1e4423b62e0c4b111745e",
        "asset": "b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23",
        "assetblinder": "29f7e3a291f7c163474f90d235925594feb8ad55235da83557312f994ba55a1d",
        "vout": 0,
        "fee": 0.00005036,
        "abandoned": false

In the details above, the asset hash b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23 is nowhere near the standard Regtest LBTC asset hash.

Here’s where it gets even crazier. If I use the rawtransaction and unblind the outputs with liquidjs-lib, I get all the right unblinded output values, but I get completely different asset hashes:

My UTXO output: <Buffer 23 0f 4f 5d 4b 7c 6f a8 45 80 6e e4 f6 77 13 45 9e 1b 69 e8 e6 0f ce e2 e4 94 0c 7a 0d 5d e1 b2>

Change Output: <Buffer b2 e1 5d 0d 7a 0c 94 e4 e2 ce 0f e6 e8 69 1b 9e 45 13 77 f6 e4 6e 80 45 a8 6f 7c 4b 5d 4f 0f 23>

The change output here has the same asset hash my node reported, which is not the standard Regtest LBTC hash. The UTXO asset hash has a different asset hash all together. What gives?!

Apologies for the extremely long-winded question; I have just tried so many different things at this point that I wanted to be sure to include as much information in my post as I can, including all steps to reproduce.

client – How does a node send a chain?

I apologize for the newbie question. I understand that in selfish mining a malicious node can “send its entire hidden chain”. Exactly how is this done? I know that usually a single block is broadcast-ed right after it is mined, but how does it relay an entire chain?

I am looking at the original bitcoin protocol https://en.bitcoin.it/wiki/Protocol_documentation#inv
It seems that inv can broadcast many objects. So would a malicious node send an entire chain via one call to inv or many?

8 – Drupal way of storing data related to a node

I want to store some data that is related to a node and trying to figure out the best way of doing it. For example, I send emails related to a node and I want to save details such as:

  • To Email address
  • Cc Email Addresses
  • Date sent
  • User
  • Email type
  • Other chosen email options etc

In the past I would use Paragraphs to have an unlimited field but this will, over time, grow to have a lot of entries. I’m also using Revisions on the node so I think this will slow everything down when saving the node.

My question is… should I create my own entity for this? One that doesn’t have a page like a node does? Or is there a better way of storing the data? I could create a custom table, store it there, and maybe register that with Views but I would like to have the entity API available on the content and maybe add fields in future using the UI. Any ideas?

Is there a module similar to Paragraphs but is not a Entity Reference Revision type? Or is the Drupal way to create a custom entity in a module?