SignatureHash takes in as input a scriptCode:

uint256 SignatureHash(
    const CScript& scriptCode, 
    const CTransaction& txTo, 
    unsigned int nIn, 
    int nHashType, 
    const CAmount& amount, 
    SigVersion sigversion, 
    const PrecomputedTransactionData* cache)

What is the scriptCode exactly?


In this particular case, the parameter script code refers to a public key script.

Usually, the function SignatureHash is invoked to either sign a transaction or to verify a signature. Thus it refers to a transaction input (this is either the transaction input for which we want to generate the signature that will then be placed in the signature script or the transaction input from which we have extracted the signature that we want to verify). This transaction input refers to an unspent (at the time of creating the transaction) transaction output, and this transaction output contains a script that should match the script in the input. It is this script that is passed as a parameter.

On my blog, I have a detailed post on the process of signing a bitcoin transaction which you might find helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.