renproject/ren-js

How to restore a transaction with BTC TXID?

Closed this issue · 3 comments

For the usecase of depositing (or minting), there is a time window (to wait for 6 confirmations) between a successful ren transaction submission and a valid ren response which holds signature and etc that are necessary for subsequent Ethereum submission.

Suppose that, for some reason, our application lost track of the process in this time window, which means the random nonce used to produce gatewayAddress and ren txHash is lost, and the only thing that our user can provide us with is his/her BTC TXID and corresponding amount.

In this senario, what can be done to restore the transaction process? I did a quick look at 2.0.0-alpha and the new processDeposit method, but it requires same nonce to be provided, which is lost.

A possible workaround is to tag every mint with user's Ethereum wallet address, and if above said case occurs, we can use queryTxs rpc method to query all transactions tagged with user's Ethereum wallet address, and filter them with BTC TXID and amount (as ren tx holds corresponding UTXO).

However, this approach is quite time consuming: queryTxs does not support status filtering yet and it is sorted by creation time in ascending order, and pageSize parameter also has a upper bound, so we need to do an exhaustive search to find the lost transaction.

0x31 commented

The nonce is required in RenJS v1 due to it's limited capability to handle multiple deposits to the same gateway address, which has been improved in RenJS v2. For this reason, the nonce now defaults to the value 0x0, and the recommendation in the v2 docs is to not set a nonce.

However, you still need the remaining details of the mint in order to recover it, so the only thing I can recommend is to ensure data availability is guaranteed before showing a deposit address to a user.

Wow, it's realy a huge improvement and I didn't read the v2 doc thoroughly. For my usecase, "remaining details of the mint" are all application specific and restorable.

One more question for v2: Is v2 backward compatible? i.e. Do I need to re-deploy corresponding smart contracts to use ren-js@2.* ?