Is transaction malleability an issue when receiving payments?

3

Assume I'm using the original client to receive payments. Is the following scenario possible?

My wallet gets notified of unconfirmed transaction with id 12 in which one of the outputs is an address that belongs to me.

Someone changes the id of the transaction to 13 and relays it to the miner who finds the next block.

My wallet gets notified of block that contains transaction with id 13 in which one of the outputs is an address that belongs to me.

Transaction with id 13 gets 6 confirmations but transaction with 12 gets stuck in my wallet as an unconfirmed transaction.

If I'm showing my customers their unconfirmed transactions, then the customer will see a confirmed transaction with id 13 and an unconfirmed transaction with id 12. Is that correct? Or will QT automatically delete the first transaction?

What can I do to prevent this?

Emre Kenci

Posted 2014-02-17T15:19:59.900

Reputation: 3 008

I think your Bitcoin-Qt would discard its knowledge of t12 as soon as t13 gets confirmed as they are doublespends of each other.Murch 2014-02-17T19:11:42.167

1Thanks. Can you point me to a certain part of the source code where I can check to make sure?Emre Kenci 2014-02-17T19:54:13.453

2

@AntonAnsgar Here is where stale transaction removal happens. removeConflicts checks memory pool for conflicting inputs here.

John T 2014-02-17T21:33:43.760

@JacobTorba Can you write an answer so I can mark as valid? Thank you.Emre Kenci 2014-02-18T07:06:47.013

@AntonAnsgar you got it.John T 2014-02-18T15:54:47.907

Answers

2

If you wait for a confirmed transaction you will be fine. The common mistake people/large exchanges make is when they constructed "withdraw" transactions from unconfirmed "deposit" transactions. Those invalidate quickly due to double spend rules. The Satoshi client does this as a last resort when picking unspent outputs.

The code that deals with it is here, removeConflicts is defined here.

John T

Posted 2014-02-17T15:19:59.900

Reputation: 2 759

1I have transactions that are stuck on my wallet. What I mean is I have two TXes which have same inputs same outputs. One of them is confirmed. The other one is waiting unconfirmed. I have multiple TXes that are just stuck like this. Any idea why they might have been created? These transactions are mostly received transactions. There is also one sending transaction where I have the same inputs and outputs but different TX ids for 3 transactions. Again one of them is confirmed. The other two are just stuck. I really need help with this. Thanks a lot.Emre Kenci 2014-02-20T16:08:36.527

That method removes conflicting transactions from the memory pool, not from the wallet.Pieter Wuille 2014-02-20T17:41:51.423

@PieterWullie Thanks. I don't know what memory pool actually does, I'll take a look. But does that mean that they are in the wallet forever? How can I get rid of them? And do you think this is what is going on with the situation I described in this question: http://bitcoin.stackexchange.com/questions/22663/stuck-duplicate-transaction-in-bitcoinqt

Emre Kenci 2014-02-25T21:33:34.033

1

I just figured out from the answer of Pieter to question: http://bitcoin.stackexchange.com/questions/22663/stuck-duplicate-transaction-in-bitcoinqt that the existing removeConflicts code does not deal with this issue.

Emre Kenci 2014-03-09T13:57:30.417

-1

An unconfirmed transaction cannot be spent. End of story really.

But for the sake of completeness, if you try to spend it your transaction will also remain unconfirmed with the person you paid. Neither of these transactions will ever enter the blockchain.

T9b

Posted 2014-02-17T15:19:59.900

Reputation: 1 254

The question is not whether it can be spent. The question is whether the situation described in the question is possibleEmre Kenci 2014-02-17T19:46:24.040

No this is not possible.T9b 2014-02-17T21:36:58.277

Really? How? Do you know which part of the source code is going to delete the first transaction?Emre Kenci 2014-02-17T22:21:50.990

1

I just learned that it is indeed possible. See: http://bitcoin.stackexchange.com/questions/22663/stuck-duplicate-transaction-in-bitcoinqt

Emre Kenci 2014-03-09T13:58:09.997