init: Fix surprising behaviors of negated options #36880

Open
fjahr wants to merge 8 commits from 2026-11-rpc-no-fix into master AGit
fjahr commented 2026-11-15 12:42:00 +00:00 (Migrated from github.com)

While looking into #36759 I discovered -notorcontrol did the opposite of what would be expected from it and I then checked for similar issues in other init options. There are several more where -nofoo does something surprising including one of them crashing the node.

This PR attempts to fix all these surprising behaviors while also keeping things as simple as possible and just change behavior to something that makes sense harmless in the context of the option. Fixes that use a common approach for the fix are grouped together into a commit even if the options included themselves may have no relation at all.

Commit Problematic options behavior Fix approach
mempool: Reject cluster limits below 1 -nolimitclustercount hits an assertion in TxGraph on the first mempool transaction. -nolimitclustersize rejects every transaction. Reject values below 1 at startup.
args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string GetArg() returns "0" for a negated option. The -no*notify options run the command 0, -nosigner uses 0 as signer, -noi2psam fails startup and -norpcpassword sets the password to 0. Opt-in because options like -noonion and -noblockfilterindex depend on reading "0". New opt-in flag NEGATE_TO_EMPTY makes GetArg() return "".
init: Read -cjdnsreachable and -help as booleans -cjdnsreachable=0 and -nocjdnsreachable turn CJDNS on. -nohelp prints the help. Use GetBoolArg() instead of IsArgSet().
args, wallet: Fix empty and negated -blocksdir and -walletdir -noblocksdir writes block files relative to the working directory. -nowalletdir fails startup. Fail at startup with DISALLOW_NEGATION. An empty value falls back to the default directory, like -datadir does.
init: Require -nolistenonion with -notorcontrol -notorcontrol connects to 0.0.0.0:9051, which reaches a local Tor. Fail at startup unless -listenonion is disabled.
init: Disallow negating options where it has no meaning -nocheckblocks, -nomaxreceivebuffer, -nomaxsendbuffer and -nomaxtipage read as 0, the opposite of what the user asked for. Fail at startup with DISALLOW_NEGATION.

-nomempoolexpiry has a similar kind of problem. It evicts transactions as soon as the next one arrives. I left it out because #36540 already is open and addresses this.

While looking into #36759 I discovered `-notorcontrol` did the opposite of what would be expected from it and I then checked for similar issues in other init options. There are several more where `-nofoo` does something surprising including one of them crashing the node. This PR attempts to fix all these surprising behaviors while also keeping things as simple as possible and just change behavior to something that makes sense harmless in the context of the option. Fixes that use a common approach for the fix are grouped together into a commit even if the options included themselves may have no relation at all. | Commit | Problematic options behavior | Fix approach | |---|---|---| | [mempool: Reject cluster limits below 1](https://github.com/bitcoin/bitcoin/commit/512773d111daaa4330c873ed5889b9ef511f6e3a) | `-nolimitclustercount` hits an assertion in `TxGraph` on the first mempool transaction. `-nolimitclustersize` rejects every transaction. | Reject values below 1 at startup. | | [args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string](https://github.com/bitcoin/bitcoin/commit/ac4b8feb3fe151d1b00085cfe15a856ccede6e6e) | `GetArg()` returns `"0"` for a negated option. The `-no*notify` options run the command `0`, `-nosigner` uses `0` as signer, `-noi2psam` fails startup and `-norpcpassword` sets the password to `0`. Opt-in because options like `-noonion` and `-noblockfilterindex` depend on reading `"0"`. | New opt-in flag `NEGATE_TO_EMPTY` makes `GetArg()` return `""`. | | [init: Read -cjdnsreachable and -help as booleans](https://github.com/bitcoin/bitcoin/commit/dc4ddbacf791ac6742261bf66dcf42887bfb74ff) | `-cjdnsreachable=0` and `-nocjdnsreachable` turn CJDNS on. `-nohelp` prints the help. | Use `GetBoolArg()` instead of `IsArgSet()`. | | [args, wallet: Fix empty and negated -blocksdir and -walletdir](https://github.com/bitcoin/bitcoin/commit/be71581c2fc65722f6e335e6506cda342eb23ef7) | `-noblocksdir` writes block files relative to the working directory. `-nowalletdir` fails startup. | Fail at startup with `DISALLOW_NEGATION`. An empty value falls back to the default directory, like `-datadir` does. | | [init: Require -nolistenonion with -notorcontrol](https://github.com/bitcoin/bitcoin/commit/44b1c5b05057bf3a768eac63922c085163975dcc) | `-notorcontrol` connects to `0.0.0.0:9051`, which reaches a local Tor. | Fail at startup unless `-listenonion` is disabled. | | [init: Disallow negating options where it has no meaning](https://github.com/bitcoin/bitcoin/commit/6447b07919072f12aba36313814fd4962dd4363a) | `-nocheckblocks`, `-nomaxreceivebuffer`, `-nomaxsendbuffer` and `-nomaxtipage` read as 0, the opposite of what the user asked for. | Fail at startup with `DISALLOW_NEGATION`. | `-nomempoolexpiry` has a similar kind of problem. It evicts transactions as soon as the next one arrives. I left it out because #36540 already is open and addresses this.
DrahtBot commented 2026-11-15 12:42:08 +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.

Type Reviewers
ACK ryanofsky
Concept ACK l0rinc

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #37019 (http: free idle connection slots for waiting connections at the limit by optout21)
  • #36970 (RFC: netbase: Remove manual_connection and return the failure reason to callers by fjahr)
  • #36969 (net: Warn only once when a proxy or the I2P proxy is unreachable by fjahr)
  • #36861 (Configuration argument handling improvements. by jlopp)
  • #36759 (torcontrol: Improve connection logging by ViniciusCestarii)
  • #36380 (wallet: extend -walletbroadcast to allow initial send only by vasild)
  • #17783 (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky)
  • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky)
  • #16545 (refactor: Implement missing error checking for ArgsManager flags by ryanofsky)

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/36880 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36880.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36880#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. | Type | Reviewers | | ---- | --------- | | ACK | [ryanofsky](https://github.com/bitcoin/bitcoin/pull/36880#pullrequestreview-6114261243) | | Concept ACK | [l0rinc](https://github.com/bitcoin/bitcoin/pull/36880#issuecomment-6899435975) | 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: * [#37019](https://github.com/bitcoin/bitcoin/pull/37019) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/37019.svg"></sub> (http: free idle connection slots for waiting connections at the limit by optout21) * [#36970](https://github.com/bitcoin/bitcoin/pull/36970) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36970.svg"></sub> (RFC: netbase: Remove manual_connection and return the failure reason to callers by fjahr) * [#36969](https://github.com/bitcoin/bitcoin/pull/36969) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36969.svg"></sub> (net: Warn only once when a proxy or the I2P proxy is unreachable by fjahr) * [#36861](https://github.com/bitcoin/bitcoin/pull/36861) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36861.svg"></sub> (Configuration argument handling improvements. by jlopp) * [#36759](https://github.com/bitcoin/bitcoin/pull/36759) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36759.svg"></sub> (torcontrol: Improve connection logging by ViniciusCestarii) * [#36380](https://github.com/bitcoin/bitcoin/pull/36380) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36380.svg"></sub> (wallet: extend -walletbroadcast to allow initial send only by vasild) * [#17783](https://github.com/bitcoin/bitcoin/pull/17783) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/17783.svg"></sub> (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky) * [#17580](https://github.com/bitcoin/bitcoin/pull/17580) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/17580.svg"></sub> (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky) * [#16545](https://github.com/bitcoin/bitcoin/pull/16545) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/16545.svg"></sub> (refactor: Implement missing error checking for ArgsManager flags by ryanofsky) 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-->
First-time contributor

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

🔵 Suggestion · CLI -norpcuser assertion also accepts the old username

The new bitcoin-cli -norpcuser assertion accepts the same authentication error for both "" and "0", so removing the CLI’s NEGATE_TO_EMPTY flag would leave it passing.

Location: test/functional/interface_bitcoin_cli.py:247 (head).

🔵 Suggestion · GUI signer field still displays 0 for a negated -signer

With nosigner=1 in bitcoin.conf, the node now clears the signer but the Options dialog still displays 0, because its string conversion bypasses NEGATE_TO_EMPTY.

Location: src/init.cpp:640 (head).

🔵 Suggestion · The NEGATE_TO_EMPTY test misses literal "0"

The stringarg test would still pass if NEGATE_TO_EMPTY also erased a literal "0", despite that value needing to remain distinct from negation.

Location: src/test/getarg_tests.cpp:229 (head).

Review coverage was incomplete.


