diff --git a/lib/cash-in-tx.js b/lib/cash-in-tx.js index 1c608433..f66e7270 100644 --- a/lib/cash-in-tx.js +++ b/lib/cash-in-tx.js @@ -30,11 +30,22 @@ function post (tx, pi) { }) } +function nilEqual (a, b) { + if (_.isNil(a) && _.isNil(b)) return true + + return undefined +} + function diff (oldTx, newTx) { let updatedTx = {} UPDATEABLE_FIELDS.forEach(fieldKey => { - if (oldTx && _.isEqual(oldTx[fieldKey], newTx[fieldKey])) return + console.log('DEBUG80: %j', [oldTx[fieldKey], newTx[fieldKey]]) + if (oldTx && _.isEqualWith(nilEqual, oldTx[fieldKey], newTx[fieldKey])) return + + // We never null out an existing field + if (oldTx && _.isNil(newTx[fieldKey])) return + updatedTx[fieldKey] = newTx[fieldKey] }) diff --git a/lib/plugins.js b/lib/plugins.js index f05c9f63..3506a088 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -136,7 +136,6 @@ function plugins (settings, deviceId) { // NOTE: This will fail if we have already sent coins because there will be // a unique dbm record in the table already. function sendCoins (tx) { - console.log('DEBUG50: %j', settings) return wallet.sendCoins(settings, tx.toAddress, tx.cryptoAtoms, tx.cryptoCode) } diff --git a/lib/routes.js b/lib/routes.js index 35fe056a..4eda34a6 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -79,7 +79,6 @@ function poll (req, res, next) { } function postTx (req, res, next) { - console.log('DEBUG60: %j', req.settings) const pi = plugins(req.settings, req.deviceId) return Tx.post(_.set('deviceId', req.deviceId, req.body), pi)