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

Optimize Coinswap: Use a Single Funding and Contract tx for Efficiency #446

Open
KnowWhoami opened this issue Mar 11, 2025 · 3 comments
Open
Labels
bug Something isn't working discussion Discussion topics Protocol Backward incompatible changes
Milestone

Comments

@KnowWhoami
Copy link
Collaborator

Current Scenario:

  • Let's say taker wants to perform coinswap with tx_count= 3 on each step.
  • tx_count = 3 means that each peer participating in the coinswap has to break the forwarding amount in 3 random values and create a seperate funding tx for each of them.

This introduces several edge cases which are as follows:

  • A peer must have at least 3 utxos in its wallet in order to create 3 seperate funding txes otherwise they can't forward and coinswap would fail..
  • Taker has to pay the mining fees of all the funding txes which are being created during this coinswap and in case of unsuccesfull swap , each peer has to broadcast its own 3 contract txes as each of them aims to spend just a single funding utxo which makes the whole protocol expensive whether it went successful or not..

Proposed Solution:

  • Only a single funding transaction should be created, generating tx_count + 1 UTXOs (accounting for change, if applicable). Similarly, a single contract transaction should be created to spend this funding UTXO.
@KnowWhoami KnowWhoami added bug Something isn't working enhancement This enhances the code and improves stuffs Protocol Backward incompatible changes discussion Discussion topics and removed enhancement This enhances the code and improves stuffs labels Mar 11, 2025
@KnowWhoami KnowWhoami added this to the v0.1.2 milestone Mar 11, 2025
@mojoX911
Copy link

Added pointers:

  • These tx_count (we should give a more apt name) number of utxos should be created with random amounts utilizing randomize amounts and fees #432
  • As an optional feature, we can add payjoin like input mixing between the swap partners in the funding txs. This increases fees slightly, but adds further ambiguity in the flow.
  • Corollary feature: the wallet should automatically maintain a random but well-distributed utxo set, which can be intelligently used to mix both inputs and outputs. This will make payjoining very effective and easy through out the swap market.

@khadar1020
Copy link

I would like to work on this issue

@mojoX911
Copy link

This is not up for grab immediately. This will require quite a lot of thinking and designing. This will also be done over various preliminary works, which are yet to come. If you are interested feel free to join our dev calls (community link in the readme).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion Discussion topics Protocol Backward incompatible changes
Projects
None yet
Development

No branches or pull requests

3 participants