fix redeem bugs
This commit is contained in:
parent
91e1077daa
commit
dd7d06f38b
4 changed files with 17 additions and 6 deletions
|
|
@ -25,6 +25,15 @@ const STALE_INCOMING_TX_AGE = T.week
|
|||
const STALE_LIVE_INCOMING_TX_AGE = 10 * T.minutes
|
||||
const MAX_NOTIFY_AGE = 2 * T.days
|
||||
const MIN_NOTIFY_AGE = 5 * T.minutes
|
||||
const INSUFFICIENT_FUNDS_CODE = 570
|
||||
|
||||
function httpError (msg, code) {
|
||||
const err = new Error(msg)
|
||||
err.name = 'HTTPError'
|
||||
err.code = code || 500
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
function post (tx, pi) {
|
||||
console.log('DEBUG101: %j', tx)
|
||||
|
|
@ -275,7 +284,9 @@ function postProcess (txVector, pi) {
|
|||
return pi.buildCassettes()
|
||||
.then(cassettes => {
|
||||
pi.sell(newTx)
|
||||
return _.set('bills', billMath.makeChange(cassettes.cassettes, newTx.fiat), newTx)
|
||||
const bills = billMath.makeChange(cassettes.cassettes, newTx.fiat)
|
||||
if (!bills) throw httpError('Out of bills', INSUFFICIENT_FUNDS_CODE)
|
||||
return _.set('bills', bills, newTx)
|
||||
})
|
||||
.then(tx => {
|
||||
const rec = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue