https://github.com/bitcoin/bitcoin/commit/be066fad7d2a8f95d50667262f255ce67f49b51a added an RPC to decode a hex input script. The returned object is:
{
"asm":"asm", (string) Script public key
"hex":"hex", (string) hex encoded public key
"type":"type", (string) The output type
"reqSigs": n, (numeric) The required signatures
"addresses": [ (json array of string)
"address" (string) bitcoin address
,...
],
"p2sh","address" (string) script address.
}
That "p2sh" return value is the address of a P2SH with the hex input script as the redeem script.
If the input script is already a P2SH script, this doesn't make sense (we can't wrap a P2SH in a P2SH). Only return a P2SH address if the input script is not a P2SH script.