Bitcoind

腳本評估沒有錯誤,但以錯誤/空的頂部堆棧元素結束

  • November 16, 2018

我正在嘗試從這個 tx 中花費硬幣

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

scriptpubkey 很簡單:

1 OP_CHECKSEQUENCEVERIFY OP_DROP OP_SHA256 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b OP_EQUAL

SHA256 (1) = 6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b

所以,我只需要使用OP_1將****1推入堆棧

這是我的交易:

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"
       ]
     }
   }
 ]
}

當我使用 sendrawtransaction 我得到

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

我的兌換腳本錯了嗎?還是 scriptpubkey 有問題?

1 的 SHA256 是4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a

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

您可能正在嘗試執行 ascii 字元“1”的 SHA256,它的字節值為0x3141十進制。

引用自:https://bitcoin.stackexchange.com/questions/81073