<p>You must provide a <code>scriptSig</code> that, when executed with <code>scriptPubKey</code> results in a true (or any nonzero item) on the stack (and passes all verification ops).</p>
<p>The <code>scriptPubKey</code> you need to satisfy (with a <code>scriptSig</code>) is:</p>
<pre><code>2 OP_CHECKSEQUENCEVERIFY f45d94733d430261962932e0c847075195916a04 OP_CHECKSIG 
</code></pre>
<p>(note this is not the <code>redeemScript</code>)</p>
<p>There main problem is:</p>
<p><a href="https://en.bitcoin.it/wiki/OP_CHECKSIG" rel="nofollow noreferrer"><code>OP_CHECKSIG</code></a> is looking for a public key, but you have provided a script hash: <code>f45d94733d430261962932e0c847075195916a04</code>. This will never be satisfied so this transaction output is not spendable.</p>
<p>If you want to use the same <code>redeemScript</code> as before, you probably want the following <code>scriptPubKey</code>:</p>
<p><code>2 OP_CHECKSEQUENCEVERIFY OP_DROP HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL</code></p>
<p>Note the <code>OP_DROP</code> because the <code>OP_CHECKSEQUENCEVERIFY</code> leaves the 2 on the stack.</p>
<p>In order to spend this, you must provide any signatures and the <code>redeemScript</code> whose hash equals <code>f45d94733d430261962932e0c847075195916a04</code>.</p>
<p><strong>Update</strong>:</p>
<p>The <code>redeemScript</code> is still wrong. Instead of <code>03e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef</code>, try <code>0014e17bbad678e82f8188099a351170c3e0efd4011b</code>. This is the <code>P2WPKH</code> script you used previously in <a href="https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4" rel="nofollow noreferrer">https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4</a>. Also note this is a segwit script so it will look for the signature and pubkey in the witness data: <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh</a></p>

CC BY-SA 4.0
2018-11-14T15:04:15.847Z
Shouldn't that be `OP_DUP OP_HASH160 <hash> OP_EQUAL OP_CHECKSIG`? Your example only verifies that the pubkey matches, it does not verify the signature.
Raghav Sood
CC BY-SA 4.0
2018-11-14T15:19:43.973Z
I was attempting to provide a `P2SH` example, not a `P2PKH`.
JBaczuk
CC BY-SA 4.0
2018-11-14T15:21:06.283Z
Ah, of course, my mistake then!
Raghav Sood
CC BY-SA 4.0
2018-11-14T17:45:24.570Z
Please, see my updated post
Andrew
CC BY-SA 4.0
2018-11-14T18:33:17.470Z
@Andrew It looks like you're providing a public key `03e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef` that doesn't hash to the right value for the `OP_EQUAL` check. You need the `redeemScript` that hashes to `f45d94733d430261962932e0c847075195916a04`
JBaczuk
CC BY-SA 4.0
2018-11-14T18:44:59.767Z
What about this transaction? The public key and redeem script is the same, but it's valid tx https://tchain.btc.com/194fe9b2e266b47f51410ceb58f0765551f75bd018e7bfc3439efee14a344777
Andrew
CC BY-SA 4.0
2018-11-14T18:55:11.393Z
That is a witness transaction, and the `redeemScript`is provided in the `scriptSig`: `0014e17bbad678e82f8188099a351170c3e0efd4011b`
JBaczuk
CC BY-SA 4.0
2018-11-14T19:47:48.100Z
Can you spend this tx https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4  ? Here is a private key: cUB1iazKDHngknjpTHUfKtH9zNRvHn1aBMPJbK2s913zUegjkeNn
Andrew
CC BY-SA 4.0
2018-11-14T22:06:14.770Z
@Andrew see my updated answer
JBaczuk
CC BY-SA 4.0
2018-11-14T22:42:29.573Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/85770/discussion-between-andrew-and-jbaczuk).
Andrew
CC BY-SA 4.0
2018-11-15T01:02:55.787Z
Oh my God! I'm so sorry, but I'm not a programmer. I have no idea how to insert redeemscript into transaction and/or how to calculate it. Is there a easy way to just spend this inputs using bitcoin-cli with the folowing private key ?
Andrew
CC BY-SA 4.0
2018-11-14T14:58:39.167Z
2018-11-14T22:05:59.280Z
2020-06-16T11:10:03.350Z
JBaczuk
<p>I'm playing with OP_CHECKSEQUENCEVERIFY.</p>

<p>Here is my transaction that I'm trying to spend:</p>

<blockquote>
  <p><a href="https://tchain.btc.com/e79d469698915aa6724288ae3a4141a31706d081f39fb7fd0b956a73a9044b22" rel="nofollow noreferrer">https://tchain.btc.com/e79d469698915aa6724288ae3a4141a31706d081f39fb7fd0b956a73a9044b22</a></p>
