only trade after receiving funds

This commit is contained in:
Josh Harvey 2017-04-20 20:19:13 +03:00
parent d5aab9dfd0
commit b9465a4cf9

View file

@ -189,13 +189,12 @@ function preProcess (tx, newTx, pi) {
}
function postProcess (txVector, pi) {
const [oldTx, newTx] = txVector
if (!oldTx) pi.sell(newTx)
const [, newTx] = txVector
if (newTx.dispensed && !newTx.bills) {
return pi.buildCartridges()
.then(cartridges => {
pi.sell(newTx)
return _.set('bills', billMath.makeChange(cartridges.cartridges, newTx.fiat), newTx)
})
}