user44824: How do I compute the double sha256 shown in example of bip 143?
The example in Native P2WPKH
  hashPrevouts:
     dSHA256(fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000ef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a01000000)
     = 96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37

I tried
  export PREV_OUT=fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000ef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a01000000
  echo -n $PREV_OUT |openssl dgst -sha256 -binary |openssl dgst -sha256

This is what I am getting
  cf4cff3b2196ae87636af6088736f0f9102106375f306c032804845a2d3b92d4


user2306: Do this:
echo -n $PREV_OUT | xxd -r -p | openssl dgst -sha256 -binary | openssl dgst -sha256

Explanation
You want to do this:

prevout (raw bytes) -> sha256 -> sha256 -> convert to hex

You're doing this:

prevout (raw bytes) -> convert to hex -> sha256 -> sha256 -> convert to hex

xxd -r -p reverses the hex conversion.

44824: <p>How do I compute the double sha256 shown in example of <a href="https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki" rel="nofollow noreferrer">bip 143</a>?</p>

<p>The <a href="https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#native-p2wpkh" rel="nofollow noreferrer">example in Native P2WPKH</a></p>

<pre><code>  hashPrevouts:
     dSHA256(fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000ef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a01000000)
     = 96b827c8483d4e9b96712b6713a7b68d6e8003a781feba36c31143470b4efd37
</code></pre>

<p>I tried</p>

<pre><code>  export PREV_OUT=fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000ef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a01000000
  echo -n $PREV_OUT |openssl dgst -sha256 -binary |openssl dgst -sha256
</code></pre>

<p>This is what I am getting</p>

<pre><code>  cf4cff3b2196ae87636af6088736f0f9102106375f306c032804845a2d3b92d4
</code></pre>
 2306: <p>Do this:</p>

<pre><code>echo -n $PREV_OUT | xxd -r -p | openssl dgst -sha256 -binary | openssl dgst -sha256
</code></pre>

<h3>Explanation</h3>

<p>You want to do this:</p>

<blockquote>
  <p>prevout (raw bytes) -> sha256 -> sha256 -> convert to hex</p>
</blockquote>

<p>You're doing this:</p>

<blockquote>
  <p>prevout (raw bytes) -> convert to hex -> sha256 -> sha256 -> convert to hex</p>
</blockquote>

<p><code>xxd -r -p</code> reverses the hex conversion.</p>
