No description
Find a file
2023-05-04 10:00:07 +02:00
.github chore: Include Sigstore Cosign signing in release workflow 2023-05-04 00:28:42 +02:00
docs README: add architecture description for onion messages 2023-03-08 10:39:12 -05:00
src Use listpeers to check onion message support rather than graph lookup 2023-04-21 16:19:22 -04:00
.gitignore gitignore: add target and cargo lock 2023-02-07 09:24:39 -05:00
build.rs use configure_me crate to manage argument parsing 2023-04-06 16:06:18 +01:00
Cargo.toml chore: Add release hook for CHANGELOG generation 2023-05-04 10:00:07 +02:00
cliff.toml chore: Add release hook for CHANGELOG generation 2023-05-04 10:00:07 +02:00
code_of_conduct.md docs: add contributor covenant code of conduct v2.1 2023-04-04 14:46:12 +02:00
config_spec.toml use configure_me crate to manage argument parsing 2023-04-06 16:06:18 +01:00
CONTRIBUTING.md Add crev note and security audit GH Action for PRs 2023-04-24 12:40:51 +02:00
LICENSE Initial commit 2023-02-07 09:21:10 -05:00
MAINTAINERS.md chore: Add MAINTAINERS.md with release process 2023-05-04 10:00:04 +02:00
README.md Add crev note and security audit GH Action for PRs 2023-04-24 12:40:51 +02:00

LNDK

An experimental attempt at using LDK to implement bolt 12 features for LND.

Setting up LNDK

To run LNDK, LND is assumed to be running. For directions on how to do this, try this guide.

When compiling LND, make sure that the peersrpc and signerrpc services are enabled, like this:

make install --tags="peersrpc signerrpc dev"

LND must also be run with --protocol.custom-message=513 to allow it to report onion messages to LNDK, which requires LND version v0.16.0-beta).

In order to successfully connect to LND, we need to pass in the grpc address and authentication credentials. These values can be passed in via the command line when running the LNDK program, like this:

  • cargo run -- --address=<ADDRESS> --cert=<TLSPATH> --macaroon=<MACAROONPATH>

In a more concrete example:

cargo run -- --address=https://localhost:10009 --cert=/home/<USERNAME>/.lnd/tls.cert --macaroon=/home/<USERNAME>/.lnd/data/chain/bitcoin/regtest/admin.macaroon

Remember that the grpc address must start with https:// for the program to work.

  • Alternatively, you can use a configuration file to add the required arguments.
  • In the lndk directory, create fle named lndk.conf.
  • Add the following lines to the file
    • address="https://localhost:10009"
    • cert="/home/<USERNAME>/.lnd/tls.cert"
    • macaroon="/home/<USERNAME>/.lnd/data/chain/bitcoin/regtest/admin.macaroon"
  • Run cargo run -- --conf lndk.conf
  • Use any of the commands with the --help option for more information about each argument.

Architecture

There are three components relevant to our architecture:

  1. LDK: imported as a dependency to provide onion message processing and forwarding capabilities.
  2. LND: the grpc API that is exposed by the target LND node built with the appropriate rpc subservers.
  3. LNDK: a thin rust shim that connects to LND's API (via grpc), acting as a shim that connects LND's APIs to LDK's functionality and providing input/output to the LND node.

The use of LND's flexible API and LDK's modular lightning library allows us to re-use the bolt 12 implementation in LDK. LNDK itself is intended to act as a simple shim that facilitates communication between LND and the LDK library - wrapping API calls in trait implementations for LDK, converting types and passing messages between the LDK state machine and LND's APIs.

So, basically, Frankeinstein's monster. With extra steps.

Onion Messages

Onion messaging is implemented using by implementing a custom version of LDK's OnionMessenger that can use LND's node key to process onion messages. This is achieved by implementing the NodeSigner trait, making relevant calls to LND's signerrpc API to perform ECDH ops with the node's private key. All other components can use the built-in options available in LDK.

Onion messenger

Once we have an OnionMessenger that can process messages on behalf of the LND node, we need to handle events that are relevant to the messenger.

  1. SubscribePeerEvents: subscribe to peer events and notify the OnionMessenger of peer_connected and peer_disconnected events.
  2. SubscribeCustomMessages: receive incoming onion messages from LND and deliver them to the OnionMessenger via handle_onion_message
  3. SendCustomMessage: poll the OnionMessenger for next_onion_message_for_peer and deliver queued outbound onion messages to LND for sending.

Onion message processing

NOTE: It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies, including this one.