How to validate raw transactions using bitcoind and/or bitcoin-cli (preferably offline)?
You can validate transactions in an offline instance of bitcoind that has absolutely none of the block chain!

Launch it like this:

$ bitcoind -datadir=some-datadir -server -connect=localhost:9999


The "connect" parameter gives it the remote connect to. If you point it at a non-listening port, it will never gather any blocks. This is fine for validating transactions.

It will tell you that you need to create a bitcoin.conf, and where, and what to put into it (rpcuser=bitcoinrpc and rpcpassword=some_long_string).

Then your bitcoind RPC url will be

http://bitcoinrpc:password@localhost:8332/


You use the JSON API signrawtransaction documented in section 7.2 of https://en.bitcoin.it/wiki/Raw_Transactions. You will need to pass in the inputs, since they will not be known to the bitcoin daemon.

I'm the author of the Python library pycoin https://github.com/richardkiss/pycoin/ and I use bitcoind to verify that transactions created by pycoin are valid (or in some cases, invalid). See bitcoind_agrees_on_transaction_validity in https://github.com/richardkiss/pycoin/blob/offline_tx/pycoin/services/bitcoind.py for an example usage.

(You could also use pycoin to validate transactions. It works, but it's not quite there yet documentation-wise. It also hasn't been extensively tested on non-standard transactions, so its VM implementation is hardly authoritative.)