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] <digest> OP_EQUALVERIFY OP_DUP OP_HASH160 <seller pubkey hash>
OP_ELSE
<num> [TIMEOUTOP] OP_DROP OP_DUP OP_HASH160 <buyer pubkey hash>
OP_ENDIF
OP_EQUALVERIFY
OP_CHECKSIG
From miniscript's received HTLC demo:
<key_remote> OP_CHECKSIG OP_NOTIF
<key_revocation> OP_CHECKSIG
OP_ELSE
OP_IF
OP_DUP OP_HASH160 <HASH160(key_local)> OP_EQUALVERIFY OP_CHECKSIGVERIFY
OP_SIZE <20> OP_EQUALVERIFY OP_HASH160 <h> OP_EQUAL
OP_ELSE
<f003> OP_CHECKSEQUENCEVERIFY
OP_ENDIF
OP_ENDIF