This repository contains the code for the server that the lastbit mobile application (v0) connects to. User records are maintained on mongodb, on-chain transactions are tracked using electrum and separate user accounts are maintained with functionality to move funds between users off-chain and pay nearby invoices for merchant scenarios.
Autopilot, Autorebalancing and allowing users to withdraw funds are experimental and should be used only in development mode.
USE AT YOUR OWN RISK ON MAINNET - There are several known issues with regards to concurrency, autopilot, autorebalance, locking funds, signing of user tokens and scaling with thousands of user invoices.
These issues have been fixed and significantly more advanced enterprise grade server is currently WIP and serves the backend for the latest application on www.lastbit.io
- Clone
npm install
- Install
bitcoind
,c-lightning
. Editconfig.js
and ensure that your bitcoind, c-lightning and mongodb parameters are correct. - Use
pm2
or your favourite node runtime to start app.js
CLAM connects to c-lightning, Blockstream's Electrum. Balance calculation logic using payment hashes and deposit addresses to track user balances is inspired from lndhub.
Allow your newly created lightning node to connect automatically to some seed nodes and start creating channels with them.
(READ THE CODE UNDER AUTOPILOT, MODIFY AND USE AT YOUR OWN RISK)
Automatically rebalance your channels with outgoing capacity to 50/50 outgoing and incoming channel capacity by using the lightning rebalance plugin
- Connect from another node and fund a max capacity channel (16777215 sats) with your node.
- Obtain the
short_channel_id
of the created channel after status isCHANNELD_NORMAL
- Run
node autorebalance <short_channel_id>