Given an arbitrary signed raw transaction, how can we easily verify if all inputs are correctly signed (assuming all inputs are existent/unspent and the fee is higher than zero)? Bitcoin core's RPC command
testmempoolaccept will check if all inputs are available to be spent in the mempool/blockchain so it's impossible to test transactions that have parents not yet broadcasted.
- Peter Todd's python-bitcoinlib requires each input to be validated manually with some flags indicating the type of ScriptPubKey.
- 1200wd bitcoinlib, has a transaction.verify() method but it seems to only verify the basic transaction types: coinbase, P2PKH, P2SH(P2PKH), P2SH(multisig), ...
- BitcoinJS has a method for this, psbt.validateSignaturesOfAllInputs() but converting a raw transaction to PSBT is not possible/easy.
- Bitcore's transaction.verify() does mostly some basic sanity checks and doesn't verify the signatures.
- BitcoinJ's transaction.verify() does also basic verification and the script execution, as python-bitcoinlib, has also to be done manually with verification flags.