Code prevention of sending bitcoin to an address on the wrong chain btc/bch/bsv Since they share several common addressing schemes, can I figure out in code how to send them to the right chain?
There are three partial remedies:


bech32 addresses are invalid on BCH and BSV
CashAddr is an alternative encoding (inspired by bech32) for p2pkh and p2sh addresses that is only valid on BCH and BSV
You can check whether the recipient address is subject to address reuse: if it was previously used on another network, you should request confirmation or another address from the recipient


Unfortunately, BSV and BCH share all address formats, so you cannot distinguish which network an address was generated for between the two.

Likewise, the original p2pkh and p2sh addresses are valid on all three networks and there is no way to distinguish which network an address was intended for just from the address itself.