Closes #27583.
PSBT_GLOBAL_XPUB already serializes, deserializes and merges when PSBTs are combined. Nothing writes it, so a PSBT produced by the wallet never carries it, and a signer that only has the file cannot rebuild the multisig from it. Today Specter fills the field itself after getting the PSBT from Core.
<details><summary>Before and after with the BitBox02 and Trezor simulators</summary>
A 2-of-3 wsh(sortedmulti(...)) on regtest with the simulator as one co-signer, signed through HWI 3.2.0. The "before" file is the same PSBT with its PSBT_GLOBAL_XPUB records removed, so nothing else differs.
| without the field | with the field | |
|---|---|---|
| BitBox02 | refuses, This BitBox02 is not one of the cosigners |
signs |
| Trezor T | signs, co-signer nodes sent with zeroed chain codes and no derivation paths | signs, nodes sent with the real chain codes and paths |
What parse_multisig hands the Trezor for the change output:
without: global xpubs=0 zeroed chain codes=3/3 depths=[0, 0, 0] paths=[[], [], []]
with : global xpubs=3 zeroed chain codes=0/3 depths=[4, 4, 4] paths=[[1, 0], [1, 0], [1, 0]]
</details>
A new Descriptor accessor returns the extended keys a descriptor is built from, and DescriptorScriptPubKeyMan::FillPSBT writes those of every descriptor with an input or an output in the PSBT. That covers walletcreatefundedpsbt, walletprocesspsbt, send, sendall, psbtbumpfee and the GUI send dialog, which all go through CWallet::FillPSBT.
Only the keys BIP 174 allows are added, the ones that derive, through unhardened steps alone, a key their descriptor produced, listed in the PSBT at the origin the descriptor gave it. So a key expression ending in /*h adds nothing.
Whoever holds a PSBT from the wallet can now derive the addresses of the descriptors it uses. Setting bip32derivs to false in walletcreatefundedpsbt or walletprocesspsbt leaves the field out, along with the derivation paths.
descriptorprocesspsbt is left out, since it signs from the descriptors it is given without going through the wallet, and I intend to cover it as a follow-up.