Skip to main content

extract_p2sh_redeem_script

Function extract_p2sh_redeem_script 

Source
pub(crate) fn extract_p2sh_redeem_script(
    unlock_script: &Script,
) -> Option<Vec<u8>>
Expand description

Extract the redeem script bytes from a P2SH scriptSig.

Mirrors zcashd’s P2SH redeem-script extraction in CScript::GetSigOpCount(const CScript& scriptSig).

Iterates the scriptSig opcodes and returns the last successfully pushed data value. Returns None if any opcode fails to parse, OR if any opcode is not a push value (zcashd: opcode > OP_16). This matches zcashd’s behavior of returning 0 P2SH sigops for malformed or non-push-only scriptSigs.