diff --git a/lib/bitcoin/sighash_generator.rb b/lib/bitcoin/sighash_generator.rb
index <HASH>..<HASH> 100644
--- a/lib/bitcoin/sighash_generator.rb
+++ b/lib/bitcoin/sighash_generator.rb
@@ -71,7 +71,9 @@ module Bitcoin
         amount = [amount].pack('Q')
         nsequence = [tx.inputs[input_index].sequence].pack('V')
         hash_outputs = Bitcoin.double_sha256(tx.outputs.map{|o|o.to_payload}.join)
-
+        if output_script.p2wsh?
+          warn('The output_script must be a witness script, not the P2WSH itself.')
+        end
         script_code = output_script.to_script_code(skip_separator_index)
 
         case (hash_type & 0x1f)
Add waring to Tx#sighash_for_input when P2WSH output_script are specified

In P2WSH case, it should pass witness script instead of scriptPubkey. Add a warning message to make you aware of this mistake.