For the P2SH transaction, an instance of the redeem script:
CScript([my_private_key.pub,OP_CHECKSIG,OP_IF,OP_1,OP_ELSE,OP_1,OP_ENDIF])
It really works when the expression is true resulting in execute IF’s statements, that means the primary signature is matched. Nonetheless, when the primary signature does not match the general public key, as an alternative of executing ELSE’s statements the location returns :
sendrawtransaction RPC error -26: non-mandatory-script-verify-flag
(Signature should be zero for failed CHECK(MULTI)SIG operation)
Nonetheless, VerifyScript(txin.scriptSig, (txin_scriptPubKey), tx, 0, (SCRIPT_VERIFY_P2SH,))
does not throw an error.
Additionally, that is how signature is generated:
def create_OP_CHECKSIG_signature(tx, txin_scriptPubKey, seckey):
sighash = SignatureHash(txin_scriptPubKey, tx, 0, SIGHASH_ALL)
signature = seckey.signal(sighash) + bytes([SIGHASH_ALL])
return signature
#utilization
sig = create_OP_CHECKSIG_signature(tx, redeemscript, my_private_key)
Any assistance is appreciated.