feat(santoTirso): logic from santo-tirso branch merged
This commit is contained in:
parent
adfb5f48fc
commit
bd3d51b9f2
3 changed files with 148 additions and 13 deletions
|
|
@ -50,9 +50,14 @@ function poll(req, res) {
|
|||
var response = {
|
||||
err: null,
|
||||
rate: rate * config.exchanges.settings.commission,
|
||||
|
||||
// TODO this should actually be based on the sell rate
|
||||
fiatRate: rate / config.exchanges.settings.commission,
|
||||
|
||||
fiat: fiatBalance,
|
||||
locale: config.brain.locale,
|
||||
txLimit: parseInt(complianceSettings.maximum.limit, 10),
|
||||
dispenseStatus: plugins.dispenseStatus(fingerprint),
|
||||
idVerificationEnabled: complianceSettings.idVerificationEnabled
|
||||
};
|
||||
|
||||
|
|
@ -69,6 +74,40 @@ function trade(req, res) {
|
|||
});
|
||||
}
|
||||
|
||||
function send(req, res) {
|
||||
plugins.sendBitcoins(getFingerprint(req), req.body, function(err, status) {
|
||||
// TODO: use status.statusCode here after confirming machine compatibility
|
||||
res.json({
|
||||
errType: err && err.name,
|
||||
err: err && err.message,
|
||||
txHash: status && status.txHash,
|
||||
txId: status && status.txId
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function cashOut(req, res) {
|
||||
logger.info({tx: req.body, cmd: 'cashOut'});
|
||||
plugins.cashOut(getFingerprint(req), req.body, function(err, bitcoinAddress) {
|
||||
if (err) logger.error(err);
|
||||
|
||||
res.json({
|
||||
err: err && err.message,
|
||||
errType: err && err.name,
|
||||
bitcoinAddress: bitcoinAddress
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function depositAck(req, res) {
|
||||
plugins.depositAck(getFingerprint(req), req.body, function(err) {
|
||||
res.json({
|
||||
err: err && err.message,
|
||||
errType: err && err.name
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function deviceEvent(req, res) {
|
||||
plugins.logEvent(req.body, getFingerprint(req));
|
||||
res.json({err: null});
|
||||
|
|
@ -100,18 +139,6 @@ function verifyTx(req, res) {
|
|||
});
|
||||
}
|
||||
|
||||
function send(req, res) {
|
||||
plugins.sendBitcoins(getFingerprint(req), req.body, function(err, status) {
|
||||
// TODO: use status.statusCode here after confirming machine compatibility
|
||||
res.json({
|
||||
errType: err && err.name,
|
||||
err: err && err.message,
|
||||
txHash: status && status.txHash,
|
||||
txId: status && status.txId
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function pair(req, res) {
|
||||
var token = req.body.token;
|
||||
var name = req.body.name;
|
||||
|
|
@ -137,8 +164,13 @@ function init(localConfig) {
|
|||
var app = localConfig.app;
|
||||
|
||||
app.get('/poll', authMiddleware, poll);
|
||||
app.post('/send', authMiddleware, send);
|
||||
|
||||
app.post('/trade', authMiddleware, trade);
|
||||
app.post('/send', authMiddleware, send);
|
||||
|
||||
app.post('/cash_out', authMiddleware, cashOut);
|
||||
app.post('/deposit_ack', authMiddleware, depositAck);
|
||||
|
||||
app.post('/event', authMiddleware, deviceEvent);
|
||||
app.post('/verify_user', authMiddleware, verifyUser);
|
||||
app.post('/verify_transaction', authMiddleware, verifyTx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue