The caller needs to know the address is either p2sh or p2pkh, and v3 doesn’t support other types (ie nonstandard and witness). V4 will support all payment indexing using the Electrum model. In that case the caller must have or create (and hash) the script.