You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
loop/client
Olaoluwa Osuntokun a770e3d7c1
loop: update all import paths to public repo
5 years ago
..
README.md Lightning Loop initial version 5 years ago
client.go loop: update all import paths to public repo 5 years ago
client_test.go loop: update all import paths to public repo 5 years ago
config.go loop: update all import paths to public repo 5 years ago
executor.go loop: update all import paths to public repo 5 years ago
interface.go Lightning Loop initial version 5 years ago
log.go Lightning Loop initial version 5 years ago
server_mock_test.go loop: update all import paths to public repo 5 years ago
state_type.go Lightning Loop initial version 5 years ago
store.go loop: update all import paths to public repo 5 years ago
store_interface.go Lightning Loop initial version 5 years ago
store_meta.go Lightning Loop initial version 5 years ago
store_mock_test.go loop: update all import paths to public repo 5 years ago
store_test.go loop: update all import paths to public repo 5 years ago
swap.go loop: update all import paths to public repo 5 years ago
swap_server_client.go loop: update all import paths to public repo 5 years ago
testcontext_test.go loop: update all import paths to public repo 5 years ago
uncharge.go loop: update all import paths to public repo 5 years ago
uncharge_state.go Lightning Loop initial version 5 years ago
uncharge_test.go loop: update all import paths to public repo 5 years ago
utils.go Lightning Loop initial version 5 years ago

README.md

Swaplet

Uncharge swap (off -> on-chain)

       swapcli uncharge 500   
                  |
                  |
                  v
   .-----------------------------.
   | Swap CLI                    |
   | ./cmd/swapcli               |
   |                             |
   |                             |
   |       .-------------------. |            .--------------.                   .---------------.
   |       | Swap Client (lib) | |            | LND node     |                   | Bitcoin node  |
   |       | ./                |<-------------|              |-------------------|               |
   |       |                   | |            |              |   on-chain        |               |
   |       |                   |------------->|              |   htlc            |               |
   |       |                   | | off-chain  |              |                   |               |
   |       '-------------------' | htlc       '--------------'                   '---------------'
   '-----------------|-----------'                    |                                  ^
                     |                                |                                  |
                     |                                v                                  |
                     |                              .--.                               .--.               
                     |                          _ -(    )- _                       _ -(    )- _           
                     |                     .--,(            ),--.             .--,(            ),--.      
             initiate|                 _.-(                       )-._    _.-(                       )-._ 
             swap    |                (       LIGHTNING NETWORK       )  (        BITCOIN NETWORK        )
                     |                 '-._(                     )_.-'    '-._(                     )_.-' 
                     |                      '__,(            ),__'             '__,(            ),__'     
                     |                           - ._(__)_. -                       - ._(__)_. -          
                     |                                |                                  ^
                     |                                |                                  |
                     v                                v                                  |
           .--------------------.  off-chain   .--------------.                  .---------------.
           | Swap Server        |  htlc        | LND node     |                  | Bitcoin node  |
           |                    |<-------------|              |                  |               |
           |                    |              |              |   on-chain       |               |
           |                    |              |              |   htlc           |               |
           |                    |--------------|              |----------------->|               |
           |                    |              |              |                  |               |
           '--------------------'              '--------------'                  '---------------'

Setup

LND and the swaplet are using go modules. Make sure that the GO111MODULE env variable is set to on.

In order to execute a swap, LND needs to be rebuilt with sub servers enabled.

LND

  • Checkout branch master
  • make install tags="signrpc walletrpc chainrpc" to build and install lnd with required sub-servers enabled.

  • Make sure there are no macaroons in the lnd dir ~/.lnd/data/chain/bitcoin/mainnet. If there are, lnd has been started before and in that case, it could be that admin.macaroon doesn't contain signer permission. Delete macaroons.db and *.macaroon.

    DO NOT DELETE wallet.db !

  • Start lnd

Swaplet

  • git clone git@gitlab.com:lightning-labs/swaplet.git
  • cd swaplet/cmd
  • go install ./...

Execute a swap

  • Swaps are executed by a client daemon process. Run:

    swapd

    By default swapd attempts to connect to an lnd instance running on localhost:10009 and reads the macaroon and tls certificate from ~/.lnd. This can be altered using command line flags. See swapd --help.

    swapd only listens on localhost and uses an unencrypted and unauthenticated connection.

  • To initiate a swap, run:

    swapcli uncharge <amt_msat>

    When the swap is initiated successfully, swapd will see the process through.

  • To query and track the swap status, run swapcli without arguments.

Resume

When swapd is terminated (or killed) for whatever reason, it will pickup pending swaps after a restart.

Information about pending swaps is stored persistently in the swap database. Its location is ~/.swaplet/<network>/swapclient.db.

Multiple simultaneous swaps

It is possible to execute multiple swaps simultaneously.