Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying tx with no recipients/ 0 value #405

Open
FrediDealCash opened this issue Aug 24, 2020 · 6 comments · May be fixed by #424
Open

Displaying tx with no recipients/ 0 value #405

FrediDealCash opened this issue Aug 24, 2020 · 6 comments · May be fixed by #424

Comments

@FrediDealCash
Copy link

The explorer is displaying tx with 0 value and/or txs with no recipients

Any chance this can be changed so that the explorer only displays transactions that have recipients &/or a value greater than 0?

explorer

Thanks a lot for your time!

@B1ackt34
Copy link

I'm interested into this too. I follow.

@uaktags
Copy link
Collaborator

uaktags commented Aug 31, 2020

Sorry guys, I've been swamped with work that I haven't been too active.

That table is referencing /ext/getlasttxesajax/0 from here:

ajax: '/ext/getlasttxsajax/0',

which corresponds to this:

explorer/app.js

Lines 147 to 173 in 9692ab9

app.use('/ext/getlasttxsajax/:min', function(req,res){
if(typeof req.query.length === 'undefined' || isNaN(req.query.length) || req.query.length > settings.index.last_txs){
req.query.length = settings.index.last_txs;
}
if(typeof req.query.start === 'undefined' || isNaN(req.query.start) || req.query.start < 0){
req.query.start = 0;
}
if(typeof req.params.min === 'undefined' || isNaN(req.params.min ) || req.params.min < 0){
req.params.min = 0;
} else {
req.params.min = (req.params.min * 100000000);
}
db.get_last_txs_ajax(req.query.start, req.query.length, req.params.min,function(txs, count){
var data = [];
for(i=0; i<txs.length; i++){
var row = [];
row.push(txs[i].blockindex);
row.push(txs[i].blockhash);
row.push(txs[i].txid);
row.push(txs[i].vout.length);
row.push((txs[i].total));
row.push(new Date((txs[i].timestamp) * 1000).toUTCString());
data.push(row);
}
res.json({"data":data, "draw": req.query.draw, "recordsTotal": count, "recordsFiltered": count});
});
});

So we see in that app.js that /ext/getlasttxsajax/:min has the "min" variable which we've hardcoded in the view to be "0" So /ext/getlasttxsajax/0 ends up passing "0" to the following call here:

explorer/lib/database.js

Lines 374 to 384 in 9692ab9

get_last_txs_ajax: function(start, length, min, cb) {
Tx.find({'total': {$gte: min}}).count(function(err, count){
Tx.find({'total': {$gte: min}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs){
if (err) {
return cb(err);
} else {
return cb(txs, count);
}
});
});
},

Here though is where your issue lies. We're searching for records that have a "TOTAL" amount that is greater-than-or-equal to "0".
I would try changing this to something ridiculously small like ".0000001" in your views/index.pug file on line 56. That should give you the output you're looking to which hides the "0" transactions. Granted, right this moment, I can't think of any ill-effects this will have, but there may be some (hides a false-positive being the worst case scenario).

You can test it by just hitting /ext/getlasttxsajax/.0000001 and seeing if you get any outputs that have 0's in it.

@FrediDealCash
Copy link
Author

FrediDealCash commented Sep 1, 2020

Sorry guys, I've been swamped with work that I haven't been too active.

That table is referencing /ext/getlasttxesajax/0 from here:

ajax: '/ext/getlasttxsajax/0',

which corresponds to this:

explorer/app.js

Lines 147 to 173 in 9692ab9

app.use('/ext/getlasttxsajax/:min', function(req,res){
if(typeof req.query.length === 'undefined' || isNaN(req.query.length) || req.query.length > settings.index.last_txs){
req.query.length = settings.index.last_txs;
}
if(typeof req.query.start === 'undefined' || isNaN(req.query.start) || req.query.start < 0){
req.query.start = 0;
}
if(typeof req.params.min === 'undefined' || isNaN(req.params.min ) || req.params.min < 0){
req.params.min = 0;
} else {
req.params.min = (req.params.min * 100000000);
}
db.get_last_txs_ajax(req.query.start, req.query.length, req.params.min,function(txs, count){
var data = [];
for(i=0; i<txs.length; i++){
var row = [];
row.push(txs[i].blockindex);
row.push(txs[i].blockhash);
row.push(txs[i].txid);
row.push(txs[i].vout.length);
row.push((txs[i].total));
row.push(new Date((txs[i].timestamp) * 1000).toUTCString());
data.push(row);
}
res.json({"data":data, "draw": req.query.draw, "recordsTotal": count, "recordsFiltered": count});
});
});

So we see in that app.js that /ext/getlasttxsajax/:min has the "min" variable which we've hardcoded in the view to be "0" So /ext/getlasttxsajax/0 ends up passing "0" to the following call here:

explorer/lib/database.js

Lines 374 to 384 in 9692ab9

get_last_txs_ajax: function(start, length, min, cb) {
Tx.find({'total': {$gte: min}}).count(function(err, count){
Tx.find({'total': {$gte: min}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs){
if (err) {
return cb(err);
} else {
return cb(txs, count);
}
});
});
},

Here though is where your issue lies. We're searching for records that have a "TOTAL" amount that is greater-than-or-equal to "0".
I would try changing this to something ridiculously small like ".0000001" in your views/index.pug file on line 56. That should give you the output you're looking to which hides the "0" transactions. Granted, right this moment, I can't think of any ill-effects this will have, but there may be some (hides a false-positive being the worst case scenario).

You can test it by just hitting /ext/getlasttxsajax/.0000001 and seeing if you get any outputs that have 0's in it.

I have changed line 56 in views/index.pug to ajax: '/ext/getlasttxsajax/0.00000001', which has worked as you can see below:

image

explorer.idealcash.io

Thanks a lot for helping with this @uaktags

@B1ackt34
Copy link

It works for me too, thank you!

@uaktags
Copy link
Collaborator

uaktags commented Oct 24, 2020

We may want this to go down as a user-setting to hide such transactions. As an overall explorer, we'd want that because it's part of the blockchain that we're "exploring". However, as you guys can tell, it provides no realworld benefit.

@rubber-duckie-au
Copy link

been struggling with this one for a bit and finally stumbled across this. Thanks @uaktags for spending the time on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants