WIP
This commit is contained in:
parent
2c756e231a
commit
2e51bf646e
2 changed files with 4 additions and 43 deletions
|
|
@ -30,7 +30,6 @@ var tradeInterval = null;
|
|||
var reapTxInterval = null;
|
||||
|
||||
var tradesQueue = [];
|
||||
var dispenseStatuses = {};
|
||||
|
||||
// that's basically a constructor
|
||||
exports.init = function init(databaseHandle) {
|
||||
|
|
@ -280,35 +279,6 @@ exports.sendBitcoins = function sendBitcoins(deviceFingerprint, rawTx, cb) {
|
|||
executeTx(deviceFingerprint, rawTx, cb);
|
||||
};
|
||||
|
||||
// sets given status both "locally" (dispenseStatuses) and saves to db
|
||||
function _setDispenseStatus(deviceFingerprint, tx, status, deposit) {
|
||||
tx.status = status;
|
||||
|
||||
// No need to set default state again
|
||||
if (status !== 'noDeposit')
|
||||
// save to db ASAP
|
||||
db.changeTxStatus(tx.txId, status, {
|
||||
hash: tx.txHash
|
||||
});
|
||||
|
||||
var fiat = 0;
|
||||
if (status === 'authorizedDeposit')
|
||||
fiat = tx.fiat;
|
||||
|
||||
var statusObject = null;
|
||||
if (status !== 'dispensedDeposit')
|
||||
statusObject = {
|
||||
status: status,
|
||||
txId: tx.txId,
|
||||
deposit: deposit || 0,
|
||||
dispenseFiat: fiat,
|
||||
expectedDeposit: tx.satoshis
|
||||
};
|
||||
|
||||
// keep local copy
|
||||
dispenseStatuses[deviceFingerprint] = statusObject;
|
||||
}
|
||||
|
||||
exports.cashOut = function cashOut(deviceFingerprint, tx, cb) {
|
||||
var tmpInfo = {
|
||||
label: 'TX ' + Date.now(),
|
||||
|
|
@ -324,11 +294,6 @@ exports.cashOut = function cashOut(deviceFingerprint, tx, cb) {
|
|||
};
|
||||
|
||||
exports.dispenseAck = function dispenseAck(deviceFingerprint, tx) {
|
||||
_setDispenseStatus(deviceFingerprint, tx, 'dispensedDeposit');
|
||||
};
|
||||
|
||||
exports.dispenseStatus = function dispenseStatus(deviceFingerprint) {
|
||||
return dispenseStatuses[deviceFingerprint];
|
||||
};
|
||||
|
||||
exports.fiatBalance = function fiatBalance() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue