From e2d619c56da90b74074d25b1dd0f7a814aecd8fe Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Thu, 7 Apr 2016 13:25:34 +0100 Subject: [PATCH] cash-in working --- lib/plugins.js | 4 ++-- lib/postgresql_interface.js | 6 +++--- lib/routes.js | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index 072454eb..64980173 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -251,7 +251,7 @@ function _sendCoins (toAddress, cryptoAtoms, cryptoCode, cb) { var walletPlugin = walletPlugins[cryptoCode] var transactionFee = cachedConfig.exchanges.settings.transactionFee if (cryptoCode === 'BTC') { - walletPlugin.sendBitcoins(toAddress, cryptoAtoms, transactionFee, cb) + walletPlugin.sendBitcoins(toAddress, cryptoAtoms.truncated().toNumber(), transactionFee, cb) } else { walletPlugin.sendBitcoins(toAddress, cryptoAtoms, cryptoCode, transactionFee, cb) } @@ -301,7 +301,7 @@ function reapTx (row) { var session = {fingerprint: row.device_fingerprint, id: row.session_id} var tx = { fiat: 0, - satoshis: row.satoshis, + satoshis: new BigNumber(row.satoshis), toAddress: row.to_address, currencyCode: row.currency_code, cryptoCode: row.crypto_code, diff --git a/lib/postgresql_interface.js b/lib/postgresql_interface.js index e75b2c08..e27f6487 100644 --- a/lib/postgresql_interface.js +++ b/lib/postgresql_interface.js @@ -182,8 +182,8 @@ function computeSendAmount (tx, totals) { var fiatRemaining = (tx.fiat || totals.billsFiat) - totals.txFiat var satoshisRemaining = tx.satoshis.eq(0) - ? totals.billsSatoshis.minus(totals.txSatoshis) - : tx.satoshis.minus(totals.txSatoshis) + ? totals.billsSatoshis.minus(totals.txSatoshis) + : tx.satoshis.minus(totals.txSatoshis) var result = { fiat: fiatRemaining, @@ -296,7 +296,7 @@ function insertTx (client, session, incoming, tx, satoshis, fiat, stage, incoming, session.fingerprint, tx.toAddress, - satoshis, + satoshis.toString(), tx.currencyCode, tx.cryptoCode, fiat, diff --git a/lib/routes.js b/lib/routes.js index c6520654..ad298f9a 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -115,6 +115,7 @@ function trade (req, res) { function send (req, res) { var tx = req.body tx.cryptoAtoms = new BigNumber(tx.cryptoAtoms) + tx.satoshis = tx.cryptoAtoms plugins.sendCoins(session(req), tx, function (err, status) { // TODO: use status.statusCode here after confirming machine compatibility