Revert "no more partial transactions"

This reverts commit bf91825495.
This commit is contained in:
Josh Harvey 2016-02-07 02:44:26 +02:00
parent bf91825495
commit 142ef12bd6

View file

@ -121,7 +121,7 @@ function loadOrConfigPlugin(pluginHandle, pluginType, currency,
pluginHandle = loadPlugin(currentName, pluginConfig); pluginHandle = loadPlugin(currentName, pluginConfig);
currentlyUsedPlugins[pluginType] = currentName currentlyUsedPlugins[pluginType] = currentName
logger.debug('plugin(%s) loaded: %s', pluginType, pluginHandle.NAME || logger.debug('plugin(%s) loaded: %s', pluginType, pluginHandle.NAME ||
currentName); currentName);
} }
} }
@ -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,12 +294,28 @@ 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) rawTrade.toAddress = 'remit' if (!rawTrade.toAddress) {
return db.recordBill(session, rawTrade, cb) var newRawTrade = _.cloneDeep(rawTrade);
} 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);