wallet: avoid global access in external signer SPKM #35429

pull w0xlt wants to merge 2 commits into bitcoin:master from w0xlt:wallet-external-signer-no-globals changing 6 files +68 −17
  1. w0xlt commented at 3:39 AM on June 1, 2026: contributor

    This PR removes direct access to process-wide state from ExternalSignerScriptPubKeyMan.

    Instead 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.

    This keeps argument and chain selection at the wallet boundary and makes the SPKM less coupled to global state.

  2. DrahtBot added the label Wallet on Jun 1, 2026
  3. DrahtBot commented at 3:39 AM on June 1, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35444 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35444.svg"></sub> (wallet: make descriptor SPKM mutex non-recursive by w0xlt)
    • #33112 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33112.svg"></sub> (wallet: relax external_signer flag constraints by Sjors)
    • #31260 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/31260.svg"></sub> (scripted-diff: Type-safe settings retrieval 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-->

  4. DrahtBot added the label Needs rebase on Sep 9, 2026
  5. sedited commented at 7:42 AM on September 17, 2026: contributor

    Ping for rebase @w0xlt

  6. sedited commented at 11:13 AM on October 31, 2026: contributor

    Are you still working on this?

  7. wallet: avoid global access in external signer SPKM
    ExternalSignerScriptPubKeyMan::GetExternalSigner() reached into global state
    (gArgs for -signer, Params() for the chain type) from deep inside the signing
    and descriptor-setup paths.
    
    Capture both in LoadWalletArgs -- where the wallet already reads its other
    settings from the injected WalletContext -- store them on CWallet, and pass
    them to ExternalSignerScriptPubKeyMan through its LoadFromStorage() and
    CreateNew() factories. GetExternalSigner() now takes the command and chain as
    parameters.
    
    When -signer is unset the command is empty and the same "restart bitcoind
    with -signer" error is returned. The chain string comes from the same
    ArgsManager that Params() is selected from at startup.
    
    -signer is now read when the wallet is loaded rather than each time a signer
    is used, so a value changed at runtime (e.g. via the GUI options dialog,
    which already requires a restart) only applies to wallets loaded afterwards.
    This matches the other wallet options read in LoadWalletArgs.
    96bf425361
  8. test: cover external signer command and chain
    Add unit tests asserting that:
    - GetExternalSigner() with an empty command returns the "needs -signer"
      error before any external process is launched.
    - LoadWalletArgs captures -signer and the chain from the wallet's
      injected ArgsManager. The chain is set to differ from the global
      Params(), so reading it from globals would fail the test.
    
    In wallet_signer.py, check the debug log when spending from a wallet
    loaded with a disconnected signer. A missing signer and an empty -signer
    command both surface as the same "External signer not found" RPC error,
    so the log message is what shows that the configured command reached
    the loaded wallet's ScriptPubKeyMan.
    d28c185d27
  9. w0xlt force-pushed on Nov 2, 2026
  10. w0xlt commented at 9:31 PM on November 2, 2026: contributor

    @sedited Still on it, thanks for the ping! Rebased, conflicts resolved, and tests strengthened. Ready for review.

  11. DrahtBot removed the label Needs rebase on Nov 2, 2026
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-06 23:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me