Skip to content

Instantly share code, notes, and snippets.

@RHavar
Last active February 1, 2018 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RHavar/cff76a026ece8446c898470db4f35682 to your computer and use it in GitHub Desktop.
Save RHavar/cff76a026ece8446c898470db4f35682 to your computer and use it in GitHub Desktop.

Super Withdrawals

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment