Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth: Manual refunds #1311

Closed
martonp opened this issue Nov 25, 2021 · 4 comments
Closed

eth: Manual refunds #1311

martonp opened this issue Nov 25, 2021 · 4 comments

Comments

@martonp
Copy link
Contributor

martonp commented Nov 25, 2021

For BTC and DCR, we log a signed refund transaction that the user can manually submit to the blockchain in case the dex fails to properly refund a swap. For ETH this is not possible, because the nonce might have been incremented by the time the user would need to do a refund. We need an different way to do manual refunds for ETH.

@chappjc
Copy link
Member

chappjc commented Nov 25, 2021

In the past I had made a couple quick and dirty tools to do refunds and redeems without dexc.

cb15c2f

  • The redeem tool works like redeem <txid> <vout> <contract script> <secret>, but it can be made to work like redeem <raw tx hex> <contract script> <secret>. This tool is useful if you are the taker, and the maker has redeemed your contract, but your dexc is disabled before you can redeem theirs. With logged data, you can do the redeem manually.
  • The refundall tool is a bit different in that it chugs through the dexc.log file and attempts to refund any unspent contract that was logged. Instead of scanning the log file, a new refund tool can be made to work like redeem by processing a specified contract of your own.

These are not well generalized at all currently, only working with DCR and BTC, but that can change.

In general, I think we need to make sure sufficient info is logged. Longer term, we should consider if and how the swaps can be made deterministic w.r.t. the secret keys so that more recovery options are available given the dex Core app seed. It's not clear if there is such a solution though.

@martonp
Copy link
Contributor Author

martonp commented Nov 26, 2021

Those look nice.. I was thinking about something similar to the refund tool that you mentioned where you specify a contract of your own, but it would definitely be more convenient to have something that just scans the log files.

With ETH they are already deterministic as long as we only use a single swap contract. Definitely would be harder with DCR/BTC. I guess we would need the wallet to keep track of all the unredeemed swaps in the UTXO set.

@chappjc
Copy link
Member

chappjc commented Nov 28, 2021

With ETH they are already deterministic as long as we only use a single swap contract

Address reuse and the central contract with ETH certainly makes things easier, even if crazier.

A complementary idea that @buck54321 had suggested was a secondary record of the essential swap data, which would be redundant with both the DB and the log file, but potentially provide a more concise and easily parseable record of the critical on-chain swap data.

  • another file such as "critical.txt", synchronous and flushed after each write
  • match ID on each line to link all logged data
  • more structured than the .log file so that it is easily machine readable
  • any data that would be required to perform refund or taker redeems such as contract scripts, transaction IDs, counter party secrets

It's all already in the log file as I've demonstrated, but this would still be valuable IMO.

@chappjc
Copy link
Member

chappjc commented Feb 2, 2022

Resolved by #1455, which permits manual refunds to be performed. The refund of course still pays to the initiator's account, which would be the dex ETH wallet, so actually claiming those funds requires the app or asset seed, but it can at least be done without the dexc.db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants