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

<h1>Bitcoin Script</h1>

<p>Bitcoin uses it's own stack-based <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">scripting language</a> 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 <code>scriptPubKey</code>. To satisfy the script, you must provide the correct <code>scriptSig</code>, which is also a script, which is prepended to the <code>scriptSig</code> and executed to test if the spending succeeded. Let's look at an example:</p>

<p><strong>scriptPubKey (raw):</strong> <code>76a914306e2ea1eed91bf66dfe5d94f3957d4ba63bde8488ac</code><br>
<strong>scriptPubKey (assembly):</strong> <code>OP_DUP OP_HASH160 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84 OP_EQUALVERIFY OP_CHECKSIG</code></p>

<p>In plain english, this script, when executed will do the following:</p>

<ul>
<li><code>OP_DUP</code>: Duplicate the top item on the stack (place a copy of it on the stack)</li>
<li><code>OP_HASH160</code>: Pop the top item off the stack, calculate it's HASH160, i.e. the  <code>RIPEMD160(SHA256())</code>, and place that on the stack</li>
<li><code>OP_EQUALVERIFY</code>: Pop the top 2 items off the stack, and if they are not equal, it will exit immediately and fail, otherwise nothing</li>
<li><code>OP_CHECKSIG</code>: 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</li>
</ul>

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

<h2>Example</h2>

<p>Let's visualize this example with a <code>scriptSig</code>. Let's use kallewoof's <a href="https://github.com/kallewoof/btcdeb" rel="nofollow noreferrer"><code>btcdeb</code></a> Script visualization tool. After the first command, you can type <code>step</code> once, and then just press enter each time after that to step through each operation:</p>

<pre><code>$ 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&gt; step
        &lt;&gt; PUSH stack
script                                                             |  stack
-------------------------------------------------------------------+--------
030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046 |      0x
OP_DUP                                                             |
OP_HASH160                                                         |
306e2ea1eed91bf66dfe5d94f3957d4ba63bde84                           |
OP_EQUALVERIFY                                                     |
OP_CHECKSIG                                                        |
#0001 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
btcdeb&gt;
        &lt;&gt; PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
script                                                             |                                                             stack
-------------------------------------------------------------------+-------------------------------------------------------------------
OP_DUP                                                             | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
OP_HASH160                                                         |                                                                 0x
306e2ea1eed91bf66dfe5d94f3957d4ba63bde84                           |
OP_EQUALVERIFY                                                     |
OP_CHECKSIG                                                        |
#0002 OP_DUP
btcdeb&gt;
        &lt;&gt; PUSH stack 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
script                                                             |                                                             stack
-------------------------------------------------------------------+-------------------------------------------------------------------
OP_HASH160                                                         | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
306e2ea1eed91bf66dfe5d94f3957d4ba63bde84                           | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
OP_EQUALVERIFY                                                     |                                                                 0x
OP_CHECKSIG                                                        |
#0003 OP_HASH160
btcdeb&gt;
        &lt;&gt; POP  stack
        &lt;&gt; PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
script                                                             |                                                             stack
-------------------------------------------------------------------+-------------------------------------------------------------------
306e2ea1eed91bf66dfe5d94f3957d4ba63bde84                           |                           306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
OP_EQUALVERIFY                                                     | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
OP_CHECKSIG                                                        |                                                                 0x
#0004 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
btcdeb&gt;
        &lt;&gt; PUSH stack 306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
script                                                             |                                                             stack
-------------------------------------------------------------------+-------------------------------------------------------------------
OP_EQUALVERIFY                                                     |                           306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
OP_CHECKSIG                                                        |                           306e2ea1eed91bf66dfe5d94f3957d4ba63bde84
                                                                   | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                                                                   |                                                                 0x
#0005 OP_EQUALVERIFY
btcdeb&gt;
        &lt;&gt; POP  stack
        &lt;&gt; POP  stack
        &lt;&gt; PUSH stack 01
        &lt;&gt; POP  stack
script                                                             |                                                             stack
-------------------------------------------------------------------+-------------------------------------------------------------------
OP_CHECKSIG                                                        | 030cfcefa07af9dd6dbe770b87d7dbdd2c31ba7f4fcf8f3a1196d502f13561b046
                                                                   |                                                                 0x
#0006 OP_CHECKSIG
</code></pre>

<p>You can play around with this using any of the opcodes listed at <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">Script</a>.</p>

CC BY-SA 4.0
2019-01-24T22:28:11.850Z
2019-01-24T22:28:11.850Z
JBaczuk
<p>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. </p>

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

<p>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?</p>

<p>Thanks for taking the time out help</p>

<transactions>
What does the Sender of a Transaction include in the Input that allows the Recipient to Unlock/Redeem?
Nathaniel Richardson
# What does the Sender of a Transaction include in the Input that allows the Recipient to Unlock/Redeem?

(Asked by: username_0 on 2019-01-24)

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

**Tags:** transactions


---

## 1 answers

### Answer by username_1 on 2019-01-24. Score: 4

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](https://en.bitcoin.it/wiki/Script) 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`](https://github.com/kallewoof/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](https://en.bitcoin.it/wiki/Script).


---

