no more partial transactions
This commit is contained in:
parent
dfe35b81cb
commit
bf91825495
1 changed files with 6 additions and 22 deletions
|
|
@ -286,7 +286,7 @@ function reapTxs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Run these in parallel and return success
|
// TODO: Run these in parallel and return success
|
||||||
exports.trade = function trade(session, rawTrade, cb) {
|
exports.trade = function trade (session, rawTrade, cb) {
|
||||||
|
|
||||||
// TODO: move this to DB, too
|
// TODO: move this to DB, too
|
||||||
// add bill to trader queue (if trader is enabled)
|
// add bill to trader queue (if trader is enabled)
|
||||||
|
|
@ -294,28 +294,12 @@ exports.trade = function trade(session, rawTrade, cb) {
|
||||||
tradesQueue.push({
|
tradesQueue.push({
|
||||||
currency: rawTrade.currency,
|
currency: rawTrade.currency,
|
||||||
satoshis: rawTrade.satoshis
|
satoshis: rawTrade.satoshis
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rawTrade.toAddress) {
|
if (!rawTrade.toAddress) rawTrade.toAddress = 'remit'
|
||||||
var newRawTrade = _.cloneDeep(rawTrade);
|
return db.recordBill(session, rawTrade, cb)
|
||||||
newRawTrade.toAddress = 'remit';
|
}
|
||||||
return db.recordBill(session, newRawTrade, cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
var tx = {
|
|
||||||
txId: rawTrade.txId,
|
|
||||||
fiat: 0,
|
|
||||||
satoshis: 0,
|
|
||||||
toAddress: rawTrade.toAddress,
|
|
||||||
currencyCode: rawTrade.currency
|
|
||||||
};
|
|
||||||
|
|
||||||
async.parallel([
|
|
||||||
async.apply(db.addOutgoingPending, session, tx.currencyCode, tx.toAddress),
|
|
||||||
async.apply(db.recordBill, session, rawTrade)
|
|
||||||
], cb);
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.sendBitcoins = function sendBitcoins(session, rawTx, cb) {
|
exports.sendBitcoins = function sendBitcoins(session, rawTx, cb) {
|
||||||
executeTx(session, rawTx, 'machine', cb);
|
executeTx(session, rawTx, 'machine', cb);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue