1

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.

010000000001012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac020151045593568700000000

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

010000000001012649c299694db1b608d4463e3b0535b3b8c0d5a1e9558b4d71be3790bde1dce800000000232200201f41c545a5c0b1c370c2e2812b3256d690fc098ae56aa21c94cd98d7c3ca5ec6ffffffff01401f0000000000001976a91451d2a5e04d25ceaa86e600a6ec34bd24431c675d88ac020101045593568700000000

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. :(

  • 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? – Pieter Wuille Sep 21 at 6:28
  • 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 Sep 21 at 16:12
  • Does it work when you change the stack to be 0x01 instead of 0x51? – Pieter Wuille Sep 21 at 16:13
  • @PieterWuille yes, it works – Atlas Chiew Sep 21 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.