Fix some issues tracking unconfirmed txs
This commit is contained in:
parent
997276638f
commit
f3e8bf22e3
4 changed files with 17 additions and 15 deletions
|
@ -98,7 +98,7 @@ 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, '');
|
||||
if (re.test(memo)) {
|
||||
//console.log('Processing tx:', memo);
|
||||
var match = re.exec(memo);
|
||||
|
@ -109,6 +109,11 @@ var blockInterval = setInterval( function() {
|
|||
var amount = txData.amount;
|
||||
var expiration = blocktime;
|
||||
//console.log(' ', session, blocktime);
|
||||
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 >= 10 ) {
|
||||
usermodel.findOne({address: address, session: session, blocktime: blocktime}).then(function(doc){
|
||||
if (doc != null) {
|
||||
|
@ -162,16 +167,6 @@ 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,8 +225,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<p *ngIf="pinError">Wrong pin!</p>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" [disabled]="!entryForm.valid" (click)="login()">
|
||||
<mat-icon class="icon">login</mat-icon><span class="bigbutton">Log in</span>
|
||||
|
|
|
@ -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: '',
|
||||
|
@ -83,6 +84,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);
|
||||
|
@ -145,6 +147,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue