Merge branch 'master' into dev
This commit is contained in:
commit
2265ab6512
6 changed files with 34 additions and 20 deletions
|
@ -98,7 +98,12 @@ var blockInterval = setInterval( function() {
|
||||||
rpc.z_listreceivedbyaddress(fullnode.addr, 1).then(txs => {
|
rpc.z_listreceivedbyaddress(fullnode.addr, 1).then(txs => {
|
||||||
var re = /.*ZGO::(.*)\sReply-To:\s(z\w+)/;
|
var re = /.*ZGO::(.*)\sReply-To:\s(z\w+)/;
|
||||||
async.each (txs, function(txData, callback) {
|
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)) {
|
if (re.test(memo)) {
|
||||||
//console.log('Processing tx:', memo);
|
//console.log('Processing tx:', memo);
|
||||||
var match = re.exec(memo);
|
var match = re.exec(memo);
|
||||||
|
@ -109,7 +114,12 @@ var blockInterval = setInterval( function() {
|
||||||
var amount = txData.amount;
|
var amount = txData.amount;
|
||||||
var expiration = blocktime;
|
var expiration = blocktime;
|
||||||
//console.log(' ', session, 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){
|
usermodel.findOne({address: address, session: session, blocktime: blocktime}).then(function(doc){
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
console.log('Found user');
|
console.log('Found user');
|
||||||
|
@ -162,17 +172,7 @@ var blockInterval = setInterval( function() {
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(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) {
|
}, function (err) {
|
||||||
|
@ -230,8 +230,8 @@ app.get('/api/users', (req, res, next) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/pending', (req, res, next) => {
|
app.get('/api/pending', (req, res, next) => {
|
||||||
console.log('Get: /api/pending');
|
console.log('Get: /api/pending', req.query.session);
|
||||||
txmodel.find({'session': req.query.session}).
|
txmodel.find({'session': req.query.session, 'confirmations': {$lt: 10}}).
|
||||||
then((documents) => {
|
then((documents) => {
|
||||||
if (documents.length > 0) {
|
if (documents.length > 0) {
|
||||||
//console.log('pending', documents);
|
//console.log('pending', documents);
|
||||||
|
|
|
@ -4,7 +4,9 @@ const txSchema = mongoose.Schema({
|
||||||
address: {type: String},
|
address: {type: String},
|
||||||
session: {type: String, required:true},
|
session: {type: String, required:true},
|
||||||
confirmations: {type: Number, 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);
|
module.exports = mongoose.model('Tx', txSchema);
|
||||||
|
|
|
@ -56,10 +56,10 @@
|
||||||
<mat-card class="alert-success" *ngIf = "txs.length > 0">
|
<mat-card class="alert-success" *ngIf = "txs.length > 0">
|
||||||
<h4>Login received!</h4>
|
<h4>Login received!</h4>
|
||||||
<mat-list>
|
<mat-list>
|
||||||
<mat-list-item *ngFor="let tx of txsUpdate | async">It needs {{10 - tx.confirmations}} more confirmations.</mat-list-item>
|
<mat-list-item *ngFor="let tx of txsUpdate | async">It needs {{6 - tx.confirmations}} more confirmations.</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
<mat-card [formGroup]="entryForm" *ngIf="!prompt">
|
<mat-card [formGroup]="entryForm" *ngIf="!prompt && txs.length <=0">
|
||||||
<div align="center" id="info">
|
<div align="center" id="info">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Session length</mat-label>
|
<mat-label>Session length</mat-label>
|
||||||
|
@ -69,6 +69,7 @@
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<p *ngIf="pinError">Wrong pin!</p>
|
||||||
<mat-card-actions>
|
<mat-card-actions>
|
||||||
<button mat-raised-button color="primary" [disabled]="!entryForm.valid" (click)="login()">
|
<button mat-raised-button color="primary" [disabled]="!entryForm.valid" (click)="login()">
|
||||||
<mat-icon class="icon">login</mat-icon><span class="bigbutton">Log in</span>
|
<mat-icon class="icon">login</mat-icon><span class="bigbutton">Log in</span>
|
||||||
|
|
|
@ -26,6 +26,7 @@ export class LoginComponent implements OnInit {
|
||||||
nodeAddress: string = '';
|
nodeAddress: string = '';
|
||||||
localToken: string | null = '';
|
localToken: string | null = '';
|
||||||
selectedValue: number = 0.001;
|
selectedValue: number = 0.001;
|
||||||
|
pinError: boolean = false;
|
||||||
public user:User = {
|
public user:User = {
|
||||||
address: '',
|
address: '',
|
||||||
session: '',
|
session: '',
|
||||||
|
@ -43,10 +44,13 @@ export class LoginComponent implements OnInit {
|
||||||
tickets = [
|
tickets = [
|
||||||
{
|
{
|
||||||
value: 0.001,
|
value: 0.001,
|
||||||
viewValue: 'One hour'
|
viewValue: '1 hour: 0.001 ZEC'
|
||||||
},{
|
},{
|
||||||
value: 0.005,
|
value: 0.005,
|
||||||
viewValue: 'One day'
|
viewValue: '1 day: 0.005 ZEC'
|
||||||
|
},{
|
||||||
|
value: 0.025,
|
||||||
|
viewValue: '1 week: 0.025 ZEC'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
prompt: boolean = false;
|
prompt: boolean = false;
|
||||||
|
@ -85,6 +89,7 @@ export class LoginComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(){
|
ngOnInit(){
|
||||||
|
this.pinError = false;
|
||||||
//console.log('Activated route data in Component:::', this.activatedRoute.data);
|
//console.log('Activated route data in Component:::', this.activatedRoute.data);
|
||||||
this.activatedRoute.data.subscribe((addrData) => {
|
this.activatedRoute.data.subscribe((addrData) => {
|
||||||
//console.log('FETCH ADDRESS', addrData);
|
//console.log('FETCH ADDRESS', addrData);
|
||||||
|
@ -151,6 +156,8 @@ export class LoginComponent implements OnInit {
|
||||||
if (this.user.pin === this.pinForm.value.pinValue) {
|
if (this.user.pin === this.pinForm.value.pinValue) {
|
||||||
this.userService.validateUser();
|
this.userService.validateUser();
|
||||||
this.router.navigate(['/shop']);
|
this.router.navigate(['/shop']);
|
||||||
|
} else {
|
||||||
|
this.pinError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,3 +7,6 @@
|
||||||
h4.text{
|
h4.text{
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
.small {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
|
@ -23,4 +23,5 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<p class="small text">Can't scan? Use this <a [href]="zcashUrl">wallet link</a>.
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
|
|
Loading…
Reference in a new issue