Reviewed: 9cf00ac7ae7f · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:806938d40e279b6d701b2e78128bb1a09b55193a0b697245a1dce6241d3081c1:3607c760b63c01fb7f1f349adfc3fd0614b148a7df02e42f2f0edc2d448925a1 --> <!-- ralph-base:0e8f70a86314bc73539b110d947c41d40c4886fc --> <!-- ralph-head:9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd --> <!-- ralph-case:2565eb59098455e9fb7406031c01563ff5c0276dcba73090f9d2798f3b8ef7d0 --> Earlier concerns neither republished nor resolved: 3 suggestions. See the Run archive linked from the Review report for their assessments. **🔵 Suggestion · CLI `-norpcuser` assertion also accepts the old username** The new `bitcoin-cli -norpcuser` assertion accepts the same authentication error for both `""` and `"0"`, so removing the CLI’s `NEGATE_TO_EMPTY` flag would leave it passing. Location: [`test/functional/interface_bitcoin_cli.py:247`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd/test/functional/interface_bitcoin_cli.py#L247>) (head). **🔵 Suggestion · GUI signer field still displays `0` for a negated `-signer`** With `nosigner=1` in `bitcoin.conf`, the node now clears the signer but the Options dialog still displays `0`, because its string conversion bypasses `NEGATE_TO_EMPTY`. Location: [`src/init.cpp:640`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd/src/init.cpp#L640>) (head). **🔵 Suggestion · The `NEGATE_TO_EMPTY` test misses literal `"0"`** The `stringarg` test would still pass if `NEGATE_TO_EMPTY` also erased a literal `"0"`, despite that value needing to remain distinct from negation. Location: [`src/test/getarg_tests.cpp:229`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd/src/test/getarg_tests.cpp#L229>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`9cf00ac7ae7f`](<https://git.fish.foo/bitcoin/bitcoin/commit/9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd>) · [Review report](<https://review.fish.foo/report/36880-9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd-3196-7.html>) · [Previous reports](<https://review.fish.foo/traces/36880/>) [permalink](<https://review.fish.foo/report/36880-9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd-3196-7.html>)
l0rinc commented 2026-11-15 18:47:43 +00:00 (Migrated from github.com)

Concept ACK, the surprising nature of the negations was documented a few times, e.g. in https://github.com/bitcoin/bitcoin/pull/36861#issuecomment-6862113841

Concept ACK, the surprising nature of the negations was documented a few times, e.g. in https://github.com/bitcoin/bitcoin/pull/36861#issuecomment-6862113841
fjahr commented 2026-11-17 08:50:20 +00:00 (Migrated from github.com)

e.g. in #36861 (comment)

Hm, that was opened after I did my initial research on related open PRs. Clearly there is a lot overlap, I will check if a separate PR still make sense.

> e.g. in [#36861 (comment)](https://github.com/bitcoin/bitcoin/pull/36861#issuecomment-6862113841) Hm, that was opened after I did my initial research on related open PRs. Clearly there is a lot overlap, I will check if a separate PR still make sense.
fjahr commented 2026-11-17 09:04:15 +00:00 (Migrated from github.com)

The first commit (cluster limit below 1) is covered in #36861 and the last commit (disallow negating) got some approach push back there already. Generally the "piecemeal" approach there got push back too. I think this here is a bit better but it also doesn't handle everything inside argsman. I tend to drop the first and the last commit and otherwise keep the PR open separately but I will comment about it on #36861 and see what the feedback is first.

The first commit (cluster limit below 1) is covered in #36861 and the last commit (disallow negating) got some approach push back there already. Generally the "piecemeal" approach there got push back too. I think this here is a bit better but it also doesn't handle everything inside argsman. I tend to drop the first and the last commit and otherwise keep the PR open separately but I will comment about it on #36861 and see what the feedback is first.
ryanofsky (Migrated from github.com) reviewed 2026-11-17 17:11:46 +00:00
ryanofsky (Migrated from github.com) left a comment

Concept ACK 4b181fd471, and approach ACK with a few tweaks.

My main feedback is that "no" should mean none, false, or zero, or else be an error. We should avoid more clever interpretations like "default" or "unlimited", even where they could be sensible, because the precedent for mapping negated options to falsy values is well established, and other interpretations create unnecessary ambiguity.

Inline comments suggest changes to NEGATE_TO_DEFAULT (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602822953), -noblocksdir/-nowalletdir (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602823499, https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602824031), -notorcontrol (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602824369) and -nobantime (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602823756).

Concept ACK 4b181fd471f2826659e000439f10345a483309f4, and approach ACK with a few tweaks. My main feedback is that "no" should mean none, false, or zero, or else be an error. We should avoid more clever interpretations like "default" or "unlimited", even where they could be sensible, because the precedent for mapping negated options to falsy values is well established, and other interpretations create unnecessary ambiguity. Inline comments suggest changes to `NEGATE_TO_DEFAULT` (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602822953), `-noblocksdir`/`-nowalletdir` (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602823499, https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602824031), `-notorcontrol` (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602824369) and `-nobantime` (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602823756).
Lines 309-310
ryanofsky (Migrated from github.com) commented 2026-11-17 16:49:44 +00:00

In commit "args, wallet: Treat empty -blocksdir and -walletdir as unset" (cd5bfc8230)

Treating an empty -blocksdir= as unset looks good, but I think -noblocksdir should be an error instead of falling back to the default directory. -noblocksdir reads like an explicit instruction not to use a blocks directory, so writing blocks to the default location anyway would be misleading. -nodatadir is already rejected (#31212).

The simplest way to do this would be the DISALLOW_NEGATION flag that -datadir uses. A better approach in the long run would map these to std::optional<fs::path>, with std::nullopt when the option is not set and an empty path when it is negated, so code like this could return specific errors about required paths that are missing instead of generic errors about negated arguments.

In commit "args, wallet: Treat empty -blocksdir and -walletdir as unset" (cd5bfc823063f5d06e8a15180ba05e2afc7506fb) Treating an empty `-blocksdir=` as unset looks good, but I think `-noblocksdir` should be an error instead of falling back to the default directory. `-noblocksdir` reads like an explicit instruction not to use a blocks directory, so writing blocks to the default location anyway would be misleading. `-nodatadir` is already rejected (#31212). The simplest way to do this would be the `DISALLOW_NEGATION` flag that `-datadir` [uses](https://github.com/bitcoin/bitcoin/blob/4b181fd471f2826659e000439f10345a483309f4/src/init.cpp#L524). A better approach in the long run would map these to `std::optional<fs::path>`, with `std::nullopt` when the option is not set and an empty path when it is negated, so code like this could return specific errors about required paths that are missing instead of generic errors about negated arguments.
ryanofsky (Migrated from github.com) commented 2026-11-17 16:49:42 +00:00

In commit "args: Make negation a no-op for options that are off by default" (5d2ddcae41)

The handling of -nosigner, -noi2psam, -norpcpassword and the other options here looks right to me. I'd suggest renaming NEGATE_TO_DEFAULT to NEGATE_TO_EMPTY and having GetArg() return "" instead of std::nullopt.

All of these options are read with GetArg(name, ""), so this doesn't change behavior now, but it matters if a default changes: if we someday enable a default signer, I2P connectivity, or RPC password, -nosigner, -noi2psam and -norpcpassword should still mean no signer, no I2P connections and no RPC password, not whatever the new default is. It would also be consistent with GetPathArg(), which already returns an empty path for negated options, and with the general rule in doc/bitcoin-conf.md.

And it would be a step toward the more general fix in #16545, which parses nonlegacy negated string options as "" instead of "0", and keeps the old behavior for legacy options like -onion.

In commit "args: Make negation a no-op for options that are off by default" (5d2ddcae41522a0651e20476b7481ea2e50a6fcb) The handling of `-nosigner`, `-noi2psam`, `-norpcpassword` and the other options here looks right to me. I'd suggest renaming `NEGATE_TO_DEFAULT` to `NEGATE_TO_EMPTY` and having `GetArg()` return `""` instead of `std::nullopt`. All of these options are read with `GetArg(name, "")`, so this doesn't change behavior now, but it matters if a default changes: if we someday enable a default signer, I2P connectivity, or RPC password, `-nosigner`, `-noi2psam` and `-norpcpassword` should still mean no signer, no I2P connections and no RPC password, not whatever the new default is. It would also be consistent with [`GetPathArg()`](https://github.com/bitcoin/bitcoin/blob/4b181fd471f2826659e000439f10345a483309f4/src/common/args.cpp#L285), which already returns an empty path for negated options, and with the general rule in [doc/bitcoin-conf.md](https://github.com/bitcoin/bitcoin/blob/4b181fd471f2826659e000439f10345a483309f4/doc/bitcoin-conf.md#negated-options). And it would be a step toward the more general fix in #16545, which parses nonlegacy negated string options as `""` instead of `"0"`, and keeps the old behavior for legacy options like `-onion`.
ryanofsky (Migrated from github.com) commented 2026-11-17 16:49:45 +00:00

re: https://github.com/bitcoin/bitcoin/pull/36880#issuecomment-6943566644

In commit "init: Disallow negating options where it has no meaning" (4b181fd471)

I tend to drop the first and the last commit

I think this commit is worth keeping. These are limits where -nofoo reads as "no limit", but treating it as 0 means something very different: -nocheckblocks checks all blocks, and -nomaxsendbuffer pauses sending whenever anything is queued. Ideally -nofoo might mean unlimited for options like these, but since negation has always meant 0, an error is the safest choice.

My #36861 review recommended against more DISALLOW_NEGATION, but that was overbroad and I will post a correction. I still think that when 0 is just an invalid value, it's better to check for 0 so -foo=0 and -nofoo get the same error, but most options here aren't like that.

The exception is -bantime. "No ban time" can only mean a ban time of 0, or not banning, so I think -nobantime should just be treated the same as -bantime=0, whether 0 ends up allowed or rejected (#36861 rejects it).

re: https://github.com/bitcoin/bitcoin/pull/36880#issuecomment-6943566644 In commit "init: Disallow negating options where it has no meaning" (4b181fd471f2826659e000439f10345a483309f4) > I tend to drop the first and the last commit I think this commit is worth keeping. These are limits where `-nofoo` reads as "no limit", but treating it as 0 means something very different: `-nocheckblocks` checks all blocks, and `-nomaxsendbuffer` pauses sending whenever anything is queued. Ideally `-nofoo` might mean unlimited for options like these, but since negation has always meant 0, an error is the safest choice. My #36861 review recommended against more `DISALLOW_NEGATION`, but that was overbroad and I will post a correction. I still think that when 0 is just an invalid value, it's better to check for 0 so `-foo=0` and `-nofoo` get the same error, but most options here aren't like that. The exception is `-bantime`. "No ban time" can only mean a ban time of 0, or not banning, so I think `-nobantime` should just be treated the same as `-bantime=0`, whether 0 ends up allowed or rejected (#36861 rejects it).
Lines 846-850
ryanofsky (Migrated from github.com) commented 2026-11-17 16:49:48 +00:00

In commit "init: Disable the automatic onion service with -notorcontrol" (faf0a22033)

I think it would be safer to make -notorcontrol an error while -listenonion is enabled, asking the user to pass -nolistenonion if that's what they want, instead of soft-setting -listenonion=0. Since -listenonion is on by default, the error could say something like "-notorcontrol requires -nolistenonion" rather than mention -listenonion=1.

-torcontrol is only used for the onion service now, but it could be used for other things later, so it's useful to know whether the user wants to disable onion listening or everything that uses the control port. An error also helps users who don't know what the control port is used for.

That said, this is more borderline than the other cases, since "no" here really does mean none, so keeping the soft-set as a convenience seems ok too. But then -torcontrol=0 should behave the same way, like -proxy=0, -onion=0 and -connect=0, which already treat 0 as disabled. Currently it still connects to 0.0.0.0:9051, since it isn't a negated value.

In commit "init: Disable the automatic onion service with -notorcontrol" (faf0a220338cbff2e045f0535635590f2d33fbe2) I think it would be safer to make `-notorcontrol` an error while `-listenonion` is enabled, asking the user to pass `-nolistenonion` if that's what they want, instead of soft-setting `-listenonion=0`. Since `-listenonion` is on by default, the error could say something like "-notorcontrol requires -nolistenonion" rather than mention `-listenonion=1`. `-torcontrol` is only used for the onion service now, but it could be used for other things later, so it's useful to know whether the user wants to disable onion listening or everything that uses the control port. An error also helps users who don't know what the control port is used for. That said, this is more borderline than the other cases, since "no" here really does mean none, so keeping the soft-set as a convenience seems ok too. But then `-torcontrol=0` should behave the same way, like `-proxy=0`, `-onion=0` and `-connect=0`, which already treat 0 as disabled. Currently it still connects to `0.0.0.0:9051`, since it isn't a negated value.
ryanofsky (Migrated from github.com) commented 2026-11-17 16:49:43 +00:00

In commit "init: Read -cjdnsreachable and -help as booleans" (08b4f85510)

Note: The -nocjdnsreachable and -nohelp fixes look right. IsArgSet() returns true for negated options, so many of its current uses have this kind of bug, which makes it a footgun and something that would be great to drop.

In commit "init: Read -cjdnsreachable and -help as booleans" (08b4f855104b7ef25b82d66447b9e502c9bef5e9) Note: The `-nocjdnsreachable` and `-nohelp` fixes look right. `IsArgSet()` returns true for negated options, so many of its current uses have this kind of bug, which makes it a footgun and something that would be great to drop.
ryanofsky (Migrated from github.com) commented 2026-11-17 16:49:40 +00:00

In commit "mempool: Reject cluster limits below 1" (512773d111)

Note: This change looks right to me: -nolimitclustercount is treated as 0, and 0 is rejected as out of bounds. If we ever need an unlimited or automatic setting, an explicit value like -limitclustercount=unlimited would be better than a special meaning for -nolimitclustercount.

Also fine with me if this moves to #36861. Both reject negated and 0 values, but the checks there range-check before narrowing to unsigned and multiplying by 1000, so they also reject -limitclustercount=4294967297, which wraps to 1 here, and very large -limitclustersize values, which overflow here and crash a -ftrapv debug build.

In commit "mempool: Reject cluster limits below 1" (512773d111daaa4330c873ed5889b9ef511f6e3a) Note: This change looks right to me: `-nolimitclustercount` is treated as 0, and 0 is rejected as out of bounds. If we ever need an unlimited or automatic setting, an explicit value like `-limitclustercount=unlimited` would be better than a special meaning for `-nolimitclustercount`. Also fine with me if this moves to #36861. Both reject negated and 0 values, but the [checks there](https://github.com/bitcoin/bitcoin/blob/0ad0c71387783753356840d17d2b950367257e78/src/node/mempool_args.cpp#L37-L57) range-check before narrowing to `unsigned` and multiplying by 1000, so they also reject `-limitclustercount=4294967297`, which wraps to 1 here, and very large `-limitclustersize` values, which overflow here and crash a `-ftrapv` debug build.
ryanofsky (Migrated from github.com) commented 2026-11-17 16:49:47 +00:00

In commit "args, wallet: Treat empty -blocksdir and -walletdir as unset" (cd5bfc8230)

I don't think -nowalletdir should fall back to the default wallet directory, for the same reason as -noblocksdir (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602823499). For bitcoind, an error seems simplest for now. But I wouldn't rule out -nowalletdir and -nodatadir meaning what they say in the future, since they could be useful for other tools. bitcoin-cli -nodatadir could connect to a node without trying to read files from a datadir that may not be available, and bitcoin-wallet -nodatadir -nowalletdir could operate on external wallet files without touching any default wallets. Treating them as an error now keeps that possible, while treating them as the default would not.

In commit "args, wallet: Treat empty -blocksdir and -walletdir as unset" (cd5bfc823063f5d06e8a15180ba05e2afc7506fb) I don't think `-nowalletdir` should fall back to the default wallet directory, for the same reason as `-noblocksdir` (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4602823499). For bitcoind, an error seems simplest for now. But I wouldn't rule out `-nowalletdir` and `-nodatadir` meaning what they say in the future, since they could be useful for other tools. `bitcoin-cli -nodatadir` could connect to a node without trying to read files from a datadir that may not be available, and `bitcoin-wallet -nodatadir -nowalletdir` could operate on external wallet files without touching any default wallets. Treating them as an error now keeps that possible, while treating them as the default would not.
fjahr (Migrated from github.com) reviewed 2026-11-19 09:08:21 +00:00
Lines 846-850
fjahr (Migrated from github.com) commented 2026-11-19 09:08:21 +00:00

Done, made -notorcontrol an error.

Done, made `-notorcontrol` an error.
fjahr (Migrated from github.com) reviewed 2026-11-19 09:08:24 +00:00
fjahr (Migrated from github.com) commented 2026-11-19 09:08:24 +00:00

Done

Done
fjahr (Migrated from github.com) reviewed 2026-11-19 09:08:26 +00:00
fjahr (Migrated from github.com) commented 2026-11-19 09:08:26 +00:00

Done, I removed -bantime from the commit.

Done, I removed `-bantime` from the commit.
fjahr (Migrated from github.com) reviewed 2026-11-19 09:08:27 +00:00
Lines 309-310
fjahr (Migrated from github.com) commented 2026-11-19 09:08:27 +00:00

Done with DISALLOW_NEGATION.

Done with `DISALLOW_NEGATION`.
fjahr (Migrated from github.com) reviewed 2026-11-19 09:08:48 +00:00
fjahr (Migrated from github.com) commented 2026-11-19 09:08:48 +00:00

Done as suggested

Done as suggested
fjahr (Migrated from github.com) reviewed 2026-11-19 09:08:51 +00:00
fjahr (Migrated from github.com) commented 2026-11-19 09:08:51 +00:00

I decided to keep it here for now so the crash fix doesn't depend on #36861. I'll drop it if #36861 is merged first of course since that is a more complete fix but with the pending questions about the approach there is a chance it may take a bit longer it seems.

I decided to keep it here for now so the crash fix doesn't depend on #36861. I'll drop it if #36861 is merged first of course since that is a more complete fix but with the pending questions about the approach there is a chance it may take a bit longer it seems.
fjahr commented 2026-11-19 09:11:42 +00:00 (Migrated from github.com)

Addressed review feedback from @ryanofsky, thanks a lot! Also rebased for good measure since the CI failed with an unrelated error. The table in the pull description is updated as well.

Addressed review feedback from @ryanofsky, thanks a lot! Also rebased for good measure since the CI failed with an unrelated error. The table in the pull description is updated as well.
ryanofsky (Migrated from github.com) approved these changes 2026-11-24 16:54:24 +00:00
ryanofsky (Migrated from github.com) left a comment

Code review ACK 8731550b05. This fixes a set of options where -nofoo did the opposite of what it says, failed startup, or crashed the node, and makes negation behave predictably: negated options now mean empty or 0, and negating a limit where 0 would mean something very different is an error.

Thanks for taking all the suggestions from my last review!

Code review ACK 8731550b059b76bbecadae87f28638ef706b57c7. This fixes a set of options where `-nofoo` did the opposite of what it says, failed startup, or crashed the node, and makes negation behave predictably: negated options now mean empty or 0, and negating a limit where 0 would mean something very different is an error. Thanks for taking all the suggestions from my last review!
Lines 309-310
ryanofsky (Migrated from github.com) commented 2026-11-24 16:39:00 +00:00

In commit "args, wallet: Fix empty and negated -blocksdir and -walletdir" (e954bebe35)

I think the commit message could be clearer about what changes, and the description of the old -noblocksdir behavior only applies to some platforms. When I ran a master build on Linux, -noblocksdir and -blocksdir= didn't write blocks to the working directory. Startup aborted with an uncaught exception ("filesystem error: cannot make absolute path"), because fs::absolute("") throws with libstdc++ and only returns the working directory with libc++. Here's a suggestion listing the before and after behavior for each value that changes:

args, wallet: Reject -noblocksdir/-nowalletdir and treat empty values as unset

This changes the behavior of negated and empty -blocksdir and -walletdir
values. Other values behave the same as before.

-noblocksdir
  Before: same as -blocksdir= below.
  After: startup error "Negating of -blocksdir is meaningless and
  therefore forbidden".

-blocksdir=
  Before: depended on the C++ standard library. With libstdc++ (most
  Linux builds), startup aborted with an uncaught "cannot make absolute
  path" filesystem exception. With libc++ (macOS), block files were
  written under the working directory while the block index stayed in
  the datadir.
  After: blocks are stored in the default location in the datadir, as if
  -blocksdir were not set.

-nowalletdir
  Before: startup error 'Specified -walletdir "" does not exist'.
  After: startup error "Negating of -walletdir is meaningless and
  therefore forbidden".

-walletdir=
  Before: startup error 'Specified -walletdir "" does not exist'.
  After: wallets are loaded from the default wallet directory, as if
  -walletdir were not set.

The negated forms are rejected, like -nodatadir, instead of falling back
to the default directory, because -noblocksdir and -nowalletdir read as
not using a directory at all.

The -noblocksdir row in the PR description table could be updated the same way.

In commit "args, wallet: Fix empty and negated -blocksdir and -walletdir" (e954bebe3591d0d3fd79648e729a87fd532a0fce) I think the commit message could be clearer about what changes, and the description of the old `-noblocksdir` behavior only applies to some platforms. When I ran a master build on Linux, `-noblocksdir` and `-blocksdir=` didn't write blocks to the working directory. Startup aborted with an uncaught exception ("filesystem error: cannot make absolute path"), because `fs::absolute("")` throws with libstdc++ and only returns the working directory with libc++. Here's a suggestion listing the before and after behavior for each value that changes: ```text args, wallet: Reject -noblocksdir/-nowalletdir and treat empty values as unset This changes the behavior of negated and empty -blocksdir and -walletdir values. Other values behave the same as before. -noblocksdir Before: same as -blocksdir= below. After: startup error "Negating of -blocksdir is meaningless and therefore forbidden". -blocksdir= Before: depended on the C++ standard library. With libstdc++ (most Linux builds), startup aborted with an uncaught "cannot make absolute path" filesystem exception. With libc++ (macOS), block files were written under the working directory while the block index stayed in the datadir. After: blocks are stored in the default location in the datadir, as if -blocksdir were not set. -nowalletdir Before: startup error 'Specified -walletdir "" does not exist'. After: startup error "Negating of -walletdir is meaningless and therefore forbidden". -walletdir= Before: startup error 'Specified -walletdir "" does not exist'. After: wallets are loaded from the default wallet directory, as if -walletdir were not set. The negated forms are rejected, like -nodatadir, instead of falling back to the default directory, because -noblocksdir and -nowalletdir read as not using a directory at all. ``` The `-noblocksdir` row in the PR description table could be updated the same way.
ryanofsky (Migrated from github.com) commented 2026-11-24 16:38:06 +00:00

In commit "init: Require -nolistenonion with -notorcontrol" (c0bc030a10)

I think an error explaining how these are connected could be more helpful here:

        return InitError(Untranslated("-notorcontrol cannot be used while -listenonion is enabled (the default). Use -nolistenonion to stop connecting to the Tor control port."));

-listenonion is on by default, so someone passing -notorcontrol may not know how it's involved. And -nolistenonion on its own is enough to stop the node from connecting to the control port, since -listenonion is the only thing that uses it.

In commit "init: Require -nolistenonion with -notorcontrol" (c0bc030a10d7aaea62ea22ce6cabe875ac111eaa) I think an error explaining how these are connected could be more helpful here: ```suggestion return InitError(Untranslated("-notorcontrol cannot be used while -listenonion is enabled (the default). Use -nolistenonion to stop connecting to the Tor control port.")); ``` `-listenonion` is on by default, so someone passing `-notorcontrol` may not know how it's involved. And `-nolistenonion` on its own is enough to stop the node from connecting to the control port, since [`-listenonion`](https://github.com/bitcoin/bitcoin/blob/8731550b059b76bbecadae87f28638ef706b57c7/src/init.cpp#L2314-L2320) is the only thing that uses it.
Lines 1055-1057
ryanofsky (Migrated from github.com) commented 2026-11-24 16:11:28 +00:00

In commit "init: Require -nolistenonion with -notorcontrol" (c0bc030a10)

Not blocking, but it might be worth adding a short release note, since some settings that used to be accepted now fail at startup: -notorcontrol while onion listening is enabled, -noblocksdir, -nocheckblocks, -nomaxreceivebuffer, -nomaxsendbuffer and -nomaxtipage. A note listing them, with -nolistenonion as the replacement for -notorcontrol, would help anyone who hits the new errors after upgrading. The Ralph review suggested this too.

In commit "init: Require -nolistenonion with -notorcontrol" (c0bc030a10d7aaea62ea22ce6cabe875ac111eaa) Not blocking, but it might be worth adding a short release note, since some settings that used to be accepted now fail at startup: `-notorcontrol` while onion listening is enabled, `-noblocksdir`, `-nocheckblocks`, `-nomaxreceivebuffer`, `-nomaxsendbuffer` and `-nomaxtipage`. A note listing them, with `-nolistenonion` as the replacement for `-notorcontrol`, would help anyone who hits the new errors after upgrading. The [Ralph review](https://review.fish.foo/report/36880-8731550b059b76bbecadae87f28638ef706b57c7-2836-3.html#finding-finding%3A2) suggested this too.
ryanofsky (Migrated from github.com) commented 2026-11-24 16:48:34 +00:00

In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (a040ec7116)

This only checks that the node starts with -noi2psam -norpcpassword, so most options changed in this commit have no test showing that -nofoo now does something sensible. I tried adding a check for each one to the existing functional test for that option. Each passes -foo=X -nofoo, the way someone would turn off a setting from bitcoin.conf:

  • feature_startupnotify.py: -nostartupnotify doesn't run the command.
  • feature_notifications.py: -noblocknotify and -nowalletnotify write no notification files and run no command. -noalertnotify only checks that no command runs, since the alert doesn't fire again after a restart.
  • rpc_signer.py: with -nosigner, enumeratesigners reports that no signer is configured.
  • p2p_i2p_ports.py: with -noi2psam, I2P is unreachable and has no proxy.
  • rpc_users.py: -norpcpassword falls back to cookie authentication, and -norpcuser sets an empty user name, not 0.
  • interface_bitcoin_cli.py: bitcoin-cli -norpcpassword uses the cookie file. -norpcuser sends an empty user name, which this node can't distinguish from 0 since it uses cookie authentication.
  • feature_torcontrol.py: with -notorpassword, the node uses NULL authentication.

All of these pass on this branch and fail with the NEGATE_TO_EMPTY check in GetArg() commented out. With the old behavior, the notify options print "0: command not found" to stderr, which the test framework checks when stopping the node. With these tests, the startup check here could probably be dropped. Feel free to use any of this:

Diff
diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py
index 19e278440da..7e33a71896d 100755
--- a/test/functional/feature_notifications.py
+++ b/test/functional/feature_notifications.py
@@ -221,6 +221,38 @@ class NotificationsTest(BitcoinTestFramework):
         self.stop_nodes()
         self.wait_until(lambda: os.path.isfile(self.shutdownnotify_file), timeout=10)

+        self.test_negated_notify_options()
+
+    def test_negated_notify_options(self):
+        self.log.info("test -noblocknotify, -noalertnotify and -nowalletnotify disable earlier commands")
+        # Each option comes after the command it disables, as when a user
+        # turns off a command set in bitcoin.conf. Before NEGATE_TO_EMPTY,
+        # these options ran the command "0", which writes no files but fails,
+        # printing "0: command not found" to stderr (which stop_nodes()
+        # checks) and logging a runCommand error. The commands run in
+        # detached threads, so the test stops the nodes before checking.
+        #
+        # -alertnotify is only checked for not running a bogus command: node0
+        # has the large-work invalid chain from the test above, but the
+        # warning is not raised again on restart, so the alert command would
+        # not run here even without -noalertnotify.
+        blocknotify_files = sorted(os.listdir(self.blocknotify_dir))
+        walletnotify_files = sorted(os.listdir(self.walletnotify_dir))
+        with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]), \
+             self.nodes[1].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]):
+            self.start_node(0, extra_args=self.extra_args[0] + ["-noblocknotify", "-noalertnotify"])
+            self.start_node(1, extra_args=self.extra_args[1] + ["-nowalletnotify"])
+            self.connect_nodes(0, 1)
+            if self.is_wallet_compiled():
+                # The wallet was created with load_on_startup=True
+                address = self.nodes[1].get_wallet_rpc(self.wallet).getnewaddress()
+            else:
+                address = ADDRESS_BCRT1_UNSPENDABLE
+            self.generatetoaddress(self.nodes[1], 2, address)
+            self.stop_nodes()
+        assert_equal(sorted(os.listdir(self.blocknotify_dir)), blocknotify_files)
+        assert_equal(sorted(os.listdir(self.walletnotify_dir)), walletnotify_files)
+
     def large_work_invalid_chain_warning_in_alert_file(self):
         with open(self.alertnotify_file, 'r') as f:
             alert_text = f.read()
diff --git a/test/functional/feature_startupnotify.py b/test/functional/feature_startupnotify.py
index dc1a7eb804a..cfef2087b48 100755
--- a/test/functional/feature_startupnotify.py
+++ b/test/functional/feature_startupnotify.py
@@ -37,6 +37,16 @@ class StartupNotifyTest(BitcoinTestFramework):
         self.log.info("Test node is fully started")
         assert_equal(self.nodes[0].getblockcount(), 200)

+        self.log.info("Test -nostartupnotify disables an earlier -startupnotify")
+        # Before NEGATE_TO_EMPTY, -nostartupnotify ran the command "0", which
+        # fails, printing "0: command not found" to stderr (which stop_node()
+        # checks) and logging a runCommand error. The command runs in a
+        # detached thread, so the test stops the node before checking.
+        with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]):
+            self.restart_node(0, extra_args=[f"-startupnotify=echo '{FILE_NAME}' >> {NODE_DIR}/{FILE_NAME}", "-nostartupnotify"])
+            self.stop_node(0)
+        assert_equal(get_count(), 1)
+

 if __name__ == '__main__':
     StartupNotifyTest(__file__).main()
diff --git a/test/functional/feature_torcontrol.py b/test/functional/feature_torcontrol.py
index c309fd2a41f..e728b88cab8 100755
--- a/test/functional/feature_torcontrol.py
+++ b/test/functional/feature_torcontrol.py
@@ -123,7 +123,7 @@ class TorControlTest(BitcoinTestFramework):
     def private_key_path(self):
         return self.nodes[0].chain_path / "onion_v3_private_key"

-    def restart_with_mock(self, mock_tor, cached_private_key=None):
+    def restart_with_mock(self, mock_tor, cached_private_key=None, extra_args=()):
         self.stop_node(0)
         key_path = self.private_key_path()
         if cached_private_key is None:
@@ -136,6 +136,7 @@ class TorControlTest(BitcoinTestFramework):
             f"-torcontrol=127.0.0.1:{mock_tor.port}",
             "-listenonion=1",
             "-debug=tor",
+            *extra_args,
         ])

         # Wait for connection and PROTOCOLINFO command
@@ -294,6 +295,18 @@ class TorControlTest(BitcoinTestFramework):

         mock_tor.stop()

+    def test_notorpassword(self):
+        self.log.info("Test -notorpassword disables an earlier -torpassword")
+        # The mock only offers NULL authentication. Before NEGATE_TO_EMPTY,
+        # the password was "0", so bitcoind logged that HASHEDPASSWORD wasn't
+        # available and never sent AUTHENTICATE.
+        mock_tor = MockTorControlServer(self.next_port())
+        with self.nodes[0].assert_debug_log(["Using NULL authentication"], timeout=10):
+            self.restart_with_mock(mock_tor, extra_args=["-torpassword=secret", "-notorpassword"])
+        self.wait_until(lambda: len(mock_tor.received_commands) >= 2, timeout=10)
+        assert_equal(mock_tor.received_commands[1], "AUTHENTICATE")
+        mock_tor.stop()
+
     def test_notorcontrol(self):
         self.log.info("Test that -notorcontrol requires -nolistenonion")
         self.stop_node(0)
@@ -375,6 +388,7 @@ class TorControlTest(BitcoinTestFramework):
         self.test_invalid_service_id()
         self.test_private_key_tor_command_injection()
         self.test_reconnect_backoff()
+        self.test_notorpassword()
         self.test_notorcontrol()


diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py
index 60d34e0bf65..d161f86e8b4 100755
--- a/test/functional/interface_bitcoin_cli.py
+++ b/test/functional/interface_bitcoin_cli.py
@@ -234,6 +234,16 @@ class TestBitcoinCli(BitcoinTestFramework):
         self.log.info("Test connecting with invalid cookie file")
         assert_raises_process_error(1, "Cookie file credentials were invalid and no rpcpassword was specified.", self.nodes[0].cli(f"-rpccookiefile={self.nodes[0].datadir_path / 'bitcoin.conf'}").echo)

+        self.log.info("Test -norpcpassword uses the cookie file")
+        # Before NEGATE_TO_EMPTY, bitcoin-cli sent the password "0" instead.
+        assert_equal(BLOCKS, self.nodes[0].cli('-rpcpassword=foo', '-norpcpassword').getblockcount())
+        assert_raises_process_error(1, "Cookie file was disabled via -norpccookiefile and no rpcpassword was specified.", self.nodes[0].cli("-norpccookiefile", "-norpcpassword").echo)
+
+        self.log.info("Test -norpcuser sends an empty user name")
+        # The node's cookie user is __cookie__, so an empty user name fails
+        # here. Node-side -norpcuser is tested in rpc_users.py.
+        assert_raises_process_error(1, 'Incorrect rpcuser or rpcpassword were specified', self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', '-norpcuser', f'-rpcpassword={password}').echo)
+
         self.log.info("Test connecting without RPC cookie file and with password arg")
         assert_equal(BLOCKS, self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', f'-rpcpassword={password}').getblockcount())

diff --git a/test/functional/p2p_i2p_ports.py b/test/functional/p2p_i2p_ports.py
index 83a95123a8b..96205721723 100755
--- a/test/functional/p2p_i2p_ports.py
+++ b/test/functional/p2p_i2p_ports.py
@@ -7,7 +7,10 @@ Test ports handling for I2P hosts
 """

 from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import p2p_port
+from test_framework.util import (
+    assert_equal,
+    p2p_port,
+)


 class I2PPorts(BitcoinTestFramework):
@@ -31,6 +34,14 @@ class I2PPorts(BitcoinTestFramework):
         with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}: Cannot connect to {self.proxy}"]):
             node.addnode(node=addr, command="onetry")

+        self.log.info("Ensure -noi2psam disables an earlier -i2psam")
+        # Before NEGATE_TO_EMPTY, -noi2psam was read as the proxy address "0"
+        # and startup failed.
+        self.restart_node(0, extra_args=[f"-i2psam={self.proxy}", "-noi2psam"])
+        i2p = next(n for n in node.getnetworkinfo()["networks"] if n["name"] == "i2p")
+        assert_equal(i2p["reachable"], False)
+        assert_equal(i2p["proxy"], "")
+

 if __name__ == '__main__':
     I2PPorts(__file__).main()
diff --git a/test/functional/rpc_signer.py b/test/functional/rpc_signer.py
index 6d51182c6bf..884f47b5742 100755
--- a/test/functional/rpc_signer.py
+++ b/test/functional/rpc_signer.py
@@ -93,5 +93,14 @@ class RPCSignerTest(BitcoinTestFramework):

         assert_equal({'fingerprint': '00000001', 'name': 'trezor_t'} in self.nodes[1].enumeratesigners()['signers'], True)

+        self.log.info('Test -nosigner disables an earlier -signer')
+        # Before NEGATE_TO_EMPTY, -nosigner ran "0" as the signer command
+        # and enumeratesigners failed with a RunCommandParseJSON error.
+        self.restart_node(1, extra_args=[f"-signer={self.mock_signer_path()}", "-nosigner"])
+        assert_raises_rpc_error(-1, 'Error: restart bitcoind with -signer=<cmd>',
+            self.nodes[1].enumeratesigners
+        )
+
+
 if __name__ == '__main__':
     RPCSignerTest(__file__).main()
diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py
index ca1d1124141..eede5ed55c7 100755
--- a/test/functional/rpc_users.py
+++ b/test/functional/rpc_users.py
@@ -137,6 +137,29 @@ class HTTPBasicsTest(BitcoinTestFramework):
         assert_equal(200, call_with_auth(self.nodes[0], "rt", self.rtpassword, method="stop").status)
         self.nodes[0].wait_until_stopped()

+    def test_negated_rpc_credentials(self, node0_cookie_path):
+        assert self.nodes[0].is_node_stopped(), "We expect previous test to stopped the node"
+
+        self.log.info('Check -norpcpassword disables an earlier -rpcpassword and enables cookie authentication')
+        # Before NEGATE_TO_EMPTY, the password was "0", so no cookie file was
+        # written and the node couldn't be reached through it.
+        self.start_node(0, extra_args=["-rpcuser=alice", "-rpcpassword=secret", "-norpcpassword"])
+        assert node0_cookie_path.exists()
+        assert_equal(401, call_with_auth(self.nodes[0], "alice", "secret").status)
+        assert_equal(401, call_with_auth(self.nodes[0], "alice", "0").status)
+        self.stop_node(0)
+
+        self.log.info('Check -norpcuser makes the user name empty')
+        # An empty user name is what -rpcuser= already gives. Before
+        # NEGATE_TO_EMPTY, the user name was "0".
+        with self.nodes[0].busy_wait_for_debug_log([b'init message: Done loading']):
+            self.nodes[0].start(extra_args=["-norpccookiefile", "-rpcuser=alice", "-norpcuser", "-rpcpassword=secret"])
+        assert_equal(200, call_with_auth(self.nodes[0], "", "secret").status)
+        assert_equal(401, call_with_auth(self.nodes[0], "0", "secret").status)
+        assert_equal(401, call_with_auth(self.nodes[0], "alice", "secret").status)
+        assert_equal(200, call_with_auth(self.nodes[0], "", "secret", method="stop").status)
+        self.nodes[0].wait_until_stopped()
+
     def run_test(self):
         self.conf_setup()
         self.log.info('Check correctness of the rpcauth config option')
@@ -196,5 +219,7 @@ class HTTPBasicsTest(BitcoinTestFramework):

         self.test_norpccookiefile(cookie_path)

+        self.test_negated_rpc_credentials(cookie_path)
+
 if __name__ == '__main__':
     HTTPBasicsTest(__file__).main()
In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (a040ec7116c9b83c925a724930610376c6035fb5) This only checks that the node starts with `-noi2psam -norpcpassword`, so most options changed in this commit have no test showing that `-nofoo` now does something sensible. I tried adding a check for each one to the existing functional test for that option. Each passes `-foo=X -nofoo`, the way someone would turn off a setting from `bitcoin.conf`: - `feature_startupnotify.py`: `-nostartupnotify` doesn't run the command. - `feature_notifications.py`: `-noblocknotify` and `-nowalletnotify` write no notification files and run no command. `-noalertnotify` only checks that no command runs, since the alert doesn't fire again after a restart. - `rpc_signer.py`: with `-nosigner`, `enumeratesigners` reports that no signer is configured. - `p2p_i2p_ports.py`: with `-noi2psam`, I2P is unreachable and has no proxy. - `rpc_users.py`: `-norpcpassword` falls back to cookie authentication, and `-norpcuser` sets an empty user name, not `0`. - `interface_bitcoin_cli.py`: `bitcoin-cli -norpcpassword` uses the cookie file. `-norpcuser` sends an empty user name, which this node can't distinguish from `0` since it uses cookie authentication. - `feature_torcontrol.py`: with `-notorpassword`, the node uses NULL authentication. All of these pass on this branch and fail with the `NEGATE_TO_EMPTY` check in `GetArg()` commented out. With the old behavior, the notify options print "0: command not found" to stderr, which the test framework checks when stopping the node. With these tests, the startup check here could probably be dropped. Feel free to use any of this: <details><summary>Diff</summary> ```diff diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py index 19e278440da..7e33a71896d 100755 --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -221,6 +221,38 @@ class NotificationsTest(BitcoinTestFramework): self.stop_nodes() self.wait_until(lambda: os.path.isfile(self.shutdownnotify_file), timeout=10) + self.test_negated_notify_options() + + def test_negated_notify_options(self): + self.log.info("test -noblocknotify, -noalertnotify and -nowalletnotify disable earlier commands") + # Each option comes after the command it disables, as when a user + # turns off a command set in bitcoin.conf. Before NEGATE_TO_EMPTY, + # these options ran the command "0", which writes no files but fails, + # printing "0: command not found" to stderr (which stop_nodes() + # checks) and logging a runCommand error. The commands run in + # detached threads, so the test stops the nodes before checking. + # + # -alertnotify is only checked for not running a bogus command: node0 + # has the large-work invalid chain from the test above, but the + # warning is not raised again on restart, so the alert command would + # not run here even without -noalertnotify. + blocknotify_files = sorted(os.listdir(self.blocknotify_dir)) + walletnotify_files = sorted(os.listdir(self.walletnotify_dir)) + with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]), \ + self.nodes[1].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]): + self.start_node(0, extra_args=self.extra_args[0] + ["-noblocknotify", "-noalertnotify"]) + self.start_node(1, extra_args=self.extra_args[1] + ["-nowalletnotify"]) + self.connect_nodes(0, 1) + if self.is_wallet_compiled(): + # The wallet was created with load_on_startup=True + address = self.nodes[1].get_wallet_rpc(self.wallet).getnewaddress() + else: + address = ADDRESS_BCRT1_UNSPENDABLE + self.generatetoaddress(self.nodes[1], 2, address) + self.stop_nodes() + assert_equal(sorted(os.listdir(self.blocknotify_dir)), blocknotify_files) + assert_equal(sorted(os.listdir(self.walletnotify_dir)), walletnotify_files) + def large_work_invalid_chain_warning_in_alert_file(self): with open(self.alertnotify_file, 'r') as f: alert_text = f.read() diff --git a/test/functional/feature_startupnotify.py b/test/functional/feature_startupnotify.py index dc1a7eb804a..cfef2087b48 100755 --- a/test/functional/feature_startupnotify.py +++ b/test/functional/feature_startupnotify.py @@ -37,6 +37,16 @@ class StartupNotifyTest(BitcoinTestFramework): self.log.info("Test node is fully started") assert_equal(self.nodes[0].getblockcount(), 200) + self.log.info("Test -nostartupnotify disables an earlier -startupnotify") + # Before NEGATE_TO_EMPTY, -nostartupnotify ran the command "0", which + # fails, printing "0: command not found" to stderr (which stop_node() + # checks) and logging a runCommand error. The command runs in a + # detached thread, so the test stops the node before checking. + with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]): + self.restart_node(0, extra_args=[f"-startupnotify=echo '{FILE_NAME}' >> {NODE_DIR}/{FILE_NAME}", "-nostartupnotify"]) + self.stop_node(0) + assert_equal(get_count(), 1) + if __name__ == '__main__': StartupNotifyTest(__file__).main() diff --git a/test/functional/feature_torcontrol.py b/test/functional/feature_torcontrol.py index c309fd2a41f..e728b88cab8 100755 --- a/test/functional/feature_torcontrol.py +++ b/test/functional/feature_torcontrol.py @@ -123,7 +123,7 @@ class TorControlTest(BitcoinTestFramework): def private_key_path(self): return self.nodes[0].chain_path / "onion_v3_private_key" - def restart_with_mock(self, mock_tor, cached_private_key=None): + def restart_with_mock(self, mock_tor, cached_private_key=None, extra_args=()): self.stop_node(0) key_path = self.private_key_path() if cached_private_key is None: @@ -136,6 +136,7 @@ class TorControlTest(BitcoinTestFramework): f"-torcontrol=127.0.0.1:{mock_tor.port}", "-listenonion=1", "-debug=tor", + *extra_args, ]) # Wait for connection and PROTOCOLINFO command @@ -294,6 +295,18 @@ class TorControlTest(BitcoinTestFramework): mock_tor.stop() + def test_notorpassword(self): + self.log.info("Test -notorpassword disables an earlier -torpassword") + # The mock only offers NULL authentication. Before NEGATE_TO_EMPTY, + # the password was "0", so bitcoind logged that HASHEDPASSWORD wasn't + # available and never sent AUTHENTICATE. + mock_tor = MockTorControlServer(self.next_port()) + with self.nodes[0].assert_debug_log(["Using NULL authentication"], timeout=10): + self.restart_with_mock(mock_tor, extra_args=["-torpassword=secret", "-notorpassword"]) + self.wait_until(lambda: len(mock_tor.received_commands) >= 2, timeout=10) + assert_equal(mock_tor.received_commands[1], "AUTHENTICATE") + mock_tor.stop() + def test_notorcontrol(self): self.log.info("Test that -notorcontrol requires -nolistenonion") self.stop_node(0) @@ -375,6 +388,7 @@ class TorControlTest(BitcoinTestFramework): self.test_invalid_service_id() self.test_private_key_tor_command_injection() self.test_reconnect_backoff() + self.test_notorpassword() self.test_notorcontrol() diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py index 60d34e0bf65..d161f86e8b4 100755 --- a/test/functional/interface_bitcoin_cli.py +++ b/test/functional/interface_bitcoin_cli.py @@ -234,6 +234,16 @@ class TestBitcoinCli(BitcoinTestFramework): self.log.info("Test connecting with invalid cookie file") assert_raises_process_error(1, "Cookie file credentials were invalid and no rpcpassword was specified.", self.nodes[0].cli(f"-rpccookiefile={self.nodes[0].datadir_path / 'bitcoin.conf'}").echo) + self.log.info("Test -norpcpassword uses the cookie file") + # Before NEGATE_TO_EMPTY, bitcoin-cli sent the password "0" instead. + assert_equal(BLOCKS, self.nodes[0].cli('-rpcpassword=foo', '-norpcpassword').getblockcount()) + assert_raises_process_error(1, "Cookie file was disabled via -norpccookiefile and no rpcpassword was specified.", self.nodes[0].cli("-norpccookiefile", "-norpcpassword").echo) + + self.log.info("Test -norpcuser sends an empty user name") + # The node's cookie user is __cookie__, so an empty user name fails + # here. Node-side -norpcuser is tested in rpc_users.py. + assert_raises_process_error(1, 'Incorrect rpcuser or rpcpassword were specified', self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', '-norpcuser', f'-rpcpassword={password}').echo) + self.log.info("Test connecting without RPC cookie file and with password arg") assert_equal(BLOCKS, self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', f'-rpcpassword={password}').getblockcount()) diff --git a/test/functional/p2p_i2p_ports.py b/test/functional/p2p_i2p_ports.py index 83a95123a8b..96205721723 100755 --- a/test/functional/p2p_i2p_ports.py +++ b/test/functional/p2p_i2p_ports.py @@ -7,7 +7,10 @@ Test ports handling for I2P hosts """ from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import p2p_port +from test_framework.util import ( + assert_equal, + p2p_port, +) class I2PPorts(BitcoinTestFramework): @@ -31,6 +34,14 @@ class I2PPorts(BitcoinTestFramework): with node.assert_debug_log(expected_msgs=[f"Error connecting to {addr}: Cannot connect to {self.proxy}"]): node.addnode(node=addr, command="onetry") + self.log.info("Ensure -noi2psam disables an earlier -i2psam") + # Before NEGATE_TO_EMPTY, -noi2psam was read as the proxy address "0" + # and startup failed. + self.restart_node(0, extra_args=[f"-i2psam={self.proxy}", "-noi2psam"]) + i2p = next(n for n in node.getnetworkinfo()["networks"] if n["name"] == "i2p") + assert_equal(i2p["reachable"], False) + assert_equal(i2p["proxy"], "") + if __name__ == '__main__': I2PPorts(__file__).main() diff --git a/test/functional/rpc_signer.py b/test/functional/rpc_signer.py index 6d51182c6bf..884f47b5742 100755 --- a/test/functional/rpc_signer.py +++ b/test/functional/rpc_signer.py @@ -93,5 +93,14 @@ class RPCSignerTest(BitcoinTestFramework): assert_equal({'fingerprint': '00000001', 'name': 'trezor_t'} in self.nodes[1].enumeratesigners()['signers'], True) + self.log.info('Test -nosigner disables an earlier -signer') + # Before NEGATE_TO_EMPTY, -nosigner ran "0" as the signer command + # and enumeratesigners failed with a RunCommandParseJSON error. + self.restart_node(1, extra_args=[f"-signer={self.mock_signer_path()}", "-nosigner"]) + assert_raises_rpc_error(-1, 'Error: restart bitcoind with -signer=<cmd>', + self.nodes[1].enumeratesigners + ) + + if __name__ == '__main__': RPCSignerTest(__file__).main() diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py index ca1d1124141..eede5ed55c7 100755 --- a/test/functional/rpc_users.py +++ b/test/functional/rpc_users.py @@ -137,6 +137,29 @@ class HTTPBasicsTest(BitcoinTestFramework): assert_equal(200, call_with_auth(self.nodes[0], "rt", self.rtpassword, method="stop").status) self.nodes[0].wait_until_stopped() + def test_negated_rpc_credentials(self, node0_cookie_path): + assert self.nodes[0].is_node_stopped(), "We expect previous test to stopped the node" + + self.log.info('Check -norpcpassword disables an earlier -rpcpassword and enables cookie authentication') + # Before NEGATE_TO_EMPTY, the password was "0", so no cookie file was + # written and the node couldn't be reached through it. + self.start_node(0, extra_args=["-rpcuser=alice", "-rpcpassword=secret", "-norpcpassword"]) + assert node0_cookie_path.exists() + assert_equal(401, call_with_auth(self.nodes[0], "alice", "secret").status) + assert_equal(401, call_with_auth(self.nodes[0], "alice", "0").status) + self.stop_node(0) + + self.log.info('Check -norpcuser makes the user name empty') + # An empty user name is what -rpcuser= already gives. Before + # NEGATE_TO_EMPTY, the user name was "0". + with self.nodes[0].busy_wait_for_debug_log([b'init message: Done loading']): + self.nodes[0].start(extra_args=["-norpccookiefile", "-rpcuser=alice", "-norpcuser", "-rpcpassword=secret"]) + assert_equal(200, call_with_auth(self.nodes[0], "", "secret").status) + assert_equal(401, call_with_auth(self.nodes[0], "0", "secret").status) + assert_equal(401, call_with_auth(self.nodes[0], "alice", "secret").status) + assert_equal(200, call_with_auth(self.nodes[0], "", "secret", method="stop").status) + self.nodes[0].wait_until_stopped() + def run_test(self): self.conf_setup() self.log.info('Check correctness of the rpcauth config option') @@ -196,5 +219,7 @@ class HTTPBasicsTest(BitcoinTestFramework): self.test_norpccookiefile(cookie_path) + self.test_negated_rpc_credentials(cookie_path) + if __name__ == '__main__': HTTPBasicsTest(__file__).main() ``` </details>
fjahr (Migrated from github.com) reviewed 2026-11-24 22:12:38 +00:00
Lines 1055-1057
fjahr (Migrated from github.com) commented 2026-11-24 22:12:38 +00:00

Added a release note in a new commit.

Added a release note in a new commit.
fjahr (Migrated from github.com) reviewed 2026-11-24 22:12:44 +00:00
fjahr (Migrated from github.com) commented 2026-11-24 22:12:44 +00:00

Taken, thanks.

Taken, thanks.
fjahr (Migrated from github.com) reviewed 2026-11-24 22:12:50 +00:00
Lines 309-310
fjahr (Migrated from github.com) commented 2026-11-24 22:12:50 +00:00

Taken the suggested commit message, thanks!

Taken the suggested commit message, thanks!
fjahr (Migrated from github.com) reviewed 2026-11-24 22:13:00 +00:00
fjahr (Migrated from github.com) commented 2026-11-24 22:13:00 +00:00

Thanks, I added them to the NEGATE_TO_EMPTY commit with you as co-author and dropped the startup check.

Thanks, I added them to the `NEGATE_TO_EMPTY` commit with you as co-author and dropped the startup check.
fjahr commented 2026-11-24 22:23:02 +00:00 (Migrated from github.com)

Addressed feedback from @ryanofsky , thanks a lot again! Also required a rebase due to the merge of #36637.

Addressed feedback from @ryanofsky , thanks a lot again! Also required a rebase due to the merge of #36637.
ryanofsky (Migrated from github.com) reviewed 2026-11-25 20:52:15 +00:00
ryanofsky (Migrated from github.com) left a comment

Code review f65919e115. The changes from my last review all look good, but the new -nosigner test found a real bug in builds without the wallet (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4699787496), so I'll re-ACK once that's fixed.

Thanks for the quick update and for adding the tests!

Code review f65919e1159202e4bfe50f6b30f6493556ed0233. The changes from my last review all look good, but the new `-nosigner` test found a real bug in builds without the wallet (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4699787496), so I'll re-ACK once that's fixed. Thanks for the quick update and for adding the tests!
Lines 1058-1060
ryanofsky (Migrated from github.com) commented 2026-11-25 19:23:39 +00:00

re: https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4687251685

In commit "doc: Add release note for negated option changes" (f65919e115)

Added a release note in a new commit.

Thanks! It could also mention the settings that now work or mean something different, since those can change what a node does after upgrading too: -blocksdir= and -walletdir= now use the default directory, -cjdnsreachable=0 and -nocjdnsreachable now disable CJDNS instead of enabling it, and negated options like -norpcpassword, -nosigner and -noblocknotify are now treated as empty instead of 0, so -norpcpassword uses cookie authentication. The Ralph review suggested this too.

re: https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4687251685 In commit "doc: Add release note for negated option changes" (f65919e1159202e4bfe50f6b30f6493556ed0233) > Added a release note in a new commit. Thanks! It could also mention the settings that now work or mean something different, since those can change what a node does after upgrading too: `-blocksdir=` and `-walletdir=` now use the default directory, `-cjdnsreachable=0` and `-nocjdnsreachable` now disable CJDNS instead of enabling it, and negated options like `-norpcpassword`, `-nosigner` and `-noblocknotify` are now treated as empty instead of `0`, so `-norpcpassword` uses cookie authentication. The [Ralph review](https://review.fish.foo/report/36880-f65919e1159202e4bfe50f6b30f6493556ed0233-3090-5.html#finding-finding%3A1) suggested this too.
ryanofsky (Migrated from github.com) commented 2026-11-25 19:23:36 +00:00

In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (fb15cb374f)

The new rpc_signer.py check is failing in the "No wallet" CI job, and I think it found a real bug. In builds without the wallet, -signer is only registered by DummyWalletInit as a plain hidden option, so it doesn't get NEGATE_TO_EMPTY, but the node still reads it, for example in the enumeratesigners RPC, so -nosigner still runs the command 0 there.

Since the node reads -signer whether or not the wallet is enabled, I think it should be registered as a node option instead of a wallet option. Moving this registration into SetupServerArgs() in init.cpp, inside the same #ifdef ENABLE_EXTERNAL_SIGNER, and dropping -signer from the DummyWalletInit list fixes the test for me in a no-wallet build. Keeping OptionsCategory::WALLET leaves the -help output unchanged in wallet builds.

(Not directly related to this PR, but it might be good for ArgsManager to handle placeholder options like the DummyWalletInit ones better. Currently they are registered as ordinary hidden options, the same way as real hidden options like -dbcrashratio, so setting them on the command line or in the config file is silently ignored, and nothing stops code from reading them. If they were marked as placeholders, ArgsManager could warn when they are set and raise an error when one is retrieved, which would have caught this bug even without a test.)

In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (fb15cb374f1a734ecf7dfcef11e56d8f082e9a4d) The new `rpc_signer.py` check is failing in the "No wallet" CI job, and I think it found a real bug. In builds without the wallet, `-signer` is only registered by [`DummyWalletInit`](https://github.com/bitcoin/bitcoin/blob/f65919e1159202e4bfe50f6b30f6493556ed0233/src/dummywallet.cpp#L42) as a plain hidden option, so it doesn't get `NEGATE_TO_EMPTY`, but the node still reads it, for example in the [`enumeratesigners`](https://github.com/bitcoin/bitcoin/blob/f65919e1159202e4bfe50f6b30f6493556ed0233/src/rpc/external_signer.cpp#L49) RPC, so `-nosigner` still runs the command `0` there. Since the node reads `-signer` whether or not the wallet is enabled, I think it should be registered as a node option instead of a wallet option. Moving this registration into `SetupServerArgs()` in `init.cpp`, inside the same `#ifdef ENABLE_EXTERNAL_SIGNER`, and dropping `-signer` from the `DummyWalletInit` list fixes the test for me in a no-wallet build. Keeping `OptionsCategory::WALLET` leaves the `-help` output unchanged in wallet builds. (Not directly related to this PR, but it might be good for ArgsManager to handle placeholder options like the `DummyWalletInit` ones better. Currently they are registered as ordinary hidden options, the same way as real hidden options like `-dbcrashratio`, so setting them on the command line or in the config file is silently ignored, and nothing stops code from reading them. If they were marked as placeholders, ArgsManager could warn when they are set and raise an error when one is retrieved, which would have caught this bug even without a test.)
ryanofsky (Migrated from github.com) commented 2026-11-25 19:23:38 +00:00

In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (fb15cb374f)

The version of this test I posted in https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4683423642 had a comment here saying the large-work invalid chain warning isn't raised again after node0 restarts, so -alertnotify couldn't be tested. That was wrong, and thanks for correcting it in this push: the warning is raised again, so the alert command would run without -noalertnotify. That means the "only checked for not running a bogus command" part no longer applies, and the test could check the alert file the same way as the other two options:

        # node0 still has the large-work invalid chain from the test above, so
        # the warning is raised again on restart and -alertnotify would run.
        with open(self.alertnotify_file) as f:
            alert_text = f.read()

and after the walletnotify check:

        with open(self.alertnotify_file) as f:
            assert_equal(f.read(), alert_text)

With that, the test fails if -noalertnotify is removed.

In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (fb15cb374f1a734ecf7dfcef11e56d8f082e9a4d) The version of this test I posted in https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4683423642 had a comment here saying the large-work invalid chain warning isn't raised again after node0 restarts, so `-alertnotify` couldn't be tested. That was wrong, and thanks for correcting it in this push: the warning is raised again, so the alert command would run without `-noalertnotify`. That means the "only checked for not running a bogus command" part no longer applies, and the test could check the alert file the same way as the other two options: ```python # node0 still has the large-work invalid chain from the test above, so # the warning is raised again on restart and -alertnotify would run. with open(self.alertnotify_file) as f: alert_text = f.read() ``` and after the `walletnotify` check: ```python with open(self.alertnotify_file) as f: assert_equal(f.read(), alert_text) ``` With that, the test fails if `-noalertnotify` is removed.
fjahr (Migrated from github.com) reviewed 2026-11-26 12:30:31 +00:00
Lines 1062-1064
fjahr (Migrated from github.com) commented 2026-11-26 12:30:31 +00:00

Added these to the release notes, thanks.

Added these to the release notes, thanks.
fjahr (Migrated from github.com) reviewed 2026-11-26 12:30:35 +00:00
fjahr (Migrated from github.com) commented 2026-11-26 12:30:35 +00:00

Cool, that works! Taken, thanks!

Cool, that works! Taken, thanks!
fjahr (Migrated from github.com) reviewed 2026-11-26 12:30:39 +00:00
fjahr (Migrated from github.com) commented 2026-11-26 12:30:39 +00:00

Right, I agree with your analysis. I moved the registration to SetupServerArgs() into a new commit before the NEGATE_TO_EMPTY one and drop -signer from DummyWalletInit.

If they were marked as placeholders, ArgsManager could warn when they are set and raise an error when one is retrieved

Makes sense, I am looking into this as a follow-up now.

Right, I agree with your analysis. I moved the registration to `SetupServerArgs()` into a new commit before the `NEGATE_TO_EMPTY` one and drop `-signer` from `DummyWalletInit`. > If they were marked as placeholders, ArgsManager could warn when they are set and raise an error when one is retrieved Makes sense, I am looking into this as a follow-up now.
fjahr commented 2026-11-26 12:35:28 +00:00 (Migrated from github.com)

Addressed feedback from @ryanofsky , thanks again for the review!

Addressed feedback from @ryanofsky , thanks again for the review!
l0rinc (Migrated from github.com) approved these changes 2026-11-26 19:43:51 +00:00
l0rinc (Migrated from github.com) left a comment

I like this targeted cleanup of surprising -no behavior while preserving options where 0 is meaningful. I left inline suggestions for -nodbcache, the signer field in Qt, and a few test gaps.

I like this targeted cleanup of surprising -no behavior while preserving options where 0 is meaningful. I left inline suggestions for -nodbcache, the signer field in Qt, and a few test gaps.
l0rinc (Migrated from github.com) commented 2026-11-26 18:58:55 +00:00

c3b3522 args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string:

With nosigner=1, the Options dialog should show an empty signer path instead of 0.

Example patch
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 0744702888..c4bcaeb668 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -445,8 +445,10 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
 #ifdef ENABLE_WALLET
     case SpendZeroConfChange:
         return SettingToBool(setting()).value_or(wallet::DEFAULT_SPEND_ZEROCONF_CHANGE);
-    case ExternalSignerPath:
-        return QString::fromStdString(SettingToString(setting()).value_or(""));
+    case ExternalSignerPath: {
+        const auto signer{setting()};
+        return QString::fromStdString(signer.isFalse() ? "" : SettingToString(signer).value_or(""));
+    }
     case SubFeeFromAmount:
         return m_sub_fee_from_amount;
 #endif
diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp
index 144743b107..6bbd9fd9fa 100644
--- a/src/qt/test/optiontests.cpp
+++ b/src/qt/test/optiontests.cpp
@@ -13,6 +13,7 @@
 
 #include <QSettings>
 #include <QTest>
+#include <QVariant>
 
 #include <univalue.h>
 
@@ -103,6 +104,19 @@ void OptionTests::integerGetArgBug()
     gArgs.WriteSettingsFile();
 }
 
+void OptionTests::negatedExternalSigner()
+{
+#ifdef ENABLE_WALLET
+    OptionsModel options{m_node};
+    gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = false; });
+    QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{});
+    gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = "0"; });
+    QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{"0"});
+#else
+    QSKIP("Wallet support is disabled");
+#endif
+}
+
 void OptionTests::parametersInteraction()
 {
     // Test that the bug https://github.com/bitcoin-core/gui/issues/567 does not resurface.
diff --git a/src/qt/test/optiontests.h b/src/qt/test/optiontests.h
index f8791882f9..8562169a4c 100644
--- a/src/qt/test/optiontests.h
+++ b/src/qt/test/optiontests.h
@@ -21,6 +21,7 @@ private Q_SLOTS:
     void init(); // called before each test function execution.
     void migrateSettings();
     void integerGetArgBug();
+    void negatedExternalSigner();
     void parametersInteraction();
     void extractFilter();
 
> [c3b3522](https://github.com/bitcoin/bitcoin/pull/36880/changes/c3b35225b5388d0975544b8340d96f41fcedeba3) _args: Add NEGATE\_TO\_EMPTY so -nofoo reads as an empty string_: With `nosigner=1`, the Options dialog should show an empty signer path instead of `0`. <details> <summary>Example patch</summary> ```diff diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 0744702888..c4bcaeb668 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -445,8 +445,10 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con #ifdef ENABLE_WALLET case SpendZeroConfChange: return SettingToBool(setting()).value_or(wallet::DEFAULT_SPEND_ZEROCONF_CHANGE); - case ExternalSignerPath: - return QString::fromStdString(SettingToString(setting()).value_or("")); + case ExternalSignerPath: { + const auto signer{setting()}; + return QString::fromStdString(signer.isFalse() ? "" : SettingToString(signer).value_or("")); + } case SubFeeFromAmount: return m_sub_fee_from_amount; #endif diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp index 144743b107..6bbd9fd9fa 100644 --- a/src/qt/test/optiontests.cpp +++ b/src/qt/test/optiontests.cpp @@ -13,6 +13,7 @@ #include <QSettings> #include <QTest> +#include <QVariant> #include <univalue.h> @@ -103,6 +104,19 @@ void OptionTests::integerGetArgBug() gArgs.WriteSettingsFile(); } +void OptionTests::negatedExternalSigner() +{ +#ifdef ENABLE_WALLET + OptionsModel options{m_node}; + gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = false; }); + QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{}); + gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = "0"; }); + QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{"0"}); +#else + QSKIP("Wallet support is disabled"); +#endif +} + void OptionTests::parametersInteraction() { // Test that the bug https://github.com/bitcoin-core/gui/issues/567 does not resurface. diff --git a/src/qt/test/optiontests.h b/src/qt/test/optiontests.h index f8791882f9..8562169a4c 100644 --- a/src/qt/test/optiontests.h +++ b/src/qt/test/optiontests.h @@ -21,6 +21,7 @@ private Q_SLOTS: void init(); // called before each test function execution. void migrateSettings(); void integerGetArgBug(); + void negatedExternalSigner(); void parametersInteraction(); void extractFilter(); ``` </details>
l0rinc (Migrated from github.com) commented 2026-11-26 19:00:12 +00:00

27c2e46 args, wallet: Reject -noblocksdir/-nowalletdir and treat empty values as unset:

Without a configured blocksdir, this test passes even if the empty -blocksdir= override is ignored.

Example patch
diff --git a/test/functional/feature_blocksdir.py b/test/functional/feature_blocksdir.py
index 9af23fbf88..f4b476536e 100755
--- a/test/functional/feature_blocksdir.py
+++ b/test/functional/feature_blocksdir.py
@@ -8,6 +8,7 @@
 from pathlib import Path
 
 from test_framework.test_framework import BitcoinTestFramework, initialize_datadir
+from test_framework.util import append_config
 
 
 class BlocksdirTest(BitcoinTestFramework):
@@ -39,6 +40,7 @@ class BlocksdirTest(BitcoinTestFramework):
         self.log.info("Starting with an empty -blocksdir uses the datadir ...")
         self.cleanup_folder(self.nodes[0].datadir_path)
         initialize_datadir(self.options.tmpdir, 0, self.chain)
+        append_config(self.nodes[0].datadir_path, [f"blocksdir={blocksdir_path}"])
         self.start_node(0, ["-blocksdir="])
         assert (self.nodes[0].blocks_path / "blk00000.dat").is_file()
 
> [27c2e46](https://github.com/bitcoin/bitcoin/pull/36880/changes/27c2e463460f119c9ce39efec044633fe7099994) _args, wallet: Reject -noblocksdir/-nowalletdir and treat empty values as unset_: Without a configured `blocksdir`, this test passes even if the empty `-blocksdir=` override is ignored. <details> <summary>Example patch</summary> ```diff diff --git a/test/functional/feature_blocksdir.py b/test/functional/feature_blocksdir.py index 9af23fbf88..f4b476536e 100755 --- a/test/functional/feature_blocksdir.py +++ b/test/functional/feature_blocksdir.py @@ -8,6 +8,7 @@ from pathlib import Path from test_framework.test_framework import BitcoinTestFramework, initialize_datadir +from test_framework.util import append_config class BlocksdirTest(BitcoinTestFramework): @@ -39,6 +40,7 @@ class BlocksdirTest(BitcoinTestFramework): self.log.info("Starting with an empty -blocksdir uses the datadir ...") self.cleanup_folder(self.nodes[0].datadir_path) initialize_datadir(self.options.tmpdir, 0, self.chain) + append_config(self.nodes[0].datadir_path, [f"blocksdir={blocksdir_path}"]) self.start_node(0, ["-blocksdir="]) assert (self.nodes[0].blocks_path / "blk00000.dat").is_file() ``` </details>
l0rinc (Migrated from github.com) commented 2026-11-26 19:42:01 +00:00

9b63d8f init: Disallow negating options where it has no meaning:

-nodbcache silently selects the 4 MiB minimum rather than disabling the cache. It should be rejected alongside the buffer negations.

Example patch
diff --git a/src/init.cpp b/src/init.cpp
index 01f25de271..a89e137663 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -526,7 +526,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc)
     argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
     argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS);
     argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", DEFAULT_DB_CACHE_BATCH), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS);
-    argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DBCACHE_BYTES / 1_MiB, node::GetDefaultDBCache() / 1_MiB), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
+    argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DBCACHE_BYTES / 1_MiB, node::GetDefaultDBCache() / 1_MiB), ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS);
     argsman.AddArg("-includeconf=<file>", "Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
     argsman.AddArg("-allowignoredconf", strprintf("For backwards compatibility, treat an unused %s file in the datadir as a warning, not an error.", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
     argsman.AddArg("-loadblock=<file>", "Imports blocks from an external file on startup. Obfuscated blocks are not supported.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py
index f328b7f3a9..4be06e7d02 100755
--- a/test/functional/feature_config_args.py
+++ b/test/functional/feature_config_args.py
@@ -220,7 +220,7 @@ class ConfArgsTest(BitcoinTestFramework):
             expected_msg='Error: Error parsing command line arguments: Can not set -proxy with no value. Please specify value with -proxy=value.',
             extra_args=['-proxy'],
         )
-        for option in ['checkblocks', 'maxreceivebuffer', 'maxsendbuffer', 'maxtipage']:
+        for option in ['checkblocks', 'dbcache', 'maxreceivebuffer', 'maxsendbuffer', 'maxtipage']:
             self.nodes[0].assert_start_raises_init_error(
                 expected_msg=f'Error: Error parsing command line arguments: Negating of -{option} is meaningless and therefore forbidden',
                 extra_args=[f'-no{option}'],
> [9b63d8f](https://github.com/bitcoin/bitcoin/pull/36880/changes/9b63d8fcab26bc78e807a2ae14e64c6349797132) _init: Disallow negating options where it has no meaning_: `-nodbcache` silently selects the 4 MiB minimum rather than disabling the cache. It should be rejected alongside the buffer negations. <details> <summary>Example patch</summary> ```diff diff --git a/src/init.cpp b/src/init.cpp index 01f25de271..a89e137663 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -526,7 +526,7 @@ void SetupServerArgs(ArgsManager& argsman, bool can_listen_ipc) argsman.AddArg("-conf=<file>", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS); argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", DEFAULT_DB_CACHE_BATCH), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); - argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DBCACHE_BYTES / 1_MiB, node::GetDefaultDBCache() / 1_MiB), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-dbcache=<n>", strprintf("Maximum database cache size <n> MiB (minimum %d, default: %d). Make sure you have enough RAM. In addition, unused memory allocated to the mempool is shared with this cache (see -maxmempool).", MIN_DBCACHE_BYTES / 1_MiB, node::GetDefaultDBCache() / 1_MiB), ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS); argsman.AddArg("-includeconf=<file>", "Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-allowignoredconf", strprintf("For backwards compatibility, treat an unused %s file in the datadir as a warning, not an error.", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-loadblock=<file>", "Imports blocks from an external file on startup. Obfuscated blocks are not supported.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index f328b7f3a9..4be06e7d02 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -220,7 +220,7 @@ class ConfArgsTest(BitcoinTestFramework): expected_msg='Error: Error parsing command line arguments: Can not set -proxy with no value. Please specify value with -proxy=value.', extra_args=['-proxy'], ) - for option in ['checkblocks', 'maxreceivebuffer', 'maxsendbuffer', 'maxtipage']: + for option in ['checkblocks', 'dbcache', 'maxreceivebuffer', 'maxsendbuffer', 'maxtipage']: self.nodes[0].assert_start_raises_init_error( expected_msg=f'Error: Error parsing command line arguments: Negating of -{option} is meaningless and therefore forbidden', extra_args=[f'-no{option}'], ``` </details>
l0rinc (Migrated from github.com) commented 2026-11-26 18:59:35 +00:00

c3b3522 args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string:

The alert-file check can pass without exercising -noalertnotify if the warning does not recur after restart.

Example patch
diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py
index 4249120bce..89dcb3748d 100755
--- a/test/functional/feature_notifications.py
+++ b/test/functional/feature_notifications.py
@@ -238,7 +238,7 @@ class NotificationsTest(BitcoinTestFramework):
             alert_text = f.read()
         blocknotify_files = sorted(os.listdir(self.blocknotify_dir))
         walletnotify_files = sorted(os.listdir(self.walletnotify_dir))
-        with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]), \
+        with self.nodes[0].assert_debug_log(expected_msgs=["Found invalid chain more than 6 blocks longer"], unexpected_msgs=["runCommand error"]), \
              self.nodes[1].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]):
             self.start_node(0, extra_args=self.extra_args[0] + ["-noblocknotify", "-noalertnotify"])
             self.start_node(1, extra_args=self.extra_args[1] + ["-nowalletnotify"])
> [c3b3522](https://github.com/bitcoin/bitcoin/pull/36880/changes/c3b35225b5388d0975544b8340d96f41fcedeba3) _args: Add NEGATE\_TO\_EMPTY so -nofoo reads as an empty string_: The alert-file check can pass without exercising `-noalertnotify` if the warning does not recur after restart. <details> <summary>Example patch</summary> ```diff diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py index 4249120bce..89dcb3748d 100755 --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -238,7 +238,7 @@ class NotificationsTest(BitcoinTestFramework): alert_text = f.read() blocknotify_files = sorted(os.listdir(self.blocknotify_dir)) walletnotify_files = sorted(os.listdir(self.walletnotify_dir)) - with self.nodes[0].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]), \ + with self.nodes[0].assert_debug_log(expected_msgs=["Found invalid chain more than 6 blocks longer"], unexpected_msgs=["runCommand error"]), \ self.nodes[1].assert_debug_log(expected_msgs=[], unexpected_msgs=["runCommand error"]): self.start_node(0, extra_args=self.extra_args[0] + ["-noblocknotify", "-noalertnotify"]) self.start_node(1, extra_args=self.extra_args[1] + ["-nowalletnotify"]) ``` </details>
l0rinc (Migrated from github.com) commented 2026-11-26 19:00:01 +00:00

f204dc0 init: Require -nolistenonion with -notorcontrol:

This test also needs to cover -notorcontrol -listen=0, which disables onion listening implicitly.

Example patch
diff --git a/test/functional/feature_torcontrol.py b/test/functional/feature_torcontrol.py
index c1fc55241f..aa098e2134 100755
--- a/test/functional/feature_torcontrol.py
+++ b/test/functional/feature_torcontrol.py
@@ -343,11 +343,13 @@ class TorControlTest(BitcoinTestFramework):
         mock_tor.stop()
 
     def test_notorcontrol(self):
-        self.log.info("Test that -notorcontrol requires -nolistenonion")
+        self.log.info("Test that -notorcontrol requires onion listening to be disabled")
         self.stop_node(0)
         self.nodes[0].replace_in_config([("listenonion=0\n", "")])
         self.nodes[0].assert_start_raises_init_error(["-notorcontrol"], "Error: -notorcontrol cannot be used while -listenonion is enabled (the default). Use -nolistenonion to stop connecting to the Tor control port.")
         self.start_node(0, extra_args=["-notorcontrol", "-nolistenonion"])
+        self.nodes[0].replace_in_config([("bind=127.0.0.1\n", "")])
+        self.restart_node(0, extra_args=["-notorcontrol", "-listen=0"])
 
     def test_invalid_service_id(self):
         invalid_service_id = "a" + SERVICE_ID[1:]
> [f204dc0](https://github.com/bitcoin/bitcoin/pull/36880/changes/f204dc026a67faadf638ade0748b47fcfbab97c4) _init: Require -nolistenonion with -notorcontrol_: This test also needs to cover `-notorcontrol -listen=0`, which disables onion listening implicitly. <details> <summary>Example patch</summary> ```diff diff --git a/test/functional/feature_torcontrol.py b/test/functional/feature_torcontrol.py index c1fc55241f..aa098e2134 100755 --- a/test/functional/feature_torcontrol.py +++ b/test/functional/feature_torcontrol.py @@ -343,11 +343,13 @@ class TorControlTest(BitcoinTestFramework): mock_tor.stop() def test_notorcontrol(self): - self.log.info("Test that -notorcontrol requires -nolistenonion") + self.log.info("Test that -notorcontrol requires onion listening to be disabled") self.stop_node(0) self.nodes[0].replace_in_config([("listenonion=0\n", "")]) self.nodes[0].assert_start_raises_init_error(["-notorcontrol"], "Error: -notorcontrol cannot be used while -listenonion is enabled (the default). Use -nolistenonion to stop connecting to the Tor control port.") self.start_node(0, extra_args=["-notorcontrol", "-nolistenonion"]) + self.nodes[0].replace_in_config([("bind=127.0.0.1\n", "")]) + self.restart_node(0, extra_args=["-notorcontrol", "-listen=0"]) def test_invalid_service_id(self): invalid_service_id = "a" + SERVICE_ID[1:] ``` </details>
l0rinc (Migrated from github.com) commented 2026-11-26 18:59:49 +00:00

c3b3522 args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string:

The authentication failure is the same for an empty username and 0, so this check does not prove -norpcuser works.

Example patch
diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py
index bf90935828..a0904e4f71 100755
--- a/test/functional/interface_bitcoin_cli.py
+++ b/test/functional/interface_bitcoin_cli.py
@@ -241,11 +241,6 @@ class TestBitcoinCli(BitcoinTestFramework):
         assert_equal(BLOCKS, self.nodes[0].cli('-rpcpassword=foo', '-norpcpassword').getblockcount())
         assert_raises_process_error(1, "Cookie file was disabled via -norpccookiefile and no rpcpassword was specified.", self.nodes[0].cli("-norpccookiefile", "-norpcpassword").echo)
 
-        self.log.info("Test -norpcuser sends an empty user name")
-        # The node's cookie user is __cookie__, so an empty user name fails
-        # here. Node-side -norpcuser is tested in rpc_users.py.
-        assert_raises_process_error(1, 'Incorrect rpcuser or rpcpassword were specified', self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', '-norpcuser', f'-rpcpassword={password}').echo)
-
         self.log.info("Test connecting without RPC cookie file and with password arg")
         assert_equal(BLOCKS, self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', f'-rpcpassword={password}').getblockcount())
 
diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py
index eede5ed55c..197ce6336f 100755
--- a/test/functional/rpc_users.py
+++ b/test/functional/rpc_users.py
@@ -157,6 +157,8 @@ class HTTPBasicsTest(BitcoinTestFramework):
         assert_equal(200, call_with_auth(self.nodes[0], "", "secret").status)
         assert_equal(401, call_with_auth(self.nodes[0], "0", "secret").status)
         assert_equal(401, call_with_auth(self.nodes[0], "alice", "secret").status)
+        if self.is_cli_compiled():
+            assert_equal(["hello"], self.nodes[0].cli("-rpcuser=alice", "-norpcuser", "-rpcpassword=secret").echo("hello"))
         assert_equal(200, call_with_auth(self.nodes[0], "", "secret", method="stop").status)
         self.nodes[0].wait_until_stopped()
 
> [c3b3522](https://github.com/bitcoin/bitcoin/pull/36880/changes/c3b35225b5388d0975544b8340d96f41fcedeba3) _args: Add NEGATE\_TO\_EMPTY so -nofoo reads as an empty string_: The authentication failure is the same for an empty username and `0`, so this check does not prove `-norpcuser` works. <details> <summary>Example patch</summary> ```diff diff --git a/test/functional/interface_bitcoin_cli.py b/test/functional/interface_bitcoin_cli.py index bf90935828..a0904e4f71 100755 --- a/test/functional/interface_bitcoin_cli.py +++ b/test/functional/interface_bitcoin_cli.py @@ -241,11 +241,6 @@ class TestBitcoinCli(BitcoinTestFramework): assert_equal(BLOCKS, self.nodes[0].cli('-rpcpassword=foo', '-norpcpassword').getblockcount()) assert_raises_process_error(1, "Cookie file was disabled via -norpccookiefile and no rpcpassword was specified.", self.nodes[0].cli("-norpccookiefile", "-norpcpassword").echo) - self.log.info("Test -norpcuser sends an empty user name") - # The node's cookie user is __cookie__, so an empty user name fails - # here. Node-side -norpcuser is tested in rpc_users.py. - assert_raises_process_error(1, 'Incorrect rpcuser or rpcpassword were specified', self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', '-norpcuser', f'-rpcpassword={password}').echo) - self.log.info("Test connecting without RPC cookie file and with password arg") assert_equal(BLOCKS, self.nodes[0].cli('-norpccookiefile', f'-rpcuser={user}', f'-rpcpassword={password}').getblockcount()) diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py index eede5ed55c..197ce6336f 100755 --- a/test/functional/rpc_users.py +++ b/test/functional/rpc_users.py @@ -157,6 +157,8 @@ class HTTPBasicsTest(BitcoinTestFramework): assert_equal(200, call_with_auth(self.nodes[0], "", "secret").status) assert_equal(401, call_with_auth(self.nodes[0], "0", "secret").status) assert_equal(401, call_with_auth(self.nodes[0], "alice", "secret").status) + if self.is_cli_compiled(): + assert_equal(["hello"], self.nodes[0].cli("-rpcuser=alice", "-norpcuser", "-rpcpassword=secret").echo("hello")) assert_equal(200, call_with_auth(self.nodes[0], "", "secret", method="stop").status) self.nodes[0].wait_until_stopped() ``` </details>
ryanofsky (Migrated from github.com) approved these changes 2026-11-30 15:23:15 +00:00
ryanofsky (Migrated from github.com) left a comment

Code review ACK 9cf00ac7ae. This fixes a set of options where -nofoo did the opposite of what it says, failed startup, or crashed the node, and makes negation behave predictably: negated options now mean empty or 0, and negating a limit where 0 would mean something very different is an error.

Thanks for the quick updates and for following up on the placeholder options! l0rinc's suggestions look good to me too, especially making -nodbcache an error (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4740765473) and the two test improvements (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4740764896, https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4740765205).

Code review ACK 9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd. This fixes a set of options where `-nofoo` did the opposite of what it says, failed startup, or crashed the node, and makes negation behave predictably: negated options now mean empty or 0, and negating a limit where 0 would mean something very different is an error. Thanks for the quick updates and for following up on the placeholder options! l0rinc's suggestions look good to me too, especially making `-nodbcache` an error (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4740765473) and the two test improvements (https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4740764896, https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4740765205).
ryanofsky (Migrated from github.com) commented 2026-11-30 15:20:29 +00:00

In commit "doc: Add release note for negated option changes" (9cf00ac7ae)

It might help to mention what previous behavior was, since "now uses the default directory" raises question of what was happening before:

- An empty `-blocksdir=` or `-walletdir=` now uses the default directory, as
  if the option were not set. Previously they could fail at startup or, for
  `-blocksdir=`, use the current working directory, depending on the platform.
  (#36880)
In commit "doc: Add release note for negated option changes" (9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd) It might help to mention what previous behavior was, since "now uses the default directory" raises question of what was happening before: ```suggestion - An empty `-blocksdir=` or `-walletdir=` now uses the default directory, as if the option were not set. Previously they could fail at startup or, for `-blocksdir=`, use the current working directory, depending on the platform. (#36880) ```
ryanofsky (Migrated from github.com) commented 2026-11-30 15:11:43 +00:00

re: https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4712445114

In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (c3b35225b5)

With nosigner=1, the Options dialog should show an empty signer path instead of 0.

Good catch. But I think it would be better to fix this in SettingToString() than in the GUI. The underlying problem is that SettingToString() converts negated values differently from GetArg(), which applies NEGATE_TO_EMPTY itself before calling it. If SettingToString() took the option's flags as a required argument and applied NEGATE_TO_EMPTY itself, GetArg() could pass GetArgFlags() and OptionsModel could pass the flags from gArgs, where the GUI registers its options, so the two couldn't disagree. Making the argument required also lets the compiler find every caller.

I tried this with your test, and it passes with the change and fails without it. The test needs to register the options first, because the Qt test harness clears them:

Diff
diff --git a/src/common/args.cpp b/src/common/args.cpp
index 338ef7f9ad..36c2fc2178 100644
--- a/src/common/args.cpp
+++ b/src/common/args.cpp
@@ -283,7 +283,7 @@ fs::path ArgsManager::GetPathArg_(std::string arg, const fs::path& default_value
     AssertLockHeld(cs_args);
     const auto value = GetSetting_(arg);
     if (value.isFalse()) return {};
-    std::string path_str = SettingToString(value).value_or("");
+    std::string path_str = SettingToString(value, GetArgFlags_(arg).value_or(0)).value_or("");
     if (path_str.empty()) return default_value;
     fs::path result = fs::PathFromString(path_str).lexically_normal();
     // Remove trailing slash, if present.
@@ -524,14 +524,13 @@ std::string ArgsManager::GetArg(const std::string& strArg, const std::string& st
 std::optional<std::string> ArgsManager::GetArg(const std::string& strArg) const
 {
     const common::SettingsValue value = GetSetting(strArg);
-    if (value.isFalse() && (GetArgFlags(strArg).value_or(0) & NEGATE_TO_EMPTY)) return "";
-    return SettingToString(value);
+    return SettingToString(value, GetArgFlags(strArg).value_or(0));
 }

-std::optional<std::string> SettingToString(const common::SettingsValue& value)
+std::optional<std::string> SettingToString(const common::SettingsValue& value, unsigned int flags)
 {
     if (value.isNull()) return std::nullopt;
-    if (value.isFalse()) return "0";
+    if (value.isFalse()) return (flags & ArgsManager::NEGATE_TO_EMPTY) ? "" : "0";
     if (value.isTrue()) return "1";
     if (value.isNum()) return value.getValStr();
     return value.get_str();
diff --git a/src/common/args.h b/src/common/args.h
index db55b5402e..262de886f8 100644
--- a/src/common/args.h
+++ b/src/common/args.h
@@ -91,7 +91,9 @@ struct SectionInfo {
     int m_line;
 };

-std::optional<std::string> SettingToString(const common::SettingsValue&);
+//! Convert a setting value to a string. Pass the option's ArgsManager flags
+//! (e.g. from GetArgFlags()) so flags like NEGATE_TO_EMPTY apply.
+std::optional<std::string> SettingToString(const common::SettingsValue&, unsigned int flags);

 template <std::integral Int>
 std::optional<Int> SettingTo(const common::SettingsValue&);
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 0744702888..c45c3d37dc 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -160,7 +160,7 @@ void OptionsModel::addOverriddenOption(const std::string &option)
 bool OptionsModel::Init(bilingual_str& error)
 {
     // Initialize display settings from stored settings.
-    language = QString::fromStdString(SettingToString(node().getPersistentSetting("lang")).value_or(""));
+    language = QString::fromStdString(SettingToString(node().getPersistentSetting("lang"), gArgs.GetArgFlags("-lang").value_or(0)).value_or(""));

     checkAndMigrate();

@@ -401,6 +401,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
 QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) const
 {
     auto setting = [&]{ return node().getPersistentSetting(SettingName(option) + suffix); };
+    auto flags = [&]{ return gArgs.GetArgFlags(std::string{"-"} + SettingName(option)).value_or(0); };

     QSettings settings;
     switch (option) {
@@ -418,10 +419,10 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
     // default proxy
     case ProxyUse:
     case ProxyUseTor:
-        return ParseProxyString(SettingToString(setting()).value_or("")).is_set;
+        return ParseProxyString(SettingToString(setting(), flags()).value_or("")).is_set;
     case ProxyIP:
     case ProxyIPTor: {
-        ProxySetting proxy = ParseProxyString(SettingToString(setting()).value_or(""));
+        ProxySetting proxy = ParseProxyString(SettingToString(setting(), flags()).value_or(""));
         if (proxy.is_set) {
             return proxy.ip;
         } else if (suffix.empty()) {
@@ -432,7 +433,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
     }
     case ProxyPort:
     case ProxyPortTor: {
-        ProxySetting proxy = ParseProxyString(SettingToString(setting()).value_or(""));
+        ProxySetting proxy = ParseProxyString(SettingToString(setting(), flags()).value_or(""));
         if (proxy.is_set) {
             return proxy.port;
         } else if (suffix.empty()) {
@@ -446,7 +447,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
     case SpendZeroConfChange:
         return SettingToBool(setting()).value_or(wallet::DEFAULT_SPEND_ZEROCONF_CHANGE);
     case ExternalSignerPath:
-        return QString::fromStdString(SettingToString(setting()).value_or(""));
+        return QString::fromStdString(SettingToString(setting(), flags()).value_or(""));
     case SubFeeFromAmount:
         return m_sub_fee_from_amount;
 #endif
@@ -455,7 +456,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
     case ThirdPartyTxUrls:
         return strThirdPartyTxUrls;
     case Language:
-        return QString::fromStdString(SettingToString(setting()).value_or(""));
+        return QString::fromStdString(SettingToString(setting(), flags()).value_or(""));
     case FontForMoney:
         return QVariant::fromValue(m_font_money);
     case CoinControlFeatures:
diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp
index 144743b107..9b538b789a 100644
--- a/src/qt/test/optiontests.cpp
+++ b/src/qt/test/optiontests.cpp
@@ -13,6 +13,7 @@

 #include <QSettings>
 #include <QTest>
+#include <QVariant>

 #include <univalue.h>

@@ -26,6 +27,7 @@ OptionTests::OptionTests(interfaces::Node& node) : m_node(node)
 void OptionTests::init()
 {
     // reset args
+    gArgs.ClearArgs();
     gArgs.LockSettings([&](common::Settings& s) { s = m_previous_settings; });
     gArgs.ClearPathCache();
 }
@@ -103,6 +105,22 @@ void OptionTests::integerGetArgBug()
     gArgs.WriteSettingsFile();
 }

+void OptionTests::negatedExternalSigner()
+{
+#ifdef ENABLE_WALLET
+    // Register options the way the GUI does in bitcoin.cpp, so -signer has its
+    // NEGATE_TO_EMPTY flag. cleanup() clears them again.
+    SetupServerArgs(gArgs, /*can_listen_ipc=*/false);
+    OptionsModel options{m_node};
+    gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = false; });
+    QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{});
+    gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = "0"; });
+    QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{"0"});
+#else
+    QSKIP("Wallet support is disabled");
+#endif
+}
+
 void OptionTests::parametersInteraction()
 {
     // Test that the bug https://github.com/bitcoin-core/gui/issues/567 does not resurface.
diff --git a/src/qt/test/optiontests.h b/src/qt/test/optiontests.h
index f8791882f9..8562169a4c 100644
--- a/src/qt/test/optiontests.h
+++ b/src/qt/test/optiontests.h
@@ -21,6 +21,7 @@ private Q_SLOTS:
     void init(); // called before each test function execution.
     void migrateSettings();
     void integerGetArgBug();
+    void negatedExternalSigner();
     void parametersInteraction();
     void extractFilter();

re: https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4712445114 In commit "args: Add NEGATE_TO_EMPTY so -nofoo reads as an empty string" (c3b35225b5388d0975544b8340d96f41fcedeba3) > With `nosigner=1`, the Options dialog should show an empty signer path instead of `0`. Good catch. But I think it would be better to fix this in `SettingToString()` than in the GUI. The underlying problem is that `SettingToString()` converts negated values differently from `GetArg()`, which applies `NEGATE_TO_EMPTY` itself before calling it. If `SettingToString()` took the option's flags as a required argument and applied `NEGATE_TO_EMPTY` itself, `GetArg()` could pass `GetArgFlags()` and `OptionsModel` could pass the flags from `gArgs`, where the GUI registers its options, so the two couldn't disagree. Making the argument required also lets the compiler find every caller. I tried this with your test, and it passes with the change and fails without it. The test needs to register the options first, because the Qt test harness clears them: <details><summary>Diff</summary> ```diff diff --git a/src/common/args.cpp b/src/common/args.cpp index 338ef7f9ad..36c2fc2178 100644 --- a/src/common/args.cpp +++ b/src/common/args.cpp @@ -283,7 +283,7 @@ fs::path ArgsManager::GetPathArg_(std::string arg, const fs::path& default_value AssertLockHeld(cs_args); const auto value = GetSetting_(arg); if (value.isFalse()) return {}; - std::string path_str = SettingToString(value).value_or(""); + std::string path_str = SettingToString(value, GetArgFlags_(arg).value_or(0)).value_or(""); if (path_str.empty()) return default_value; fs::path result = fs::PathFromString(path_str).lexically_normal(); // Remove trailing slash, if present. @@ -524,14 +524,13 @@ std::string ArgsManager::GetArg(const std::string& strArg, const std::string& st std::optional<std::string> ArgsManager::GetArg(const std::string& strArg) const { const common::SettingsValue value = GetSetting(strArg); - if (value.isFalse() && (GetArgFlags(strArg).value_or(0) & NEGATE_TO_EMPTY)) return ""; - return SettingToString(value); + return SettingToString(value, GetArgFlags(strArg).value_or(0)); } -std::optional<std::string> SettingToString(const common::SettingsValue& value) +std::optional<std::string> SettingToString(const common::SettingsValue& value, unsigned int flags) { if (value.isNull()) return std::nullopt; - if (value.isFalse()) return "0"; + if (value.isFalse()) return (flags & ArgsManager::NEGATE_TO_EMPTY) ? "" : "0"; if (value.isTrue()) return "1"; if (value.isNum()) return value.getValStr(); return value.get_str(); diff --git a/src/common/args.h b/src/common/args.h index db55b5402e..262de886f8 100644 --- a/src/common/args.h +++ b/src/common/args.h @@ -91,7 +91,9 @@ struct SectionInfo { int m_line; }; -std::optional<std::string> SettingToString(const common::SettingsValue&); +//! Convert a setting value to a string. Pass the option's ArgsManager flags +//! (e.g. from GetArgFlags()) so flags like NEGATE_TO_EMPTY apply. +std::optional<std::string> SettingToString(const common::SettingsValue&, unsigned int flags); template <std::integral Int> std::optional<Int> SettingTo(const common::SettingsValue&); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 0744702888..c45c3d37dc 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -160,7 +160,7 @@ void OptionsModel::addOverriddenOption(const std::string &option) bool OptionsModel::Init(bilingual_str& error) { // Initialize display settings from stored settings. - language = QString::fromStdString(SettingToString(node().getPersistentSetting("lang")).value_or("")); + language = QString::fromStdString(SettingToString(node().getPersistentSetting("lang"), gArgs.GetArgFlags("-lang").value_or(0)).value_or("")); checkAndMigrate(); @@ -401,6 +401,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) const { auto setting = [&]{ return node().getPersistentSetting(SettingName(option) + suffix); }; + auto flags = [&]{ return gArgs.GetArgFlags(std::string{"-"} + SettingName(option)).value_or(0); }; QSettings settings; switch (option) { @@ -418,10 +419,10 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con // default proxy case ProxyUse: case ProxyUseTor: - return ParseProxyString(SettingToString(setting()).value_or("")).is_set; + return ParseProxyString(SettingToString(setting(), flags()).value_or("")).is_set; case ProxyIP: case ProxyIPTor: { - ProxySetting proxy = ParseProxyString(SettingToString(setting()).value_or("")); + ProxySetting proxy = ParseProxyString(SettingToString(setting(), flags()).value_or("")); if (proxy.is_set) { return proxy.ip; } else if (suffix.empty()) { @@ -432,7 +433,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con } case ProxyPort: case ProxyPortTor: { - ProxySetting proxy = ParseProxyString(SettingToString(setting()).value_or("")); + ProxySetting proxy = ParseProxyString(SettingToString(setting(), flags()).value_or("")); if (proxy.is_set) { return proxy.port; } else if (suffix.empty()) { @@ -446,7 +447,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con case SpendZeroConfChange: return SettingToBool(setting()).value_or(wallet::DEFAULT_SPEND_ZEROCONF_CHANGE); case ExternalSignerPath: - return QString::fromStdString(SettingToString(setting()).value_or("")); + return QString::fromStdString(SettingToString(setting(), flags()).value_or("")); case SubFeeFromAmount: return m_sub_fee_from_amount; #endif @@ -455,7 +456,7 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con case ThirdPartyTxUrls: return strThirdPartyTxUrls; case Language: - return QString::fromStdString(SettingToString(setting()).value_or("")); + return QString::fromStdString(SettingToString(setting(), flags()).value_or("")); case FontForMoney: return QVariant::fromValue(m_font_money); case CoinControlFeatures: diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp index 144743b107..9b538b789a 100644 --- a/src/qt/test/optiontests.cpp +++ b/src/qt/test/optiontests.cpp @@ -13,6 +13,7 @@ #include <QSettings> #include <QTest> +#include <QVariant> #include <univalue.h> @@ -26,6 +27,7 @@ OptionTests::OptionTests(interfaces::Node& node) : m_node(node) void OptionTests::init() { // reset args + gArgs.ClearArgs(); gArgs.LockSettings([&](common::Settings& s) { s = m_previous_settings; }); gArgs.ClearPathCache(); } @@ -103,6 +105,22 @@ void OptionTests::integerGetArgBug() gArgs.WriteSettingsFile(); } +void OptionTests::negatedExternalSigner() +{ +#ifdef ENABLE_WALLET + // Register options the way the GUI does in bitcoin.cpp, so -signer has its + // NEGATE_TO_EMPTY flag. cleanup() clears them again. + SetupServerArgs(gArgs, /*can_listen_ipc=*/false); + OptionsModel options{m_node}; + gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = false; }); + QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{}); + gArgs.LockSettings([](common::Settings& settings) { settings.rw_settings["signer"] = "0"; }); + QCOMPARE(options.getOption(OptionsModel::ExternalSignerPath).toString(), QString{"0"}); +#else + QSKIP("Wallet support is disabled"); +#endif +} + void OptionTests::parametersInteraction() { // Test that the bug https://github.com/bitcoin-core/gui/issues/567 does not resurface. diff --git a/src/qt/test/optiontests.h b/src/qt/test/optiontests.h index f8791882f9..8562169a4c 100644 --- a/src/qt/test/optiontests.h +++ b/src/qt/test/optiontests.h @@ -21,6 +21,7 @@ private Q_SLOTS: void init(); // called before each test function execution. void migrateSettings(); void integerGetArgBug(); + void negatedExternalSigner(); void parametersInteraction(); void extractFilter(); ``` </details>
ryanofsky (Migrated from github.com) commented 2026-11-30 14:45:03 +00:00

re: https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4712452641

The authentication failure is the same for an empty username and 0, so this check does not prove -norpcuser works.

Agree, this is better than the check I suggested, which only showed the request failed. In rpc_users.py the node's user name is already checked to be empty by the call_with_auth lines before it, so the bitcoin-cli call there should only succeed if -norpcuser sends an empty user name too. The Ralph review flagged the old check too.

re: https://github.com/bitcoin/bitcoin/pull/36880#discussion_r4712452641 > The authentication failure is the same for an empty username and `0`, so this check does not prove `-norpcuser` works. Agree, this is better than the check I suggested, which only showed the request failed. In `rpc_users.py` the node's user name is already checked to be empty by the `call_with_auth` lines before it, so the `bitcoin-cli` call there should only succeed if `-norpcuser` sends an empty user name too. The [Ralph review](https://review.fish.foo/report/36880-9cf00ac7ae7f35ccdfa8f511e55a6a78bc3075dd-3196-7.html#finding-finding%3A1) flagged the old check too.
DrahtBot commented 2026-12-02 15:53:34 +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 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!36880
No description provided.