</blockquote>

<p>which has the folowing redeem script:</p>

<pre><code>2 OP_CHECKSEQUENCEVERIFY f45d94733d430261962932e0c847075195916a04 OP_CHECKSIG
</code></pre>

<p>But got an error when I  broadcast it (after two block confirmations left):</p>

<pre><code>mandatory-script-verify-flag-failed (Non-canonical DER signature) (code 16)
</code></pre>

<p>I have no issues to spend transaction if I:</p>

<ol>
<li>Just specify <code>2 CHECKLOCKTIMEVERIFY</code> (can spend anyone)</li>
<li>With standart transaction <code>HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL</code></li>
</ol>

<p>but none with combination of them.
Here is a signed transaction:</p>

<pre><code>0200000001224b04a9736a950bfdb79ff381d00617a341413aae884272a65a919896469de7000000006b4830450221008801d7f0e402724b090133ec01a817e993675a44a871f1a3afc0dba730e24ea4022044097be610bece524e90a743fa9d060cd194079105e6f6d150265a1164e722c3012103e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef020000000120a107000000000017a914f45d94733d430261962932e0c847075195916a048700000000
</code></pre>

<p>Can someone explain me what I'm doing wrong?</p>

<p>P.S. With the folowing redeem script (OP_DROP added)</p>

<blockquote>
  <p><a href="https://tchain.btc.com/022d42355ac90e63f2667208112cf22471397dd2812645b5571da2d212596932" rel="nofollow noreferrer">https://tchain.btc.com/022d42355ac90e63f2667208112cf22471397dd2812645b5571da2d212596932</a></p>
</blockquote>

<pre><code>2 OP_CHECKSEQUENCEVERIFY OP_DROP f45d94733d430261962932e0c847075195916a04 OP_CHECKSIG
</code></pre>

<p>I got another error </p>

<pre><code>(Script evaluated without error but finished with a false/empty top stack element) (code 16)
</code></pre>

<p>[UPDATED]:</p>

<blockquote>
  <p><a href="https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4" rel="nofollow noreferrer">https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4</a></p>
</blockquote>

<pre><code>3 OP_CHECKSEQUENCEVERIFY OP_DROP OP_HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL
</code></pre>

<p>Then trying to broadcast this tx:</p>

<pre><code>0200000001b4b92baf46586fbd040d43383360645c8c8eaca3b12365824701e2d59d4d8946000000006a47304402205649f715d2553cc4a66dd36a61b3c1b187d19f585bd40427d795c600373a45ab02203325ef44a3aae191ed3f2a90efe382d7992712c03f249f8dd61d8a30997806dc012103e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef0300000001e00f97000000000017a914f45d94733d430261962932e0c847075195916a048700000000
</code></pre>

<p>I got </p>

<pre><code>error code: -26
error message:
mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element) (code 16)
</code></pre>

<p>Here is a privatekey </p>

<pre><code>cUB1iazKDHngknjpTHUfKtH9zNRvHn1aBMPJbK2s913zUegjkeNn
</code></pre>

<p>Can someone spend it? </p>

<bitcoind><script><input-script>
Cant spend input with non-standart redeemscript (OP_CSV)
Andrew
# Cant spend input with non-standart redeemscript (OP_CSV)

(Asked by: username_0 on 2018-11-14)

I'm playing with OP\_CHECKSEQUENCEVERIFY.

Here is my transaction that I'm trying to spend:

> <https://tchain.btc.com/e79d469698915aa6724288ae3a4141a31706d081f39fb7fd0b956a73a9044b22>

which has the folowing redeem script:

```
2 OP_CHECKSEQUENCEVERIFY f45d94733d430261962932e0c847075195916a04 OP_CHECKSIG

```

But got an error when I broadcast it (after two block confirmations left):

```
mandatory-script-verify-flag-failed (Non-canonical DER signature) (code 16)

```

I have no issues to spend transaction if I:

1. Just specify `2 CHECKLOCKTIMEVERIFY` (can spend anyone)
2. With standart transaction `HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL`

but none with combination of them.
Here is a signed transaction:

```
0200000001224b04a9736a950bfdb79ff381d00617a341413aae884272a65a919896469de7000000006b4830450221008801d7f0e402724b090133ec01a817e993675a44a871f1a3afc0dba730e24ea4022044097be610bece524e90a743fa9d060cd194079105e6f6d150265a1164e722c3012103e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef020000000120a107000000000017a914f45d94733d430261962932e0c847075195916a048700000000

```

Can someone explain me what I'm doing wrong?

