wallet: avoid global access in external signer SPKM #35429

Open
w0xlt wants to merge 2 commits from wallet-external-signer-no-globals into master AGit
w0xlt commented 2026-06-01 03:39:06 +00:00 (Migrated from github.com)

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.

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.
DrahtBot commented 2026-06-01 03:39:13 +00:00 (Migrated from github.com)

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

External sites

Reviews

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #35444 (wallet: make descriptor SPKM mutex non-recursive by w0xlt)
  • #33112 (wallet: relax external_signer flag constraints by Sjors)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35429 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35429.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35429#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#35444](https://github.com/bitcoin/bitcoin/pull/35444) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35444.svg"></sub> (wallet: make descriptor SPKM mutex non-recursive by w0xlt) * [#33112](https://github.com/bitcoin/bitcoin/pull/33112) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33112.svg"></sub> (wallet: relax external_signer flag constraints by Sjors) 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-->
DrahtBot commented 2026-09-09 11:44:44 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
sedited commented 2026-09-17 07:42:44 +00:00 (Migrated from github.com)

Ping for rebase @w0xlt

Ping for rebase @w0xlt
sedited commented 2026-10-31 11:13:27 +00:00 (Migrated from github.com)

Are you still working on this?

Are you still working on this?
First-time contributor

🔵 Suggestion · Signer configuration has independent wallet and SPKM copies

Independent wallet and SPKM copies require extra factory parameters and leave address display and signing reading configuration from different owners.

Location: src/wallet/external_signer_scriptpubkeyman.h:21 (head).

🔵 Suggestion · Tests miss reload-path command propagation and chain forwarding

The reload-path command gap is fixed: test_disconnected_signer now asserts "No external signers found". Chain forwarding is still untested. mocks/signer.py ignores --chain, and the new unit test only checks CWallet fields on a non-signer wallet, so a wrong SPKM chain would go unnoticed.

Location: test/functional/mocks/signer.py:74 (head).

Review coverage was incomplete.


Reviewed: d28c185d275b · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:965af1044d9e41839565702e4d9bd0a751eda81f6e8b6402747fa296ef84ebea:7efd3c3ba41667382004cfa7a7db56605da7d8f9b7ab69bc483f27117390ba48 --> <!-- ralph-base:ddea9196493d3b8fd841a36a6c53efd85dac7a05 --> <!-- ralph-head:d28c185d275baf3773b49de380dd28793ccda381 --> <!-- ralph-case:2b24b858a547d147489f443d3fc831685f03ddab1880f8847c8237c756277591 --> **🔵 Suggestion · Signer configuration has independent wallet and SPKM copies** Independent wallet and SPKM copies require extra factory parameters and leave address display and signing reading configuration from different owners. Location: [`src/wallet/external_signer_scriptpubkeyman.h:21`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d28c185d275baf3773b49de380dd28793ccda381/src/wallet/external_signer_scriptpubkeyman.h#L21>) (head). **🔵 Suggestion · Tests miss reload-path command propagation and chain forwarding** The reload-path command gap is fixed: test_disconnected_signer now asserts "No external signers found". Chain forwarding is still untested. mocks/signer.py ignores --chain, and the new unit test only checks CWallet fields on a non-signer wallet, so a wrong SPKM chain would go unnoticed. Location: [`test/functional/mocks/signer.py:74`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d28c185d275baf3773b49de380dd28793ccda381/test/functional/mocks/signer.py#L74>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`d28c185d275b`](<https://git.fish.foo/bitcoin/bitcoin/commit/d28c185d275baf3773b49de380dd28793ccda381>) · [Full review report](<https://review.fish.foo/traces/35429-d28c185d275baf3773b49de380dd28793ccda381-2018-2.html>) · [Previous reports](<https://review.fish.foo/traces/35429/>) [permalink](<https://review.fish.foo/traces/35429-d28c185d275baf3773b49de380dd28793ccda381-2018-2.html>)
w0xlt commented 2026-11-02 21:31:09 +00:00 (Migrated from github.com)

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

@sedited Still on it, thanks for the ping! Rebased, conflicts resolved, and tests strengthened. Ready for review.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35429
No description provided.