For P2SH transactions, an example redemption script:
CScript((my_private_key.pub,OP_CHECKSIG,OP_IF,OP_1,OP_ELSE,OP_1,OP_ENDIF))
Works if the expression is true. Executes the IF statement. That is, the first signature matches. However, if the initial signature does not match the public key, instead of performing another statement, the site will return:
SendRawTransaction RPC Error-26: Non-monitoring-Script-Verify-Flag (must be zero if signature fails (multi-)SIG operation)
but, VerifyScript(txin.scriptSig, (txin_scriptPubKey), tx, 0, (SCRIPT_VERIFY_P2SH,))
Does not throw errors. This is also how you generate a signature.
def create_OP_CHECKSIG_signature(tx, txin_scriptPubKey, seckey):
sighash = SignatureHash(txin_scriptPubKey, tx, 0, SIGHASH_ALL)
signature = seckey.sign(sighash) + bytes((SIGHASH_ALL))
return signature
#usage
sig = create_OP_CHECKSIG_signature(tx, redeemscript, my_private_key)
Any help is appreciated.
Discover more from Earlybirds Invest
Subscribe to get the latest posts sent to your email.