<p>The online script check program that you are using to evaluate the script has numerous issues. First, there is a <a href="http://github.com/siminchen/bitcoinIDE/issues/14" rel="nofollow noreferrer">known issue</a> of the software calculating the <code>OP_HASH160</code> incorrectly. For example, the <code>HASH160</code> of the public key that you have entered (the one starting with 04...) is <code>7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8</code> while the program is calculating it as <code>6DF13DE1F1D824380834E0D42E49E5E451A647CF</code>. This results in a failed validation when the <code>OP_EQUALVERIFY</code> opcode runs. </p>

<p>The error derives from mishandling the hashing strings as ASCII instead of binary. By this I mean that the program is hashing the public key as a string rather than treating the public key as a hexadecimal number and hashing the bytes. Below is a python code of how the hashing should actually be done.</p>



<pre><code>import hashlib

def hash160(payload_in_hex):
    payload_in_bytes = bytes.fromhex(payload_in_hex) # note this step
    payload_sha256 = hashlib.sha256(payload_in_bytes).digest()
    payload_sha256_ripemd160 = hashlib.new('ripemd160', payload_sha256).hexdigest()
    return payload_sha256_ripemd160

pub_key = '0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf'
hash160(pub_key)
&gt;&gt;&gt; '7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8'
</code></pre>

<p>Secondly, the signature verification against a public key without knowing what message was signed is simply incorrect. This is resulting in the program accepting any signature for any given public key. For example just try the below script and it will show you that execution was successful. </p>

<pre><code>aecd 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf OP_CHECKSIG
</code></pre>

CC BY-SA 4.0
2019-07-24T08:38:46.363Z
2019-07-24T09:06:31.200Z
2019-07-24T09:06:31.200Z
Ugam Kamat
<p>I'm working my way through "Mastering Bitcoin".</p>

<p>The author made a transaction:</p>

<pre><code>0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2
</code></pre>

<p><a href="https://www.blockchain.com/btc/tx/0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qbOOI.png" alt="">
https://www.blockchain.com/btc/tx/0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2</a></p>

<p>I tried to execute the transaction script (with the Unlock script in vout) in a Bitcoin Script online simulator:
<a href="https://siminchen.github.io/bitcoinIDE/build/editor.html" rel="nofollow noreferrer">https://siminchen.github.io/bitcoinIDE/build/editor.html</a>
putting the current ScriptSig:</p>

<pre><code>ScriptSig: PUSHDATA(72)[3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301] PUSHDATA(65)[0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf]
</code></pre>

<p>with the output script:</p>

<pre><code>DUP HASH160 PUSHDATA(20)[7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8] EQUALVERIFY CHECKSIG
</code></pre>

<p>according the blockchain explorer.</p>

<p>I got "execution unsuccessful" even though i didn't figure out what's the problem.
Apparently the op_EQUALVERIFY got failed.</p>

<p><a href="https://i.sstatic.net/u4icZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/u4icZ.png" alt="enter image description here"></a></p>

<transactions><script>
Bitcoin script execution unsuccessful
Yoav Henig
# Bitcoin script execution unsuccessful

(Asked by: username_0 on 2019-06-12)

I'm working my way through "Mastering Bitcoin".

The author made a transaction:

```
0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

```

[![](https://i.sstatic.net/qbOOI.png)
https://www.blockchain.com/btc/tx/0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2](https://www.blockchain.com/btc/tx/0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2)

I tried to execute the transaction script (with the Unlock script in vout) in a Bitcoin Script online simulator:
<https://siminchen.github.io/bitcoinIDE/build/editor.html>
putting the current ScriptSig:

```
ScriptSig: PUSHDATA(72)[3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301] PUSHDATA(65)[0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf]

```

with the output script:

```
DUP HASH160 PUSHDATA(20)[7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8] EQUALVERIFY CHECKSIG

```

according the blockchain explorer.

I got "execution unsuccessful" even though i didn't figure out what's the problem.
Apparently the op\_EQUALVERIFY got failed.

[![enter image description here](https://i.sstatic.net/u4icZ.png)](https://i.sstatic.net/u4icZ.png)

**Tags:** transactions, script


---

## 1 answers

### Answer by username_1 on 2019-07-24. Score: 2 | Accepted answer

The online script check program that you are using to evaluate the script has numerous issues. First, there is a [known issue](http://github.com/siminchen/bitcoinIDE/issues/14) of the software calculating the `OP_HASH160` incorrectly. For example, the `HASH160` of the public key that you have entered (the one starting with 04...) is `7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8` while the program is calculating it as `6DF13DE1F1D824380834E0D42E49E5E451A647CF`. This results in a failed validation when the `OP_EQUALVERIFY` opcode runs.

The error derives from mishandling the hashing strings as ASCII instead of binary. By this I mean that the program is hashing the public key as a string rather than treating the public key as a hexadecimal number and hashing the bytes. Below is a python code of how the hashing should actually be done.

```
import hashlib

def hash160(payload_in_hex):
    payload_in_bytes = bytes.fromhex(payload_in_hex) # note this step
    payload_sha256 = hashlib.sha256(payload_in_bytes).digest()
    payload_sha256_ripemd160 = hashlib.new('ripemd160', payload_sha256).hexdigest()
    return payload_sha256_ripemd160

pub_key = '0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf'
hash160(pub_key)
>>> '7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8'

```

Secondly, the signature verification against a public key without knowing what message was signed is simply incorrect. This is resulting in the program accepting any signature for any given public key. For example just try the below script and it will show you that execution was successful.

```
aecd 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf OP_CHECKSIG

```


---

