OP_HASH160 vs OP_SHA256 Why would I use OP_HASH160 over OP_SHA256 and vice versa? Why are there two options? In what situations should I use one over the other?

Example unlocking scripts:

From BIP199: ( where HASHOP could be either )

    OP_IF
        [HASHOP] &lt;digest&gt; OP_EQUALVERIFY OP_DUP OP_HASH160 &lt;seller pubkey hash&gt;            
    OP_ELSE
        &lt;num&gt; [TIMEOUTOP] OP_DROP OP_DUP OP_HASH160 &lt;buyer pubkey hash&gt;
    OP_ENDIF
    OP_EQUALVERIFY
    OP_CHECKSIG


From miniscript's received HTLC demo:

&lt;key_remote&gt; OP_CHECKSIG OP_NOTIF
  &lt;key_revocation&gt; OP_CHECKSIG
OP_ELSE
  OP_IF
    OP_DUP OP_HASH160 &lt;HASH160(key_local)&gt; OP_EQUALVERIFY OP_CHECKSIGVERIFY
    OP_SIZE &lt;20&gt; OP_EQUALVERIFY OP_HASH160 &lt;h&gt; OP_EQUAL
  OP_ELSE
    &lt;f003&gt; OP_CHECKSEQUENCEVERIFY
  OP_ENDIF
OP_ENDIF
I think HASH160 is the standard/preferable to SHA-256 in locking/unlocking scripts just because its digest is smaller (20-byte digest instead of 32-byte of SHA-256) and, therefore, it takes less space in the blockchain. As it takes less space, you pay less in mining fees with no security cost (160 bits is well above the 128-bit threshold)

Remember that with HASH160 you are already hashing twice (HASH160 = RIPEMD160(SHA-256)) so the little security benefit compared to two rounds of SHA-256 doesn't compensate for the extra fee/blockchain space.