nix-bitcoin icon indicating copy to clipboard operation
nix-bitcoin copied to clipboard

Add PeerSwap

Open sputn1ck opened this issue 2 years ago • 4 comments

This PR adds peerswap. Peerswap allows you to rebalance channels with your direct peers using submarine swaps on bitcoin and on liquid. It is alpha software so should be used with caution.

I added modules for lnd as well as the clightning plugin.

Let me know if the testcase makes sense. I don't know how to run clightning plugin tests, however running ./run-tests.sh -s "{ services.clightning.enable = true;services.clightning.plugins.peerswap.enable = true;}" container --run c "lightning-cli peerswap-listswaps" went fine

sputn1ck avatar Mar 08 '22 12:03 sputn1ck

Fixups.

  • peerswap-liquid-rpcwallet should probably be renamed to peerswap-liquid-wallet.

  • allowlisted_peers should be renamed to allowed_peers.

  • Currently, running peerswap-lnd and the clightning plugin in parallel fails with:

    -4:Wallet file verification failed. Failed to create database path '/var/lib/liquidd/liquidv1/wallets/peerswap'. Database already exists.
    

    Should we assign different wallet names to each implementation?

  • Why does peerswap-lnd require lnd group access?

  • When running the clightning plugin with liquid support it exits right after starting. You can check this with:

    run-tests.sh -s '{
      services.liquidd.enable = true;
      services.clightning.plugins.peerswap.enable = true;
    }' container --run c journalctl -u clightning
    

    Output:

    lightningd[490]: INFO    plugin-peerswap: Liquid swaps enabled
    lightningd[490]: INFO    plugin-peerswap: Killing plugin: exited during normal operation
    

    You can also run a VM and check the logs (journalctl -u clightning):

    run-tests.sh -s '{
      services.liquidd.enable = true;
      services.clightning.plugins.peerswap.enable = true;
    }' vm
    
  • Does it make sense to enable liquid peerswaps by default when liquid is enabled? Could this be too intrusive, given that a wallet is created? Or do you expect that most liquid users want to enable liquid peerswap support?

erikarvstedt avatar Mar 10 '22 14:03 erikarvstedt

concept ACK for adding peerswap

Fixups

Randomly noticed that peerswap isn't mentioned in the README.

Does it make sense to enable liquid peerswaps by default when liquid is enabled?

A downside with peerswap is that it has full access to all liquidd wallets, which is something that we should mention somewhere and allow the user to explicitly opt-in to (similarly to how we note this for joinmarket in the example config).

jonasnick avatar Mar 10 '22 21:03 jonasnick

By the way, would be good to get rid of the "DO NOT USE ON MAINNET YET" warning in the peerswap README before we merge this.

jonasnick avatar Mar 12 '22 20:03 jonasnick

concept ACK for adding peerswap

Should we assign different wallet names to each implementation?

Yes

Does it make sense to enable liquid peerswaps by default when liquid is enabled? Could this be too intrusive, given that a wallet is created? Or do you expect that most liquid users want to enable liquid peerswap support?

Too intrusive in my opinion, especially because this is alpha software and it requires full access to all liquidd wallets, as @jonasnick mentioned above.

nixbitcoin avatar Apr 04 '22 11:04 nixbitcoin