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

[feature request] Avoid dust outputs #99

Open
openoms opened this issue Jul 11, 2022 · 4 comments
Open

[feature request] Avoid dust outputs #99

openoms opened this issue Jul 11, 2022 · 4 comments
Assignees
Milestone

Comments

@openoms
Copy link
Contributor

openoms commented Jul 11, 2022

Was running a this successful swap between LND v0.15.0 nodes on signet (testing the PR #79):

₿ pscli listswaps
{
    "swaps": [
        {
            "id": "4fe4b28c2138bd75474ece52603a0e019998941df0f0fa95ef6f67fded7580a1",
            "created_at": "2022-07-11 16:39:17 +0100 BST",
            "type": "swap out",
            "role": "sender",
            "state": "State_ClaimedPreimage",
            "initiator_node_id": "02bad9bbc74153e191c5852fac04000a45ac45bb4363c99e099a5402ee3beeebf0",
            "peer_node_id": "020bdef67ab9fdc7575ee13851b2ffc01ca1b033de2c4af5292e3672ca5ba44be3",
            "amount": "100000",
            "channel_id": "98321:1:1",
            "opening_tx_id": "61a5e4456fa8e7b35d432ef4a063247e069d853944f3e85341ffa4b57df82d1c",
            "claim_tx_id": "f7e94ccf0f7dcdd0476648488e97d0a450136f8dcfa061e66cc30917e1a1d37c",
            "cancel_message": ""
        }
    ]
}

Got a dustsize (303 sats) change output in the first transaction: https://mempool.space/signet/tx/61a5e4456fa8e7b35d432ef4a063247e069d853944f3e85341ffa4b57df82d1c
going back into the swapout receiver's onchain wallet:

₿ slncli listunspent
{
        "utxos": [
                {
                        "address_type": 0,
                        "address": "tb1q9wdnxyft5wn487mh3yem4hxc8xkk0urf99zfe4",
                        "amount_sat": 303,
                        "pk_script": "00142b9b33112ba3a753fb778933badcd839ad67f069",
                        "outpoint": "61a5e4456fa8e7b35d432ef4a063247e069d853944f3e85341ffa4b57df82d1c:0",
                        "confirmations": 4
                },

PeerSwap should avoid creating such a tiny output onchain.
Amounts below the dust limit should be added to the miner fee for both convenience and privacy.

The limit for SegWit outputs is 330 sats https://bitcoin.stackexchange.com/questions/113649/dust-threshold-for-testnet, but would be comfortable with a higher limit.

@wtogami
Copy link
Contributor

wtogami commented Jul 13, 2022

Normal wallets have only one option to avoid dust creation: Send it all to miners.

PeerSwap has another way to avoid dust creation. When you request a swap you eyeball the channel and decide you want to swap 10 million sats but you don't actually need that particular amount. What if the swap amount is allowed to be within a small range +/-. The other side could auto-negotiate the swap cost and the exact amount it wants to swap. I personally would allow a range as big as like 100k sats if it avoids the need for another output.

File this under ideas for the next protocol spec.

Concept: Option peerswap-strict-amount default to false. It would also be an field per-swap. Most swaps for the purpose of channel balancing don't care about the particular amount swapped. If swaps happen for some other purpose in a future protocol like for trade then they may insist upon a particular amount. Then the other side could accept or reject it.

@wtogami
Copy link
Contributor

wtogami commented Jul 15, 2022

We should add a dumb dust mitigation for now where a mempool policy failing tiny output would go to fees. That doesn't require any negotiation with the peer.

Later it could be optimized by making the swap amount flexible which is the better way to avoid not only dust outputs but many additional small outputs as well. This would be a significant win to the blockchain in terms of storage efficiency.

@wtogami wtogami added this to the v0.3.0 milestone Jul 15, 2022
@wtogami wtogami self-assigned this Jul 15, 2022
@nepet
Copy link
Contributor

nepet commented Aug 23, 2022

What would be a sufficient dust limit?

@nepet nepet removed this from the v0.3.0 milestone Sep 28, 2022
@openoms
Copy link
Contributor Author

openoms commented Oct 4, 2022

I would go as high as avoiding outputs less than 20k sats (the minimum LN channel size) then later a dynamically chosen amount makes sense with peerswap-strict-amount=false as described above.

@wtogami wtogami added this to the v1.1 milestone Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants