Error with Empty Witness Script in P2WSH Transactions

5 replies 361 views
rocket365Senior Member
Posts: 220 · Reputation: 905
#1Feb 28, 2025, 08:00 PM
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.
3 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#2Mar 1, 2025, 12:47 AM
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.
4 Reply Quote Share
im_apeHero Member
Posts: 629 · Reputation: 3824
#3Mar 1, 2025, 02:29 AM
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.
3 Reply Quote Share
rocket365Senior Member
Posts: 220 · Reputation: 905
#4Mar 1, 2025, 05:10 AM
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.
4 Reply Quote Share
ryan_nodeSenior Member
Posts: 204 · Reputation: 859
#5Mar 1, 2025, 04:03 PM
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".
2 Reply Quote Share
rocket365Senior Member
Posts: 220 · Reputation: 905
#6Mar 1, 2025, 10:12 PM
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!
0 Reply Quote Share

Related topics