WIP: build: Enable -Wunused #36167

Draft
fanquake wants to merge 3 commits from enable_wunused into master AGit
fanquake commented 2026-09-04 14:32:39 +00:00 (Migrated from github.com)

We've had a handful of dead code removal PRs recently:

Also well as an instance of what was thought to be dead code, but it'd just been forgotten to be used: #36137.

It could be beneficial to get -Wunused enabled, to catch dead/unused code in CI.

Enabling some of these flags may also help enforce other stuff, like inline constexpr usage (#35852). i.e:

  /home/runner/work/_temp/src/leveldb/db/dbformat.h:67:29: error: 'leveldb::kMaxSequenceNumber' defined but not used [-Werror=unused-const-variable=]
     67 | static const SequenceNumber kMaxSequenceNumber = ((0x1ull << 56) - 1);
        |                             ^~~~~~~~~~~~~~~~~~

Based on:

We've had a handful of dead code removal PRs recently: * #35679 * #35910 * #35914 * #35971 * #36009 * #36012 * #36103 * #36127 * #36509 * #36706 * #36713 Also well as an instance of what was thought to be dead code, but it'd just been forgotten to be used: #36137. It could be beneficial to get `-Wunused` enabled, to catch dead/unused code in CI. Enabling some of these flags may also help enforce other stuff, like `inline constexpr` usage (#35852). i.e: ```bash /home/runner/work/_temp/src/leveldb/db/dbformat.h:67:29: error: 'leveldb::kMaxSequenceNumber' defined but not used [-Werror=unused-const-variable=] 67 | static const SequenceNumber kMaxSequenceNumber = ((0x1ull << 56) - 1); | ^~~~~~~~~~~~~~~~~~ ``` Based on: * https://github.com/bitcoin-core/minisketch/pull/104
DrahtBot commented 2026-09-04 14:32:51 +00:00 (Migrated from github.com)

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

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37033 (rpc: remove duplicate avgfeerate key in getblockstats by fanquake)
  • #36946 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)
  • #36897 (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101)
  • #36885 (wallet, rpc: Add analyzedescriptor for multisig setups by pablomartin4btc)
  • #36871 (wallet: Clear streams before advancing BDB cursor by jaromil)
  • #36856 (kernel: add manual pruning by pzafonte)
  • #36854 (kernel: let callers create the block manager by pzafonte)
  • #36823 (wallet, migration: Skip legacy wallet records rather than erasing them, and drop unused record erase functions by achow101)
  • #36820 (refactor: remove more dead code by fanquake)
  • #36603 (Improve loadtxoutset performance by ajtowns)
  • #36326 (kernel: Use typed errors for fatal and flush error notifications by arejula27)
  • #36154 (wallet: fill PSBT_GLOBAL_XPUB by jeanpablojp)
  • #36122 (BIP460: CISA for Taproot key path spends by fjahr)
  • #35911 (Warn on and add missing [[noreturn]] by fanquake)
  • #35906 (First steps towards a stateless, side-effect free validation library by purpleKarrot)
  • #35760 (wallet: make corrupted transaction records fail wallet loading instead of forcing a rescan by achow101)
  • #35591 ([DO NOT MERGE] Erlay: bandwidth-efficient transaction relay protocol (Full implementation) by sr-gi)
  • #35302 (Silent Payments: Sending (take 2) by Eunovo)
  • #34520 (refactor: Add nodiscard to functions returning bool+mutable ref by maflcko)
  • #34132 (coins,dbwrapper: make database point-read failures fatal by l0rinc)
  • #33324 (blocks: add resumable reobfuscation for existing block files by l0rinc)
  • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36167 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36167.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36167#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#37033](https://github.com/bitcoin/bitcoin/pull/37033) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37033.svg"></sub> (rpc: remove duplicate `avgfeerate` key in `getblockstats` by fanquake) * [#36946](https://github.com/bitcoin/bitcoin/pull/36946) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36946.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko) * [#36897](https://github.com/bitcoin/bitcoin/pull/36897) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36897.svg"></sub> (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101) * [#36885](https://github.com/bitcoin/bitcoin/pull/36885) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36885.svg"></sub> (wallet, rpc: Add analyzedescriptor for multisig setups by pablomartin4btc) * [#36871](https://github.com/bitcoin/bitcoin/pull/36871) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36871.svg"></sub> (wallet: Clear streams before advancing BDB cursor by jaromil) * [#36856](https://github.com/bitcoin/bitcoin/pull/36856) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36856.svg"></sub> (kernel: add manual pruning by pzafonte) * [#36854](https://github.com/bitcoin/bitcoin/pull/36854) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36854.svg"></sub> (kernel: let callers create the block manager by pzafonte) * [#36823](https://github.com/bitcoin/bitcoin/pull/36823) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36823.svg"></sub> (wallet, migration: Skip legacy wallet records rather than erasing them, and drop unused record erase functions by achow101) * [#36820](https://github.com/bitcoin/bitcoin/pull/36820) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36820.svg"></sub> (refactor: remove more dead code by fanquake) * [#36603](https://github.com/bitcoin/bitcoin/pull/36603) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36603.svg"></sub> (Improve loadtxoutset performance by ajtowns) * [#36326](https://github.com/bitcoin/bitcoin/pull/36326) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36326.svg"></sub> (kernel: Use typed errors for fatal and flush error notifications by arejula27) * [#36154](https://github.com/bitcoin/bitcoin/pull/36154) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36154.svg"></sub> (wallet: fill PSBT_GLOBAL_XPUB by jeanpablojp) * [#36122](https://github.com/bitcoin/bitcoin/pull/36122) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36122.svg"></sub> (BIP460: CISA for Taproot key path spends by fjahr) * [#35911](https://github.com/bitcoin/bitcoin/pull/35911) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35911.svg"></sub> (Warn on and add missing `[[noreturn]]` by fanquake) * [#35906](https://github.com/bitcoin/bitcoin/pull/35906) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35906.svg"></sub> (First steps towards a stateless, side-effect free validation library by purpleKarrot) * [#35760](https://github.com/bitcoin/bitcoin/pull/35760) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35760.svg"></sub> (wallet: make corrupted transaction records fail wallet loading instead of forcing a rescan by achow101) * [#35591](https://github.com/bitcoin/bitcoin/pull/35591) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35591.svg"></sub> ([DO NOT MERGE] Erlay: bandwidth-efficient transaction relay protocol (Full implementation) by sr-gi) * [#35302](https://github.com/bitcoin/bitcoin/pull/35302) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35302.svg"></sub> (Silent Payments: Sending (take 2) by Eunovo) * [#34520](https://github.com/bitcoin/bitcoin/pull/34520) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34520.svg"></sub> (refactor: Add [[nodiscard]] to functions returning bool+mutable ref by maflcko) * [#34132](https://github.com/bitcoin/bitcoin/pull/34132) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34132.svg"></sub> (coins,dbwrapper: make database point-read failures fatal by l0rinc) * [#33324](https://github.com/bitcoin/bitcoin/pull/33324) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33324.svg"></sub> (blocks: add resumable reobfuscation for existing block files by l0rinc) * [#27865](https://github.com/bitcoin/bitcoin/pull/27865) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/27865.svg"></sub> (wallet: Track no-longer-spendable TXOs separately by achow101) 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-->
DrahtBot commented 2026-09-04 15:54:50 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task lint: https://github.com/bitcoin/bitcoin/actions/runs/33884346846/job/101060370925
LLM reason (✨ experimental): CI failed the subtree lint check because a subtree directory was modified without the required subtree merge (FAIL: subtree directory was touched without subtree merge).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `lint`: https://github.com/bitcoin/bitcoin/actions/runs/33884346846/job/101060370925</sub> <sub>LLM reason (✨ experimental): CI failed the `subtree` lint check because a subtree directory was modified without the required subtree merge (`FAIL: subtree directory was touched without subtree merge`).</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
maflcko (Migrated from github.com) reviewed 2026-09-16 10:46:48 +00:00
maflcko (Migrated from github.com) commented 2026-09-16 10:46:48 +00:00

Nice, but I think those should:

  • use the C++11 narrowing-check init `double ...{0.75};
  • Maybe be split up into a separate pull from the unused parameter warnings

Haven't tried this, but what about just a small pull to add:

try_append_cxx_flags("-Wunused-macros" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wunused-const-variable=2" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wunused-member-function" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wunused-template" TARGET warn_interface SKIP_LINK)
etc...whatever...

And leave the -Wno-unused-parameter as-is for now?

Those should catch most of the issues mentioned in OP (except for the unused parameter ones)?

Nice, but I think those should: * use the C++11 narrowing-check init `double ...{0.75}; * Maybe be split up into a separate pull from the unused parameter warnings Haven't tried this, but what about just a small pull to add: ``` try_append_cxx_flags("-Wunused-macros" TARGET warn_interface SKIP_LINK) try_append_cxx_flags("-Wunused-const-variable=2" TARGET warn_interface SKIP_LINK) try_append_cxx_flags("-Wunused-member-function" TARGET warn_interface SKIP_LINK) try_append_cxx_flags("-Wunused-template" TARGET warn_interface SKIP_LINK) etc...whatever... ``` And leave the `-Wno-unused-parameter` as-is for now? Those should catch most of the issues mentioned in OP (except for the unused parameter ones)?
fanquake (Migrated from github.com) reviewed 2026-09-16 15:15:03 +00:00
fanquake (Migrated from github.com) commented 2026-09-16 15:15:03 +00:00

Split a portion out into #36275.

Split a portion out into #36275.
DrahtBot commented 2026-09-17 15:25:49 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
First-time contributor

This is a draft pull request, so Ralph reviewed only its concept. Code review runs on the first push after it is marked ready for review.

Earlier concerns neither republished nor resolved: 5 suggestions. See the Run archive linked from the Review report for their assessments.

Design and approach

Catching dead code and accidentally omitted uses through CI is worth pursuing, but this draft has not demonstrated additional detection sufficient to justify the broad cleanup. The submitted policy retains -Wno-unused-parameter, while the baseline already requests broad and specific unused-code warnings. The historical overlap concern strengthens the need for evidence, without proving redundancy on every supported compiler.

Before investing in detailed review, show an actionable mistake that the pinned base accepts but the submitted policy rejects on a supported CI compiler, alongside an intentional-non-use case that remains quiet. That would make the detection benefit assessable against annotation churn and compiler-dependent maintenance. If the intended benefit instead depends on enabling unused-parameter diagnostics later, state that scope explicitly. The current evidence does not establish that the approach should be abandoned.

Review coverage was incomplete.


Reviewed: 2322fd4802fb · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:e1a29e5e677c47d383756f0fcf8f3760725c91d1104dd3ccb2f333b6217eba26:47880f5569fd2047d249266f337c4f2a509adf7d96c3ccb1c7644c2c2a650bff --> <!-- ralph-base:8bb33f349e6d9c3bbcd8cd108cecf67048d907a2 --> <!-- ralph-head:2322fd4802fb855d64fa4a47ee6c07f0a44e9dec --> <!-- ralph-case:c5f9aa9cca57341b91045581cb23cc9ecb7178226b8386dcc6c937008a48acbd --> This is a draft pull request, so Ralph reviewed only its concept. Code review runs on the first push after it is marked ready for review. Earlier concerns neither republished nor resolved: 5 suggestions. See the Run archive linked from the Review report for their assessments. ##### Design and approach Catching dead code and accidentally omitted uses through CI is worth pursuing, but this draft has not demonstrated additional detection sufficient to justify the broad cleanup. The [submitted policy](https://git.fish.foo/bitcoin/bitcoin/pulls/36167) retains `-Wno-unused-parameter`, while the baseline already requests broad and specific unused-code warnings. The [historical overlap concern](https://github.com/bitcoin/bitcoin/pull/21458#discussion_r727715726) strengthens the need for evidence, without proving redundancy on every supported compiler. Before investing in detailed review, show an actionable mistake that the pinned base accepts but the submitted policy rejects on a supported CI compiler, alongside an intentional-non-use case that remains quiet. That would make the detection benefit assessable against annotation churn and compiler-dependent maintenance. If the intended benefit instead depends on enabling unused-parameter diagnostics later, state that scope explicitly. The current evidence does not establish that the approach should be abandoned. Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`2322fd4802fb`](<https://git.fish.foo/bitcoin/bitcoin/commit/2322fd4802fb855d64fa4a47ee6c07f0a44e9dec>) · [Review report](<https://review.fish.foo/report/36167-2322fd4802fb855d64fa4a47ee6c07f0a44e9dec-3478-15.html>) · [Previous reports](<https://review.fish.foo/traces/36167/>) [permalink](<https://review.fish.foo/report/36167-2322fd4802fb855d64fa4a47ee6c07f0a44e9dec-3478-15.html>)
maflcko (Migrated from github.com) reviewed 2026-09-29 15:12:00 +00:00
maflcko (Migrated from github.com) commented 2026-09-29 15:12:00 +00:00

still not sure about enabling the unused-param one. I think we want to use self here more, not remove it. But using it would require touching this line again.

Maybe some of the other warnings can be enabled https://github.com/bitcoin/bitcoin/pull/36167#discussion_r4025132623?

still not sure about enabling the unused-param one. I think we want to use `self` here more, not remove it. But using it would require touching this line again. Maybe some of the other warnings can be enabled https://github.com/bitcoin/bitcoin/pull/36167#discussion_r4025132623?
fanquake (Migrated from github.com) reviewed 2026-09-29 16:53:51 +00:00
fanquake (Migrated from github.com) commented 2026-09-29 16:53:51 +00:00

I'll split more of this out.

I'll split more of this out.
fanquake (Migrated from github.com) reviewed 2026-09-29 16:54:37 +00:00
fanquake (Migrated from github.com) commented 2026-09-29 16:54:37 +00:00

I think we want to use self here more,

Are there any PRs currently doing this? I'll split more of this out.

> I think we want to use self here more, Are there any PRs currently doing this? I'll split more of this out.
maflcko (Migrated from github.com) reviewed 2026-09-29 20:06:51 +00:00
maflcko (Migrated from github.com) commented 2026-09-29 20:06:51 +00:00
Sure, see https://github.com/bitcoin/bitcoin/pull/36384
DrahtBot commented 2026-10-02 15:24:53 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
maflcko (Migrated from github.com) reviewed 2026-10-13 06:39:36 +00:00
maflcko (Migrated from github.com) commented 2026-10-13 06:39:36 +00:00

can you split this one out? Possibly also -Wunused-macros (if meaningful, etc)?

can you split this one out? Possibly also -Wunused-macros (if meaningful, etc)?
fanquake (Migrated from github.com) reviewed 2026-10-13 08:39:58 +00:00
fanquake (Migrated from github.com) commented 2026-10-13 08:39:58 +00:00

Put them into #36509.

Put them into #36509.
DrahtBot commented 2026-10-21 11:36:23 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-04 13:05:57 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
maflcko (Migrated from github.com) reviewed 2026-11-05 18:08:23 +00:00
maflcko (Migrated from github.com) commented 2026-11-05 18:08:23 +00:00

Also, for the context, I wonder if we can pipe it through self and then instead remove the JSONRPCRequest instead of RPCMethod:

diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 3852358..6123c38 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -170,3 +170,3 @@ static RPCMethod stop()
                 RPCExamples{""},
-        [](const RPCMethod& self, const JSONRPCRequest& jsonRequest) -> UniValue
+        [](const RPCMethod& self, const JSONRPCRequest&) -> UniValue
 {
@@ -174,5 +174,5 @@ static RPCMethod stop()
     // this reply will get back to the client.
-    CHECK_NONFATAL((CHECK_NONFATAL(EnsureAnyNodeContext(jsonRequest.context).shutdown_request))());
-    if (jsonRequest.params[0].isNum()) {
-        UninterruptibleSleep(std::chrono::milliseconds{jsonRequest.params[0].getInt<int>()});
+    CHECK_NONFATAL((CHECK_NONFATAL(EnsureAnyNodeContext(self.Context()).shutdown_request))());
+    if (const auto wait{self.MaybeArg<int>("wait")}) {
+        UninterruptibleSleep(std::chrono::milliseconds{*wait});
     }
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index e2cf363..ccad9da 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -694,2 +694,7 @@ UniValue RPCMethod::HandleRequest(const JSONRPCRequest& request) const
 
+const std::any& RPCMethod::Context() const
+{
+    return CHECK_NONFATAL(m_req)->context;
+}
+
 using CheckFn = void(const RPCArg&);
diff --git a/src/rpc/util.h b/src/rpc/util.h
index bf17885..0e2a075 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -18,2 +18,3 @@
 
+#include <any>
 #include <cstddef>
@@ -451,2 +452,5 @@ public:
     UniValue HandleRequest(const JSONRPCRequest& request) const;
+    /// Return the context for the current RPC method invocation.
+    /// Like Arg(), this is only available during the method implementation.
+    const std::any& Context() const;
     /**
Also, for the context, I wonder if we can pipe it through `self` and then instead remove the `JSONRPCRequest` instead of `RPCMethod`: ```diff diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 3852358..6123c38 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -170,3 +170,3 @@ static RPCMethod stop() RPCExamples{""}, - [](const RPCMethod& self, const JSONRPCRequest& jsonRequest) -> UniValue + [](const RPCMethod& self, const JSONRPCRequest&) -> UniValue { @@ -174,5 +174,5 @@ static RPCMethod stop() // this reply will get back to the client. - CHECK_NONFATAL((CHECK_NONFATAL(EnsureAnyNodeContext(jsonRequest.context).shutdown_request))()); - if (jsonRequest.params[0].isNum()) { - UninterruptibleSleep(std::chrono::milliseconds{jsonRequest.params[0].getInt<int>()}); + CHECK_NONFATAL((CHECK_NONFATAL(EnsureAnyNodeContext(self.Context()).shutdown_request))()); + if (const auto wait{self.MaybeArg<int>("wait")}) { + UninterruptibleSleep(std::chrono::milliseconds{*wait}); } diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index e2cf363..ccad9da 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -694,2 +694,7 @@ UniValue RPCMethod::HandleRequest(const JSONRPCRequest& request) const +const std::any& RPCMethod::Context() const +{ + return CHECK_NONFATAL(m_req)->context; +} + using CheckFn = void(const RPCArg&); diff --git a/src/rpc/util.h b/src/rpc/util.h index bf17885..0e2a075 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -18,2 +18,3 @@ +#include <any> #include <cstddef> @@ -451,2 +452,5 @@ public: UniValue HandleRequest(const JSONRPCRequest& request) const; + /// Return the context for the current RPC method invocation. + /// Like Arg(), this is only available during the method implementation. + const std::any& Context() const; /**
DrahtBot commented 2026-11-06 00:22:17 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-23 10:39:22 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-12-03 10:52:06 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36167
No description provided.