Skip to content

Reintroduce external signer support for Windows#29868

Merged
fanquake merged 3 commits into
bitcoin:masterfrom
hebasto:240414-win-subprocess
May 20, 2025
Merged

Reintroduce external signer support for Windows#29868
fanquake merged 3 commits into
bitcoin:masterfrom
hebasto:240414-win-subprocess

Conversation

@hebasto

@hebasto hebasto commented Apr 14, 2024

Copy link
Copy Markdown
Member

This PR partially reverts:

After this PR, we can proceed to actually remove the unused code from src/util/subprocess.h.

@DrahtBot

DrahtBot commented Apr 14, 2024

Copy link
Copy Markdown
Contributor

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

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/29868.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK Sjors, theStack, laanwj

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #32566 (Use subprocess library for notifications by laanwj)

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.

Comment thread ci/test/00_setup_env_win64.sh Outdated
@fanquake

Copy link
Copy Markdown
Member

There are no conflicts with #29865.

Looks like there are now?

@hebasto

hebasto commented Apr 18, 2024

Copy link
Copy Markdown
Member Author

There are no conflicts with #29865.

Looks like there are now?

Well, there is a conflict in the code, which is being removed in #29865. It won't be a problem for either PR if the other one goes first.

@hebasto

hebasto commented Apr 23, 2024

Copy link
Copy Markdown
Member Author

Rebased.

@hebasto
hebasto force-pushed the 240414-win-subprocess branch from 718e11c to a0f3fc9 Compare April 23, 2024 19:48
@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/24165845040

@hebasto

hebasto commented Apr 24, 2024

Copy link
Copy Markdown
Member Author

Rebased on top of the merged #29910.

