Module ln
Expand description
Implementations of various parts of the Lightning protocol are in this module.
Modules§
- chan_
utils - Various utilities for building scripts related to channels. These are
largely of interest for those implementing the traits on
crate::sign
by hand. - channel_
keys - Keys used to generate commitment transactions. See: https://github.com/lightning/bolts/blob/master/03-transactions.md#keys
- channelmanager
- The top-level channel management and payment tracking stuff lives here.
- features
- Feature flag definitions for the Lightning protocol according to BOLT #9.
- functional_
test_ utils - A bunch of useful utilities for building networks of nodes and exchanging messages between nodes for functional tests.
- inbound_
payment - Utilities to generate inbound payment information in service of invoice creation.
- msgs
- Wire messages, traits representing wire message handlers, and a few error types live here.
- onion_
payment - Utilities to decode payment onions and do contextless validation of incoming payments.
- peer_
handler - Top level peer message handling and socket handling logic lives here.
- script
- Abstractions for scripts used in the Lightning Network.
- types
- Various wrapper types (most around 32-byte arrays) for use in lightning.
- wire
- Wire encoding/decoding for Lightning messages according to BOLT #1, and for
custom message through the
CustomMessageReader
trait.
Structs§
- Channel
Id - A unique 32-byte identifier for a channel. Depending on how the ID is generated, several varieties are distinguished (but all are stored as 32 bytes): v1 and temporary. A v1 channel ID is generated based on funding tx outpoint (txid & index). A temporary ID is generated randomly. (Later revocation-point-based v2 is a possibility.) The variety (context) is not stored, it is relevant only at creation.
- Payment
Hash - The payment hash is the hash of the
PaymentPreimage
which is the value used to lock funds in HTLCs while they transit the lightning network. - Payment
Preimage - The payment preimage is the “secret key” which is used to claim the funds of an HTLC on-chain or in a lightning channel.
- Payment
Secret - The payment secret is used to authenticate the sender of an HTLC to the recipient and tie multi-part HTLCs together into a single payment.
Constants§
- LN_
MAX_ MSG_ LEN - Maximum Lightning message data length according to BOLT-8 and BOLT-1:
Functions§
- create_
payment_ onion - Build a payment onion, returning the first hop msat and cltv values as well.
cur_block_height
should be set to the best known block height + 1.