Author

Topic: listtransactions output is not in order (Read 2170 times)

hero member
Activity: 525
Merit: 531
December 22, 2015, 12: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

jr. member
Activity: 46
Merit: 1
July 30, 2013, 04:06:51 AM
#5
I've already figured outworkaround:
listtransactions "*" 1000 0
instead of
listtransactions "" 1000 0

in this case it works as expected
legendary
Activity: 1106
Merit: 1006
Lead Blockchain Developer
July 24, 2013, 04: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.
jr. member
Activity: 46
Merit: 1
July 24, 2013, 03:26:29 AM
#3
I've submitted this bug to github: https://github.com/bitcoin/bitcoin/issues/2853
legendary
Activity: 1106
Merit: 1006
Lead Blockchain Developer
anyone?
legendary
Activity: 1106
Merit: 1006
Lead Blockchain Developer
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?
Jump to: