peerswap icon indicating copy to clipboard operation
peerswap copied to clipboard

[feature request] Avoid dust outputs

Open openoms opened this issue 2 years ago • 4 comments

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.

openoms avatar Jul 11 '22 18:07 openoms