Script evaluated without error but finished with a false/empty top stack element

1

I'm trying to spend coins from this tx

https://tchain.btc.com/ad7a1ed858eecdd146d9c932779aecae4b33f068d29cf794fad6de20f5a5d449

The scriptpubkey is simple:

1 OP_CHECKSEQUENCEVERIFY OP_DROP OP_SHA256 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b OP_EQUAL

SHA256 (1) = 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b

So, I just need to push 1 to the stack using OP_1

Here is my transaction:

bitcoin-cli -testnet decoderawtransaction 020000000149d4a5f520ded6fa94f79cd268f0334baeec9a7732c9d946d1cdee58d81e7aad0000000001510100000001904c96000000000017a914f45d94733d430261962932e0c847075195916a048700000000
{
  "txid": "51060bbaf1b29b2ec3b1bb4eef0d56f61121e4df167768f52e6f67f81321eaf5",
  "hash": "51060bbaf1b29b2ec3b1bb4eef0d56f61121e4df167768f52e6f67f81321eaf5",
  "version": 2,
  "size": 84,
  "vsize": 84,
  "weight": 336,
  "locktime": 0,
  "vin": [
    {
      "txid": "ad7a1ed858eecdd146d9c932779aecae4b33f068d29cf794fad6de20f5a5d449",
      "vout": 0,
      "scriptSig": {
        "asm": "1",
        "hex": "51"
      },
      "sequence": 1
    }
  ],
  "vout": [
    {
      "value": 0.09850000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_HASH160 f45d94733d430261962932e0c847075195916a04 OP_EQUAL",
        "hex": "a914f45d94733d430261962932e0c847075195916a0487",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2NFXJy8mvz7ZiT4VVN29xPGC38hTygd3AyJ"
        ]
      }
    }
  ]
}

When I use sendrawtransaction I got

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

Is my redeem script wrong? Or it's something wrong with the scriptpubkey ?

Andrew

Posted 2018-11-16T02:32:07.053

Reputation: 161

Answers

2

The SHA256 of 1 is 4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a

$ printf "01" | xxd -r -p | openssl sha256
(stdin)= 4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a
$ printf "31" | xxd -r -p | openssl sha256
(stdin)= 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b

You were probably trying to do the SHA256 of the ascii character "1" which has a byte value of 0x31 or 41 in decimal.

JBaczuk

Posted 2018-11-16T02:32:07.053

Reputation: 6 172

1oh.. I think this is 99% of all my problems. Thank youAndrew 2018-11-16T03:31:43.000