What does the Sender of a Transaction include in the Input that allows the Recipient to Unlock/Redeem?












1















I have been struggling to grasp what exactly is included in the input of a Transaction that allows the intended recipient to then redeem/unlock that UTXO when they are ready to do so.



I understand that a transaction contains a Digital Signature created by the Senders Private Key on the message.



I become confused when trying to understand what data the sender includes in the Transaction that allows the recipient to unlock that UTXO and turn it into a subsequent input when they choose to do so. Is the Sender including the Recipients Public Key in the Transaction allowing them to use a scriptSig to unlock that UTXO?



Thanks for taking the time out help










share|improve this question



























    1















    I have been struggling to grasp what exactly is included in the input of a Transaction that allows the intended recipient to then redeem/unlock that UTXO when they are ready to do so.



    I understand that a transaction contains a Digital Signature created by the Senders Private Key on the message.



    I become confused when trying to understand what data the sender includes in the Transaction that allows the recipient to unlock that UTXO and turn it into a subsequent input when they choose to do so. Is the Sender including the Recipients Public Key in the Transaction allowing them to use a scriptSig to unlock that UTXO?



    Thanks for taking the time out help










    share|improve this question

























      1












      1








      1








      I have been struggling to grasp what exactly is included in the input of a Transaction that allows the intended recipient to then redeem/unlock that UTXO when they are ready to do so.



      I understand that a transaction contains a Digital Signature created by the Senders Private Key on the message.



      I become confused when trying to understand what data the sender includes in the Transaction that allows the recipient to unlock that UTXO and turn it into a subsequent input when they choose to do so. Is the Sender including the Recipients Public Key in the Transaction allowing them to use a scriptSig to unlock that UTXO?



      Thanks for taking the time out help










      share|improve this question














      I have been struggling to grasp what exactly is included in the input of a Transaction that allows the intended recipient to then redeem/unlock that UTXO when they are ready to do so.



      I understand that a transaction contains a Digital Signature created by the Senders Private Key on the message.



      I become confused when trying to understand what data the sender includes in the Transaction that allows the recipient to unlock that UTXO and turn it into a subsequent input when they choose to do so. Is the Sender including the Recipients Public Key in the Transaction allowing them to use a scriptSig to unlock that UTXO?



      Thanks for taking the time out help







      transactions






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 5 hours ago









      Nathaniel RichardsonNathaniel Richardson

      161




      161






















          1 Answer
          1






          active

          oldest

          votes


















          3














          The transaction output has a property called the scriptPubkey that is executed with the scriptSig when the output is spent in a transaction. An understanding of Bitcoin script would help.



          Bitcoin Script



          Bitcoin uses it's own stack-based scripting language with a set of op-codes. This scripting language is used to determine whether an unspent transaction output (utxo) can be spent. When you send Bitcoin, you are really just assigning a Bitcoin value to a script, which can be spent only if the script executes successfully and results in a single true value on the stack. The script that is assigned to the Bitcoin transaction output is called the scriptPubKey. To satisfy the script, you must provide the correct scriptSig, which is also a script, which is prepended to the scriptSig and executed to test if the spending succeeded. Let's look at an example:



          scriptPubKey (raw): 76a914306e2ea1eed91bf66dfe5d94f3957d4ba63bde8488ac
          scriptPubKey (assembly): OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG



          In plain english, this script, when executed will do the following:





          • OP_DUP: Duplicate the top item on the stack (place a copy of it on the stack)


          • OP_HASH160: Pop the top item off the stack, calculate it's HASH160, i.e. the RIPEMD160(SHA256()), and place that on the stack


          • OP_EQUALVERIFY: Pop the top 2 items off the stack, and if they are not equal, it will exit immediately and fail, otherwise nothing


          • OP_CHECKSIG: Pop the top 2 items off the stack, and use the top as the public key, the second as the signature, and verify the transaction signature


          In order to spend this output, we must provide a valid signature and public key. We'll just provide 00 for the signature for this example, and not worry about the final checksig op.



          Example



          Let's visualize this example with a scriptSig. Let's use kallewoof's btcdeb Script visualization tool. After the first command, you can type step once, and then just press enter each time after that to step through each operation:



          $ btcdeb '[00 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG]'

          btcdeb -- type `btcdeb -h` for start up options
          valid script
          7 op script loaded. type `help` for usage information
          script | stack
          -------------------------------------------------------------------+--------
          0 |
          030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 |
          OP_DUP |
          OP_HASH160 |
          306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
          OP_EQUALVERIFY |
          OP_CHECKSIG |
          #0000 0
          btcdeb> step
          <> PUSH stack
          script | stack
          -------------------------------------------------------------------+--------
          030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 | 0x
          OP_DUP |
          OP_HASH160 |
          306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
          OP_EQUALVERIFY |
          OP_CHECKSIG |
          #0001 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          btcdeb>
          <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          script | stack
          -------------------------------------------------------------------+-------------------------------------------------------------------
          OP_DUP | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          OP_HASH160 | 0x
          306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
          OP_EQUALVERIFY |
          OP_CHECKSIG |
          #0002 OP_DUP
          btcdeb>
          <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          script | stack
          -------------------------------------------------------------------+-------------------------------------------------------------------
          OP_HASH160 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          OP_EQUALVERIFY | 0x
          OP_CHECKSIG |
          #0003 OP_HASH160
          btcdeb>
          <> POP stack
          <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
          script | stack
          -------------------------------------------------------------------+-------------------------------------------------------------------
          306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
          OP_EQUALVERIFY | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          OP_CHECKSIG | 0x
          #0004 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
          btcdeb>
          <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
          script | stack
          -------------------------------------------------------------------+-------------------------------------------------------------------
          OP_EQUALVERIFY | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
          OP_CHECKSIG | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
          | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          | 0x
          #0005 OP_EQUALVERIFY
          btcdeb>
          <> POP stack
          <> POP stack
          <> PUSH stack 01
          <> POP stack
          script | stack
          -------------------------------------------------------------------+-------------------------------------------------------------------
          OP_CHECKSIG | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
          | 0x
          #0006 OP_CHECKSIG


          You can play around with this using any of the opcodes listed at Script.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "308"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbitcoin.stackexchange.com%2fquestions%2f83980%2fwhat-does-the-sender-of-a-transaction-include-in-the-input-that-allows-the-recip%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            The transaction output has a property called the scriptPubkey that is executed with the scriptSig when the output is spent in a transaction. An understanding of Bitcoin script would help.



            Bitcoin Script



            Bitcoin uses it's own stack-based scripting language with a set of op-codes. This scripting language is used to determine whether an unspent transaction output (utxo) can be spent. When you send Bitcoin, you are really just assigning a Bitcoin value to a script, which can be spent only if the script executes successfully and results in a single true value on the stack. The script that is assigned to the Bitcoin transaction output is called the scriptPubKey. To satisfy the script, you must provide the correct scriptSig, which is also a script, which is prepended to the scriptSig and executed to test if the spending succeeded. Let's look at an example:



            scriptPubKey (raw): 76a914306e2ea1eed91bf66dfe5d94f3957d4ba63bde8488ac
            scriptPubKey (assembly): OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG



            In plain english, this script, when executed will do the following:





            • OP_DUP: Duplicate the top item on the stack (place a copy of it on the stack)


            • OP_HASH160: Pop the top item off the stack, calculate it's HASH160, i.e. the RIPEMD160(SHA256()), and place that on the stack


            • OP_EQUALVERIFY: Pop the top 2 items off the stack, and if they are not equal, it will exit immediately and fail, otherwise nothing


            • OP_CHECKSIG: Pop the top 2 items off the stack, and use the top as the public key, the second as the signature, and verify the transaction signature


            In order to spend this output, we must provide a valid signature and public key. We'll just provide 00 for the signature for this example, and not worry about the final checksig op.



            Example



            Let's visualize this example with a scriptSig. Let's use kallewoof's btcdeb Script visualization tool. After the first command, you can type step once, and then just press enter each time after that to step through each operation:



            $ btcdeb '[00 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG]'

            btcdeb -- type `btcdeb -h` for start up options
            valid script
            7 op script loaded. type `help` for usage information
            script | stack
            -------------------------------------------------------------------+--------
            0 |
            030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 |
            OP_DUP |
            OP_HASH160 |
            306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
            OP_EQUALVERIFY |
            OP_CHECKSIG |
            #0000 0
            btcdeb> step
            <> PUSH stack
            script | stack
            -------------------------------------------------------------------+--------
            030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 | 0x
            OP_DUP |
            OP_HASH160 |
            306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
            OP_EQUALVERIFY |
            OP_CHECKSIG |
            #0001 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            btcdeb>
            <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            script | stack
            -------------------------------------------------------------------+-------------------------------------------------------------------
            OP_DUP | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            OP_HASH160 | 0x
            306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
            OP_EQUALVERIFY |
            OP_CHECKSIG |
            #0002 OP_DUP
            btcdeb>
            <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            script | stack
            -------------------------------------------------------------------+-------------------------------------------------------------------
            OP_HASH160 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            OP_EQUALVERIFY | 0x
            OP_CHECKSIG |
            #0003 OP_HASH160
            btcdeb>
            <> POP stack
            <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
            script | stack
            -------------------------------------------------------------------+-------------------------------------------------------------------
            306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
            OP_EQUALVERIFY | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            OP_CHECKSIG | 0x
            #0004 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
            btcdeb>
            <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
            script | stack
            -------------------------------------------------------------------+-------------------------------------------------------------------
            OP_EQUALVERIFY | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
            OP_CHECKSIG | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
            | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            | 0x
            #0005 OP_EQUALVERIFY
            btcdeb>
            <> POP stack
            <> POP stack
            <> PUSH stack 01
            <> POP stack
            script | stack
            -------------------------------------------------------------------+-------------------------------------------------------------------
            OP_CHECKSIG | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
            | 0x
            #0006 OP_CHECKSIG


            You can play around with this using any of the opcodes listed at Script.






            share|improve this answer




























              3














              The transaction output has a property called the scriptPubkey that is executed with the scriptSig when the output is spent in a transaction. An understanding of Bitcoin script would help.



              Bitcoin Script



              Bitcoin uses it's own stack-based scripting language with a set of op-codes. This scripting language is used to determine whether an unspent transaction output (utxo) can be spent. When you send Bitcoin, you are really just assigning a Bitcoin value to a script, which can be spent only if the script executes successfully and results in a single true value on the stack. The script that is assigned to the Bitcoin transaction output is called the scriptPubKey. To satisfy the script, you must provide the correct scriptSig, which is also a script, which is prepended to the scriptSig and executed to test if the spending succeeded. Let's look at an example:



              scriptPubKey (raw): 76a914306e2ea1eed91bf66dfe5d94f3957d4ba63bde8488ac
              scriptPubKey (assembly): OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG



              In plain english, this script, when executed will do the following:





              • OP_DUP: Duplicate the top item on the stack (place a copy of it on the stack)


              • OP_HASH160: Pop the top item off the stack, calculate it's HASH160, i.e. the RIPEMD160(SHA256()), and place that on the stack


              • OP_EQUALVERIFY: Pop the top 2 items off the stack, and if they are not equal, it will exit immediately and fail, otherwise nothing


              • OP_CHECKSIG: Pop the top 2 items off the stack, and use the top as the public key, the second as the signature, and verify the transaction signature


              In order to spend this output, we must provide a valid signature and public key. We'll just provide 00 for the signature for this example, and not worry about the final checksig op.



              Example



              Let's visualize this example with a scriptSig. Let's use kallewoof's btcdeb Script visualization tool. After the first command, you can type step once, and then just press enter each time after that to step through each operation:



              $ btcdeb '[00 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG]'

              btcdeb -- type `btcdeb -h` for start up options
              valid script
              7 op script loaded. type `help` for usage information
              script | stack
              -------------------------------------------------------------------+--------
              0 |
              030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 |
              OP_DUP |
              OP_HASH160 |
              306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
              OP_EQUALVERIFY |
              OP_CHECKSIG |
              #0000 0
              btcdeb> step
              <> PUSH stack
              script | stack
              -------------------------------------------------------------------+--------
              030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 | 0x
              OP_DUP |
              OP_HASH160 |
              306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
              OP_EQUALVERIFY |
              OP_CHECKSIG |
              #0001 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              btcdeb>
              <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              script | stack
              -------------------------------------------------------------------+-------------------------------------------------------------------
              OP_DUP | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              OP_HASH160 | 0x
              306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
              OP_EQUALVERIFY |
              OP_CHECKSIG |
              #0002 OP_DUP
              btcdeb>
              <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              script | stack
              -------------------------------------------------------------------+-------------------------------------------------------------------
              OP_HASH160 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              OP_EQUALVERIFY | 0x
              OP_CHECKSIG |
              #0003 OP_HASH160
              btcdeb>
              <> POP stack
              <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
              script | stack
              -------------------------------------------------------------------+-------------------------------------------------------------------
              306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
              OP_EQUALVERIFY | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              OP_CHECKSIG | 0x
              #0004 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
              btcdeb>
              <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
              script | stack
              -------------------------------------------------------------------+-------------------------------------------------------------------
              OP_EQUALVERIFY | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
              OP_CHECKSIG | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
              | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              | 0x
              #0005 OP_EQUALVERIFY
              btcdeb>
              <> POP stack
              <> POP stack
              <> PUSH stack 01
              <> POP stack
              script | stack
              -------------------------------------------------------------------+-------------------------------------------------------------------
              OP_CHECKSIG | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
              | 0x
              #0006 OP_CHECKSIG


              You can play around with this using any of the opcodes listed at Script.






              share|improve this answer


























                3












                3








                3







                The transaction output has a property called the scriptPubkey that is executed with the scriptSig when the output is spent in a transaction. An understanding of Bitcoin script would help.



                Bitcoin Script



                Bitcoin uses it's own stack-based scripting language with a set of op-codes. This scripting language is used to determine whether an unspent transaction output (utxo) can be spent. When you send Bitcoin, you are really just assigning a Bitcoin value to a script, which can be spent only if the script executes successfully and results in a single true value on the stack. The script that is assigned to the Bitcoin transaction output is called the scriptPubKey. To satisfy the script, you must provide the correct scriptSig, which is also a script, which is prepended to the scriptSig and executed to test if the spending succeeded. Let's look at an example:



                scriptPubKey (raw): 76a914306e2ea1eed91bf66dfe5d94f3957d4ba63bde8488ac
                scriptPubKey (assembly): OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG



                In plain english, this script, when executed will do the following:





                • OP_DUP: Duplicate the top item on the stack (place a copy of it on the stack)


                • OP_HASH160: Pop the top item off the stack, calculate it's HASH160, i.e. the RIPEMD160(SHA256()), and place that on the stack


                • OP_EQUALVERIFY: Pop the top 2 items off the stack, and if they are not equal, it will exit immediately and fail, otherwise nothing


                • OP_CHECKSIG: Pop the top 2 items off the stack, and use the top as the public key, the second as the signature, and verify the transaction signature


                In order to spend this output, we must provide a valid signature and public key. We'll just provide 00 for the signature for this example, and not worry about the final checksig op.



                Example



                Let's visualize this example with a scriptSig. Let's use kallewoof's btcdeb Script visualization tool. After the first command, you can type step once, and then just press enter each time after that to step through each operation:



                $ btcdeb '[00 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG]'

                btcdeb -- type `btcdeb -h` for start up options
                valid script
                7 op script loaded. type `help` for usage information
                script | stack
                -------------------------------------------------------------------+--------
                0 |
                030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 |
                OP_DUP |
                OP_HASH160 |
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
                OP_EQUALVERIFY |
                OP_CHECKSIG |
                #0000 0
                btcdeb> step
                <> PUSH stack
                script | stack
                -------------------------------------------------------------------+--------
                030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 | 0x
                OP_DUP |
                OP_HASH160 |
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
                OP_EQUALVERIFY |
                OP_CHECKSIG |
                #0001 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                btcdeb>
                <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_DUP | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                OP_HASH160 | 0x
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
                OP_EQUALVERIFY |
                OP_CHECKSIG |
                #0002 OP_DUP
                btcdeb>
                <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_HASH160 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                OP_EQUALVERIFY | 0x
                OP_CHECKSIG |
                #0003 OP_HASH160
                btcdeb>
                <> POP stack
                <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                OP_EQUALVERIFY | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                OP_CHECKSIG | 0x
                #0004 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                btcdeb>
                <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_EQUALVERIFY | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                OP_CHECKSIG | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                | 0x
                #0005 OP_EQUALVERIFY
                btcdeb>
                <> POP stack
                <> POP stack
                <> PUSH stack 01
                <> POP stack
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_CHECKSIG | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                | 0x
                #0006 OP_CHECKSIG


                You can play around with this using any of the opcodes listed at Script.






                share|improve this answer













                The transaction output has a property called the scriptPubkey that is executed with the scriptSig when the output is spent in a transaction. An understanding of Bitcoin script would help.



                Bitcoin Script



                Bitcoin uses it's own stack-based scripting language with a set of op-codes. This scripting language is used to determine whether an unspent transaction output (utxo) can be spent. When you send Bitcoin, you are really just assigning a Bitcoin value to a script, which can be spent only if the script executes successfully and results in a single true value on the stack. The script that is assigned to the Bitcoin transaction output is called the scriptPubKey. To satisfy the script, you must provide the correct scriptSig, which is also a script, which is prepended to the scriptSig and executed to test if the spending succeeded. Let's look at an example:



                scriptPubKey (raw): 76a914306e2ea1eed91bf66dfe5d94f3957d4ba63bde8488ac
                scriptPubKey (assembly): OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG



                In plain english, this script, when executed will do the following:





                • OP_DUP: Duplicate the top item on the stack (place a copy of it on the stack)


                • OP_HASH160: Pop the top item off the stack, calculate it's HASH160, i.e. the RIPEMD160(SHA256()), and place that on the stack


                • OP_EQUALVERIFY: Pop the top 2 items off the stack, and if they are not equal, it will exit immediately and fail, otherwise nothing


                • OP_CHECKSIG: Pop the top 2 items off the stack, and use the top as the public key, the second as the signature, and verify the transaction signature


                In order to spend this output, we must provide a valid signature and public key. We'll just provide 00 for the signature for this example, and not worry about the final checksig op.



                Example



                Let's visualize this example with a scriptSig. Let's use kallewoof's btcdeb Script visualization tool. After the first command, you can type step once, and then just press enter each time after that to step through each operation:



                $ btcdeb '[00 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG]'

                btcdeb -- type `btcdeb -h` for start up options
                valid script
                7 op script loaded. type `help` for usage information
                script | stack
                -------------------------------------------------------------------+--------
                0 |
                030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 |
                OP_DUP |
                OP_HASH160 |
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
                OP_EQUALVERIFY |
                OP_CHECKSIG |
                #0000 0
                btcdeb> step
                <> PUSH stack
                script | stack
                -------------------------------------------------------------------+--------
                030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 | 0x
                OP_DUP |
                OP_HASH160 |
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
                OP_EQUALVERIFY |
                OP_CHECKSIG |
                #0001 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                btcdeb>
                <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_DUP | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                OP_HASH160 | 0x
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 |
                OP_EQUALVERIFY |
                OP_CHECKSIG |
                #0002 OP_DUP
                btcdeb>
                <> PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_HASH160 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                OP_EQUALVERIFY | 0x
                OP_CHECKSIG |
                #0003 OP_HASH160
                btcdeb>
                <> POP stack
                <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                OP_EQUALVERIFY | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                OP_CHECKSIG | 0x
                #0004 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                btcdeb>
                <> PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_EQUALVERIFY | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                OP_CHECKSIG | 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                | 0x
                #0005 OP_EQUALVERIFY
                btcdeb>
                <> POP stack
                <> POP stack
                <> PUSH stack 01
                <> POP stack
                script | stack
                -------------------------------------------------------------------+-------------------------------------------------------------------
                OP_CHECKSIG | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                | 0x
                #0006 OP_CHECKSIG


                You can play around with this using any of the opcodes listed at Script.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 5 hours ago









                JBaczukJBaczuk

                4,3861321




                4,3861321






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Bitcoin Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbitcoin.stackexchange.com%2fquestions%2f83980%2fwhat-does-the-sender-of-a-transaction-include-in-the-input-that-allows-the-recip%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    الفوسفات في المغرب

                    Four equal circles intersect: What is the area of the small shaded portion and its height

                    جامعة ليفربول