A rebased and modified version of #2121. Changes:
- Support P2SH addresses, so listunspent/signrawtransaction can be used without having all keys for M-of-N multisig.
- Add a fRequireSpendable flag to script’s matching routines, so watch-only addresses can be avoided. This is used in SelectCoins (CreateTransaction would fail to sign them anyway).
- Different storage format in database, which supports P2SH too.