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. Nevertheless, when the primary signature would not match the general public key, as an alternative of executing ELSE’s statements the positioning returns :
sendrawtransaction RPC error -26: non-mandatory-script-verify-flag
(Signature have to be zero for failed CHECK(MULTI)SIG operation)
Nevertheless, VerifyScript(txin.scriptSig, (txin_scriptPubKey), tx, 0, (SCRIPT_VERIFY_P2SH,)) would 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.
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. Nevertheless, when the primary signature would not match the general public key, as an alternative of executing ELSE’s statements the positioning returns :
sendrawtransaction RPC error -26: non-mandatory-script-verify-flag
(Signature have to be zero for failed CHECK(MULTI)SIG operation)
Nevertheless, VerifyScript(txin.scriptSig, (txin_scriptPubKey), tx, 0, (SCRIPT_VERIFY_P2SH,)) would 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.













