Since scriptSig is a signed transaction hash with the spender's private key, how is the scriptsig different for each input?
1 Answer
yes, it is. For each input you create a raw transaction with the pubkey script in the scriptsig "slot". Then this raw tx gets seigned. Each input has a different "source" (previous input tx and previous input "outpoint"), since they are hashed before signing, it creates a different result. A sample how to do this for two inputs is shown here:
-
Thanks! In that case, which hash is eventually placed in the transaction "hash" field? Commented Dec 27, 2017 at 15:41
-
1for each input, the hash of the previous tx, from which you'd want to spend (in the example it is displayed as aaaa and bbbb). Commented Dec 27, 2017 at 15:44
-
1Yes, basically you create the whole tx (with tx hash and outpoint from previous transaction), and put the pubkey script into the location of the script sig, and then sign it, and repeat this for all inputs. Ken Shirrif’s webpage “righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html” gives a good overview for a single input tx. Commented Dec 27, 2017 at 19:03
-
Thanks for all your help. When creating the transaction we have a "hash" parameter. Until now I thought it was the double hashed raw transaction (before signing). Is that the actual case? Commented Dec 27, 2017 at 19:48
-
see here the detailed, step-by-step explanation in the answer section: bitcoin.stackexchange.com/questions/3374/… Commented Dec 28, 2017 at 7:34