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.