refactor(tx): transaction(s) changed to tx(s)
This commit is contained in:
parent
55abaa1bb9
commit
5a78376ad5
3 changed files with 16 additions and 14 deletions
|
|
@ -203,7 +203,7 @@ function _sendBitcoins(tx, callback) {
|
|||
);
|
||||
}
|
||||
|
||||
function executeTransaction(deviceFingerprint, txId, autoTriggered, cb) {
|
||||
function executeTx(deviceFingerprint, txId, autoTriggered, cb) {
|
||||
cb = typeof cb === 'function' ? cb : function() {};
|
||||
|
||||
clearSession(deviceFingerprint);
|
||||
|
|
@ -220,7 +220,7 @@ function executeTransaction(deviceFingerprint, txId, autoTriggered, cb) {
|
|||
return cb(null, {statusCode: 304}); // Not Modified
|
||||
}
|
||||
|
||||
db.summonTransaction(deviceFingerprint, tx, function(err, txInfo) {
|
||||
db.summonTx(deviceFingerprint, tx, function(err, txInfo) {
|
||||
if (err) return cb(err);
|
||||
|
||||
// actual sending
|
||||
|
|
@ -255,7 +255,7 @@ exports.trade = function trade(rawTrade, deviceFingerprint, cb) {
|
|||
sessions[deviceFingerprint] = {
|
||||
timestamp: Date.now(),
|
||||
reaper: setTimeout(function() {
|
||||
executeTransaction(deviceFingerprint, rawTrade.txId, true);
|
||||
executeTx(deviceFingerprint, rawTrade.txId, true);
|
||||
}, SESSION_TIMEOUT)
|
||||
};
|
||||
}
|
||||
|
|
@ -273,7 +273,7 @@ exports.trade = function trade(rawTrade, deviceFingerprint, cb) {
|
|||
};
|
||||
|
||||
exports.sendBitcoins = function sendBitcoins(deviceFingerprint, rawTx, callback) {
|
||||
executeTransaction(deviceFingerprint, rawTx.txId, false, callback);
|
||||
executeTx(deviceFingerprint, rawTx.txId, false, callback);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -474,6 +474,6 @@ exports.verifyUser = function verifyUser(data, callback) {
|
|||
idVerifierPlugin.verifyUser(data, callback);
|
||||
};
|
||||
|
||||
exports.verifyTransaction = function verifyTransaction(data, callback) {
|
||||
exports.verifyTx = function verifyTx(data, callback) {
|
||||
idVerifierPlugin.verifyTransaction(data, callback);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ exports.recordDeviceEvent = function recordDeviceEvent(deviceFingerprint, event,
|
|||
cb);
|
||||
};
|
||||
|
||||
function _getTransactions(txId, onlyPending, cb) {
|
||||
function _getTxs(txId, onlyPending, cb) {
|
||||
var query = 'SELECT * FROM transactions WHERE id=$1';
|
||||
var values = [txId];
|
||||
|
||||
|
|
@ -110,8 +110,8 @@ function _getTransactions(txId, onlyPending, cb) {
|
|||
}
|
||||
|
||||
// returns complete [txs]
|
||||
exports.getTransactions = function getTransactions(txId, cb) {
|
||||
_getTransactions(txId, false, cb);
|
||||
exports.getTxs = function getTxs(txId, cb) {
|
||||
_getTxs(txId, false, cb);
|
||||
};
|
||||
|
||||
exports.getPendingAmount = function getPendingAmount(txId, cb) {
|
||||
|
|
@ -162,14 +162,16 @@ exports.getPendingAmount = function getPendingAmount(txId, cb) {
|
|||
}
|
||||
|
||||
// Nothing to send == nothing to do
|
||||
if (newTx.satoshis <= 0)
|
||||
if (newTx.satoshis <= 0) {
|
||||
logger.error('Negative tx amount (%d) for txId: %s', newTx.satoshis, txId);
|
||||
return cb();
|
||||
}
|
||||
|
||||
cb(null, newTx);
|
||||
});
|
||||
};
|
||||
|
||||
exports.summonTransaction = function summonTransaction(deviceFingerprint, tx, cb) {
|
||||
exports.summonTx = function summonTx(deviceFingerprint, tx, cb) {
|
||||
var fields = [
|
||||
'id',
|
||||
'status',
|
||||
|
|
@ -202,7 +204,7 @@ exports.summonTransaction = function summonTransaction(deviceFingerprint, tx, cb
|
|||
function(err) {
|
||||
if (err) {
|
||||
if (PG_ERRORS[err.code] === 'uniqueViolation')
|
||||
return _getTransactions(tx.txId, false, cb);
|
||||
return _getTxs(tx.txId, false, cb);
|
||||
|
||||
return cb(err);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,10 +87,10 @@ function verifyUser(req, res) {
|
|||
});
|
||||
}
|
||||
|
||||
function verifyTransaction(req, res) {
|
||||
function verifyTx(req, res) {
|
||||
if (mock) return res.json({success: true});
|
||||
|
||||
plugins.verifyTransaction(req.body, function (err, idResult) {
|
||||
plugins.verifyTx(req.body, function (err, idResult) {
|
||||
if (err) {
|
||||
logger.error(err);
|
||||
return res.json({err: 'Verification failed'});
|
||||
|
|
@ -140,7 +140,7 @@ function init(localConfig) {
|
|||
app.post('/trade', authMiddleware, trade);
|
||||
app.post('/event', authMiddleware, deviceEvent);
|
||||
app.post('/verify_user', authMiddleware, verifyUser);
|
||||
app.post('/verify_transaction', authMiddleware, verifyTransaction);
|
||||
app.post('/verify_transaction', authMiddleware, verifyTx);
|
||||
app.post('/pair', pair);
|
||||
|
||||
return app;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue