<p>this is my first question at this platform.</p>

<p>this matter has scratched my head badly, please pay patient to read my question.</p>

<p>i am trying to move traditional p2sh tx into p2wsh-nestedin-p2sh tx and this is also an ANYONE_CAN_SPEND tx.</p>

<h1>locking script</h1>

<p>scriptpubkey(hex) = a9149a6185672bafea7a16309a9f6e2fe03927499c6e87</p>

<p>scriptpubkey(asm) = OP_HASH160 9a6185672bafea7a16309a9f6e2fe03927499c6e OP_EQUAL</p>

<h1>unlocking script</h1>

<p>scriptsig(hex) = 2200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6</p>

<p>p2sh redeemscript(hex)=00201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6</p>

<p>so far all i mentioned above are simple traditional p2sh lock/unlock, my <strong>base serialized tx</strong> now showing.</p>

<p>01000000012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac00000000</p>

<p>this is correct because result generated from <a href="https://testnet.smartbit.com.au/txs/pushtx" rel="nofollow noreferrer">https://testnet.smartbit.com.au/txs/pushtx</a> shows me "PUSH TRANSACTION ERROR: 64: NON-MANDATORY-SCRIPT-VERIFY-FLAG (WITNESS PROGRAM WAS PASSED AN EMPTY WITNESS)"</p>

<p>so what i gonna do next is to solve witness data.</p>

<p>Witness Data:  </p>

<p>P2WSH-RedeemScript(hex) = 55935687</p>

<p>P2WSH-RedeemScript(asm) = OP_5 OP_ADD OP_6 OP_EQUAL</p>

<p>witness items(hex) = 51</p>

<p>witness items(asm) = OP_1</p>

<p>so now the serialized tx looks like this and the bolded part is my new changes compared to previous one.</p>

<p><strong>010000000001</strong>012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac<strong>0201510455935687</strong>00000000</p>

<p>when i submit this tx, error told me "PUSH TRANSACTION ERROR: 64: NON-MANDATORY-SCRIPT-VERIFY-FLAG (SCRIPT EVALUATED WITHOUT ERROR BUT FINISHED WITH A FALSE/EMPTY TOP STACK ELEMENT)"</p>

<p>i try hard to solve the puzzle and magically i success when i change script to </p>

<p>010000000001012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac0201<strong>01</strong>045593568700000000</p>

<p>so my latest submitted tx show over here <a href="https://testnet.smartbit.com.au/tx/e627feb66ed572b97ef393f20be0e76edb8dfe34fd98a9c606f62af04496341d" rel="nofollow noreferrer">https://testnet.smartbit.com.au/tx/e627feb66ed572b97ef393f20be0e76edb8dfe34fd98a9c606f62af04496341d</a></p>

<p>raw tx show over here <a href="https://api.blockcypher.com/v1/btc/test3/txs/e627feb66ed572b97ef393f20be0e76edb8dfe34fd98a9c606f62af04496341d?limit=50&amp;includeHex=true" rel="nofollow noreferrer">https://api.blockcypher.com/v1/btc/test3/txs/e627feb66ed572b97ef393f20be0e76edb8dfe34fd98a9c606f62af04496341d?limit=50&amp;includeHex=true</a></p>

<p>i dun understand how come change of this can solve my math puzzle. :(</p>

CC BY-SA 4.0
2019-09-21T06:28:46.870Z
The witness items are not encoded as scripts, so I think you're making it compute 0x51 + 5 == 6, rather than 1 + 5 == 6. Is that islt?
Pieter Wuille
CC BY-SA 4.0
2019-09-21T16:12:20.983Z
hi @PieterWuille , thanks for clarify this for me, i just knew that witness item is not doing as script, well, for beginner like me, witness item sound confusing and increase cost of learning.
Atlas Chiew
CC BY-SA 4.0
2019-09-21T16:13:42.187Z
Does it work when you change the stack to be 0x01 instead of 0x51?
Pieter Wuille
CC BY-SA 4.0
2019-09-21T16:17:26.833Z
@PieterWuille yes, it works
Atlas Chiew
<p2sh><witness-data><p2wsh>
(P2WSH-nestedin-P2SH) Problem in solving question 1+5=6
Atlas Chiew
# (P2WSH-nestedin-P2SH) Problem in solving question 1+5=6

(Asked by: username_0 on 2019-09-21)

this is my first question at this platform.

this matter has scratched my head badly, please pay patient to read my question.

i am trying to move traditional p2sh tx into p2wsh-nestedin-p2sh tx and this is also an ANYONE\_CAN\_SPEND tx.

# locking script

scriptpubkey(hex) = a9149a6185672bafea7a16309a9f6e2fe03927499c6e87

scriptpubkey(asm) = OP\_HASH160 9a6185672bafea7a16309a9f6e2fe03927499c6e OP\_EQUAL

# unlocking script

scriptsig(hex) = 2200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6

p2sh redeemscript(hex)=00201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6

so far all i mentioned above are simple traditional p2sh lock/unlock, my **base serialized tx** now showing.

01000000012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac00000000

this is correct because result generated from <https://testnet.smartbit.com.au/txs/pushtx> shows me "PUSH TRANSACTION ERROR: 64: NON-MANDATORY-SCRIPT-VERIFY-FLAG (WITNESS PROGRAM WAS PASSED AN EMPTY WITNESS)"

so what i gonna do next is to solve witness data.

Witness Data:

P2WSH-RedeemScript(hex) = 55935687

P2WSH-RedeemScript(asm) = OP\_5 OP\_ADD OP\_6 OP\_EQUAL

witness items(hex) = 51

witness items(asm) = OP\_1

so now the serialized tx looks like this and the bolded part is my new changes compared to previous one.

**010000000001**012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac**0201510455935687**00000000

when i submit this tx, error told me "PUSH TRANSACTION ERROR: 64: NON-MANDATORY-SCRIPT-VERIFY-FLAG (SCRIPT EVALUATED WITHOUT ERROR BUT FINISHED WITH A FALSE/EMPTY TOP STACK ELEMENT)"

i try hard to solve the puzzle and magically i success when i change script to

010000000001012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac0201**01**045593568700000000

so my latest submitted tx show over here <https://testnet.smartbit.com.au/tx/e627feb66ed572b97ef393f20be0e76edb8dfe34fd98a9c606f62af04496341d>

raw tx show over here <https://api.blockcypher.com/v1/btc/test3/txs/e627feb66ed572b97ef393f20be0e76edb8dfe34fd98a9c606f62af04496341d?limit=50&includeHex=true>

i dun understand how come change of this can solve my math puzzle. :(

**Tags:** p2sh, witness-data, p2wsh

> **Comments:**
> **username_1**: The witness items are not encoded as scripts, so I think you're making it compute 0x51 + 5 == 6, rather than 1 + 5 == 6. Is that islt?  
> **username_0**: hi @PieterWuille , thanks for clarify this for me, i just knew that witness item is not doing as script, well, for beginner like me, witness item sound confusing and increase cost of learning.  
> **username_1**: Does it work when you change the stack to be 0x01 instead of 0x51?  
> **username_0**: @PieterWuille yes, it works  

---

## 0 answers

