Skip to content

Commit

Permalink
Merge pull request #53 from getAlby/feat/alby-ldk-0.4.1
Browse files Browse the repository at this point in the history
Update to LDK 0.4.2
  • Loading branch information
rolznz authored Nov 4, 2024
2 parents 9c1e2aa + 0c70be7 commit 7cb44ce
Show file tree
Hide file tree
Showing 59 changed files with 8,548 additions and 3,567 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,34 @@ jobs:
cargo update -p proptest --precise "1.2.0" --verbose # proptest 1.3.0 requires rustc 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p url --precise "2.5.0" --verbose # url v2.5.1 requires rustc 1.67 or newer
cargo update -p tokio --precise "1.38.1" --verbose # tokio v1.39.0 requires rustc 1.70 or newer
cargo update -p tokio-util --precise "0.7.11" --verbose # tokio-util v0.7.12 requires rustc 1.70 or newer
- name: Set RUSTFLAGS to deny warnings
if: "matrix.toolchain == 'stable'"
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
- name: Download bitcoind/electrs and set environment variables
if: "matrix.platform != 'windows-latest'"
- name: Enable caching for bitcoind
id: cache-bitcoind
uses: actions/cache@v4
with:
path: bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
key: bitcoind-${{ runner.os }}-${{ runner.arch }}
- name: Enable caching for electrs
id: cache-electrs
uses: actions/cache@v4
with:
path: bin/electrs-${{ runner.os }}-${{ runner.arch }}
key: electrs-${{ runner.os }}-${{ runner.arch }}
- name: Download bitcoind/electrs
if: "matrix.platform != 'windows-latest' && (steps.cache-bitcoind.outputs.cache-hit != 'true' || steps.cache-electrs.outputs.cache-hit != 'true')"
run: |
source ./scripts/download_bitcoind_electrs.sh
cp "$BITCOIND_EXE" "$HOME"/bitcoind
cp "$ELECTRS_EXE" "$HOME"/electrs
echo "BITCOIND_EXE=$HOME/bitcoind" >> "$GITHUB_ENV"
echo "ELECTRS_EXE=$HOME/electrs" >> "$GITHUB_ENV"
mkdir bin
mv "$BITCOIND_EXE" bin/bitcoind-${{ runner.os }}-${{ runner.arch }}
mv "$ELECTRS_EXE" bin/electrs-${{ runner.os }}-${{ runner.arch }}
- name: Set bitcoind/electrs environment variables
run: |
echo "BITCOIND_EXE=$( pwd )/bin/bitcoind-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
echo "ELECTRS_EXE=$( pwd )/bin/electrs-${{ runner.os }}-${{ runner.arch }}" >> "$GITHUB_ENV"
- name: Build on Rust ${{ matrix.toolchain }}
run: cargo build --verbose --color always
- name: Build with UniFFI support on Rust ${{ matrix.toolchain }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/vss-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ jobs:
./gradlew --version
./gradlew build
docker cp app/build/libs/app-1.0.war tomcat:/usr/local/tomcat/webapps/vss.war
docker cp app/build/libs/vss-1.0.war tomcat:/usr/local/tomcat/webapps/vss.war
cd ../
- name: Run VSS Integration tests against vss-instance.
run: |
cd ldk-node
export TEST_VSS_BASE_URL="http://localhost:8080/vss"
RUSTFLAGS="--cfg vss_test --cfg vss" cargo build --verbose --color always
RUSTFLAGS="--cfg vss_test --cfg vss" cargo test --test integration_tests_vss
RUSTFLAGS="--cfg vss_test" cargo build --verbose --color always
RUSTFLAGS="--cfg vss_test" cargo test --test integration_tests_vss
- name: Cleanup
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/bindings/uniffi-bindgen/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand All @@ -24,5 +25,7 @@ swift.swiftdoc
/bindings/swift/LDKNodeFFI.xcframework
/bindings/kotlin/ldk-node-android/lib/src/main/jniLibs
/bindings/kotlin/ldk-node-android/lib/src/main/kotlin/org/lightningdevkit/ldknode/ldk_node.kt
/bindings/kotlin/ldk-node-jvm/lib/src/main/kotlin/org/lightningdevkit/ldknode/ldk_node.kt
/bindings/kotlin/ldk-node-jvm/lib/src/main/resources/

/ffi/
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
# 0.4.2 - Oct 28, 2024

This patch release fixes an issue that prohibited the node from using available confirmed on-chain funds to spend/bump Anchor outputs (#387).

In total, this release features 1 files changed, 40 insertions, 4 deletions in 3 commits from 3 authors, in alphabetical order:

- Fuyin
- Elias Rohrer


# 0.4.1 - Oct 18, 2024

This patch release fixes a wallet syncing issue where full syncs were used instead of incremental syncs, and vice versa (#383).

In total, this release features 3 files changed, 13 insertions, 9 deletions in 6 commits from 3 authors, in alphabetical order:

- Jeffrey Czyz
- Elias Rohrer
- Tommy Volk

# 0.4.0 - Oct 17, 2024

Besides numerous API improvements and bugfixes this fourth minor release notably adds support for sourcing chain and fee rate data from a Bitcoin Core RPC backend, as well as experimental support for the [VSS] remote storage backend.

## Feature and API updates
- Support for multiple chain sources has been added. To this end, Esplora-specific configuration options can now be given via `EsploraSyncConfig` to `Builder::set_chain_source_esplora`. Furthermore, all configuration objects (including the main `Config`) is now exposed via the `config` sub-module (#365).
- Support for sourcing chain and fee estimation data from a Bitcoin Core RPC backed has been added (#370).
- Initial experimental support for an encrypted [VSS] remote storage backend has been added (#369, #376, #378).
- **Caution**: VSS support is in **alpha** and is considered experimental. Using VSS (or any remote persistence) may cause LDK to panic if persistence failures are unrecoverable, i.e., if they remain unresolved after internal retries are exhausted.
- Support for setting the `NodeAlias` in public node announcements as been added. We now ensure that announced channels can only be opened and accepted when the required configuration options to operate as a public forwarding node are set (listening addresses and node alias). As part of this `Node::connect_open_channel` was split into `open_channel` and `open_announced_channel` API methods. (#330, #366).
- The `Node` can now be started via a new `Node::start_with_runtime` call that allows to reuse an outer `tokio` runtime context, avoiding runtime stacking when run in `async` environments (#319).
- Support for generating and paying unified QR codes has been added (#302).
- Support for `quantity` and `payer_note` fields when sending or receiving BOLT12 payments has been added (#327).
- Support for setting additional parameters when sending BOLT11 payments has been added (#336, #351).

## Bug Fixes
- The `ChannelConfig` object has been refactored, now allowing to query the currently applied `MaxDustHTLCExposure` limit (#350).
- A bug potentially leading to panicking on shutdown when stacking `tokio` runtime contexts has been fixed (#373).
- We now no longer panic when hitting a persistence failure during event handling. Instead, events will be replayed until successful (#374).
,
## Compatibility Notes
- The LDK dependency has been updated to version 0.0.125 (#358, #375).
- The BDK dependency has been updated to version 1.0-beta.4 (#358).
- Going forward, the BDK state will be persisted in the configured `KVStore` backend.
- **Note**: The old descriptor state will *not* be automatically migrated on upgrade, potentially leading to address reuse. Privacy-concious users might want to manually advance the descriptor by requesting new addresses until it reaches the previously observed height.
- After the node as been successfully upgraded users may safely delete `bdk_wallet_*.sqlite` from the storage path.
- The `rust-bitcoin` dependency has been updated to version 0.32.2 (#358).
- The UniFFI dependency has been updated to version 0.27.3 (#379).
- The `bip21` dependency has been updated to version 0.5 (#358).
- The `rust-esplora-client` has been updated to version 0.9 (#358).

In total, this release features 55 files changed, 6134 insertions, 2184 deletions in 166 commits from 6 authors, in alphabetical order:

- G8XSU
- Ian Slane
- jbesraa
- Elias Rohrer
- elnosh
- Enigbe Ochekliye

[VSS]: https://github.com/lightningdevkit/vss-server/blob/main/README.md

# 0.3.0 - June 21, 2024

This third minor release notably adds support for BOLT12 payments, Anchor
Expand Down
83 changes: 60 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ldk-node"
version = "0.3.0"
version = "0.4.2"
authors = ["Elias Rohrer <dev@tnull.de>"]
homepage = "https://lightningdevkit.org/"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -28,51 +28,78 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.123", features = ["std"] }
lightning-invoice = { version = "0.31.0" }
lightning-net-tokio = { version = "0.0.123" }
lightning-persister = { version = "0.0.123" }
lightning-background-processor = { version = "0.0.123", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.123" }
lightning-transaction-sync = { version = "0.0.123", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "=0.1.0-alpha.4", features = ["std"] }

lightning = { version = "0.0.125", features = ["std"] }
lightning-invoice = { version = "0.32.0" }
lightning-net-tokio = { version = "0.0.125" }
lightning-persister = { version = "0.0.125" }
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.125" }
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std"] }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["futures"] }
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["esplora-async"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }

bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}

# TODO: re-enable
# Alby uses forked BDK version with CACHE_ADDR_BATCH_SIZE=1 to reduce unnecessary esplora calls and speed up wallet sync
bdk = { git = "https://github.com/getAlby/bdk.git", branch = "0.29-alby-v2", default-features = false, features = ["std", "async-interface", "use-esplora-async", "sqlite-bundled", "keys-bip39"]}
#bdk = { version = "0.29.0", default-features = false, features = ["std", "async-interface", "use-esplora-async", "sqlite-bundled", "keys-bip39"]}
#bdk = { git = "https://github.com/getAlby/bdk.git", branch = "0.29-alby-v2", default-features = false, features = ["std", "async-interface", "use-esplora-async", "sqlite-bundled", "keys-bip39"]}


reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
rusqlite = { version = "0.28.0", features = ["bundled"] }
bitcoin = "0.30.2"
bitcoin = "0.32.2"
bip39 = "2.0.0"
bip21 = { version = "0.5", features = ["std"], default-features = false }

base64 = { version = "0.22.1", default-features = false, features = ["std"] }
rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync" ] }
esplora-client = { version = "0.6", default-features = false }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.9", default-features = false }
libc = "0.2"
uniffi = { version = "0.25.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
serde_json = { version = "1.0.128", default-features = false, features = ["std"] }

[target.'cfg(vss)'.dependencies]
vss-client = "0.2"
vss-client = "0.3"
prost = { version = "0.11.6", default-features = false}

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.123", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/tnull/rust-lightning", branch = "2024-03-invoice-generated-event", features = ["std", "_test_utils"] }
electrum-client = { version = "0.15.1", default-features = true }
bitcoincore-rpc = { version = "0.17.0", default-features = false }
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.26.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.26.0", features = ["legacy"] }
electrsd = { version = "0.29.0", features = ["legacy"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand All @@ -87,3 +114,13 @@ rpath = true

[profile.dev]
panic = "abort"

[lints.rust.unexpected_cfgs]
level = "forbid"
# When adding a new cfg attribute, ensure that it is added to this list.
check-cfg = [
"cfg(vss_test)",
"cfg(ldk_bench)",
"cfg(tokio_unstable)",
"cfg(cln_test)",
]
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import PackageDescription

let tag = "v0.3.0"
let checksum = "07c8741768956bf1a51d1c25f751b5e29d1ae9ee2fd786c4282031c9a8a92f0c"
let tag = "v0.4.2"
let checksum = "95ea5307eb3a99203e39cfa21d962bfe3e879e62429e8c7cdf5292cae5dc35cc"
let url = "https://github.com/lightningdevkit/ldk-node/releases/download/\(tag)/LDKNodeFFI.xcframework.zip"

let package = Package(
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A ready-to-go Lightning node library built using [LDK][ldk] and [BDK][bdk].
LDK Node is a self-custodial Lightning node in library form. Its central goal is to provide a small, simple, and straightforward interface that enables users to easily set up and run a Lightning node with an integrated on-chain wallet. While minimalism is at its core, LDK Node aims to be sufficiently modular and configurable to be useful for a variety of use cases.

## Getting Started
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `connect_open_channel`, `send`, etc.
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `open_channel`, `send`, etc.

```rust
use ldk_node::Builder;
Expand All @@ -24,7 +24,7 @@ use std::str::FromStr;
fn main() {
let mut builder = Builder::new();
builder.set_network(Network::Testnet);
builder.set_esplora_server("https://blockstream.info/testnet/api".to_string());
builder.set_chain_source_esplora("https://blockstream.info/testnet/api".to_string(), None);
builder.set_gossip_source_rgs("https://rapidsync.lightningdevkit.org/testnet/snapshot".to_string());

let node = builder.build().unwrap();
Expand All @@ -37,7 +37,7 @@ fn main() {

let node_id = PublicKey::from_str("NODE_ID").unwrap();
let node_addr = SocketAddress::from_str("IP_ADDR:PORT").unwrap();
node.connect_open_channel(node_id, node_addr, 10000, None, None, false).unwrap();
node.open_channel(node_id, node_addr, 10000, None, None).unwrap();

let event = node.wait_next_event();
println!("EVENT: {:?}", event);
Expand All @@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from an [Esplora][esplora] server, while support for Electrum and `bitcoind` RPC will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Wallet and channel state may be persisted to an [SQLite][sqlite] database, to file system, or to a custom back-end to be implemented by the user.
- Gossip data may be sourced via Lightning's peer-to-peer network or the [Rapid Gossip Sync](https://docs.rs/lightning-rapid-gossip-sync/*/lightning_rapid_gossip_sync/) protocol.
- Entropy for the Lightning and on-chain wallets may be sourced from raw bytes or a [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) mnemonic. In addition, LDK Node offers the means to generate and persist the entropy bytes to disk.
Expand Down
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
libraryVersion=0.3.0
libraryVersion=0.4.2
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-android/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
}

android {
compileSdk = 33
compileSdk = 34

defaultConfig {
minSdk = 21
Expand Down
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-jvm/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
libraryVersion=0.3.0
libraryVersion=0.4.2
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ class LibraryTest {
println("Config 2: $config2")

val builder1 = Builder.fromConfig(config1)
builder1.setEsploraServer(esploraEndpoint)
builder1.setChainSourceEsplora(esploraEndpoint, null)
val builder2 = Builder.fromConfig(config2)
builder2.setEsploraServer(esploraEndpoint)
builder2.setChainSourceEsplora(esploraEndpoint, null)

val node1 = builder1.build()
val node2 = builder2.build()
Expand Down Expand Up @@ -175,7 +175,7 @@ class LibraryTest {
assertEquals(100000uL, totalBalance1)
assertEquals(100000uL, totalBalance2)

node1.connectOpenChannel(nodeId2, listenAddress2, 50000u, null, null, true)
node1.openChannel(nodeId2, listenAddress2, 50000u, null, null)

val channelPendingEvent1 = node1.waitNextEvent()
println("Got event: $channelPendingEvent1")
Expand Down Expand Up @@ -224,7 +224,7 @@ class LibraryTest {

val invoice = node2.bolt11Payment().receive(2500000u, "asdf", 9217u)

node1.bolt11Payment().send(invoice)
node1.bolt11Payment().send(invoice, null)

val paymentSuccessfulEvent = node1.waitNextEvent()
println("Got event: $paymentSuccessfulEvent")
Expand Down
Loading

0 comments on commit 7cb44ce

Please sign in to comment.