Immortan is a minimal, privacy-focused, opinionated LN protocol implementation aimed to specifically power lite LN nodes which are mostly to be found on mobile phones or desktop computers and only run private channels.
Immortan is not based on Éclair and is not an Éclair fork. It's a standalone implementation, much smaller, written from scratch with standalone and independent logic. However it does use codecs and type definitions carefully copied and pasted from the Éclair codebase.
Existing implementations are of general purpose, that is, they neither address specific complications of running LN nodes on constrained devices nor explore various advantages unique to these setups. Here are some highlights:
-
Security. Lite nodes can not properly validate a public routing graph since that would require a direct access to local, non-pruning, tx-indexed bitcoind instance which they by definition don't have. Current popular approach of naively accepting any data without validation is prone to spam attacks, destroyed privacy and overblown payment fees. Immortan's answer is to obtain graph data from multiple random nodes at once and then select the most probable candidates based on majority vote, thus minimizing a possibility of attacks.
-
Privacy. Lite nodes need not have any
nodeId
at all which is only required for validation of public channels and otherwise degrades privacy by making node's channels and invoices linkable. Immortan uses randomnodeId
s whenever possible (when making invoices, synchronizing graph, etc) as well as separatenodeId
s for each peer a node has channels with, thus making it seen as a different remote node by each of its peers. -
Resilience. Preserving channels from getting force-closed is a top priority so IMMORTAN never force-closes channels with locally-originated expired HTLCs as well as with dusty routed HTLCs. It also rejects routing attempts early in unfavorable conditions, such as too high chain fees with too low remaining channel balances. Generally local channels are only force-closed automatically in a handful of terminal cases while in all other situations a decision whether to force-close or try to repair a channel is handed over to user.
-
Routing. Lite nodes can have much more powerful MPP and pathfinding algorithms when compared to full nodes exactly because they are not supposed to run thousands of channels by design. Immortan makes a compromise here by running all local channels within a single thread and thus obtaining a far greater degree of control over the dynamics of multipart payment, which in turn results in more successful deliveries.
-
Liquidity via hosted channels. IMMORTAN provides an implementation of private hosted channels which enables private and auditable custodians on the Lightning Network.
Install it by adding to your build.sbt
:
libraryDependencies += "com.fiatjaf" %% "immortan" % "0.7.8"
Then you must
- Import the
LNParams
object which will be the main interface between your code and Immortan. - Implement some database traits (or copy the implementation from SBW as it was done in Cliché by Ilya -- see also Cliché's DB.scala for the final touch).
- Instantiate a
PathFinder
, which will take care of syncing Lightning gossip data and later sending out payments. - Fill in
.connectionProvider
,.logBag
,.chainHash
,.ourInit
,.syncParams
,.secret
,.feeRates
,.fiatRates
,.cm
and.chainWallets
; - Instantiate
ElectrumClientPool
,ElectrumChainSync
,ElectrumWatcher
andWalletEventsCatcher
;
See Cliché's Main.scala for a mostly clean implementation of all of the above.
After that you should be able to easily
- Load onchain wallets, listen for transactions and make transactions.
- Open normal channels;
- Open hosted channels;
- Listen for outgoing Lightning payments status changes;
- Listen for incoming Lightning payments status changes;
- Create Lightning invoices;
- Send Lightning payments.
Again, Cliché's Commands.scala
has some implementations you might be able to understand and copy (the listeners are in Main.scala).
Or maybe start here at LNParams.
- The Open Bitcoin Wallet, an SBW fork with improved openness
- Cliché, a lightweight node daemon to be embedded into applications
- The seamless hosted fiat channels provider StandardSats wallet
- Simple Bitcoin Wallet, the wallet that started it all, now abandoned