In an attempt to more fully understand raw transactions etc, I went to look at tx 518c41d5e59114f6a23383afbe95f02cdd09cb50cabd8390bdd9162a890435b3 in its raw form being:


I then tried to submit that raw form, just copy and paste into my bitcoin wallet program to "sendrawtransaction" and got the error missing inputs (code -25). This seems odd in it of itself because since this is an exact copy and paste of the raw transaction that is on the blockchain, shouldn't it not be missing anything at all? Also, shouldn't I be getting a "transaction already exists" error instead? Or do I not understand something about how raw transactions are submitted?


Bitcoin Core has no idea which transactions already exist in the chain. It does not maintain a full index, because... it doesn't need to. In fact, when running in pruning mode, it doesn't even have the chain or its transactions at all.

The only thing it has is the set of unspent transaction outputs. Since you're trying to replay an existing transaction, all the inputs are already spent by its previous instance. As a result, the expected and correct response is that inputs are missing - i.e. your transaction is a double spend, and thus invalid.

I'd say that this is one of the advantages of the UTXO model: a replay and a double spend are one and the same, and there is no need to distinguish.

  • 1
    In that case, what is the point of fHaveChain in github.com/bitcoin/bitcoin/blob/master/src/rpc/… which throws RPC_TRANSACTION_ALREADY_IN_CHAIN ? – MeshCollider Aug 17 '17 at 3:02
  • 2
    @MeshCollider If I'm reading it right, if some of the outputs of the transaction exist in the blockchain and are unspent, then sendrawtransaction fails with that error, instead of failing with the missing inputs error. – Nick ODell Aug 17 '17 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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