wallet: Support quoted external signer arguments #37046

Open
hamdyaea wants to merge 1 commit from fix-signer-path-spaces into master AGit
hamdyaea commented 2026-12-02 13:57:14 +00:00 (Migrated from github.com)

The external signer command currently uses subprocess::util::split(), which does not correctly handle quoted arguments or executable paths containing spaces.

As mentioned in #34349, fixing the external signer command parsing was left as a follow-up.

This change introduces support for double-quoted arguments, preserves the existing behavior for repeated whitespace, handles escaped quotes and backslashes within quoted arguments, and rejects unterminated quotes.

The external signer documentation and functional tests have been updated accordingly.

Testing performed on Linux x86_64:

  • rpc_signer.py: PASS
  • wallet_signer.py: PASS
  • Repository paths containing spaces: PASS
  • Temporary paths containing spaces and Unicode characters: PASS
  • Unterminated quote rejection: PASS
  • Standalone parser test vectors: PASS
  • git diff --check: PASS

Native Windows testing has not been performed.

The external signer command currently uses subprocess::util::split(), which does not correctly handle quoted arguments or executable paths containing spaces. As mentioned in #34349, fixing the external signer command parsing was left as a follow-up. This change introduces support for double-quoted arguments, preserves the existing behavior for repeated whitespace, handles escaped quotes and backslashes within quoted arguments, and rejects unterminated quotes. The external signer documentation and functional tests have been updated accordingly. Testing performed on Linux x86_64: - rpc_signer.py: PASS - wallet_signer.py: PASS - Repository paths containing spaces: PASS - Temporary paths containing spaces and Unicode characters: PASS - Unterminated quote rejection: PASS - Standalone parser test vectors: PASS - git diff --check: PASS Native Windows testing has not been performed.
DrahtBot commented 2026-12-02 13:57:25 +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:

  • #36114 (wallet: harden external signer psbt processing, revamp mock by Sjors)
  • #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/37046 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/37046.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/37046#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: * [#36114](https://github.com/bitcoin/bitcoin/pull/36114) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36114.svg"></sub> (wallet: harden external signer psbt processing, revamp mock by Sjors) * [#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-->
First-time contributor

🟠 Minor · Decoded literal quotes corrupt Windows signer arguments

On native Windows, an escaped quote in a whitespace-free signer argument corrupts CRT-style child arguments; no current configuration using this input was found, and native execution was not tested.

Location: src/external_signer.cpp:28 (head).

🟠 Minor · Quoted Windows paths need undocumented backslash escaping

Source inspection shows that quoted UNC paths lose a leading backslash and quoted trailing backslashes can cause an unterminated-quote error; native Windows execution was not tested, and signer use on UNC shares is unconfirmed.

Location: src/external_signer.cpp:29 (head).

🔵 Suggestion · The -signer guidance omits the shell-escaping layer

Normal POSIX shell quoting removes the double quotes that SplitSignerCommand needs, so users need an example that preserves quotes within the -signer value.

Location: doc/external-signer.md:4 (head).

🔵 Suggestion · Parser edge cases lack exact argument-vector assertions

The functional tests do not assert exact argument vectors for escapes, empty arguments, mixed quoted tokens, or repeated, leading and trailing separators.

Location: test/functional/rpc_signer.py:73 (head).


Reviewed: 331c29b7fd27 · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:e1a29e5e677c47d383756f0fcf8f3760725c91d1104dd3ccb2f333b6217eba26:47880f5569fd2047d249266f337c4f2a509adf7d96c3ccb1c7644c2c2a650bff --> <!-- ralph-base:43236b86c28490be178991645bdc7d7c5cacd90a --> <!-- ralph-head:331c29b7fd2749d825225604a92c9f496daf680d --> <!-- ralph-case:6fd6c755aee7f42e681bc19bee41118ff4818a8bbcdb8393eee6f0d874891a0c --> **🟠 Minor · Decoded literal quotes corrupt Windows signer arguments** On native Windows, an escaped quote in a whitespace-free signer argument corrupts CRT-style child arguments; no current configuration using this input was found, and native execution was not tested. Location: [`src/external_signer.cpp:28`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/331c29b7fd2749d825225604a92c9f496daf680d/src/external_signer.cpp#L28>) (head). **🟠 Minor · Quoted Windows paths need undocumented backslash escaping** Source inspection shows that quoted UNC paths lose a leading backslash and quoted trailing backslashes can cause an unterminated-quote error; native Windows execution was not tested, and signer use on UNC shares is unconfirmed. Location: [`src/external_signer.cpp:29`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/331c29b7fd2749d825225604a92c9f496daf680d/src/external_signer.cpp#L29>) (head). **🔵 Suggestion · The `-signer` guidance omits the shell-escaping layer** Normal POSIX shell quoting removes the double quotes that `SplitSignerCommand` needs, so users need an example that preserves quotes within the `-signer` value. Location: [`doc/external-signer.md:4`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/331c29b7fd2749d825225604a92c9f496daf680d/doc/external-signer.md#L4>) (head). **🔵 Suggestion · Parser edge cases lack exact argument-vector assertions** The functional tests do not assert exact argument vectors for escapes, empty arguments, mixed quoted tokens, or repeated, leading and trailing separators. Location: [`test/functional/rpc_signer.py:73`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/331c29b7fd2749d825225604a92c9f496daf680d/test/functional/rpc_signer.py#L73>) (head). <!-- Review tier: sensitive --> --- Reviewed: [`331c29b7fd27`](<https://git.fish.foo/bitcoin/bitcoin/commit/331c29b7fd2749d825225604a92c9f496daf680d>) · [Review report](<https://review.fish.foo/report/37046-331c29b7fd2749d825225604a92c9f496daf680d-3436-1.html>) · [Previous reports](<https://review.fish.foo/traces/37046/>) [permalink](<https://review.fish.foo/report/37046-331c29b7fd2749d825225604a92c9f496daf680d-3436-1.html>)
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!37046
No description provided.