Skip to content

Commit 856c768

Browse files
committed
feat(cbf): add BIP 157 compact block filter chain source
Squashed base CBF commits (rebased onto upstream/main): - Add optional fee source from esplora/electrum - Add BIP 157 compact block filter chain source - Add CBF integration tests and documentation - Fix CBF chain source build errors and UniFFI bindings - Remove last_synced_height from cbf
1 parent fadc74f commit 856c768

24 files changed

Lines changed: 2061 additions & 255 deletions

.github/workflows/python.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ jobs:
1717
- name: Checkout repository
1818
uses: actions/checkout@v4
1919

20-
- name: Install uv
21-
uses: astral-sh/setup-uv@v7
20+
- name: Setup Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
2224

2325
- name: Generate Python bindings
2426
run: ./scripts/uniffi_bindgen_generate_python.sh
2527

2628
- name: Start bitcoind and electrs
2729
run: docker compose up -d
2830

31+
- name: Install testing prerequisites
32+
run: |
33+
pip3 install requests
34+
2935
- name: Run Python unit tests
3036
env:
3137
BITCOIN_CLI_BIN: "docker exec ldk-node-bitcoin-1 bitcoin-cli"
@@ -34,4 +40,4 @@ jobs:
3440
ESPLORA_ENDPOINT: "http://127.0.0.1:3002"
3541
run: |
3642
cd $LDK_NODE_PYTHON_DIR
37-
uv run --group dev python -m unittest discover -s src/ldk_node
43+
python3 -m unittest discover -s src/ldk_node

.github/workflows/rust.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ jobs:
4141
- name: Check formatting on Rust ${{ matrix.toolchain }}
4242
if: matrix.check-fmt
4343
run: rustup component add rustfmt && cargo fmt --all -- --check
44-
- name: Pin packages to allow for MSRV
45-
if: matrix.msrv
46-
run: |
47-
cargo update -p idna_adapter --precise "1.2.0" --verbose # idna_adapter 1.2.1 uses ICU4X 2.2.0, requiring 1.86 and newer
4844
- name: Set RUSTFLAGS to deny warnings
4945
if: "matrix.toolchain == 'stable'"
5046
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
@@ -84,7 +80,11 @@ jobs:
8480
- name: Test on Rust ${{ matrix.toolchain }}
8581
if: "matrix.platform != 'windows-latest'"
8682
run: |
87-
RUSTFLAGS="--cfg no_download --cfg cycle_tests" cargo test
83+
RUSTFLAGS="--cfg no_download --cfg cycle_tests" cargo test -- --skip cbf
84+
- name: Test CBF on Rust ${{ matrix.toolchain }}
85+
if: "matrix.platform != 'windows-latest'"
86+
run: |
87+
RUSTFLAGS="--cfg no_download --cfg cycle_tests" cargo test cbf -- --test-threads=1
8888
- name: Test with UniFFI support on Rust ${{ matrix.toolchain }}
8989
if: "matrix.platform != 'windows-latest' && matrix.build-uniffi"
9090
run: |

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning",
5454
bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
5555
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
5656
bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"]}
57+
bip157 = { version = "0.4.2", default-features = false }
5758
bdk_wallet = { version = "2.3.0", default-features = false, features = ["std", "keys-bip39"]}
5859

5960
bitreq = { version = "0.3", default-features = false, features = ["async-https", "json-using-serde"] }
@@ -66,7 +67,7 @@ bip21 = { version = "0.5", features = ["std"], default-features = false }
6667
base64 = { version = "0.22.1", default-features = false, features = ["std"] }
6768
getrandom = { version = "0.3", default-features = false }
6869
chrono = { version = "0.4", default-features = false, features = ["clock"] }
69-
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros", "net" ] }
70+
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
7071
esplora-client = { version = "0.12", default-features = false, features = ["tokio", "async-https-rustls"] }
7172
electrum-client = { version = "0.24.0", default-features = false, features = ["proxy", "use-rustls-ring"] }
7273
libc = "0.2"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn main() {
6161
LDK Node currently comes with a decidedly opinionated set of design choices:
6262

6363
- On-chain data is handled by the integrated [BDK][bdk] wallet.
64-
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
64+
- Chain data may currently be sourced from the Bitcoin Core RPC interface, from an [Electrum][electrum] or [Esplora][esplora] server, or via [compact block filters (BIP 157)][bip157].
6565
- 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.
6666
- 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.
6767
- 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.
@@ -80,6 +80,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.85.0.
8080
[bdk]: https://bitcoindevkit.org/
8181
[electrum]: https://github.com/spesmilo/electrum-protocol
8282
[esplora]: https://github.com/Blockstream/esplora
83+
[bip157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki
8384
[sqlite]: https://sqlite.org/
8485
[rust]: https://www.rust-lang.org/
8586
[swift]: https://www.swift.org/

bindings/ldk_node.udl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ typedef dictionary EsploraSyncConfig;
99

1010
typedef dictionary ElectrumSyncConfig;
1111

12+
typedef dictionary CbfSyncConfig;
13+
1214
typedef dictionary TorConfig;
1315

1416
typedef interface NodeEntropy;
@@ -38,6 +40,7 @@ interface Builder {
3840
constructor(Config config);
3941
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
4042
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
43+
void set_chain_source_cbf(sequence<string> peers, CbfSyncConfig? sync_config, FeeSourceConfig? fee_source_config);
4144
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
4245
void set_chain_source_bitcoind_rest(string rest_host, u16 rest_port, string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
4346
void set_gossip_source_p2p();
@@ -354,6 +357,8 @@ enum Currency {
354357

355358
typedef enum AsyncPaymentsRole;
356359

360+
typedef enum FeeSourceConfig;
361+
357362
[Custom]
358363
typedef string Txid;
359364

bindings/python/hatch_build.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

bindings/python/pyproject.toml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
[build-system]
2-
requires = ["hatchling"]
3-
build-backend = "hatchling.build"
4-
51
[project]
62
name = "ldk_node"
73
version = "0.7.0"
84
authors = [
95
{ name="Elias Rohrer", email="dev@tnull.de" },
106
]
117
description = "A ready-to-go Lightning node library built using LDK and BDK."
12-
readme = "../../README.md"
13-
requires-python = ">=3.8"
8+
readme = "README.md"
9+
requires-python = ">=3.6"
1410
classifiers = [
1511
"Topic :: Software Development :: Libraries",
1612
"Topic :: Security :: Cryptography",
@@ -23,11 +19,3 @@ classifiers = [
2319
"Homepage" = "https://lightningdevkit.org/"
2420
"Github" = "https://github.com/lightningdevkit/ldk-node"
2521
"Bug Tracker" = "https://github.com/lightningdevkit/ldk-node/issues"
26-
27-
[dependency-groups]
28-
dev = ["requests"]
29-
30-
[tool.hatch.build.targets.wheel]
31-
packages = ["src/ldk_node"]
32-
33-
[tool.hatch.build.hooks.custom]

bindings/python/setup.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[options]
2+
packages = find:
3+
package_dir =
4+
= src
5+
include_package_data = True
6+
7+
[options.packages.find]
8+
where = src
9+
10+
[options.package_data]
11+
ldk_node =
12+
*.so
13+
*.dylib

scripts/python_build_wheel.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

scripts/python_create_package.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
cd bindings/python || exit 1
3+
python3 -m build

0 commit comments

Comments
 (0)