Skip to main content
edited tags
Link
Murch
  • 77.9k
  • 35
  • 190
  • 641
Source Link

Why we need to repalce the ScriptSig with the previous ScriptPubKey when calculate the per input signature hash?

I'm reading Programming Bitcoin. And in Chapter7, the author talked about the way how signature hash is calculated by replacing the transaction's ScriptSig with the corresponding previous ScriptPubKey. I understand that we can't calculate the signature of a transaction with the signature inside it. But why not just drop the ScriptSig part instead of replace it with the previous ScriptPubKey? And by the way, the same confusion arise on me with the p2sh , where the ScriptSig is replaced with the corresponding RedeemScript.