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


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:


Can someone explain me what I'm doing wrong?

P.S. With the folowing redeem script (OP_DROP added)


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)



3 OP_CHECKSEQUENCEVERIFY OP_DROP OP_HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL

Then trying to broadcast this tx:


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


Can someone spend it?

1 Answer 1


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 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.


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

  • 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. Nov 14, 2018 at 15:04
  • I was attempting to provide a P2SH example, not a P2PKH.
    – JBaczuk
    Nov 14, 2018 at 15:19
  • Ah, of course, my mistake then! Nov 14, 2018 at 15:21
  • Please, see my updated post
    – Andrew
    Nov 14, 2018 at 17:45
  • @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
    Nov 14, 2018 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.