SignPSBTInput() checked existing signatures against an assumed sighash type when neither PSBT_IN_SIGHASH_TYPE nor the sighashtype parameter was given: SIGHASH_DEFAULT for taproot, SIGHASH_ALL otherwise. A PSBT holding a valid 65-byte SIGHASH_ALL taproot signature could then be neither finalized nor signed further.
BIP 174 lets a signer use any sighash type when the field is absent, so the check now runs only when the field or the parameter is given, for every input type. Without the field, RemoveUnnecessaryTransactions() now also looks at the taproot signatures for SIGHASH_ANYONECANPAY, so that the non_witness_utxo is kept. A functional test in rpc_psbt.py covers a taproot input signed with ALL, NONE and ALL|ANYONECANPAY without the field. A second commit also keeps the non_witness_utxo of a finalized taproot input, whose signatures are left only in the final witness, and tests it on a key path and a script path.
Fixes #36507.