Bitcoin Forum
November 03, 2024, 03:36:52 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: listtransactions <count> <from> returns incorrect results  (Read 1064 times)
monsterer (OP)
Legendary
*
Offline Offline

Activity: 1008
Merit: 1007


View Profile
September 06, 2013, 10:27:01 AM
 #1

Hi guys,

I'm trying to get a list of the n most recent transactions on an account, using listtransactions. However, the results returned are not the n most recent when you specify the <from> field.

Example:

What you get is only the n - <from> most recent transactions:

Code:
i.e. listtransactions <account> 3 2 

5 oldest
*-----returned data------------
4 old
3 new
2 new <--- from 2
*-----returned data------------
1 new
0 newest

When what you should get is:

Code:
i.e. listtransactions <account> 3 2 

5 oldest
4 old
3 new
*-----returned data------------
2 new <--- from 2
1 new
0 newest
*-----returned data------------

Any idea how I can get the desired result without having to pull every single transaction down, and reverse the index?

Cheers, Paul.
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4270
Merit: 8805



View Profile WWW
September 06, 2013, 10:35:53 AM
 #2

I think this is works as designed as works as you'd want it to work.

Since it returns that last count, you want the from to be end-index. Indexing the count from the start isn't useful unless you know in advance how many transactions there are.   E.g. to get all of then you would do

bitcoind listtransactions "*" 10 0
bitcoind listtransactions "*" 10 10
bitcoind listtransactions "*" 10 20
...
until you get an empty result.

monsterer (OP)
Legendary
*
Offline Offline

Activity: 1008
Merit: 1007


View Profile
September 06, 2013, 10:58:58 AM
 #3

The documentation describes:

Quote
Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]

But in actual fact:

Quote
Returns up to [count] most recent transactions skipping the newest [from] transactions for account [account]

In addition, there is no way to page through the data as it stands because there is no total transaction count?
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4270
Merit: 8805



View Profile WWW
September 06, 2013, 11:41:41 AM
 #4

In addition, there is no way to page through the data as it stands because there is no total transaction count?
... You do not need a transaction count to page through the data with that way that it actually works, as I pointed out.
Start from zero and increase by N until you have no results.  Tada.

I agree the documentation is confusing/wrong and needs to be fixed. Do you agree that you can page through it with how it actually works?
monsterer (OP)
Legendary
*
Offline Offline

Activity: 1008
Merit: 1007


View Profile
September 06, 2013, 01:15:26 PM
 #5

In addition, there is no way to page through the data as it stands because there is no total transaction count?
... You do not need a transaction count to page through the data with that way that it actually works, as I pointed out.
Start from zero and increase by N until you have no results.  Tada.

I agree the documentation is confusing/wrong and needs to be fixed. Do you agree that you can page through it with how it actually works?


I agree it's possible, but it's highly inefficient - imagine if there were 10k transactions per account, and you were paging through them in an amortised fashion, finding transactions you had not yet seen, processing them and moving on. Every time you need to check for new transactions starting from where you left off, you have to process every transaction all over again?
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4270
Merit: 8805



View Profile WWW
September 06, 2013, 01:25:49 PM
 #6

I agree it's possible, but it's highly inefficient - imagine if there were 10k transactions per account, and you were paging through them in an amortised fashion, finding transactions you had not yet seen, processing them and moving on. Every time you need to check for new transactions starting from where you left off, you have to process every transaction all over again?
If you are trying to monitor for new transactions you want the listsince call, which is designed exactly for this purpose.
monsterer (OP)
Legendary
*
Offline Offline

Activity: 1008
Merit: 1007


View Profile
September 06, 2013, 01:31:33 PM
 #7

I agree it's possible, but it's highly inefficient - imagine if there were 10k transactions per account, and you were paging through them in an amortised fashion, finding transactions you had not yet seen, processing them and moving on. Every time you need to check for new transactions starting from where you left off, you have to process every transaction all over again?
If you are trying to monitor for new transactions you want the listsince call, which is designed exactly for this purpose.


Yes, thanks - this is what I've moved on to looking at. I just wasn't sure what use case you'd ever have for listtransactions <account> <count> <from> as it stands? Seemed like a bug. Smiley
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!