I'm trying to spend a P2WSH output and here's what I've done so far:
I created a P2WSH output using bitcoin-cli. Here are the details:
You can also check it out here: https://blockstream.info/testnet/tx/3010534df31914f938014d34d0bd402ce1a741a46624b28abcfd2462126331a5?expand
To spend that output, I started making a transaction using bitcoin-cli like this:
This gives me the following serialization:
Now I’m attempting to sign the message:
But here’s the problem, I keep getting this error:
I don’t get why I keep seeing the empty witness program error since I’m definitely passing the witness script in the command line. Is there a bug or am I missing something here?
The witness script that was hashed serializes to
I heard this transaction is non-standard, but I thought the (witness) redeem could be picked freely?
Thanks for any assistance.
Error with Empty Witness Script in P2WSH Transactions
5 replies 361 views
Bitcoin Core doesn't know how to sign non-standard scripts. Script is not easy to analyze, so Bitcoin Core sticks to specific templates and patterns that it can analyze. Your script does not follow any of those patterns, so it is unable to produce any valid signatures. Furthermore, since it doesn't recognize the script, it will not place it in the witness. Thus the transaction you get after using signrawtransactionwithwallet is completely unsigned, and in fact, identical to what you passed in.
FWIW you don't need to push data smaller than 76 bytes using OP_PUSHDATA1 since it is wasteful. All you need to do is to use the size itself, which means using 0x02 and 0x14 instead of 0x4c02 and 0x4c14 respectively for the two data pushes which saves 2 bytes.
Thanks, noted. Does this mean every unlocking script in a P2WSH transaction is non-standard? If yes, does this mean P2WSH redeem scripts are not broadcasted by every client that only broadcasts standard transactions?
Thanks for the tip. Noted.
No, nodes do not inspect the contents of redeem or witness scripts for standardness checks.
Perhaps a better term would be "well known script template".
Thanks guys! Thanks to your direction I managed to sign it myself and now have my first transaction of the type indicated
that I signed myself. I am happy!
Without you I couldn't have done it!
Related topics
- What can I do to fix this Bitcoin Core error? 8
- issues with bitcoin core database read error 2
- Bitcoin Core displaying coins (UTXOs) in a new tab 13
- Are you in favor of BIP-110? Let's get a Bitcoin poll going. 0
- Erlay seems to have some issues here’s a better proposal for a bitcoin protocol without invites 3
- New Optional Hourglass Implementation is Live 3