MultiversX Tracker is Live!

What Is The Script Signature And PUSHDATA operation? [duplicate]

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 170 Views

I've been banging my head on a desk for a few days trying to understand the segwit protocol properly.

Another roadblock has thrown me off-guard and I am struggling to grasp the concept of "scriptCode:" used in the signature examples of bip0143 https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#specification

I understand that a scriptPubKey is basically the locking conditions put on an output when spent. And I also understand that scriptSig is to redeem a previously locked output (destined for my pubkey/pubkeyhash).

I had come to pretty good grips with what I have just stated above, with the scriptSig data items being pushed onto the stack then getting evaluated by the pubKeyHash ect. But now there is this weird "scriptCode" field delcared that looks suspiciously identical to a p2pkh pubKeyScript.

So I came to the conclusion that it is just used the same in every hashPreImage:

DUP HASH160 <keyhash> EQUALVERIFY CHECKSIG

But then I started thinking about stack evaluation order and got confused again. What is the order of stack evaluation? Is it: scriptSig data push > pubKeyScript evaluation > scriptCode? What about if there is witness data invloved? When is that pushed onto the stack? Or am I totally missing the point here?

Another thing I am confused about is p2sh-p2wpkh evaluation. I do not understand why the scriptSig has to be a push of the redeemScript:

 0 <20-byte-key-hash>

re-emphasising my main question. I am struggling with the concept of scriptCode and script evaluation order in general. I would like to know if the scriptCode is always the same format if I am only planning to sign p2sh-p2wpkh, pk2pkh, pk2pkh


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments