Invalid address for asset transfer

If Bob transfers 20 Algos to address p belonging to Alice. If p appears to be an invalid address i.e less than Tealtype.bytes of 32, can the protocol rejects the transaction on initiation or can it be configured to reject such a transaction? I need help please.

The addresses that you see everywhere like COVIDR5MYE757XMDCFOCS5BXFF4SKD5RTOF4RTA67F47YTJSBR5U7TKBNU contain a checksum. They are more than 32-byte long. This checksum is verified by all the official tools generating transactions (official SDK, goal command, …) and should be verified by non-official tools too.

In other words, if you use correctly any official SDK or any official tool, errors are very unlikely.

For the sake of completeness, note that the actual transaction sent to the blockchain does not contain this checksum, and just contain the 32-byte address (to save on storage and bandwidth). So if you craft manually an incorrect transaction, then you can include an incorrect 32-byte address. For example, here I used an incorrect receiver address which has been generated by truncating the address YJVVHAY4WXF65PURAZSQARLYM4BACNZXAO2X4SOPGIBWAQEEOTE63DSMVU without checksum. (This is actually in effect not straighforward to do so.)

$ msgpacktool -e -b32 > tx.tx <<EOF
> {
>   "txn": {
>     "amt": 100000,
>     "fee": 1000,
>     "fv": 6603596,
>     "gen": "testnet-v1.0",
>     "lv": 6604596,
>     "note:b32": "FWKJTNIBWUKE4===",
>     "type": "pay"
>   }
> }

$ goal clerk sign -i tx.tx -o tx.sig

$ goal clerk rawsend -f tx.sig
Transaction FQHMSD4VACOUFB6DFQ7YPRZ6IO3EAOJV4OPQXBEI2NDYZ2SJZGQQ still pending as of round 6603739
Transaction FQHMSD4VACOUFB6DFQ7YPRZ6IO3EAOJV4OPQXBEI2NDYZ2SJZGQQ committed in round 6603741

Thank you Fabrice. I see more info here. But precisely, I had meant for instance, in Algorand wallet GUI, if a user input incorrect or truncated address for a transaction, does the wallet known it is incorrect automatically? Also, can I configure in my application for a transaction to spot invalid address instead of accepting and user asset is lost, like in the case of Bitcoin and others?

Yes, the Algorand Wallet GUI would check for the address.
Similarly, in your app, you can very easily check for the address.

Brilliant. That’s answers perfectly. Many thanks for helping me out.