The current external signer functional test mock can only echo a prepared PSBT. This gets in the way of testing more complicated scenarios, i.e. misbehaving signers and (MuSig2) multisig.
Commit test: have external signer mock use a wallet revamps the mock signer by handing it its own node and wallet. The (offline) mock wallet has the private keys, while the test uses the watch-only version.
Commit external_signer: merge PSBT response instead of replacing lets the mock signer manipulate the PSBT it returns. It can drop outputs, reduce their value and change the script. Not all manipulations are malicious, e.g. a signer may simply not echo all PSBT fields, which is also covered. All this can be compensated for (thwarted) by merging the external signer PSBT instead of discarding the original.
Commit external_signer: reject unsafe sighash types adds scenarios where devices use an unsafe sighash type.
This PR absorbs the scenarios from #35358, but is better able to test them thanks to the new mock signer implementation.
This PR does not intend to fully harden against a malicious external signer, and can't protect against a malicious HWI (equivalent) process running as the same user.
Based on: