John requests a bitcoin withdrawal. There are 2 possible cases:
- a) We have no current unconfirmed send
- b) We have a previous unconfirmed send
In the event of a), just send the withdrawal normally. We are done.
Otherwise, let's call the previous send T. We get all outputs from T, and append John's output to it. We will create a new transaction V, and require that the coin selection picks at least 1 conflicting input is picked from T[1]. In the event that T does not have a change output, also require it adds at least 1 new input. We will call the new transaction V, which is guaranteed to conflict with T. We now push V onto the bitcoin network.
There are now two possible outcomes:
- V confirms
- T confirms
If V confirms, we are done. The other case that T confirms, means John has not been paid. We will create a new transaction U, which sources T's change address. If T does not have change, it will source at least one the inputs that exist in V but not in T. This guarantees that in a reorg that U and V can never occur. (During any reorg, it is likely that V will confirm)