Skip to content

Hotfix: lightning swaps maker payment instructions#1824

Merged
shamardy merged 1 commit intodevfrom
hotfix-lightning-swaps
May 13, 2023
Merged

Hotfix: lightning swaps maker payment instructions#1824
shamardy merged 1 commit intodevfrom
hotfix-lightning-swaps

Conversation

@shamardy
Copy link
Copy Markdown
Collaborator

@shamardy shamardy commented May 12, 2023

In the ETH/ERC20/UTXO swaps with watcher rewards PR #1750 , the coin used for maker_payment_instructions was changed from maker_coin to taker_coin
https://github.com/KomodoPlatform/atomicDEX-API/blob/a1fc8f7c92819f68c0dcdf7b1c650d86cdf945ad/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L946-L956
This caused lightning swaps to fail. It wasn't catched by CI since lightning swaps unit tests are ignored because the tBTC addresses are required to be refilled periodically by coins which makes the test unstable.
https://github.com/KomodoPlatform/atomicDEX-API/blob/a1fc8f7c92819f68c0dcdf7b1c650d86cdf945ad/mm2src/mm2_main/tests/mm2_tests/lightning_tests.rs#L685-L689
This problem was also missed in the PR review.

I try to fix this issue in this PR but I guess it will mess up some of the watchers operations if only the coin was changed back as done here. @caglaryucekaya please comment with what needs to be changed for watchers operations to work as they were after this PR #1750.

Please note that in the other side of the swap (the maker swap), the instructions are validated using the maker_coin, meaning the fix in this PR is the right way to do this.
https://github.com/KomodoPlatform/atomicDEX-API/blob/a1fc8f7c92819f68c0dcdf7b1c650d86cdf945ad/mm2src/mm2_main/src/lp_swap/maker_swap.rs#L723-L724
Taker swap should also mirror maker swap in operations.
https://github.com/KomodoPlatform/atomicDEX-API/blob/a1fc8f7c92819f68c0dcdf7b1c650d86cdf945ad/mm2src/mm2_main/src/lp_swap/maker_swap.rs#L455-L456
The instructions are supposed to tell the other side how to send their coin payment so it's supposed to use the other side's coin to generate the instructions.

Copy link
Copy Markdown

@caglaryucekaya caglaryucekaya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the bug. I understand how the payment instructions work, this wasn't intentional but was a mistake. With this fix, only one more line needs to be changed for the watchers to work properly. While testing for this problem I discovered another one-line bug, I can open a PR for both bugfixes after you merge this one.

@shamardy shamardy merged commit c755e14 into dev May 13, 2023
@shamardy shamardy deleted the hotfix-lightning-swaps branch May 13, 2023 13:16
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

Successfully merging this pull request may close these issues.

2 participants