0

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

enter image description here

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. enter image description here

Can you give reason about the policy of described in this post ?

2 Answers 2

5

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.

3

To expand on Andrew's answer a little, many application that interact with the Bitcoin network include some kind of "sane defaults". For Bitcoin Core, this is visible in the form of not allowing very high fee transactions, ensuring there aren't any duplicate addresses in outputs, attempting to use change addresses of the same type as the address you are sending coins to in an attempt to preserve privacy, and so on.

In many of these cases, these rules are different from the actual Bitcoin Protocol - For example, although Bitcoin Core tries to prevent absurdly high fees, there have been numerous cases of very high fee transactions (paying several BTC in fees) being mined.

Similarly, although the protocol allows multiple outputs to a single address, Bitcoin Core attempts to prevent that at an RPC level to reduce user error unintentionally costing them money. The Bitcoin Protocol itself has no rules against this, and will let you make such a transaction, and mine it, without any complaints.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.