# Running a sample LDK node
Let's run our first LDK node. We'll ensure we have a compatible Rust toolchain installed, setup Polar to create a local Lightning network and then start running the node.
Not recommended for production use!
This guide is a quick start to get you up and running with an LDK node. It serves as a playground and a foundation to build upon and is NOT recommended for production environments. LDK doesn't come with a pre-packaged node but gives you the tools to build a node from scratch!
# Installing Rust
If you already have a working installation of the latest Rust compiler, feel free to skip to the next section.
To install the latest version of Rust, we recommend using
rustup by following the instructions on its website (opens new window). Once
rustup is installed, ensure the latest toolchain is installed by running the command:
rustup default stable
# Setup Polar
Next, let's setup Polar, which was built to help Lightning Network application developers quickly spin up one or more networks locally on their computers in regtest mode.
Mac and Windows users will need to install Docker Desktop (opens new window) as a dependency before using Polar. Linux users will need to download both Docker Server (opens new window) and Docker Compose (opens new window).
After downloading, installing, and running Polar, spin up a new cluster of LND, Core Lightning, eclair, and bitcoind nodes. This will create a Docker container within which Polar will operate.
Click the orange Create Network button and Polar should display a new interface.
Press the orange Start button in the top right corner to start your local network. It takes a couple seconds for the nodes to boot up, but the indicator lights will eventually turn green signaling that the process has completed.
# Running the LDK Sample Node
Start by cloning the LDK sample node from Github and changing into the new directory
git clone https://github.com/lightningdevkit/ldk-sample cd ldk-sample
Now, run the following command:
cargo run polaruser:firstname.lastname@example.org:18443 ./ 9732 regtest hellolightning 0.0.0.0:9732
If you have a different setup that doesn't involve Polar you can modify this command so that it contains different credentials.
cargo run <bitcoind-rpc-username>:<bitcoind-rpc-password>@<bitcoind-rpc-host>:<bitcoind-rpc-port> <ldk_storage_directory_path> [<ldk-peer-listening-port>] [<bitcoin-network>] [<announced-node-name>] [<announced-listen-addr>]
bitcoind's RPC username and password likely can be found through
bitcoin-network: defaults to
ldk-peer-listening-port: defaults to 9735.
announced-listen-addr : default to nothing, disabling any public announcements of this node.
announced-node-name: can be any string up to 32 bytes in length, representing this node's alias.
announced-listen-addr: can be set to an IPv4 or IPv6 address to announce that as a publicly-connectable address for this node.
Your LDK node should now be in action!
LDK startup successful. To view available commands: "help". LDK logs are available at <your-supplied-ldk-data-dir-path>/.ldk/logs Local Node ID is 02e8788eb41ac1731352d87ced719afce91a1201cf0d6cca12ee79502db1b0e317.
If you want to connect to another node you created with Polar select the node there. In the Connect tab you can copy the
P2P External connection info. Running
connectpeer with that will get you connected.
To check out the complete reference for constructing a Lightning node with LDK check out the Github repo (opens new window)