listtransactions results order unkown #17739

issue mrbabtc opened this issue on December 12, 2019
  1. mrbabtc commented at 11:22 PM on December 12, 2019: none

    The problem is that I don't really know which is the order of listtransactions result.

    The documentation doesn't say anything about this,

    I don't know the answer but if someone does please tell me and maybe some dev could include it

    Is ordered by confirmations? By timereceived? both?

  2. mrbabtc added the label Feature on Dec 12, 2019
  3. jonatack commented at 12:31 AM on December 13, 2019: contributor

    Hi @mrbabtc, good question. I could be wrong but I think they are ordered by transaction timereceived (which is the same as time for sent transactions).

    It could probably be made a bit more clear, but here is some explanation:

    In wallet/wallet.cpp::3430 there are details on the timestamp for transactions added to the wallet, and a couple of links. See https://bitcointalk.org/?topic=54527 and #1393.

    /**
     * Compute smart timestamp for a transaction being added to the wallet.
     *
     * Logic:
     * - If sending a transaction, assign its timestamp to the current time.
     * - If receiving a transaction outside a block, assign its timestamp to the
     *   current time.
     * - If receiving a block with a future timestamp, assign all its (not already
     *   known) transactions' timestamps to the current time.
     * - If receiving a block with a past timestamp, before the most recent known
     *   transaction (that we care about), assign all its (not already known)
     *   transactions' timestamps to the same timestamp as that most-recent-known
     *   transaction.
     * - If receiving a block with a past timestamp, but after the most recent known
     *   transaction, assign all its (not already known) transactions' timestamps to
     *   the block time.
     *
     * For more information see CWalletTx::nTimeSmart,
     * https://bitcointalk.org/?topic=54527, or
     * [#1393](/bitcoin-bitcoin/1393/).
     */
    unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const
    {
        unsigned int nTimeSmart = wtx.nTimeReceived;
        if (!wtx.isUnconfirmed() && !wtx.isAbandoned()) {
            int64_t blocktime;
            if (chain().findBlock(wtx.m_confirm.hashBlock, nullptr /* block */, &blocktime)) {
                int64_t latestNow = wtx.nTimeReceived;
    
  4. mrbabtc commented at 12:47 PM on December 13, 2019: none

    Hi @mrbabtc, good question. I could be wrong but I think they are ordered by transaction timereceived (which is the same as time for sent transactions).

    It could probably be made a bit more clear, but here is some explanation:

    In wallet/wallet.cpp::3430 there are details on the timestamp for transactions added to the wallet, and a couple of links. See https://bitcointalk.org/?topic=54527 and #1393.

    /**
     * Compute smart timestamp for a transaction being added to the wallet.
     *
     * Logic:
     * - If sending a transaction, assign its timestamp to the current time.
     * - If receiving a transaction outside a block, assign its timestamp to the
     *   current time.
     * - If receiving a block with a future timestamp, assign all its (not already
     *   known) transactions' timestamps to the current time.
     * - If receiving a block with a past timestamp, before the most recent known
     *   transaction (that we care about), assign all its (not already known)
     *   transactions' timestamps to the same timestamp as that most-recent-known
     *   transaction.
     * - If receiving a block with a past timestamp, but after the most recent known
     *   transaction, assign all its (not already known) transactions' timestamps to
     *   the block time.
     *
     * For more information see CWalletTx::nTimeSmart,
     * https://bitcointalk.org/?topic=54527, or
     * [#1393](/bitcoin-bitcoin/1393/).
     */
    unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const
    {
        unsigned int nTimeSmart = wtx.nTimeReceived;
        if (!wtx.isUnconfirmed() && !wtx.isAbandoned()) {
            int64_t blocktime;
            if (chain().findBlock(wtx.m_confirm.hashBlock, nullptr /* block */, &blocktime)) {
                int64_t latestNow = wtx.nTimeReceived;
    

    Thanks. I mounted a regtest local and I played with wallets closing and opening erasing mempool.dat. Is a fact that isn't ordered by confirmations numbers, and hight probably that is ordered by timereceived

  5. mrbabtc commented at 1:09 PM on December 13, 2019: none

    After testing scenarios I can confirm that is ordered by timereceived without any another criteria (even transactions with less confirmations are shown first)

  6. mrbabtc commented at 1:10 PM on December 13, 2019: none
    
    10:05:03
    
    listtransactions "*" 10 0 true
    
    
    10:05:03
    
    [
      {
        "address": "bcrt1qkxyysf7sjx2znx5wj0jzygtad3atfuze29w3y6",
        "category": "receive",
        "amount": 1.00000000,
        "label": "",
        "vout": 0,
        "confirmations": 0,
        "trusted": false,
        "txid": "aede2bbe1f1fcd2002428d26f04a4ff0d67d37973496b2c2810916cc8567ad1f",
        "walletconflicts": [
        ],
        "time": 1576242237,
        "timereceived": 1576242237,
        "bip125-replaceable": "yes"
      },
      {
        "involvesWatchonly": true,
        "address": "bcrt1q4xx03keh8u88zyaa8p96tr54nzarmj5gghfu6f",
        "category": "receive",
        "amount": 0.10000000,
        "label": "",
        "vout": 0,
        "confirmations": 16,
        "blockhash": "133cefc923308ff7a15951a37891edb774ef269aa0c18468f2d32e8819418263",
        "blockindex": 1,
        "blocktime": 1576240732,
        "txid": "54c348447c2a59a1b052a13ffd9ecae6dc0262fe78e24956f6cb491243c33458",
        "walletconflicts": [
        ],
        "time": 1576242237,
        "timereceived": 1576242259,
        "bip125-replaceable": "no"
      },
      {
        "involvesWatchonly": true,
        "address": "bcrt1q7y7k6pqsaghf2lhvmne4zvsfpwcz6rau54mqr6",
        "category": "receive",
        "amount": 0.10000000,
        "label": "",
        "vout": 1,
        "confirmations": 10,
        "blockhash": "55beb45de2a2a66fa2226b4df5fceaee8ac16d0da830b8c8dcf649d7ba51d2fc",
        "blockindex": 1,
        "blocktime": 1576241544,
        "txid": "ca05a929516720bd1fb30ff1f96219191567ddae19d7057d5e048cca4233620f",
        "walletconflicts": [
        ],
        "time": 1576242237,
        "timereceived": 1576242259,
        "bip125-replaceable": "no"
      }
    ]
    
  7. jonatack commented at 1:13 PM on December 13, 2019: contributor

    Thanks @mrbabtc. I'll update the listtransactions help and code documentation to make this clearer and check the current tests to see if this is tested, and if not, perhaps add a test.

  8. adamjonas removed the label Feature on Aug 2, 2022
  9. adamjonas added the label Docs on Aug 2, 2022
  10. adamjonas added the label good first issue on Aug 2, 2022
  11. hernanmarino commented at 2:27 PM on August 12, 2022: contributor

    Hi , If this is considered important, I can "work" on it. What kind of documentation needs to be updated ? The RPCHelp ? Source code documentation / doxygen ? All of them ?

  12. Ayush170-Future commented at 8:04 PM on February 22, 2023: contributor

    Hello! Is this issue up for grab?  Also, if it is, could someone help specify what kind of documentation has to be updated?

    I'd love to get started on this.

  13. yashviradia commented at 10:42 PM on April 22, 2023: none

    Hi, Is this issue still open? Then I would like to work on it.

  14. maflcko removed the label good first issue on Apr 24, 2023
  15. pinheadmz commented at 1:45 PM on April 27, 2023: member

    This issue is unlikely to be fixed in Bitcoin Core. We'll close for now, but feel free to open another issue or pull request with a fix.

  16. pinheadmz closed this on Apr 27, 2023

  17. bitcoin locked this on Apr 26, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me