feat(trade): trade now understands partial txs
This commit is contained in:
parent
be6900a7a9
commit
f37b210c2e
1 changed files with 27 additions and 5 deletions
|
|
@ -184,10 +184,32 @@ exports.trade = function trade(rawTrade, deviceFingerprint) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// record (vel log) inserted bill
|
||||||
|
db.recordBill(deviceFingerprint, rawTrade);
|
||||||
|
|
||||||
|
// cache partial Transaction (if supported by machine)
|
||||||
|
if (rawTrade.partialTx) {
|
||||||
|
var tx = {
|
||||||
|
txId: rawTrade.txId,
|
||||||
|
status: 'partial',
|
||||||
|
toAddress: rawTrade.toAddress,
|
||||||
|
currencyCode: rawTrade.currency,
|
||||||
|
satoshis: rawTrade.partialTx.satoshis,
|
||||||
|
fiat: rawTrade.partialTx.fiat
|
||||||
|
};
|
||||||
|
db.summonTransaction(deviceFingerprint, tx, function(err, txInfo) {
|
||||||
|
logger.debug('plugins|cache|err', err);
|
||||||
|
logger.debug('plugins|cache|info', txInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// add bill to trader queue (if trader is enabled)
|
||||||
|
if (traderPlugin) {
|
||||||
tradesQueue.push({
|
tradesQueue.push({
|
||||||
currency: rawTrade.currency,
|
currency: rawTrade.currency,
|
||||||
satoshis: rawTrade.satoshis
|
satoshis: rawTrade.satoshis
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.fiatBalance = function fiatBalance() {
|
exports.fiatBalance = function fiatBalance() {
|
||||||
|
|
@ -222,7 +244,7 @@ exports.sendBitcoins = function sendBitcoins(deviceFingerprint, tx, callback) {
|
||||||
db.summonTransaction(deviceFingerprint, tx, function(err, txInfo) {
|
db.summonTransaction(deviceFingerprint, tx, function(err, txInfo) {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
if (!txInfo) {
|
if (!txInfo || txInfo.status === 'partial') {
|
||||||
clearSession(deviceFingerprint);
|
clearSession(deviceFingerprint);
|
||||||
|
|
||||||
return walletPlugin.sendBitcoins(
|
return walletPlugin.sendBitcoins(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue