<blockquote>
  <p>So, it's looks fine, right?</p>
</blockquote>

<p>No. It does not look fine. You have to put your 'secret' into scriptSig. And your scriptPubkey should be redeem to one of your addresses (for example to msimoNvz23QXyiRofLtGSCsVdkdsNJn4SU). You should not try to sign this transaction - redeeming it does not require ecdsa signature</p>

<p>something like this:
(sorry, I did it "by hands", so it may be incorrect)</p>

<pre><code>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
</code></pre>

CC BY-SA 3.0
2015-03-04T10:53:51.867Z
Of course! That makes sense. The confusion was arising initially bc signing wasn't required but in hindsight I see the redemption is sitting in for the signature, which makes sense. And clearly the Tx is a mess, given that outputs / inputs are either missing completely or swapped in place. I'll try it out within the hour.
Wizard Of Ozzie
CC BY-SA 3.0
2015-03-04T09:25:07.017Z
2015-03-04T09:37:20.930Z
2015-03-04T09:37:20.930Z
amaclin
<p>I created the following non-standard Tx on the Testnet3 network: <a href="https://blockexplorer.com/testnet/rawtx/6b52c981e6814072db77cb755b2633cd126b4ca21501d18ab994531e17a4a813" rel="nofollow">6b52c981e6814072db77cb755b2633cd126b4ca21501d18ab994531e17a4a813</a></p>

<pre><code>{
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"
}
]
}
</code></pre>

<p>The output of interest, is: <code>"OP_SHA256 931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8 OP_EQUAL"</code>. </p>

<p>hashed 'secret' = <code>adfladsfhuifo8ry8fh4u4et4e5tsg415et458s43etg41s35e4g3541r35g143sg54s385g41s535e1g435s4g;.:;,[@snrltgnjslenjrgklsnleignilsnklgnslnglk</code></p>

<p><code>sha256(secret)</code> = <code>931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8</code></p>

<p>The BTC Wiki Script page (namely, <a href="https://en.bitcoin.it/wiki/Script#Transaction_puzzle" rel="nofollow">Puzzle Tx section</a>) provides a high-level discussion (of DOUBLE SHA256, note this is just SHA256 ie <code>0xa8</code>. This <a href="https://bitcointalk.org/index.php?topic=915114.25" rel="nofollow">BTCtalk discussion</a> provides the aforementioned secret, raw Tx format, etc.</p>

<hr>

<p>I am trying to redeem <code>010000000113a8a4171e5394b98ad10115a24c6b12cd33265b75cb77db724081e681c9526b0000000000ffffffff01204e000000000000864c846164666c61647366687569666f38727938666834753465743465357473673431356574343538733433657467343173333565346733353431723335673134337367353473333835673431733533356531673433357334673b2e3a3b2c5b40736e726c74676e6a736c656e6a72676b6c736e6c6569676e696c736e6b6c676e736c6e676c6b00000000</code> </p>

<pre><code>{
"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"
}
}
]
}
</code></pre>

<p>So, it's looks fine, right?</p>

<p>Well, signing (with <code>signrawtransaction</code>) returns hex data with a false flag for complete. Furthermore, both signed and unsigned hex strings return this error: </p>

<ul>
<li><code>16: mandatory-script-verify-flag-failed (Operation not valid with the current stack size) (code -26)</code></li>
</ul>

<p>Has anyone got any insight into what the issue may be, and, perhaps more helpfully to everyone else, <strong>assuming P2SH is not an option</strong>, how does one redeem these outputs?</p>

<bitcoin-core><testnet><raw-transaction><transaction-verification><raw>
Redeeming OP_SHA256 hash OP_EQUAL (Testnet) Tx
Wizard Of Ozzie
# Redeeming OP_SHA256 hash OP_EQUAL (Testnet) Tx

(Asked by: username_0 on 2015-03-04)

I created the following non-standard Tx on the Testnet3 network: [6b52c981e6814072db77cb755b2633cd126b4ca21501d18ab994531e17a4a813](https://blockexplorer.com/testnet/rawtx/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"
}
]
}

```

The output of interest, is: `"OP_SHA256 931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8 OP_EQUAL"`.

hashed 'secret' = `adfladsfhuifo8ry8fh4u4et4e5tsg415et458s43etg41s35e4g3541r35g143sg54s385g41s535e1g435s4g;.:;,[@snrltgnjslenjrgklsnleignilsnklgnslnglk`

`sha256(secret)` = `931d236179670b00348f87bea4199fe18297f0ef26da02c7542bd54d5b7836d8`

The BTC Wiki Script page (namely, [Puzzle Tx section](https://en.bitcoin.it/wiki/Script#Transaction_puzzle)) provides a high-level discussion (of DOUBLE SHA256, note this is just SHA256 ie `0xa8`. This [BTCtalk discussion](https://bitcointalk.org/index.php?topic=915114.25) provides the aforementioned secret, raw Tx format, etc.

---

I am trying to redeem `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"
}
}
]
}

```

So, it's looks fine, right?

Well, signing (with `signrawtransaction`) returns hex data with a false flag for complete. Furthermore, both signed and unsigned hex strings return this error:

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

Has anyone got any insight into what the issue may be, and, perhaps more helpfully to everyone else, **assuming P2SH is not an option**, how does one redeem these outputs?

**Tags:** bitcoin-core, testnet, raw-transaction, transaction-verification, raw


---

## 1 answers

### Answer by username_1 on 2015-03-04. Score: 2 | Accepted answer

> So, it's looks fine, right?

No. It does not look fine. You have to put your 'secret' into scriptSig. And your scriptPubkey should be redeem to one of your addresses (for example to msimoNvz23QXyiRofLtGSCsVdkdsNJn4SU). You should not try to sign this transaction - redeeming it does not require ecdsa signature

something like this:
(sorry, I did it "by hands", so it may be incorrect)

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

```

> **Comments:**
> **username_0**: Of course! That makes sense. The confusion was arising initially bc signing wasn't required but in hindsight I see the redemption is sitting in for the signature, which makes sense. And clearly the Tx is a mess, given that outputs / inputs are either missing completely or swapped in place. I'll try it out within the hour.  

---

