Merge branch 'lock-table'
Merges in fix for double sending
This commit is contained in:
commit
08b8ab9575
2 changed files with 62 additions and 1 deletions
60
dev/double-spend-scenario.js
Normal file
60
dev/double-spend-scenario.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
var db = require('../lib/postgresql_interface')
|
||||
var connectionString = 'postgres://lamassu:lamassu@localhost/lamassu'
|
||||
db.init(connectionString)
|
||||
|
||||
var session = {
|
||||
id: '6ede611c-cd03-11e5-88ee-2b5fcfdb0bc2',
|
||||
fingerprint: 'xx:xx'
|
||||
}
|
||||
var tx = {
|
||||
fiat: 40,
|
||||
satoshis: 6980000,
|
||||
toAddress: '1xxx',
|
||||
currencyCode: 'CAD',
|
||||
incoming: false
|
||||
}
|
||||
|
||||
var tx2 = {
|
||||
fiat: 0,
|
||||
satoshis: 6980000,
|
||||
toAddress: '1xxx',
|
||||
currencyCode: 'CAD',
|
||||
incoming: false
|
||||
}
|
||||
|
||||
db.addOutgoingTx(session, tx, function (err, res) {
|
||||
console.log('DEBUG1')
|
||||
console.log(err)
|
||||
console.log(res)
|
||||
})
|
||||
|
||||
db.addOutgoingTx(session, tx2, function (err, res) {
|
||||
console.log('DEBUG2')
|
||||
console.log(err)
|
||||
console.log(res)
|
||||
})
|
||||
|
||||
/*
|
||||
setTimeout(function () {
|
||||
db.addOutgoingTx(session, tx2, function (err, res) {
|
||||
console.log('DEBUG2')
|
||||
console.log(err)
|
||||
console.log(res)
|
||||
})
|
||||
}, 0)
|
||||
*/
|
||||
|
||||
var bills = {
|
||||
uuid: 'c630338c-cd03-11e5-a9df-dbc9be2e9fbb',
|
||||
currency: 'CAD',
|
||||
toAddress: '1xxx',
|
||||
deviceTime: Date.now(),
|
||||
satoshis: 6980000,
|
||||
fiat: 40
|
||||
}
|
||||
|
||||
/*
|
||||
db.recordBill(session, bills, function (err) {
|
||||
console.log(err)
|
||||
})
|
||||
*/
|
||||
|
|
@ -347,6 +347,7 @@ exports.addOutgoingTx = function addOutgoingTx(session, tx, cb) {
|
|||
if (cerr) return cb(cerr);
|
||||
async.series([
|
||||
async.apply(silentQuery, client, 'BEGIN'),
|
||||
async.apply(silentQuery, client, 'LOCK TABLE transactions'),
|
||||
async.apply(insertOutgoingCompleteTx, client, session, tx),
|
||||
async.apply(removePendingTx, client, session),
|
||||
async.apply(buildOutgoingTx, client, session, tx)
|
||||
|
|
@ -357,7 +358,7 @@ exports.addOutgoingTx = function addOutgoingTx(session, tx, cb) {
|
|||
}
|
||||
silentQuery(client, 'COMMIT', [], function() {
|
||||
done();
|
||||
var toSend = results[3];
|
||||
var toSend = results[4];
|
||||
cb(null, toSend);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue