This is a feature request, and also a BIP, but curious to hear feedback at this stage.
To summarise, if for some reason, a user is using an old version of their wallet.dat, and without realising they make a transaction which tries to use coins already spent, currently the client doesn't alert the user of what they have done, they will simply (as I understand it) see that the transaction takes forever to confirm. (please correct me if I am incorrect).
My suggestion is that when a node sees such invalid transactions, rather than simply ignore them, it sends a message back to the originating node to let them know it was invalid. This should only be necessary in situations where the transaction creating node isn't up to date on the block chain, otherwise the originating wallet should presumeably already alert the user, or ideally, have corrected their balance before they even tried to spend the coins. (A -rescan, IMHO, should do this, but, in my experience, it doesn't).
edit@laanwj: clarified title
Interesting. This issue kinda explains how mtgox might have been able to lose all their bitcoins - has bitcoin-qt now at least been fixed so that this doesn't happen any longer?
Please don't spread misinformation. This can't make you lose Bitcoin.
It's also not a bug, if your node is not up to sync with the network and you're on an old wallet.dat it cannot know the coins have been spent. Current versions of the software will show those hopeless TXN as conflicted with -1 confirms.
... why would one reply "interesting" to your own issue in the first place ...
Restoring old backups can make you lose coins in only one way: because they won't contain the keys for addresses that have been generated since. This is why it is mentioned in about every newbie guide about bitcoind/bitcoin-qt that regular backups should be made of the wallet.
The keys in your wallet determine solely what coins you have access to, transactions are only stored in the wallet for efficiency. When double-spending or using a wallet in multiple places, the wallet can get confused which coins are spent and which are not. That cannot result in any permanent loss. There are tools for removing transactions from your wallet, for example, -zapwallettxes that was added recently, but there have been external tools out there forever like pywallet that can do this. Followed by a rescan this will leave only confirmed transactions.
This also has nothing to do with mtgox. They aren't even using our software. It is unknown what happened to them at this point, so insinuating that some 'interesting' issue that you posted 2 years ago caused their loss of coins is extremely irresponsible.
@gmaxwell yes, current version does this, but 2 years ago it didn't. My question was, when was this changed? And I disagree, this bug of course can contribute to one losing coins since it makes the wallet balance seem higher than it is, so humans seeing this might assume they have the number of coins as shown in the balance when in fact they have less.
@laanwj "transactions are only stored in the wallet for efficiency" - what are you implying by saying this? That people shouldn't depend on the transactions as being accurate as the wallet isn't designed for this purpose? This is pretty big disclaimer if so, and really should be displayed in all places where people might be relying on this information as being accurate.
I don't see where the irresponsibility that you suggest is - I think it's irresponsible to not be taking this more seriously.
Not seeing transactions you already made is a temporary behavior that goes away as the wallet finishes syncing. Once you have finished syncing your balance is correct— before then it will be incorrect this behavior has not changed and cannot change.
@gmaxwell Sorry, perhaps I wasn't clear. This was an issue that occured when the blockchain is up to date.