omg-js icon indicating copy to clipboard operation
omg-js copied to clipboard

Need a better example strategy to confirm a transaction is complete.

Open snowkidind opened this issue 5 years ago • 1 comments

Regarding: https://github.com/omgnetwork/omg-js/blob/master/packages/omg-js-util/src/waitForChildchainBalance.js

After playing with this in my integration I've concluded that there are a lot of problems with this, but I will bring forth a couple:

  1. If the recipient address automatically combines UTXO's it might timeout
  2. If the recipient address receives another deposit, withdraw, anything really, during the waiting period the function will timeout.

Suggested fixes:

  1. Allow for polling of pending transactions.
  2. Improve upon this strategy to handle failure cases by checking for other recent transactions, and reacting accordingly.

snowkidind avatar Oct 20 '20 17:10 snowkidind

You should not rely on this method to wait for transaction confirmation. This helper is really there to aid in some of the testing the library does when the transactions are triggered in a controlled manner in a private chain. This would be very fragile in a public environment due to the reasons you stated.

The current approach for waiting for transaction confirmation in some of the client integrations is to poll transaction.all and wait for a known sent transaction to show up there. There is work being done on the Watcher side to have pending state returned so we don't have to rely on these kinds of workarounds. Hopefuly we can remove this function in the future for something more robust.

nicholasmueller avatar Oct 28 '20 11:10 nicholasmueller