{
 "number": 35429,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/35429",
 "title": "wallet: avoid global access in external signer SPKM",
 "author": "w0xlt",
 "author_association": "CONTRIBUTOR",
 "created_at": "2026-06-01T03:39:06Z",
 "updated_at": "2026-09-17T07:42:47Z",
 "age_days": 108,
 "draft": false,
 "labels": [
  "Wallet",
  "Needs rebase"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "c0dc4d5091f95804bfcd47b78b4b45ad89a45d5b",
 "head_ref": "wallet-external-signer-no-globals",
 "head_repo": "w0xlt/bitcoin",
 "head_history": [],
 "additions": 55,
 "deletions": 27,
 "changed_files": 5,
 "commit_count": 2,
 "size_bucket": "S",
 "mergeable_state": "dirty",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {},
   "conflicts": [
    {
     "number": 35445,
     "title": "wallet, descriptor: Revert `StringType::COMPAT` for Miniscript expressions and drop the concept of a Descriptor ID that can be validated",
     "author": "achow101"
    },
    {
     "number": 33112,
     "title": "wallet: relax external_signer flag constraints",
     "author": "Sjors"
    },
    {
     "number": 29278,
     "title": "Wallet:  Add `maxfeerate` wallet startup option",
     "author": "ismaelsadeeq"
    }
   ]
  }
 },
 "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": [
   "sedited"
  ]
 },
 "signals": {
  "needs_rebase": true,
  "ci_failed": false,
  "mergeable_state": "dirty",
  "last_author_activity": "2026-06-01T03:25:36Z",
  "last_reviewer_activity": "2026-09-17T07:42:44Z",
  "last_reviewer": "sedited",
  "author_silent_days": 108,
  "waiting_on_author_days": 0,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": [
   35445,
   33112,
   29278
  ]
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [],
 "body": "This PR removes direct access to process-wide state from `ExternalSignerScriptPubKeyMan`.\n\nInstead of reading `gArgs`/`Params()` from the `SPKM`, the wallet load/setup path now reads the external signer command and chain once, stores them on `CWallet`, and passes the narrow values into the external signer SPKM.\n\nThis keeps argument and chain selection at the wallet boundary and makes the SPKM less coupled to global state.",
 "commits": [
  {
   "sha": "3fbb2d0a60ffef9ccd9c6c3dac7a9c93edd28f7a",
   "date": "2026-06-01T03:25:26Z",
   "message": "wallet: avoid global access in external signer SPKM\n\nExternalSignerScriptPubKeyMan::GetExternalSigner() reached into global state\n(gArgs for -signer, Params() for the chain type) from deep inside the signing\nand descriptor-setup paths.\n\nCapture both in LoadWalletArgs -- where the wallet already reads its other\nsettings from the injected WalletContext -- store them on CWallet, and inject\nthem into ExternalSignerScriptPubKeyMan at construction. GetExternalSigner()\nnow takes the command and chain as parameters.\n\nNo behavior change: when -signer is unset the command is empty and the same\n\"restart bitcoind with -signer\" error is returned; the chain string is the\nvalue Params().GetChainTypeString() previously provided."
  },
  {
   "sha": "c0dc4d5091f95804bfcd47b78b4b45ad89a45d5b",
   "date": "2026-06-01T03:25:36Z",
   "message": "test: cover GetExternalSigner command handling\n\nAdd a unit test asserting that GetExternalSigner() with an empty command\nreturns the \"needs -signer\" error, before any external process is launched."
  }
 ],
 "timeline": [
  {
   "t": "2026-09-17T07:42:44Z",
   "kind": "comment",
   "who": "sedited",
   "assoc": "MEMBER",
   "text": "Ping for rebase @w0xlt"
  }
 ],
 "labels_log": [
  {
   "t": "2026-06-01T03:39:09Z",
   "action": "labeled",
   "label": "Wallet",
   "who": "DrahtBot"
  },
  {
   "t": "2026-09-09T11:44:42Z",
   "action": "labeled",
   "label": "Needs rebase",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 1419,
 "text_tokens_estimate": 354,
 "changed_paths": [
  "src/wallet/external_signer_scriptpubkeyman.cpp",
  "src/wallet/external_signer_scriptpubkeyman.h",
  "src/wallet/test/scriptpubkeyman_tests.cpp",
  "src/wallet/wallet.cpp",
  "src/wallet/wallet.h"
 ],
 "files": [
  {
   "path": "src/wallet/external_signer_scriptpubkeyman.cpp",
   "add": 8,
   "del": 10
  },
  {
   "path": "src/wallet/external_signer_scriptpubkeyman.h",
   "add": 22,
   "del": 13
  },
  {
   "path": "src/wallet/test/scriptpubkeyman_tests.cpp",
   "add": 11,
   "del": 0
  },
  {
   "path": "src/wallet/wallet.cpp",
   "add": 9,
   "del": 4
  },
  {
   "path": "src/wallet/wallet.h",
   "add": 5,
   "del": 0
  }
 ],
 "test_lines": 11,
 "git": {
  "head": "c0dc4d5091f95804bfcd47b78b4b45ad89a45d5b",
  "head_matches_backup": true,
  "base": "fbe628756cc417dd4b6ccd9d3a709ca8e2f6023c",
  "commits": [
   {
    "sha": "3fbb2d0a60",
    "subject": "wallet: avoid global access in external signer SPKM",
    "files": 4,
    "add": 44,
    "del": 27
   },
   {
    "sha": "c0dc4d5091",
    "subject": "test: cover GetExternalSigner command handling",
    "files": 1,
    "add": 11,
    "del": 0
   }
  ],
  "patch_truncated": false
 },
 "input_hash": "92fa87fa85bf2909",
 "extracted_at": "2026-09-17T16:15:31+00:00"
}