An off-chain app handling BTC <-> Solana cross-chain swaps, utilizing SolLightning-program Solana on-chain program.
Principle of operation is described in depth here (for lightning network swaps) and here (for bitcoin on-chain swaps)
This software is made to be used in conjunction with client SDK.
NOTE: This implementation is hardcoded to use bitcoin testnet3 and solana devnet, as it is still in alpha stage and is not safe to use for live systems. MAY contain bugs and uncovered edge-cases
This app starts an http rest api server on several separate ports:
- 4000: For BTCLN -> Solana swap handling
- 4001: For Solana -> BTCLN swap handling
- 4002: For BTC -> Solana swap handling
- 4003: For Solana -> BTC swap handling
Be sure to open those ports so client SDK can call the REST APIs.
- bitcoind node
- lnd node (Install instructions here)
- nodejs
- npm
- Download latest version from here or build from source
- Use the configuration file bitcoin.conf
- Run the bitcoind with the configuration file:
bitcoind -conf=<path/to/bitcoin.conf>
- Wait till bitcoind finishes with IBD (initial block download), should take no more than a few hours for testnet on a regular PC with good internet connection
- Create a new wallet in bitcoind:
bitcoin-cli -testnet -conf=<path/to/bitcoin.conf> createwallet test true false "" false false true false
- Set the configured rpc ip, port, username and password in _.env file (not necessary if you used provided bitcoin.conf)
- Download latest version from here or build from source
- Use the provided configuration file lnd.conf
- Either place the lnd.conf file in ~/.lnd/ folder or run lnd with a --configfile argument:
lnd --configfile=<path/to/lnd.conf>
- Wait for the lnd to startup. It should then ask you to create a wallet.
- Create a new wallet with:
lncli -n testnet create
- Save password you used to create a wallet to some known file (e.g. ~/lnd-pass.txt), and add
wallet-unlock-password-file=<path/to/password-file>
option to lnd.conf, like so:[Application Options] tlsextraip=127.0.0.1 wallet-unlock-password-file=path/to/password-file
- Get the certificate by
base64 --wrap=0 ~/.lnd/tls.cert
and copy the output to LN_CERT field in _.env file - Get the admin macaroon by
base64 --wrap=0 ~/.lnd/data/chain/bitcoin/testnet/admin.macaroon
and copy the output to LN_MACAROON field in _.env file - Set the ip and port in the _.env (not needed if using provided lnd.conf)
- Get the bitcoin address
lncli -n testnet newaddress p2wkh
- Get some testnet bitcoin to that address through one of the faucets:
- Connect to a well connected bitcoin lightning node, you can find the list here. Pick a node and copy its connection string (should look like so: 038863cf8ab91046230f561cd5b386cbff8309fa02e3f0c3ed161a3aeb64a643b9@203.132.94.196:9735). Then use
lncli -n testnet connect <connection string>
to connect to that node. - Open a channel with the node you connected to. Take the public key from the connection string (the part before '@', e.g.: 038863cf8ab91046230f561cd5b386cbff8309fa02e3f0c3ed161a3aeb64a643b9). Open a channel with
lncli -n testnet openchannel <node public key> <amount> <push_amount>
. Be sure to push half of your channel's balance to the other node so you can receive, e.g.lncli -n testnet openchannel <node public key> 100000 50000
- Wait for the channel to be established, you can monitor pending channels with:
lncli -n testnet pendingchannels
Instructions available here. Skip steps 2.-4. as you already have bitcoind setup and running.
- Install necessary npm packages:
npm install
- Rename _.env file to .env
- Generate a new solana keypair:
npm run genKey
- Airdrop some devnet tokens to your newly generated solana wallet:
npm run airdrop
- Create the WBTC token on devnet:
npm run createToken
- Mint some WBTC token to your new keypair:
npm run mint <amount to mint in satoshis>
- You can also mint some WBTC tokens to your phantom wallet:
npm run mint <amount to mint in satoshis> <wallet address>
- Deposit your WBTC to the program
npm run deposit <amount to deposit in satoshis>
- Be sure that bitcoind, lnd and btcrelay are running before starting the app.
- Run the app with:
npm start