Why same output address is invalid in a transaction on Bitcoin Core? I'm studying Bitcoin Core currently. I found incomprehensible code, that shows making a transaction is rejected if there are same output addresses in a transaction.

See Fig1, Fig2



Origin source code : https://github.com/bitcoin/bitcoin/blob/8aac85d71e218783bc7ce06e5bf8bc660e24079d/src/rpc/rawtransaction_util.cpp#L95

So, the transaction illustrated in Fig1 will be rejected as shown Fig3.


Can you give reason about the policy of described in this post ?
It is not invalid.

The code you are looking it is unrelated to validation and relay of actual transactions. You are looking at the code for RPCs which are just things for users. The RPC disallows sending to an address multiple times because this is not efficient and usually a mistake by the user.

But this is only for creating a raw transaction using the Bitcoin Core RPC. A transaction received over the network or in a block that has dupllicate addresses in the outputs would not be rejected or be invalid in any way.