diff --git a/backend/app.js b/backend/app.js index e51a2cd..47356c6 100644 --- a/backend/app.js +++ b/backend/app.js @@ -98,7 +98,12 @@ var blockInterval = setInterval( function() { rpc.z_listreceivedbyaddress(fullnode.addr, 1).then(txs => { var re = /.*ZGO::(.*)\sReply-To:\s(z\w+)/; async.each (txs, function(txData, callback) { - var memo = hexToString(txData.memo); + var memo = hexToString(txData.memo).replace(/\0/g, ''); + txmodel.updateOne({txid: txData.txid}, { confirmations: txData.confirmations, amount:txData.amount, memo: memo}, {new:true, upsert:true}, function(err,docs) { + if (err) { + console.log(err); + } + }); if (re.test(memo)) { //console.log('Processing tx:', memo); var match = re.exec(memo); @@ -109,7 +114,12 @@ var blockInterval = setInterval( function() { var amount = txData.amount; var expiration = blocktime; //console.log(' ', session, blocktime); - if (txData.confirmations >= 10 ) { + txmodel.updateOne({txid: txData.txid}, { address: address, session: session, confirmations: txData.confirmations, amount:txData.amount, memo: memo}, {new:true, upsert:true}, function(err,docs) { + if (err) { + console.log(err); + } + }); + if (txData.confirmations >= 6 ) { usermodel.findOne({address: address, session: session, blocktime: blocktime}).then(function(doc){ if (doc != null) { console.log('Found user'); @@ -162,17 +172,7 @@ var blockInterval = setInterval( function() { }).catch((err) => { console.log(err); }); - txmodel.deleteMany({session: session}, function(err) { - if (err) console.log(err); - console.log('Deleted confirmed login'); - }); - } else { - txmodel.updateOne({address: address, session: session}, { confirmations: txData.confirmations, amount:txData.amount}, {new:true, upsert:true}, function(err,docs) { - if (err) { - console.log(err); - } - }); - } + } } } }, function (err) { @@ -230,8 +230,8 @@ app.get('/api/users', (req, res, next) => { }); app.get('/api/pending', (req, res, next) => { - console.log('Get: /api/pending'); - txmodel.find({'session': req.query.session}). + console.log('Get: /api/pending', req.query.session); + txmodel.find({'session': req.query.session, 'confirmations': {$lt: 10}}). then((documents) => { if (documents.length > 0) { //console.log('pending', documents); diff --git a/backend/models/tx.js b/backend/models/tx.js index d55ba1d..570b325 100644 --- a/backend/models/tx.js +++ b/backend/models/tx.js @@ -4,7 +4,9 @@ const txSchema = mongoose.Schema({ address: {type: String}, session: {type: String, required:true}, confirmations: {type: Number, required:true}, - amount: {type: Number, required:true} + amount: {type: Number, required:true}, + txid: {type:String, required:true}, + memo: {type:String} }); module.exports = mongoose.model('Tx', txSchema); diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index 7a12851..032e8c5 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -56,10 +56,10 @@ 0"> Login received! - It needs {{10 - tx.confirmations}} more confirmations. + It needs {{6 - tx.confirmations}} more confirmations. - + Session length @@ -69,6 +69,7 @@ + Wrong pin! loginLog in diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 5c3851c..098a2c1 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -26,6 +26,7 @@ export class LoginComponent implements OnInit { nodeAddress: string = ''; localToken: string | null = ''; selectedValue: number = 0.001; + pinError: boolean = false; public user:User = { address: '', session: '', @@ -43,10 +44,13 @@ export class LoginComponent implements OnInit { tickets = [ { value: 0.001, - viewValue: 'One hour' + viewValue: '1 hour: 0.001 ZEC' },{ value: 0.005, - viewValue: 'One day' + viewValue: '1 day: 0.005 ZEC' + },{ + value: 0.025, + viewValue: '1 week: 0.025 ZEC' } ]; prompt: boolean = false; @@ -85,6 +89,7 @@ export class LoginComponent implements OnInit { } ngOnInit(){ + this.pinError = false; //console.log('Activated route data in Component:::', this.activatedRoute.data); this.activatedRoute.data.subscribe((addrData) => { //console.log('FETCH ADDRESS', addrData); @@ -151,6 +156,8 @@ export class LoginComponent implements OnInit { if (this.user.pin === this.pinForm.value.pinValue) { this.userService.validateUser(); this.router.navigate(['/shop']); + } else { + this.pinError = true; } } diff --git a/src/app/scan/scan.component.css b/src/app/scan/scan.component.css index 08e2a87..77dd87c 100644 --- a/src/app/scan/scan.component.css +++ b/src/app/scan/scan.component.css @@ -7,3 +7,6 @@ h4.text{ margin: 0px; } +.small { + font-size: small; +} diff --git a/src/app/scan/scan.component.html b/src/app/scan/scan.component.html index ba584a3..fea942d 100644 --- a/src/app/scan/scan.component.html +++ b/src/app/scan/scan.component.html @@ -23,4 +23,5 @@ + Can't scan? Use this wallet link.
Wrong pin!
Can't scan? Use this wallet link.