0

Since scriptSig is a signed transaction hash with the spender's private key, how is the scriptsig different for each input?

1

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:

How to sign a transaction with multiple inputs?

  • Thanks! In that case, which hash is eventually placed in the transaction "hash" field? – user2298995 Dec 27 '17 at 15:41
  • 1
    for 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). – pebwindkraft Dec 27 '17 at 15:44
  • 1
    Yes, 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. – pebwindkraft Dec 27 '17 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? – user2298995 Dec 27 '17 at 19:48
  • see here the detailed, step-by-step explanation in the answer section: bitcoin.stackexchange.com/questions/3374/… – pebwindkraft Dec 28 '17 at 7:34

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.