Bitcoin-Core

兌換 OP_SHA256 雜湊 OP_EQUAL (Testnet) Tx

  • March 4, 2015

我在 Testnet3 網路上創建了以下非標準 Tx:6b52c981e6814072db77cb755b2633cd126b4ca21501d18ab994531e17a4a813

{
hash: "6b52c981e6814072db77cb755b2633cd126b4ca21501d18ab994531e17a4a813",
ver: 1,
vin_sz: 1,
vout_sz: 1,
lock_time: 0,
size: 234,
in: [
{
prev_out: {
hash: "a61a8bd4aaab2aa935f2e62672a783ca936821c94e021caed747d3ff8b658ff7",
n: 0
},
scriptSig: "3045022100b4b97d5f21efa866ffc25ae4e20b4427adbeffca0fb8ea5d90ef261e1050c43e022077d1e734b077630b3634f91b2d60eb267f4a4e3e25ad9a0f56825363eee0fdc001 04dcc0cf808a5313ee50185575a850738011730247273aa3e11f400f7904e01fda86383ff0e8ed2ba201cb6cfb974d6148199ffc635d92b92b834ec04885bb9a71"
}
],
out: [
{
value: "0.00080000",
scriptPubKey: "OP_SHA256 931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8 OP_EQUAL"
}
]
}

感興趣的輸出是:"OP_SHA256 931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8 OP_EQUAL"

散列“秘密”=adfladsfhuifo8ry8fh4u4et4e5tsg415et458s43etg41s35e4g3541r35g143sg54s385g41s535e1g435s4g;.:;,[@snrltgnjslenjrgklsnleignilsnklgnslnglk

sha256(secret)=931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8

BTC Wiki 腳本頁面(即Puzzle Tx 部分)提供了一個高級討論(關於 DOUBLE SHA256,注意這只是 SHA256 即0xa8。這個BTCtalk 討論提供了上述秘密、原始 Tx 格式等。


我正在嘗試贖回010000000113a8a4171e5394b98ad10115a24c6b12cd33265b75cb77db724081e681c9526b0000000000ffffffff01204e000000000000864c846164666c61647366687569666f38727938666834753465743465357473673431356574343538733433657467343173333565346733353431723335673134337367353473333835673431733533356531673433357334673b2e3a3b2c5b40736e726c74676e6a736c656e6a72676b6c736e6c6569676e696c736e6b6c676e736c6e676c6b00000000

{
"txid" : "717b0d0db10f79d38553d2aeda3994768fda306fa5331d055fb3cf00818a6d7e",
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "6b52c981e6814072db77cb755b2633cd126b4ca21501d18ab994531e17a4a813",
"vout" : 0,
"scriptSig" : {
"asm" : "",
"hex" : ""
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 0.00020000,
"n" : 0,
"scriptPubKey" : {
"asm" : "6164666c61647366687569666f38727938666834753465743465357473673431356574343538733433657467343173333565346733353431723335673134337367353473333835673431733533356531673433357334673b2e3a3b2c5b40736e726c74676e6a736c656e6a72676b6c736e6c6569676e696c736e6b6c676e736c6e676c6b",
"hex" : "4c846164666c61647366687569666f38727938666834753465743465357473673431356574343538733433657467343173333565346733353431723335673134337367353473333835673431733533356531673433357334673b2e3a3b2c5b40736e726c74676e6a736c656e6a72676b6c736e6c6569676e696c736e6b6c676e736c6e676c6b",
"type" : "nonstandard"
}
}
]
}

所以,它看起來不錯,對吧?

好吧,簽名(用signrawtransaction)返回帶有錯誤標誌的十六進制數據以表示完成。此外,有符號和無符號十六進製字元串都返回此錯誤:

  • 16: mandatory-script-verify-flag-failed (Operation not valid with the current stack size) (code -26)

有沒有人了解問題可能是什麼,也許對其他人更有幫助,假設 P2SH 不是一種選擇,人們如何贖回這些輸出?

所以,它看起來不錯,對吧?

不,看起來不太好。您必須將您的“秘密”放入 scriptSig。並且您的 scriptPubkey 應該兌換到您的地址之一(例如 msimoNvz23QXyiRofLtGSCsVdkdsNJn4SU)。您不應該嘗試簽署此交易 - 兌換它不需要 ecdsa 簽名

像這樣:(對不起,我是“用手”做的,所以可能不正確)

01000000
01 
13a8a4171e5394b98ad10115a24c6b12cd33265b75cb77db724081e681c9526b
00000000

86    // length of script
4c84  // push 0x84 following bytes
6164666c61647366687569666f38727938666834753465743465357473673431356574343538733433657467343173333565346733353431723335673134337367353473333835673431733533356531673433357334673b2e3a3b2c5b40736e726c74676e6a736c656e6a72676b6c736e6c6569676e696c736e6b6c676e736c6e676c6b
ffffffff

01                 // one output
204e000000000000   // value in hex
19                 // length
76 A9 14 85ddbd9c2f9733dc3860b9e1ffcdc0da2633004b 88 AC // redeem to msimoNvz23QXyiRofLtGSCsVdkdsNJn4SU

00000000

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