{
 "number": 36689,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36689",
 "title": "cli: Parse -signetchallenge like bitcoind",
 "author": "ekzyis",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-10-28T19:14:59Z",
 "updated_at": "2026-10-30T15:28:03Z",
 "description_hash": "f1b1c6ebfb8b0c14",
 "age_days": 4,
 "draft": false,
 "labels": [
  "Scripts and tools"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "54fe0ec5d80a0bb2cdc4dee4e5a4ecaf7256a832",
 "head_ref": "bitcoin-cli-signetchallenge-validation",
 "head_repo": "ekzyis/bitcoin",
 "head_history": [
  {
   "t": "2026-10-29T18:38:41Z",
   "sha": "cb7bb77a10fbccc16b90310a25d3f9f2d348bf9f"
  },
  {
   "t": "2026-10-30T15:20:22Z",
   "sha": "54fe0ec5d80a0bb2cdc4dee4e5a4ecaf7256a832"
  }
 ],
 "additions": 53,
 "deletions": 19,
 "changed_files": 4,
 "commit_count": 2,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "concept_ack": [
     {
      "login": "Sjors",
      "url": "https://github.com/bitcoin/bitcoin/pull/36689#issuecomment-6518273655"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "Sjors": {
   "kind": "concept_ack",
   "hash": null,
   "t": "2026-10-30T08:14:40Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 1,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "Sjors",
   "ValeraFinebits"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-10-30T15:28:03Z",
  "last_reviewer_activity": "2026-10-30T08:14:40Z",
  "last_reviewer": "Sjors",
  "author_silent_days": 2,
  "waiting_on_author_days": 0,
  "days_since_update": 2
 },
 "refs": {
  "mentioned": [
   34566
  ],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [
   {
    "number": 34566,
    "type": "pull",
    "state": "closed",
    "merged": true,
    "merged_at": "2026-09-16",
    "title": "feature: Use different datadirs for different signets"
   }
  ],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "test/functional/feature_signet.py"
 ],
 "body": "`bitcoind` returns an useful error when invalid hex is passed to `-signetchallenge`:\n\n```\n$ bitcoind -signet -signetchallenge=z\nError: -signetchallenge must be hex, not 'z'\n```\n\nThe error returned by `bitcoin-cli` only indicates that the RPC cookie wasn't found. It doesn't hint at invalid hex:\n\n```\n$ bitcoin-cli -signet -signetchallenge=z getblockcount\nerror: Authorization failed: ...\nIs your -signetchallenge correct for custom signets?\n```\n\nTo have consistent validation of signet args in `bitcoind` and `bitcoin-cli`, we now parse `-signetchallenge` in a new `ReadSigNetChallengeArg()` function which is called in `ReadSigNetDir()` and `ReadSigNetArgs()`.\n\nAddresses https://github.com/bitcoin/bitcoin/pull/34566#discussion_r3668123074\n\nI didn't add a release note because I don't think this change of an error message warrants one.",
 "commits": [
  {
   "sha": "23a88a41daf902184c8c06677a9be764e7d72839",
   "date": "2026-10-30T15:14:12Z",
   "message": "refactor: move -signetchallenge parsing into helper\n\nWe parse and validate -signetchallenge in two places: GetSignetDataDir()\nand ReadSigNetArgs().\n\nTo have consistent behavior between bitcoind and bitcoin-cli, we extract\nthe code for -signetchallenge in ReadSigNetArgs() into a helper function\nReadSignetChallengeArg() which can be reused in GetSignetDataDir() in\nthe next commit."
  },
  {
   "sha": "54fe0ec5d80a0bb2cdc4dee4e5a4ecaf7256a832",
   "date": "2026-10-30T15:16:54Z",
   "message": "cli: Parse -signetchallenge like bitcoind\n\nbitcoind returns an useful error when invalid hex is passed to\n-signetchallenge:\n\n```\n$ bitcoind -signet -signetchallenge=z\nError: -signetchallenge must be hex, not 'z'\n```\n\nThe error returned by bitcoin-cli only indicates that the RPC cookie\nwasn't found. It doesn't hint at invalid hex:\n\n```\n$ bitcoin-cli -signet -signetchallenge=z getblockcount\nerror: Authorization failed: ...\nIs your -signetchallenge correct for custom signets?\n```\n\nTo have consistent validation of signet args in bitcoind and\nbitcoin-cli, we now parse -signetchallenge with ReadSignetChallengeArg()\nin GetSignetDataDir() and add tests."
  }
 ],
 "timeline": [
  {
   "t": "2026-10-29T16:58:27Z",
   "kind": "comment",
   "who": "ValeraFinebits",
   "assoc": "NONE",
   "text": "Optional test suggestion: set `signetchallenge=51` in the `[signet]` config section and also pass `-signetchallenge=51` on the command line, then assert the multiple-values error.\n\nThis would cover the `GetArg()` -> `GetArgs()` change across configuration sources, using valid, identical values. Running this case with RPC unavailable would also verify that the diagnostic does not depend on a running node.",
   "id": "c:6503075583",
   "url": "https://github.com/bitcoin/bitcoin/pull/36689#issuecomment-6503075583",
   "hash": "ee1172ff9500b6a2",
   "edited": null
  },
  {
   "t": "2026-10-29T18:38:41Z",
   "kind": "force_push",
   "who": "ekzyis",
   "commit": "cb7bb77a10fbccc16b90310a25d3f9f2d348bf9f",
   "id": "push:cb7bb77a10fbccc16b90310a25d3f9f2d348bf9f"
  },
  {
   "t": "2026-10-29T18:41:40Z",
   "kind": "comment",
   "who": "ekzyis",
   "assoc": "CONTRIBUTOR",
   "text": "[quoted text omitted]\n\nThanks! I replaced the CLI test which passes the same invalid value twice (`-signetchallenge=abc`) with a test that uses `signetchallenge=51` from the config and passes the same valid value (`-signetchallenge=51`) in cb7bb77a10, as you suggested.",
   "id": "c:6505333795",
   "url": "https://github.com/bitcoin/bitcoin/pull/36689#issuecomment-6505333795",
   "hash": "513a06d83be28ae4",
   "edited": "2026-10-29T18:43:33Z"
  },
  {
   "t": "2026-10-29T19:05:51Z",
   "kind": "review_comment",
   "who": "ekzyis",
   "assoc": "CONTRIBUTOR",
   "path": "test/functional/feature_signet.py",
   "commit": "54fe0ec5d80a0bb2cdc4dee4e5a4ecaf7256a832",
   "in_reply_to": null,
   "text": "I checked if we're using patterns like here which could be refactored with context managers, but there's only one similar case I've found at interface_bitcoin_cli.py:205 where we comment out `rpcport` in the config before running some tests and restoring it.\n\nIn the other cases, we're either restarting the node with the new changes (so undo is undesired) or `node.replace_in_config()` is more ergonomic.\n\nSo in case someone has more context than me to still consider this a good idea: This and similar patterns could be refactored with a context manager like this:\n\n```python\nwith extra_config(node, \"signetchallenge=51\"):\n    assert_raises_process_error(1, \"-signetchallenge cannot be multiple values.\", node.cli(\"-signetchallenge=51\").getblockcount)\n```",
   "id": "rc:4416719146",
   "url": "https://github.com/bitcoin/bitcoin/pull/36689#discussion_r4416719146",
   "hash": "7bf5d6455a0df90e",
   "edited": "2026-10-29T19:09:06Z"
  },
  {
   "t": "2026-10-30T08:14:40Z",
   "kind": "comment",
   "who": "Sjors",
   "assoc": "MEMBER",
   "text": "Concept ACK\n\nConsider splitting cb7bb77a10fbccc16b90310a25d3f9f2d348bf9f into a pure refactor to extract the helper(s) you need, followed by the change itself.\n\nI suggest dropping the rename in 38998ad4104b1dca4db4dd039b0ddb5e7ea766fe. It's going to invite bike-shedding (and personally I prefer Signet over SigNet).",
   "id": "c:6518273655",
   "url": "https://github.com/bitcoin/bitcoin/pull/36689#issuecomment-6518273655",
   "hash": "6668103073d372ed",
   "edited": null
  },
  {
   "t": "2026-10-30T15:20:22Z",
   "kind": "force_push",
   "who": "ekzyis",
   "commit": "54fe0ec5d80a0bb2cdc4dee4e5a4ecaf7256a832",
   "id": "push:54fe0ec5d80a0bb2cdc4dee4e5a4ecaf7256a832"
  },
  {
   "t": "2026-10-30T15:28:03Z",
   "kind": "comment",
   "who": "ekzyis",
   "assoc": "CONTRIBUTOR",
   "text": "Dropped the rename.[^1] 23a88a4 now introduces `ReadSignetChallengeArg()` and 54fe0ec then uses it in `ReadSignetDataDir()` with tests. Updated commit messages accordingly.\n\n[^1]: I also prefer Signet but I think I should have favoured consistency in #34566 instead of introducing Signet over SigNet",
   "id": "c:6526513113",
   "url": "https://github.com/bitcoin/bitcoin/pull/36689#issuecomment-6526513113",
   "hash": "54a62a95c9bcef25",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-28T19:15:27Z",
   "action": "labeled",
   "label": "Scripts and tools",
   "who": "DrahtBot"
  }
 ],
 "state_log": [
  {
   "t": "2026-10-28T19:15:19Z",
   "kind": "renamed",
   "who": "ekzyis",
   "from": "Bitcoin cli signetchallenge validation",
   "to": "cli: Parse -signetchallenge like bitcoind"
  }
 ],
 "text_chars": 3970,
 "text_tokens_estimate": 992,
 "changed_paths": [
  "src/chainparams.cpp",
  "src/chainparamsbase.cpp",
  "src/chainparamsbase.h",
  "test/functional/feature_signet.py"
 ],
 "files": [
  {
   "path": "src/chainparams.cpp",
   "add": 1,
   "del": 11
  },
  {
   "path": "src/chainparamsbase.cpp",
   "add": 22,
   "del": 8
  },
  {
   "path": "src/chainparamsbase.h",
   "add": 9,
   "del": 0
  },
  {
   "path": "test/functional/feature_signet.py",
   "add": 21,
   "del": 0
  }
 ],
 "test_lines": 21,
 "git": {
  "head": "54fe0ec5d80a0bb2cdc4dee4e5a4ecaf7256a832",
  "head_matches_backup": true,
  "base": "aa76bd266df9742a266d52e0e5da8dbf033658f6",
  "patch_id": "67a96f3e6cc92d7a",
  "commits": [
   {
    "sha": "23a88a41da",
    "subject": "refactor: move -signetchallenge parsing into helper",
    "files": 3,
    "add": 30,
    "del": 11
   },
   {
    "sha": "54fe0ec5d8",
    "subject": "cli: Parse -signetchallenge like bitcoind",
    "files": 2,
    "add": 24,
    "del": 9
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "67a96f3e6cc92d7a",
 "input_hash": "0f94ca516df13dd6",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}