0

after learning a lot about script (and playing with them on the testnet) i made a way longer script.

$ btc decodescript 7455886f94935688789352885279935b88946e935b88945187
{
  "asm": "OP_DEPTH 5 OP_EQUALVERIFY OP_3DUP OP_SUB OP_ADD 6 OP_EQUALVERIFY OP_OVER OP_ADD 2 OP_EQUALVERIFY 2 OP_PICK OP_ADD 11 OP_EQUALVERIFY OP_SUB OP_2DUP OP_ADD 11 OP_EQUALVERIFY OP_SUB 1 OP_EQUAL",
  ...
  "segwit": {
    ...
    "address": "tb1q2c0uglp5tg2dhnr3ejuwppalp9urdfu4cxnl2sc495vlzmjy2ggs2wk7ry",
    ...
  }
}

the solution to this script is 6 9 4 2 0.

however, when redeeming the 1000 sat from the p2wsh address it gives me the error:

$ bitcoin-cli -testnet sendrawtransaction 010000000001019f084303418f25b5a77f36b95f293b052e9d885d98020be3f66fb223939bbbe00000000000ffffffff018c030000000000001600140f4eb1382443259e6d295d8ddf1ade059e4b1f8c0601060109010401020100197455886f94935688789352885279935b88946e935b8894518700000000
error code: -26
error message:
non-mandatory-script-verify-flag (unknown error)

i searched around a bit on bitcoin se and the only useful thing i could find was a post complaining about OP_PICK. Somebody knows how to fix this?

PS: i really don't care about 1000 test sat but just i want to fix this to learn from it :)

2 Answers 2

0

I was the guy, who asked the other question. In my case the problem was, that the operations left a unclean stack, which is technically ok, since the stack is not empty. But if I am correct its a non-standard transacition and will not be relayed by nodes.

In my case I had to finish with one element, which is not 0. And this was not possible in my script.

1
  • p2sh is not nonstandard. p2sh (or p2wsh) is the way to wrap nonstandard script in a script hash
    – Antoni
    Commented Dec 23, 2021 at 12:02
0

This error was caused by the same issue (minimal encoding) as problem with unlocking P2WSH. The solution Andrew Chow gave me there worked for me here too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.