Check merkle root

This commit is contained in:
poma 2019-07-18 16:30:24 +03:00
parent 1c642a40f1
commit f7bca08480

@ -42,6 +42,11 @@ app.post('/relay', async (req, resp) => {
if (isSpent) { if (isSpent) {
throw new Error('The note has been spent') throw new Error('The note has been spent')
} }
const root = publicSignals[0]
const isKnownRoot = await mixer.methods.isKnownRoot(root).call()
if (!isKnownRoot) {
throw new Error('The merkle root is too old or invalid')
}
const gas = await mixer.methods.withdraw(pi_a, pi_b, pi_c, publicSignals).estimateGas() const gas = await mixer.methods.withdraw(pi_a, pi_b, pi_c, publicSignals).estimateGas()
const result = mixer.methods.withdraw(pi_a, pi_b, pi_c, publicSignals).send({ const result = mixer.methods.withdraw(pi_a, pi_b, pi_c, publicSignals).send({
gas: numberToHex(gas + 50000), gas: numberToHex(gas + 50000),