mirror of
https://github.com/tornadocash/tornado-relayer.git
synced 2024-10-01 08:25:37 -04:00
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
const {
|
|
getTornadoWithdrawInputError,
|
|
getMiningRewardInputError,
|
|
getMiningWithdrawInputError,
|
|
} = require('./validator')
|
|
const { postJob } = require('./queue')
|
|
const { jobType } = require('./constants')
|
|
|
|
async function tornadoWithdraw(req, res) {
|
|
const inputError = getTornadoWithdrawInputError(req.body)
|
|
if (inputError) {
|
|
console.log('Invalid input:', inputError)
|
|
return res.status(400).json({ error: inputError })
|
|
}
|
|
|
|
const id = await postJob({
|
|
type: jobType.TORNADO_WITHDRAW,
|
|
request: req.body,
|
|
})
|
|
return res.json({ id })
|
|
}
|
|
|
|
async function miningReward(req, res) {
|
|
const inputError = getMiningRewardInputError(req.body)
|
|
if (inputError) {
|
|
console.log('Invalid input:', inputError)
|
|
return res.status(400).json({ error: inputError })
|
|
}
|
|
|
|
const id = await postJob({
|
|
type: jobType.MINING_REWARD,
|
|
request: req.body,
|
|
})
|
|
return res.json({ id })
|
|
}
|
|
|
|
async function miningWithdraw(req, res) {
|
|
const inputError = getMiningWithdrawInputError(req.body)
|
|
if (inputError) {
|
|
console.log('Invalid input:', inputError)
|
|
return res.status(400).json({ error: inputError })
|
|
}
|
|
|
|
const id = await postJob({
|
|
type: jobType.MINING_WITHDRAW,
|
|
request: req.body,
|
|
})
|
|
return res.json({ id })
|
|
}
|
|
|
|
module.exports = {
|
|
tornadoWithdraw,
|
|
miningReward,
|
|
miningWithdraw,
|
|
}
|