Bitcoin Forum
May 25, 2024, 12:48:27 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: listtransactions output is not in order  (Read 2148 times)
burnside (OP)
Legendary
*
Offline Offline

Activity: 1106
Merit: 1006


Lead Blockchain Developer


View Profile WWW
May 15, 2013, 12:42:22 AM
Last edit: May 15, 2013, 06:25:47 PM by burnside
Merited by ABCbits (2)
 #1

I have an issue where the output of listtransactions is not in chronological order.  I depend on it somewhat to be able to give people updates on their deposits.  It's been broken for some time, no idea how it got screwed up and I initially fixed it in our web application's code just by pulling 10k records, but performance has been poor and I'd much prefer to just get this fixed.

I'm guessing this code is not returning them oldest to newest:  (bitcoind 0.8.1, rpcwallet.cpp around line 1047)

Code:
    CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount);

    // iterate backwards until we have nCount items to return:
    for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
    {
        CWalletTx *const pwtx = (*it).second.first;
        if (pwtx != 0)
            ListTransactions(*pwtx, strAccount, 0, true, ret);
        CAccountingEntry *const pacentry = (*it).second.second;
        if (pacentry != 0)
            AcentryToJSON(*pacentry, strAccount, ret);

        if ((int)ret.size() >= (nCount+nFrom)) break;
    }
    // ret is newest to oldest

Because what comes out of here is not oldest to newest:

Code:
std::reverse(ret.begin(), ret.end()); // Return oldest to newest

I tried to add the following above the std::reverse():

Code:
std::stable_sort(ret.begin(), ret.end());

But with that in there it doesn't compile.

Can any C++ guys out there lend a hand?
burnside (OP)
Legendary
*
Offline Offline

Activity: 1106
Merit: 1006


Lead Blockchain Developer


View Profile WWW
May 16, 2013, 11:24:35 PM
 #2

anyone?
nixoid
Jr. Member
*
Offline Offline

Activity: 44
Merit: 1



View Profile WWW
July 24, 2013, 08:26:29 AM
Merited by ABCbits (1)
 #3

I've submitted this bug to github: https://github.com/bitcoin/bitcoin/issues/2853
burnside (OP)
Legendary
*
Offline Offline

Activity: 1106
Merit: 1006


Lead Blockchain Developer


View Profile WWW
July 24, 2013, 09:01:34 AM
 #4

Thank you.  Wink

Quoting Luke:

Quote
"Chronological order" is a bit ambiguous when it comes to Bitcoin transactions, which don't have timestamps! Where is this documentation?
listtransactions should stick to the order transactions were seen in, and try to guess a reasonable time partially based on that.

It's not displaying them in the order they were seen in.  The transactions displayed right now are months old on a wallet that sees thousands of transactions a day.  I can take the timestamp epoch and converted it is clear it's months old.  Plus it's been the same ones it displays since I first reported it.  If I list them all on a certain account, new transactions are showing up somewhere in the middle of the bunch.

I did work around this issue with the since last block call, and I'll iterate on that when I upgrade to use the new ability to call a local script when a new transaction is detected.

Still.... would be nice if things worked as described.  Wink

Cheers.
nixoid
Jr. Member
*
Offline Offline

Activity: 44
Merit: 1



View Profile WWW
July 30, 2013, 09:06:51 AM
 #5

I've already figured outworkaround:
listtransactions "*" 1000 0
instead of
listtransactions "" 1000 0

in this case it works as expected
elbandi
Hero Member
*****
Offline Offline

Activity: 525
Merit: 529


View Profile
December 22, 2015, 05:47:37 PM
 #6

I've already figured outworkaround:
listtransactions "*" 1000 0
instead of
listtransactions "" 1000 0

in this case it works as expected
it doesnt work for me.

$ callrpc listtransactions "" 99999999 0 |wc -l
36767
$ callrpclisttransactions "*" 99999999 0 |wc -l
1067733

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!