Comment thread src/util/subprocess.h Outdated
/*
~Popen()
{
#ifdef __USING_WINDOWS__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#29961 removes this, that's the only conflict I found.

@Sjors

Sjors commented Apr 26, 2024

Copy link
Copy Markdown
Member

Tested the Guix build on Windows 11.

Code changes look reasonable, but Windows stuff is not my expertise...

@hebasto

hebasto commented Apr 28, 2024

Copy link
Copy Markdown
Member Author

Rebased to resolve conflicts with the merged #29774.

@hebasto

hebasto commented Apr 28, 2024

Copy link
Copy Markdown
Member Author

cc @achow101 @theStack

Code changes look reasonable, but Windows stuff is not my expertise...

cc @sipsorcery :)

@theStack

Copy link
Copy Markdown
Contributor

Concept ACK

@hebasto
hebasto force-pushed the 240414-win-subprocess branch from 5541ef0 to ed41f61 Compare April 22, 2025 16:23
@hebasto

hebasto commented Apr 22, 2025

Copy link
Copy Markdown
Member Author

Rebased.

Picked @luke-jr's suggestion.

@hebasto
hebasto marked this pull request as ready for review April 22, 2025 16:28
Comment thread src/test/system_tests.cpp Outdated
@hebasto
hebasto force-pushed the 240414-win-subprocess branch from ed41f61 to 86c7c65 Compare April 22, 2025 22:02
@Sjors

Sjors commented Apr 23, 2025

Copy link
Copy Markdown
Member

Tested 86c7c65 on Windows 11 against HWI 3.1.0 on testnet4.

It crashes immediately after creating a new wallet from a Trezor model T. The debug log shows nothing useful, except that it didn't import descriptors. cc @achow101

2025-04-23T09:50:08Z Using SQLite Version 3.46.1
2025-04-23T09:50:08Z Using wallet C:\Users\sjors\AppData\Roaming\Bitcoin\testnet4\wallets\TrezorT
2025-04-23T09:50:08Z init message: Loading wallet…
2025-04-23T09:50:08Z [TrezorT] Wallet file version = 10500, last client version = 299900
2025-04-23T09:50:08Z [TrezorT] Legacy Wallet Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total.
2025-04-23T09:50:08Z [TrezorT] Descriptors: 0, Descriptor Keys: 0 plaintext, 0 encrypted, 0 total.
2025-04-23T09:50:08Z [TrezorT] Setting minversion to 169900

The output of hwi.exe --fingerprint=.... getdescriptors looks fine. Since HWI constructs the descriptors, it's probably not a device specific error, though I didn't test with other devices.

The wallet ends up blank with no descriptors.

Guix hashes:

9f6a6c496222c312ec6a53e870a8ff53d8374142544e6b77bb2428c42d49cfbc  guix-build-86c7c65e2fe7/output/x86_64-w64-mingw32/SHA256SUMS.part
4ad397b829a5f011b7f72dce2448755123ae11042ebb80e5e292f8078b494420  guix-build-86c7c65e2fe7/output/x86_64-w64-mingw32/bitcoin-86c7c65e2fe7-win64-codesigning.tar.gz
e51655e88f45c9adb851125d8242f63dbddc0bc8164ab1e8e9a5ffaa5aa67100  guix-build-86c7c65e2fe7/output/x86_64-w64-mingw32/bitcoin-86c7c65e2fe7-win64-debug.zip
9d6e6d2794defe412b1608bac2269b62284ac0d093479612821e98328984c5ab  guix-build-86c7c65e2fe7/output/x86_64-w64-mingw32/bitcoin-86c7c65e2fe7-win64-setup-unsigned.exe
c25f8353f4e9bdfeb7e45853881e3e34027847d55ba5003b2f92c85ef47f16be  guix-build-86c7c65e2fe7/output/x86_64-w64-mingw32/bitcoin-86c7c65e2fe7-win64-unsigned.zip

Comment thread src/util/subprocess.h Outdated
Comment thread src/util/subprocess.h
Comment thread src/util/subprocess.h Outdated
Comment thread CMakeLists.txt Outdated
@hebasto

hebasto commented Apr 27, 2025

Copy link
Copy Markdown
Member Author

Rebased on #32358 and drafted until the latter is landed.

@hebasto
hebasto marked this pull request as draft April 27, 2025 16:30
@hebasto
hebasto force-pushed the 240414-win-subprocess branch from 7806529 to 73ab0a4 Compare May 1, 2025 21:31
@hebasto
hebasto requested a review from luke-jr May 1, 2025 21:31
hebasto added a commit that referenced this pull request May 5, 2025
cd95c9d subprocess: check and handle fcntl(F_GETFD) failure (Tomás Andróil)
b7288de subprocess: Proper implementation of wait() on Windows (Haowen Liu)
7423214 subprocess: Do not escape double quotes for command line arguments on Windows (Hennadii Stepanov)
bb9ffea subprocess: Explicitly define move constructor of Streams class (Shunsuke Shimizu)
174bd43 subprocess: Avoid leaking POSIX name aliases beyond `subprocess.h` (Hennadii Stepanov)
7997b76 subprocess: Fix cross-compiling with mingw toolchain (Hennadii Stepanov)
6476304 subprocess: Get Windows return code in wait() (Haowen Liu)
d3f511b subprocess: Fix string_arg when used with rref (Haowen Liu)
2fd3f2f subprocess: Fix memory leaks (Haoran Peng)

Pull request description:

  Most of these changes were developed during work on #29868 and #32342 and have since been upstreamed.

  As they are now merged, this PR backports them to our `src/util/subprocess.h` header.

  Required for #29868.

  A list of the backported PRs:
   - arun11299/cpp-subprocess#106
  - arun11299/cpp-subprocess#110
  - arun11299/cpp-subprocess#109
  - arun11299/cpp-subprocess#99
  - arun11299/cpp-subprocess#112
  - arun11299/cpp-subprocess#107
  - arun11299/cpp-subprocess#113
  - arun11299/cpp-subprocess#116
  - arun11299/cpp-subprocess#117

  The following PRs were skipped for backporting:
  - arun11299/cpp-subprocess#108 because we are not planning to support this feature.
  - arun11299/cpp-subprocess#101 because that change has been already landed in #29849.

ACKs for top commit:
  theStack:
    Light ACK cd95c9d
  laanwj:
    Code review re-ACK cd95c9d

Tree-SHA512: f9b60b932957d2e1cad1d87f2ad8bb68c97136e9735eb78547018a42cc50c4652750367f29462eadb0512c27db1dd8a7d4b17a2f0aeab62b3dbf86db5f51a61c
@hebasto

hebasto commented May 5, 2025

Copy link
Copy Markdown
Member Author

Rebased and undrafted.

@Sjors

Sjors commented May 7, 2025

Copy link
Copy Markdown
Member

ACK 3a18075.

Windows 11 against HWI 3.1.0 on testnet4.

It crashes immediately after creating a new wallet from a Trezor model T.

This still happens, but it seems only on testnet4, e.g. not on mainnet and not on signet (didn't try testnet3). It also happens on macOS 15.4.1, so it's clearly unrelated. Update: it's because bitcoin-core/HWI#771 isn't in the latest HWI release yet (v3.1.0).

On Windows 11 I was able to create a new wallet with the GUI, verify an address and make a transaction.

I did not test handling errors from HWI.

@hebasto

hebasto commented May 7, 2025

Copy link
Copy Markdown
Member Author

@Sjors

ACK 8b73630.

Thank you for your review!

Could you please double-check the commit hash in your comment?

@Sjors

Sjors commented May 7, 2025

Copy link
Copy Markdown
Member

@hebasto fixed, that was from a different PR, but I checked that I used the right commit for my Windows guix build.

e2f572ad6ac20ed0b66c2db7a81997cf9e090c695364d88fda1c183efe2a2cbd  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/SHA256SUMS.part
886647c8c0322b1a450cc97efc1bf6a41b5efc8bf02477bb22a694cea1314a42  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-codesigning.tar.gz
4a82a01d9a12fee247e33973480183bf8a29cde28bb5bce2ab576e81f29b8d9c  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-debug.zip
1cda05c5313630e81bdacd655104850243cb98b123ab23376f7b0570f50bcf2c  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-setup-unsigned.exe
7c58ea2a69bd6e1bc27d56e208693d8873a365c69669396d7167d0c4d2c9275c  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-unsigned.zip

@hebasto

hebasto commented May 7, 2025

Copy link
Copy Markdown
Member Author

Friendly ping @achow101 @theStack @luke-jr @sipsorcery :)

@hebasto

hebasto commented May 7, 2025

Copy link
Copy Markdown
Member Author

Can we set "30.0" milestone here?

@hebasto

hebasto commented May 7, 2025

Copy link
Copy Markdown
Member Author

My Guix build:

aarch64
6b1411a20a83a7c8b791ff9ff738748b92d1a86fc7ac2337257ce418e0b966ca  guix-build-3a18075aedd7/output/dist-archive/bitcoin-3a18075aedd7.tar.gz
e2f572ad6ac20ed0b66c2db7a81997cf9e090c695364d88fda1c183efe2a2cbd  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/SHA256SUMS.part
886647c8c0322b1a450cc97efc1bf6a41b5efc8bf02477bb22a694cea1314a42  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-codesigning.tar.gz
4a82a01d9a12fee247e33973480183bf8a29cde28bb5bce2ab576e81f29b8d9c  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-debug.zip
1cda05c5313630e81bdacd655104850243cb98b123ab23376f7b0570f50bcf2c  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-setup-unsigned.exe
7c58ea2a69bd6e1bc27d56e208693d8873a365c69669396d7167d0c4d2c9275c  guix-build-3a18075aedd7/output/x86_64-w64-mingw32/bitcoin-3a18075aedd7-win64-unsigned.zip

@theStack theStack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light ACK 3a18075

Cross-compiled for Windows from a Linux machine using mingw-w64 and ran the involved unit and functional tests on a Windows 10 machine (needed to adapt the paths ./test/config.ini manually on the target system, like also done in the CI job):

>.\build\bin\test_bitcoin.exe --run_test=system_tests/run_command
Running 1 test case...

*** No errors detected

>python.exe .\build\test\functional\rpc_signer.py
2025-05-09T14:17:19.535000Z TestFramework (INFO): PRNG seed is: 1291717054418451415
2025-05-09T14:17:19.596000Z TestFramework (INFO): Initializing test directory C:\Users\thestack\AppData\Local\Temp\bitcoin_func_test_6_lj29gg
2025-05-09T14:17:21.525000Z TestFramework (INFO): Stopping nodes
2025-05-09T14:17:21.750000Z TestFramework (INFO): Cleaning up C:\Users\thestack\AppData\Local\Temp\bitcoin_func_test_6_lj29gg on exit
2025-05-09T14:17:21.750000Z TestFramework (INFO): Tests successful

>python.exe .\build\test\functional\wallet_signer.py
2025-05-09T14:17:38.230000Z TestFramework (INFO): PRNG seed is: 5844070588042404732
2025-05-09T14:17:38.280000Z TestFramework (INFO): Initializing test directory C:\Users\thestack\AppData\Local\Temp\bitcoin_func_test_w0lar663
2025-05-09T14:17:39.823000Z TestFramework (INFO): Test walletdisplayaddress
2025-05-09T14:17:41.079000Z TestFramework (INFO): Prepare mock PSBT
2025-05-09T14:17:42.235000Z TestFramework (INFO): Test send using hww1
2025-05-09T14:17:42.507000Z TestFramework (INFO): Test sendall using hww1
2025-05-09T14:17:42.771000Z TestFramework (INFO): Prepare fee bumped mock PSBT
2025-05-09T14:17:42.776000Z TestFramework (INFO): Test bumpfee using hww1
2025-05-09T14:17:43.746000Z TestFramework (INFO): Test invalid external signer
2025-05-09T14:17:44.668000Z TestFramework (INFO): Test multiple external signers
2025-05-09T14:17:44.881000Z TestFramework (INFO): Stopping nodes
2025-05-09T14:17:45.038000Z TestFramework (INFO): Cleaning up C:\Users\thestack\AppData\Local\Temp\bitcoin_func_test_w0lar663 on exit
2025-05-09T14:17:45.038000Z TestFramework (INFO): Tests successful

Didn't try any real HWI interaction. I think a release note makes sense here so that Windows users are aware they can externally sign again. A counterpart to

External Signing
----------------
- Support for external signing on Windows has been disabled. It will be re-enabled
once the underlying dependency (Boost Process), has been replaced with a different
library. (#28967)

@laanwj laanwj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review and lightly tested ACK 3a18075

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants