{
 "number": 35292,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/35292",
 "title": "test: Add coverage for Tor control `HASHEDPASSWORD` authentication",
 "author": "winterrdog",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-05-14T18:28:10Z",
 "updated_at": "2026-09-17T01:56:58Z",
 "age_days": 125,
 "draft": false,
 "labels": [
  "Tests",
  "Needs rebase"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "f24ef5b2017f074e63ac37c5d3c4bf191df25568",
 "head_ref": "test/torcontrol-hashedpassword-auth",
 "head_repo": "winterrdog/bitcoin",
 "head_history": [
  {
   "t": "2026-05-14T19:50:40Z",
   "sha": "2ca16e642bab0be1efca470b4089e27fe82711cd"
  },
  {
   "t": "2026-05-14T19:56:48Z",
   "sha": "8b2af280148b4f25487e85add5986baa8d3aeb9e"
  },
  {
   "t": "2026-05-14T20:34:59Z",
   "sha": "f886aa2434c7207bd56c7755fcb6005de8864833"
  },
  {
   "t": "2026-06-04T19:49:59Z",
   "sha": "a09fd43cc774b90057ce28ff71952313c7a0b1cf"
  },
  {
   "t": "2026-06-09T23:15:28Z",
   "sha": "a47adf8616e16b0e7a840471622c67f0ae2413b6"
  },
  {
   "t": "2026-08-03T23:55:38Z",
   "sha": "99e6ee3ace3f1bf081c0fc2bb2ee5329b6907927"
  },
  {
   "t": "2026-08-04T00:49:57Z",
   "sha": "f24ef5b2017f074e63ac37c5d3c4bf191df25568"
  }
 ],
 "additions": 69,
 "deletions": 0,
 "changed_files": 1,
 "commit_count": 1,
 "size_bucket": "S",
 "mergeable_state": "dirty",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {},
   "conflicts": [
    {
     "number": 36260,
     "title": "torcontrol: Use reconnect backoff after dropped connections",
     "author": "fjahr"
    },
    {
     "number": 36142,
     "title": "net: validate Tor onion service replies and cached keys",
     "author": "l0rinc"
    },
    {
     "number": 34486,
     "title": "net: Reduce local network activity when networkactive=0",
     "author": "willcl-ark"
    }
   ]
  }
 },
 "acks_parsed": {},
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "davidgumberg",
   "sedited"
  ]
 },
 "signals": {
  "needs_rebase": true,
  "ci_failed": false,
  "mergeable_state": "dirty",
  "last_author_activity": "2026-08-04T00:49:57Z",
  "last_reviewer_activity": "2026-05-14T23:23:40Z",
  "last_reviewer": "davidgumberg",
  "author_silent_days": 44,
  "waiting_on_author_days": 0,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": [
   36260,
   36142,
   34486
  ]
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "test/functional/feature_torcontrol.py"
 ],
 "body": "this is a _tests-only_ PR aimed at adding functional test coverage for\nTor control `HASHEDPASSWORD` authentication.\n\ncurrently, the functional test suite does not explicitly explore this\nauthentication path, which means regressions in tor authentication\nhandling could go unnoticed. for instance incorrectly formatted\n`AUTHENTICATE` commands, broken fallback behavior, or authentication\nattempts being made when no password is configured.\n\nThe 4 tests herein extend the existing mock tor control server to\nsimulate `METHODS=HASHEDPASSWORD` responses and cover successful\nauthentication with the correct password, failing with an incorrect\npassword, behavior when `-torpassword` is not set, and cases where the\nserver does not choose to advertise `HASHEDPASSWORD` as a way of\nauthenticating.\n\ntested with the test harness:\n\n```sh\n./build/test/functional/test_runner.py \\\n  ./build/test/functional/feature_torcontrol.py \\\n  --loglevel=debug --failfast\n```",
 "commits": [
  {
   "sha": "f24ef5b2017f074e63ac37c5d3c4bf191df25568",
   "date": "2026-08-04T00:49:18Z",
   "message": "test: Add HASHEDPASSWORD authentication tests for Tor control\n\nAdd functional test coverage for the HASHEDPASSWORD authentication\nmethod\n\nThe Tor control spec (section 3.5) defines HASHEDPASSWORD as one of 3\nauthentication methods. When a Tor controller advertises HASHEDPASSWORD\nsupport via PROTOCOLINFO, clients must send their password as a quoted\nstring in the AUTHENTICATE command. These tests verify Bitcoin Core's\ntorcontrol module correctly implements this protocol flow.\n\nTest scenarios:\n- Correct password: Verify AUTHENTICATE sends password as quoted string\n  per spec requirement (\"AUTHENTICATE \\\"password\\\"\" format)\n- Wrong password: Verify authentication fails with spec-compliant 515\n  error and connection stops after failure\n- Missing password: Verify no AUTHENTICATE is sent when -torpassword is\n  unset, preventing authentication attempts without credentials\n- Unsupported method: Verify -torpassword is ignored when Tor does not\n  advertise HASHEDPASSWORD support, avoiding unnecessary auth attempts"
  }
 ],
 "timeline": [
  {
   "t": "2026-05-14T18:42:54Z",
   "kind": "comment",
   "who": "sedited",
   "assoc": "MEMBER",
   "text": "@winterrdog can you re-write the description in your own words without following this LLM-formulaic format? This would give reviewers more confidence that you understand the change."
  },
  {
   "t": "2026-05-14T18:59:41Z",
   "kind": "comment",
   "who": "winterrdog",
   "assoc": "CONTRIBUTOR",
   "text": "[quoted text omitted]\n\nthanks! done edition (_seems like i followed the wrong examples online_)."
  },
  {
   "t": "2026-05-14T19:50:40Z",
   "kind": "force_push",
   "who": "winterrdog",
   "commit": "2ca16e642bab0be1efca470b4089e27fe82711cd"
  },
  {
   "t": "2026-05-14T19:56:48Z",
   "kind": "force_push",
   "who": "winterrdog",
   "commit": "8b2af280148b4f25487e85add5986baa8d3aeb9e"
  },
  {
   "t": "2026-05-14T20:34:59Z",
   "kind": "force_push",
   "who": "winterrdog",
   "commit": "f886aa2434c7207bd56c7755fcb6005de8864833"
  },
  {
   "t": "2026-05-14T23:23:40Z",
   "kind": "review_comment",
   "who": "davidgumberg",
   "assoc": "MEMBER",
   "path": "test/functional/feature_torcontrol.py",
   "commit": "f886aa2434c7207bd56c7755fcb6005de8864833",
   "in_reply_to": null,
   "text": "What is this testing separately from the correct password test?"
  },
  {
   "t": "2026-05-15T20:28:47Z",
   "kind": "review_comment",
   "who": "winterrdog",
   "assoc": "CONTRIBUTOR",
   "path": "test/functional/feature_torcontrol.py",
   "commit": "f886aa2434c7207bd56c7755fcb6005de8864833",
   "in_reply_to": 3244866659,
   "text": "this log check was an extra step i added to fully confirm that the error was actually noticed and [reported](https://github.com/bitcoin/bitcoin/blob/ddb94fd3e1061c465e425629d6c7d4b292301da5/src/torcontrol.cpp#L578) instead of being silently swallowed. it was not needed in the correct password test since there we already verify that Bitcoin Core continues past authentication by checking that more than 2 commands (`AUTHENTICATE` and `PROTOCOLINFO` - the initial commands) are sent.\n\nhere comes the long story. let's assume the correct password is the happy path and the wrong password is not.\n\nso in the happy path (correct password), this is what happens in Bitcoin Core:\n```md\ncorrect password sent\n    -> tor daemon returns `250 OK`\n        -> `TorController::auth_cb` hits the `if` branch & continues on to `GETINFO` and `ADD_ONION`\n            -> connection stays active\n```\n\nnow for the sad path (wrong password):\n```md\nincorrect password sent\n    -> tor daemon returns `515 Bad authentication`\n        -> `TorController::auth_cb` hits the `else` branch\n            -> `\"tor: Authentication failed\"` is logged\n                -> no further commands are sent\n                    -> connection effectively stops\n```\n\nthe key difference here is that _the wrong password test verifies Bitcoin Core logs and stops trying to do anything else_ when authentication fails, which is not the case with a correct password as you saw above.\n\ndid you have something different in mind ?"
  },
  {
   "t": "2026-06-04T19:49:59Z",
   "kind": "force_push",
   "who": "winterrdog",
   "commit": "a09fd43cc774b90057ce28ff71952313c7a0b1cf"
  },
  {
   "t": "2026-06-09T23:15:28Z",
   "kind": "force_push",
   "who": "winterrdog",
   "commit": "a47adf8616e16b0e7a840471622c67f0ae2413b6"
  },
  {
   "t": "2026-08-03T23:55:38Z",
   "kind": "force_push",
   "who": "winterrdog",
   "commit": "99e6ee3ace3f1bf081c0fc2bb2ee5329b6907927"
  },
  {
   "t": "2026-08-04T00:49:57Z",
   "kind": "force_push",
   "who": "winterrdog",
   "commit": "f24ef5b2017f074e63ac37c5d3c4bf191df25568"
  }
 ],
 "labels_log": [
  {
   "t": "2026-05-14T18:28:14Z",
   "action": "labeled",
   "label": "Tests",
   "who": "DrahtBot"
  },
  {
   "t": "2026-05-14T19:44:05Z",
   "action": "labeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-05-14T21:36:48Z",
   "action": "unlabeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-08-04T00:50:23Z",
   "action": "labeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-08-04T01:49:00Z",
   "action": "unlabeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-09-16T11:27:16Z",
   "action": "labeled",
   "label": "Needs rebase",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 3869,
 "text_tokens_estimate": 967,
 "changed_paths": [
  "test/functional/feature_torcontrol.py"
 ],
 "files": [
  {
   "path": "test/functional/feature_torcontrol.py",
   "add": 69,
   "del": 0
  }
 ],
 "test_lines": 69,
 "git": {
  "head": "f24ef5b2017f074e63ac37c5d3c4bf191df25568",
  "head_matches_backup": true,
  "base": "4b91316643fab0cd21b357fc2191ecf29228a617",
  "commits": [
   {
    "sha": "f24ef5b201",
    "subject": "test: Add HASHEDPASSWORD authentication tests for Tor control",
    "files": 1,
    "add": 69,
    "del": 0
   }
  ],
  "patch_truncated": false
 },
 "input_hash": "7b97a0da1d466e7e",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}