0

This question already has an answer here:

I'm confused as to the order regarding which script is run. For examples sake: say I want to spend 1 Bitcoin which was given to me by Alice in a single transaction of value 1 Bitcoin. I understand that the input to me is 1 Bitcoin and the output is 1 Bitcoin, but I am not sure about the which script runs first when i want to 'claim' this transaction

Edit: after reading the other question, I'm not sure if this is a chicken and egg kind of question. its a cycle where one runs after the other...

marked as duplicate by pebwindkraft, Raghav Sood, renlord, MCCCS, Andrew Chow Jul 3 '18 at 8:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • After reading the other question, I'm not sure if this is a chicken and egg kind of question. its kind of like a cycle where one runs after the other? – DCH Jun 21 '18 at 21:34
  • I see. The funding transaction defines the spending condition in the scriptPubKey, and the spending transaction provides the solution in the sigScript. When the tx' script logic is executed, the sigScript goes onto the stack, followed by the scriptPubKey. I recommend Andreas' book "Mastering Bitcoin", chapter 6 (Transactions, page 132ff). It is freely available online... and Ken Shirriff explains it very well (righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html). – pebwindkraft Jun 22 '18 at 7:56
  • Thanks , I have always wanted that book but thought it will be better to cover the basics via the Coursera Princeton course .... however it was the course's lecture on scripts which got me confused as to the order of scripts – DCH Jun 22 '18 at 8:03