Toffoli gates with Hadamard coins (QISKIT)

I am creating the following circuit with Qiskit (2Toffoli gates controlled with coins)

And to set the coins for one iteration of the circuit i do the following :

qsubnodes = QuantumRegister(2)
qsubnodes = QuantumRegister(2)
qc.h(subnode[0])
qc.h(subnode[1])


and then for the first Toffoli gate:

qc.ccx(subnode[0], subnode[1], *q)


and the second toffoli gate (which is the issue) :

qc.h(subnode[0])
qc.h(subnode[1])
qc.x(subnode[1]) // to invert the coin to control for 0 (as shown in the circuit)
qc.ccx(subnode[0], subnode[1], *q)


Is it the right way of inverting the coin for the second toffoli ?

Thank you,

According to your circuit diagram, the second Toffoli should act in case "lower" qubit is in state $$|1\rangle$$ and "upper" one in state $$|0\rangle$$. Since Toffoli acts only in case both inputs are in state $$|1\rangle$$, you have to invert "upper" qubit, or in other words to apply $$X$$ there.
So it seems that your construction is right. To test this, try to prepare circuit containing one Toffoli gate with $$X$$ applied on one of its input. Set a input of the circuit to $$|01\rangle$$ or $$|10\rangle$$ depending on which Toffoli's input is neggated and try to measure Toffoli's output; you should get $$|1\rangle$$.