ipc: add external signer interface - #126
Open
Sjors wants to merge 6 commits into
Open
Conversation
The external signer mock previously replayed a PSBT that the test prepared in advance. This makes it difficult to test more complicated scenarios like a misbehaving wallet and (MuSig2) multisig. Instead, give the mock its own descriptor wallet. The test provides a dedicated node for this wallet and keeps it offline, so the mock can't cheat by e.g. inspecting the UTXO set. The mock creates the wallet on first use and signs with walletprocesspsbt. wallet_signer.py now funds all four descriptor types and spends them in a single transaction, exercising every signing code path.
Add an abstract interface for an external signing service (e.g. HWI) mirroring the commands in doc/external-signer.md, and an Init method through which such a service, connected over IPC, can register itself as the node's signer backend. Expected signing failures (user cancel, unknown fingerprint) are reported in-band via a bool return and error output parameter, following the Mining::checkBlock pattern; transport failures use ipc::Exception.
Expose the ExternalSignerService interface over Cap'n Proto and add a registerExternalSigner method to the Init interface, so a signing service connected to -ipcbind can pass the node a signer capability. The signer methods deliberately take no Proxy.Context parameter: the node is always the caller (from RPC worker threads, never the event loop thread), so no thread mapping is needed, and this lets a plain pycapnp client register without implementing the ThreadMap protocol. There is also no destroy method, keeping capability teardown free of remote calls after the peer disconnects.
Sjors
force-pushed
the
2026/09/hwi-ipc
branch
from
September 1, 2026 11:32
3d9f5c5 to
af0a567
Compare
This was referenced Sep 1, 2026
Store the registered signer capability in a process-wide registry that wallet and RPC code can query. A global is used rather than plumbing through NodeContext or ipc::Context because ExternalSignerScriptPubKeyMan::GetExternalSigner() is static and already reads gArgs; revisiting this is a known discussion point if this experiment is upstreamed. The registration handler runs on the IPC event loop thread and only stores the pointer. Last registration wins; a dropped connection is detected lazily when the next call on the stale capability throws ipc::Exception.
Give ExternalSigner an alternative service-backed mode: when a signer service is registered over IPC it takes precedence over the -signer command, which remains as fallback. Only the transport differs: the service branch of SignTransaction hands the returned PSBT to the same decode and processing as the command branch. If a call on the registered capability throws ipc::Exception the registration is cleared and behavior reverts to -signer. The three call sites that error out when -signer is unset now also accept a registered service. Behavior difference from the command protocol: per-device enumerate errors are filtered by the service instead of aborting enumeration, since the typed API carries no error entries.
Add wallet_signer_ipc.py, which wraps the mocks/signer.py command mock in a Cap'n Proto ExternalSignerService served from pycapnp, registers it over the node's -ipcbind socket and mirrors the wallet_signer.py scenarios: wallet creation and deterministic addresses (with no -signer configured), walletdisplayaddress and send/sendall/bumpfee, plus IPC-specific scenarios: disconnect fallback, re-registration, and a service raising a remote exception (which clears the registration).
Sjors
force-pushed
the
2026/09/hwi-ipc
branch
from
September 1, 2026 12:05
af0a567 to
c4c2fa6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow external signer software to connect to the node. Once it registers with
Init.registerExternalSigner, the node will use it.Based on: