wallet, rpc: add wtxid in WalletTxToJSON #24198

pull brunoerg wants to merge 5 commits into bitcoin:master from brunoerg:2022-01-listtransactions-wtxid changing 4 files +10 −1
  1. brunoerg commented at 10:18 PM on January 28, 2022: member

    This PR add wtxid in WalletTxToJSON which allows to return this field in listsinceblock, listtransactions and gettransaction (RPCs).

  2. w0xlt commented at 10:57 PM on January 28, 2022: contributor

    Concept ACK

  3. DrahtBot added the label RPC/REST/ZMQ on Jan 29, 2022
  4. DrahtBot added the label Wallet on Jan 29, 2022
  5. brunoerg marked this as ready for review on Jan 29, 2022
  6. luke-jr changes_requested
  7. luke-jr commented at 3:55 AM on January 31, 2022: member

    Needs docs updated

  8. brunoerg commented at 11:32 AM on January 31, 2022: member

    Done, thanks @luke-jr.

  9. brunoerg force-pushed on Jan 31, 2022
  10. in src/wallet/rpc/transactions.cpp:38 in fe65dab3db outdated
      32 | @@ -33,7 +33,9 @@ static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue
      33 |          entry.pushKV("trusted", CachedTxIsTrusted(wallet, wtx));
      34 |      }
      35 |      uint256 hash = wtx.GetHash();
      36 | +    uint256 witness_hash = wtx.GetWitnessHash();
      37 |      entry.pushKV("txid", hash.GetHex());
      38 | +    entry.pushKV("wtxid", witness_hash.GetHex());
    


    achow101 commented at 6:12 PM on January 31, 2022:

    In fe65dab3dbef51e49b484e155ffbf7fd01ea2e8e "wallet: add wtxid in WalletTxToJSON"

    nit: witness_hash is not used anywhere else, so it does not need to be a separate variable

        entry.pushKV("wtxid", wtx.GetWitnessHash().GetHex());
    

    brunoerg commented at 6:33 PM on January 31, 2022:

    Done!

  11. achow101 commented at 6:12 PM on January 31, 2022: member

    ACK 96d2cab3b06639c4ab4fa79b72aa81bdefe03492

  12. brunoerg force-pushed on Jan 31, 2022
  13. brunoerg commented at 6:33 PM on January 31, 2022: member

    force-pushed addressing @achow101's comment.

  14. luke-jr commented at 9:50 PM on January 31, 2022: member

    Eh? Still don't see docs updated in the diff...

  15. brunoerg commented at 9:53 PM on January 31, 2022: member

    Eh? Still don't see docs updated in the diff... @luke-jr I created doc/release-notes-24198.md, isn't it the right way? See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#release-notes

  16. luke-jr commented at 10:24 PM on January 31, 2022: member

    Look in src/wallet/rpc/transactions.cpp for:

        return RPCHelpMan{"gettransaction",
                    "\nGet detailed information about in-wallet transaction <txid>\n",
                    {
                        {"txid", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction id"},
    

    You need to add "wtxid" here too. Same for the other affected RPC methods.

  17. brunoerg commented at 10:44 PM on January 31, 2022: member

    You need to add "wtxid" here too. Same for the other affected RPC methods. @luke-jr Sorry, my bad. I was with the release notes in my mind, I forgot that one. Force pushed including it. Thank you!

  18. luke-jr approved
  19. luke-jr commented at 11:17 PM on January 31, 2022: member

    utACK

  20. wallet: add GetWitnessHash() 7482b6f895
  21. wallet: add wtxid in WalletTxToJSON e8c659a297
  22. test: add wtxid in expected_fields for wallet_basic a5b66738f1
  23. brunoerg force-pushed on Feb 1, 2022
  24. brunoerg commented at 11:46 AM on February 1, 2022: member

    Force-pushed - rebasing on master now CI works.

  25. achow101 commented at 7:50 PM on February 1, 2022: member

    ACK 79d6764c133638c7feccf4fb1f98242a9ba0863e

  26. MarcoFalke commented at 7:56 PM on February 1, 2022: member

    Is there a specific use case or is this just for fun?

  27. brunoerg commented at 12:18 AM on February 2, 2022: member

    Is there a specific use case or is this just for fun?

    Not sure if there is a specific use case. I use listsinceblock a lot in a project (and I know many exchanges use it a lot as well, maybe for deposits) and missed it since it could help me to analyze transactions.

  28. in doc/release-notes-24198.md:5 in 79d6764c13 outdated
       0 | @@ -0,0 +1,5 @@
       1 | +Updated RPCs
       2 | +------------
       3 | +
       4 | +- The following RPCs: `listtransactions`, `gettransaction` and `listsinceblock`
       5 | +  now include the `wtxid` of the transaction.
    


    luke-jr commented at 9:14 PM on February 8, 2022:

    nit: Probably a better way to phrase this


    brunoerg commented at 12:27 AM on February 9, 2022:

    Hm, interesting. Maybe:

    "Every transaction returned by the following RPCs: listtransactions, gettransaction and listsinceblock now include a wtxid field (hash of serialized transaction, including witness data)."


    luke-jr commented at 7:19 PM on February 9, 2022:

    Suggest "The listtransactions, gettransaction, and listsinceblock RPC methods now include a wtxid field (hash of serialized transaction, including witness data) for each transaction."


    brunoerg commented at 11:15 PM on February 9, 2022:

    Cool!

  29. in src/wallet/rpc/transactions.cpp:435 in 79d6764c13 outdated
     431 | @@ -431,6 +432,7 @@ static const std::vector<RPCResult> TransactionDescriptionString()
     432 |             {RPCResult::Type::NUM, "blockindex", /*optional=*/true, "The index of the transaction in the block that includes it."},
     433 |             {RPCResult::Type::NUM_TIME, "blocktime", /*optional=*/true, "The block time expressed in " + UNIX_EPOCH_TIME + "."},
     434 |             {RPCResult::Type::STR_HEX, "txid", "The transaction id."},
     435 | +           {RPCResult::Type::STR_HEX, "wtxid", "The witness transaction id."},
    


    luke-jr commented at 9:16 PM on February 8, 2022:

    nit: The two existing "wtxid" descriptions are different.

    I prefer "hash of serialized transaction, including witness data"


    brunoerg commented at 12:12 AM on February 9, 2022:

    I also prefer "hash of serialized transaction, including witness data", going to change it.


    taveechaimekwan commented at 1:15 AM on February 9, 2022:

  30. luke-jr approved
  31. luke-jr commented at 9:17 PM on February 8, 2022: member

    re-utACK 79d6764c133638c7feccf4fb1f98242a9ba0863e

    nit: IMO squash 79d6764c133 (RPC docs) and a5b66738f19 (QA) into e8c659a2970 (feature addition)

  32. DrahtBot commented at 8:40 PM on February 9, 2022: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #24293 ((Refactor) QA: wallet_basic: Split wtx expected_fields over multiple lines to minimise merge conflicts by luke-jr)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  33. brunoerg force-pushed on Feb 9, 2022
  34. brunoerg commented at 11:21 PM on February 9, 2022: member

    Force-pushed addressing @luke-jr's comments

  35. doc: add wtxid info in release-notes 2d596bce6f
  36. doc: include wtxid in TransactionDescriptionString 7abd8b21ba
  37. brunoerg force-pushed on Feb 10, 2022
  38. w0xlt approved
  39. w0xlt commented at 2:20 PM on February 10, 2022: contributor

    crACK 7abd8b2

  40. achow101 commented at 1:15 PM on March 8, 2022: member

    re-ACK 7abd8b21ba34f6a42db2cd2d59a4c0e08561f609

  41. achow101 commented at 1:16 PM on March 8, 2022: member

    @luke-jr re-review this?

  42. luke-jr approved
  43. luke-jr commented at 7:22 PM on March 8, 2022: member

    re-utACK 7abd8b21ba34f6a42db2cd2d59a4c0e08561f609

  44. achow101 merged this on Mar 8, 2022
  45. achow101 closed this on Mar 8, 2022

  46. sidhujag referenced this in commit db3a7ef421 on Mar 9, 2022
  47. DrahtBot locked this on Mar 8, 2023

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