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)
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:
std::reverse(ret.begin(), ret.end()); // Return oldest to newest
I tried to add the following above the std::reverse():
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?