The current createrawtransaction + fundrawtransaction + signrawtransaction workflow is complicated by the fact that there is some information that needs to be passed out of band:
- Signing requires access to the outputs being spent to know the scriptPubKey (and amount in BIP143).
- For P2SH inputs, the signer must know the redeemscript
- For P2WSH inputs, the signer must know the witness program
These are currently handled transparently by the fact that signrawtransaction has access to the wallet transactions, scripts, and node UTXO set. However, third party signers do not necessarily have access to this information.
Given that it is known in advance what signers will need when the unsigned transaction is constructed, I wonder if the easiest approach isn't creating a more generic partial transaction format that can store multiple extra records for each input (which don't go into the final transaction):
- For non-witness transactions, the full previous transaction being spent from (so the fee can be computed trustlessly) should be included.
- For witness transactions, the UTXO being spent.
- The redeemscript and witness scripts for P2SH/P2WSH respectively.
- Partial signatures for OP_CHECKMULTISIG (instead of hacking those inside the scriptSig before it's complete)
This would also simplify extending to more complicated script types in the future.