rest: add interface for gettxspendingprevout rpc #33904

pull kevkevinpal wants to merge 1 commits into bitcoin:master from kevkevinpal:feat/rest-gettxspendingprevout changing 3 files +291 −1
  1. kevkevinpal commented at 4:37 PM on November 18, 2025: contributor

    Summary

    This creates a REST interface for the gettxspendingprevout RPC, it also includes functional tests and updates to the REST docs

    This is part of #33808, and now that sstone’s PR #24539 is merged, I added mempool_only and return_spending_tx as query params.

  2. DrahtBot added the label RPC/REST/ZMQ on Nov 18, 2025
  3. DrahtBot commented at 4:37 PM on November 18, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33904.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK sedited

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34794 (rest: add Cache-Control headers to REST responses by w0xlt)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. kevkevinpal force-pushed on Nov 18, 2025
  5. DrahtBot added the label CI failed on Nov 18, 2025
  6. DrahtBot removed the label CI failed on Nov 18, 2025
  7. DrahtBot added the label Needs rebase on Dec 17, 2025
  8. fanquake commented at 7:21 AM on March 16, 2026: member

    would still need @sstone’s PR #24539, but that can be left as a follow-up for when it is merged.

    That PR has been merged.

  9. kevkevinpal force-pushed on Mar 16, 2026
  10. kevkevinpal commented at 1:20 PM on March 16, 2026: contributor

    rebased to 9b4bc27

  11. DrahtBot removed the label Needs rebase on Mar 16, 2026
  12. kevkevinpal force-pushed on Mar 16, 2026
  13. DrahtBot added the label CI failed on Mar 16, 2026
  14. kevkevinpal commented at 2:09 PM on March 16, 2026: contributor

    I updated to add mempool_only and return_spending_tx as query params

  15. DrahtBot removed the label CI failed on Mar 16, 2026
  16. sedited requested review from stickies-v on Mar 19, 2026
  17. sedited requested review from stickies-v on Mar 19, 2026
  18. sedited commented at 9:42 AM on May 10, 2026: contributor

    Concept ACK

  19. in src/rest.cpp:940 in 296b7ade11
     935 | +
     936 | +            for (size_t idx : unresolved) {
     937 | +                const COutPoint& prevout = prevouts[idx];
     938 | +                UniValue o(UniValue::VOBJ);
     939 | +                o.pushKV("txid", prevout.hash.ToString());
     940 | +                o.pushKV("vout", (uint64_t)prevout.n);
    


    maflcko commented at 8:07 AM on May 11, 2026:

    please no redundant and confusing c-style casts.

    Also, the new code should follow the code style for new code:

    • Clang-format-diff
    • multi-line ifs with {} braces
    • ...

    kevkevinpal commented at 1:55 PM on May 11, 2026:

    Thanks for the review! I pushed updates for the code style in 84a1f67

  20. kevkevinpal force-pushed on May 11, 2026
  21. maflcko commented at 2:02 PM on May 11, 2026: member

    Also, please reword the pull description to remove @ mentions, which will turn into spam pings, when the text ends up in commit message(s)

  22. kevkevinpal commented at 2:06 PM on May 11, 2026: contributor

    Also, please reword the pull description to remove @ mentions, which will turn into spam pings, when the text ends up in commit message(s)

    Oops, good point. removed!

  23. kevkevinpal commented at 2:19 PM on May 11, 2026: contributor

    CI failure for Windows native, fuzz, VSWindows native, fuzz, VS is unrelated to the changes

  24. DrahtBot added the label CI failed on May 11, 2026
  25. DrahtBot removed the label CI failed on May 12, 2026
  26. in src/rest.cpp:962 in 84a1f671de outdated
     957 | +        }
     958 | +
     959 | +        std::string str_json = result.write() + "\n";
     960 | +        req->WriteHeader("Content-Type", "application/json");
     961 | +        req->WriteReply(HTTP_OK, str_json);
     962 | +        return true;
    


    sedited commented at 12:11 PM on June 11, 2026:

    Can you take a look at how this was now implemented in the RPC code and align this implementation with that code? The prevouts_to_process and make_output helpers make this a bit easier to deal with and the code easier to understand.


    kevkevinpal commented at 1:56 AM on June 17, 2026:

    I agree that makes sense in b7a73192b7f33d583f81a05d6b46c61d0ebffb72 I used prevouts_to_process and make_output

  27. in doc/REST-interface.md:159 in 84a1f671de outdated
     154 | @@ -155,6 +155,48 @@ Refer to the `getrawmempool` RPC help for details. Defaults to setting
     155 |  
     156 |  *Query parameters for `verbose` and `mempool_sequence` available in 25.0 and up.*
     157 |  
     158 | +#### Transaction Spending Previous Outputs
     159 | +`GET /rest/txspendingprevout/<TXID>-<N>/<TXID>-<N>/.../<TXID>-<N>.json`
    


    sedited commented at 12:18 PM on June 11, 2026:

    Should we be limiting the number of outpoints that can be queried at once?


    kevkevinpal commented at 1:55 AM on June 17, 2026:

    Yeah, that makes sense. I pushed b7a73192b7f33d583f81a05d6b46c61d0ebffb72 that reuses MAX_GETUTXOS_OUTPOINTS to limit the number of outpoints a user can query at once.

  28. in test/functional/interface_rest.py:417 in 84a1f671de outdated
     413 | @@ -414,6 +414,95 @@ def run_test(self):
     414 |          for tx in txs:
     415 |              assert tx in json_obj['tx']
     416 |  
     417 | +        self.log.info("Test the /txspendingprevout URI")
    


    sedited commented at 12:20 PM on June 11, 2026:

    We already switch on the blockfilterindex in this test. Should we switch on the txospenderindex to exercise that logic too?


    kevkevinpal commented at 1:56 AM on June 17, 2026:

    Yup added it in b7a73192b7f33d583f81a05d6b46c61d0ebffb72

    Thanks for the review!

  29. kevkevinpal force-pushed on Jun 17, 2026
  30. DrahtBot added the label CI failed on Jun 17, 2026
  31. DrahtBot marked this as a draft on Jun 19, 2026
  32. DrahtBot commented at 8:53 AM on June 19, 2026: contributor

    Converted to draft, due to failing CI

  33. rest: add interface for gettxspendingprevout rpc
    This creates a REST interface for the gettxspendingprevout rpc and also
    includes functional tests
    231eafec02
  34. kevkevinpal force-pushed on Jun 20, 2026
  35. DrahtBot removed the label CI failed on Jun 20, 2026
  36. kevkevinpal marked this as ready for review on Jun 23, 2026

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-07-04 02:51 UTC

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