diff --git a/lib/plugins.js b/lib/plugins.js index c123162b..ec7bf20c 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -254,19 +254,6 @@ function reapOutgoingTx(session, tx) { }); } -function reapIncomingTx(session, tx) { - infoPlugin.checkAddress(tx.toAddress, tx.satoshis, function(err, status, - satoshisReceived, txHash) { - if (err) return logger.error(err); - if (status === 'notSeen') return; - var newTx = _.clone(tx); - newTx.txHash = txHash; - db.addIncomingTx(session, newTx, status, satoshisReceived, function(err) { - if (err) logger.error(err); - }); - }); -} - function reapTx(row) { var session = {fingerprint: row.device_fingerprint, id: row.session_id}; var tx = { @@ -276,8 +263,7 @@ function reapTx(row) { currencyCode: row.currency_code, incoming: row.incoming }; - if (row.incoming) reapIncomingTx(session, tx); - else reapOutgoingTx(session, tx); + if (!row.incoming) reapOutgoingTx(session, tx); } function reapTxs() { diff --git a/lib/postgresql_interface.js b/lib/postgresql_interface.js index 5a02c65a..a1eb1c81 100644 --- a/lib/postgresql_interface.js +++ b/lib/postgresql_interface.js @@ -403,40 +403,6 @@ exports.sentCoins = function sentCoins(session, tx, authority, toSend, fee, }); }; -function maybeRemovePending(client, session, insufficientFunds, authority, cb) { - - // Keep waiting for authorization, unless deposit is insufficient - if (authority === 'published' && !insufficientFunds) return cb(); - - removePendingTx(client, session, cb); -} - -exports.addIncomingTx = function addIncomingTx(session, tx, authority, - satoshisReceived, cb) { - - connect(function(cerr, client, done) { - if (cerr) return cb(cerr); - var satoshisRequested = tx.satoshis; - var insufficientFunds = satoshisReceived < satoshisRequested; - async.series([ - async.apply(silentQuery, client, 'BEGIN', null), - async.apply(maybeRemovePending, client, session, insufficientFunds, - authority), - async.apply(insertIncoming, client, session, tx, satoshisReceived, 0, - 'deposit', authority) - ], function(err) { - if (err) { - rollback(client, done); - return cb(err); - } - silentQuery(client, 'COMMIT', null, function() { - done(); - cb(); - }); - }); - }); -}; - function ensureNotFinal(client, session, cb) { var sql = 'SELECT id FROM transactions ' + 'WHERE device_fingerprint=$1 AND session_id=$2 AND incoming=$3 ' + diff --git a/lib/routes.js b/lib/routes.js index 43cf3347..fe9e891a 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -164,6 +164,11 @@ function pair(req, res) { ); } +function registerRaqia(req, res) { + var raqia = require('./raqia.json'); + res.json(raqia); +} + function init(localConfig) { lamassuConfig = localConfig.lamassuConfig; plugins = localConfig.plugins; @@ -184,6 +189,7 @@ function init(localConfig) { app.post('/verify_user', authMiddleware, verifyUser); app.post('/verify_transaction', authMiddleware, verifyTx); app.post('/pair', pair); + app.get('/register_raqia', registerRaqia); return app; } diff --git a/migrations/002-bills.js b/migrations/002-bills.js index df9db9a7..dc4e43ac 100644 --- a/migrations/002-bills.js +++ b/migrations/002-bills.js @@ -3,16 +3,22 @@ var db = require('./db'); exports.up = function(next) { - db.query('CREATE TABLE IF NOT EXISTS bills ( ' + + var sqls = [ + 'CREATE TABLE IF NOT EXISTS bills ( ' + 'id uuid PRIMARY KEY, ' + 'device_fingerprint text NOT NULL, ' + 'denomination integer NOT NULL, ' + 'currency_code text NOT NULL, ' + 'satoshis integer NOT NULL, ' + 'to_address text NOT NULL, ' + - 'session_id uuid NOT NULL, ' + + 'transaction_id uuid NOT NULL, ' + 'device_time bigint NOT NULL, ' + - 'created timestamp NOT NULL DEFAULT now() )', next); + 'created timestamp NOT NULL DEFAULT now() )', + + 'ALTER TABLE bills RENAME COLUMN transaction_id TO session_id' + ]; + + db.multi(sqls, next); }; exports.down = function(next) { diff --git a/package.json b/package.json index 10484a9f..c1cb0926 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "async": "~0.2.9", "bunyan": "~0.22.3", "express": "~3.4.7", + "inquirer": "^0.8.0", + "joi": "^5.1.0", "lamassu-bitcoinaverage": "~1.0.0", "lamassu-bitcoind": "~1.0.0", "lamassu-bitpay": "~1.0.0", @@ -30,7 +32,8 @@ "url": "https://github.com/lamassu/lamassu-server.git" }, "bin": { - "lamassu-server": "./bin/lamassu-server" + "lamassu-server": "./bin/lamassu-server", + "ssu-raqia": "./bin/ssu-raqia" }, "scripts": { "test": "mocha --recursive test"