As far as i understood, function "isPayToScriptOut" assumes every output that has a datum hash is a script output. But what if we create new output with datum, assigned to some pub key (for example due to use of: "mustPayWithDatumToPubKey" in off-chain code). So our new output wont be related to script one, but "isPayToScriptOut" will return true in this case? Because datum hash can be attached to any transaction. And that makes "isPayToScriptOut" not safe enough for development.
My deductions are correct?
*Here is considered function's code from plutus library:
-- | Whether the output is a pay-to-script output.
isPayToScriptOut :: TxOut -> Bool
isPayToScriptOut = isJust . txOutDatum
txOutDatum :: TxOut -> Maybe DatumHash
txOutDatum TxOut{txOutDatumHash} = txOutDatumHash