P.S. With the folowing redeem script (OP\_DROP added)

> <https://tchain.btc.com/022d42355ac90e63f2667208112cf22471397dd2812645b5571da2d212596932>

```
2 OP_CHECKSEQUENCEVERIFY OP_DROP f45d94733d430261962932e0c847075195916a04 OP_CHECKSIG

```

I got another error

```
(Script evaluated without error but finished with a false/empty top stack element) (code 16)

```

[UPDATED]:

> <https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4>

```
3 OP_CHECKSEQUENCEVERIFY OP_DROP OP_HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL

```

Then trying to broadcast this tx:

```
0200000001b4b92baf46586fbd040d43383360645c8c8eaca3b12365824701e2d59d4d8946000000006a47304402205649f715d2553cc4a66dd36a61b3c1b187d19f585bd40427d795c600373a45ab02203325ef44a3aae191ed3f2a90efe382d7992712c03f249f8dd61d8a30997806dc012103e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef0300000001e00f97000000000017a914f45d94733d430261962932e0c847075195916a048700000000

```

I got

```
error code: -26
error message:
mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element) (code 16)

```

Here is a privatekey

```
cUB1iazKDHngknjpTHUfKtH9zNRvHn1aBMPJbK2s913zUegjkeNn

```

Can someone spend it?

**Tags:** bitcoind, script, input-script


---

## 1 answers

### Answer by username_1 on 2018-11-14. Score: 2 | Accepted answer

You must provide a `scriptSig` that, when executed with `scriptPubKey` results in a true (or any nonzero item) on the stack (and passes all verification ops).

The `scriptPubKey` you need to satisfy (with a `scriptSig`) is:

```
2 OP_CHECKSEQUENCEVERIFY f45d94733d430261962932e0c847075195916a04 OP_CHECKSIG 

```

(note this is not the `redeemScript`)

There main problem is:

[`OP_CHECKSIG`](https://en.bitcoin.it/wiki/OP_CHECKSIG) is looking for a public key, but you have provided a script hash: `f45d94733d430261962932e0c847075195916a04`. This will never be satisfied so this transaction output is not spendable.

If you want to use the same `redeemScript` as before, you probably want the following `scriptPubKey`:

`2 OP_CHECKSEQUENCEVERIFY OP_DROP HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL`

Note the `OP_DROP` because the `OP_CHECKSEQUENCEVERIFY` leaves the 2 on the stack.

In order to spend this, you must provide any signatures and the `redeemScript` whose hash equals `f45d94733d430261962932e0c847075195916a04`.

**Update**:

The `redeemScript` is still wrong. Instead of `03e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef`, try `0014e17bbad678e82f8188099a351170c3e0efd4011b`. This is the `P2WPKH` script you used previously in <https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4>. Also note this is a segwit script so it will look for the signature and pubkey in the witness data: <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh>

> **Comments:**
> **username_2**: Shouldn't that be `OP_DUP OP_HASH160 <hash> OP_EQUAL OP_CHECKSIG`? Your example only verifies that the pubkey matches, it does not verify the signature.  
> **username_1**: I was attempting to provide a `P2SH` example, not a `P2PKH`.  
> **username_2**: Ah, of course, my mistake then!  
> **username_0**: Please, see my updated post  
> **username_1**: @username_0 It looks like you're providing a public key `03e8546cfe53ca9014f6a352bc2e5c1f7cec1f5b344c73d4db3ed3b8f075d5c9ef` that doesn't hash to the right value for the `OP_EQUAL` check. You need the `redeemScript` that hashes to `f45d94733d430261962932e0c847075195916a04`  
> **username_0**: What about this transaction? The public key and redeem script is the same, but it's valid tx https://tchain.btc.com/194fe9b2e266b47f51410ceb58f0765551f75bd018e7bfc3439efee14a344777  
> **username_1**: That is a witness transaction, and the `redeemScript`is provided in the `scriptSig`: `0014e17bbad678e82f8188099a351170c3e0efd4011b`  
> **username_0**: Can you spend this tx https://tchain.btc.com/46894d9dd5e20147826523b1a3ac8e8c5c64603338430d04bd6f5846af2bb9b4  ? Here is a private key: cUB1iazKDHngknjpTHUfKtH9zNRvHn1aBMPJbK2s913zUegjkeNn  
> **username_1**: @username_0 see my updated answer  
> **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/85770/discussion-between-username_0-and-username_1).  
> **username_0**: Oh my God! I'm so sorry, but I'm not a programmer. I have no idea how to insert redeemscript into transaction and/or how to calculate it. Is there a easy way to just spend this inputs using bitcoin-cli with the folowing private key ?  

---

