### Describe the issue

### Can you reliably reproduce the issue?
#### If so, please list the steps to reproduce below:
1. Follow the steps in https://gist.github.com/gavinandresen/3966071

### Expected behaviour
The first `signrawtransaction` command should be successful and return a partially signed transaction that can be sent to the other cosigners for signing.

### Actual behaviour
Instead `signrawtransaction` fails and does not return a partially signed transaction.

### What version of bitcoin-core are you using?
This was reported for 0.14.0. However we have determined that it affects 0.11.1 and later, and likely 0.11.0. It does not affect 0.10.3.

It appears that the bug is caused by [this `VerifyScript` call](https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L849) which was introduced in 8ac2a4e1788426329b842eea7121b8eac7875c76 which has been a part of all versions since 0.11.0rc1.

See also: https://bitcointalk.org/index.php?topic=1823847.msg18164848#msg18164848
}
    CTransactionRef tx;
    uint256 hashBlock;
    if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string(fTxIndex ? "No such mempool or blockchain transaction"
            : "No such mempool transaction. Use -txindex to enable blockchain transaction queries") +
            ". Use gettransaction for wallet transactions.");
    if (!fVerbose)
        return EncodeHexTx(*tx, RPCSerializationFlags());
    UniValue result(UniValue::VOBJ);
    TxToJSON(*tx, hashBlock, result);
    return result;
}
UniValue gettxoutproof(const JSONRPCRequest& request)
{
    if (request.fHelp || (request.params.size() != 1 && request.params.size() != 2))
        throw std::runtime_error(
            "gettxoutproof [\"txid\",...] ( blockhash )\n"
            "\nReturns a hex-encoded proof that \"txid\" was included in a block.\n"
            "\nNOTE: By default this function only works sometimes. This is when there is an\n"
            "unspent output in the utxo for this transaction. To make it always work,\n"
            "you need to maintain a transaction index, using the -txindex command line option or\n"
            "specify the block in which the transaction is included manually (by blockhash).\n"
            "\nArguments:\n"
            "1. \"txids\"       (string) A json array of txids to filter\n"
            "    [\n"
            "      \"txid\"     (string) A transaction hash\n"
            "      ,...\n"
            "    ]\n"
            "2. \"blockhash\"   (string, optional) If specified, looks for txid in the block with this hash\n"