btc1 / bitcoin

btc1 project bitcoin implementation
MIT License
329 stars 55 forks source link

listtransactions in ascending order #140

Closed jgarzik closed 4 years ago

jgarzik commented 6 years ago

https://github.com/Bitcoin-com/btc1/blob/segwit2x/src/wallet/rpcwallet.cpp#L1681 [paste from email]

This code adds an RPC command that lists transactions in ascending order instead of descending. I don't know why bitcoind still don't have this. Listing transactions in asc order makes more sense for a app developer, since then I can just keep a transaction index and poll the latest transaction by running "listtransactionsasc '*' 1 [index+1]" from my app.

This code has been ported to Dash, Zcash, Zcoin and others, I have added this to Bitcoin Unlimited, BitcoinABC and BTC1, but I'm getting a little tired of porting this code every time there is a new fork of bitcoind.

bitPico commented 6 years ago

Instead of reinventing the wheel via code duplication just add an RPC Param to the existing Method and if it is set then don't do this:

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