[ad_1]
I have been banging my head on a desk for a number of days attempting to grasp the segwit protocol correctly.
One other roadblock has thrown me off-guard and I’m struggling to know the idea of “scriptCode:” used within the signature examples of bip0143 https://github.com/bitcoin/bips/blob/grasp/bip-0143.mediawiki#specification
I perceive {that a} scriptPubKey is principally the locking circumstances placed on an output when spent. And I additionally perceive that scriptSig is to redeem a beforehand locked output (destined for my pubkey/pubkeyhash).
I had come to fairly good grips with what I’ve simply said above, with the scriptSig information gadgets being pushed onto the stack then getting evaluated by the pubKeyHash ect. However now there may be this bizarre “scriptCode” area delcared that appears suspiciously similar to a p2pkh pubKeyScript.
So I got here to the conclusion that it’s simply used the identical in each hashPreImage:
DUP HASH160 <keyhash> EQUALVERIFY CHECKSIG
However then I began occupied with stack analysis order and obtained confused once more. What’s the order of stack analysis? Is it: scriptSig information push > pubKeyScript analysis > scriptCode? What about if there may be witness information invloved? When is that pushed onto the stack? Or am I completely lacking the purpose right here?
One other factor I’m confused about is p2sh-p2wpkh analysis. I don’t perceive why the scriptSig needs to be a push of the redeemScript:
0 <20-byte-key-hash>
re-emphasising my primary query. I’m fighting the idea of scriptCode and script analysis order generally. I want to know if the scriptCode is all the time the identical format if I’m solely planning to signal p2sh-p2wpkh, pk2pkh, pk2pkh
[ad_2]