Skip to content

Commit 23368f5

Browse files
committed
Add subcrate which impls a simple SPV client from Bitcoin Core RPC
This adds a new subcrate `lightning-block-sync` which is designed to make it easier to get up-and-running by removing the effort of building an SPV client and fetching the chain. Instead of building a P2P client (and all the address management that entails), this focuses on building a trivial SPV client which can fetch from several instances of an abstract BlockSource. Then, we provide two example BlockSource implementations that can fetch from Bitcoin Core's RPC interface and Bitcoin Core's REST interface. The code here is taken with heavy modifications from rust-lightning-bitcoinrpc.
1 parent eec4beb commit 23368f5

File tree

6 files changed

+1411
-1
lines changed

6 files changed

+1411
-1
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
1.22.0,
1313
# 1.34.2 is Debian stable
1414
1.34.2,
15-
# 1.39.0 is MSRV for lightning-net-tokio and generates coverage
15+
# 1.39.0 is MSRV for lightning-net-tokio and lightning-block-sync and generates coverage
1616
1.39.0]
1717
include:
1818
- toolchain: stable
@@ -38,6 +38,15 @@ jobs:
3838
- name: Build on Rust ${{ matrix.toolchain }}
3939
if: "! matrix.build-net-tokio"
4040
run: RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always -p lightning
41+
- name: Build Block Sync Clients on Rust ${{ matrix.toolchain }} with features
42+
if: matrix.build-net-tokio
43+
run: |
44+
cd lightning-block-sync
45+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rest-client
46+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client
47+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client
48+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client,tokio
49+
cd ..
4150
- name: Test on Rust ${{ matrix.toolchain }} with net-tokio
4251
if: matrix.build-net-tokio
4352
run: RUSTFLAGS="-C link-dead-code" cargo test --verbose --color always

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
members = [
44
"lightning",
55
"lightning-net-tokio",
6+
"lightning-block-sync",
67
]
78

89
# Our tests do actual crypo and lots of work, the tradeoff for -O1 is well worth it

lightning-block-sync/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "lightning-block-sync"
3+
version = "0.0.1"
4+
authors = ["Matt Corallo"]
5+
license = "Apache-2.0"
6+
edition = "2018"
7+
description = """
8+
Utilities to fetch the chain from Bitcoin Core REST/RPC Interfaces and feed them into Rust Lightning.
9+
"""
10+
11+
[features]
12+
rest-client = [ "serde", "serde_json", "serde_derive" ]
13+
rpc-client = [ "serde", "serde_json", "serde_derive", "base64" ]
14+
15+
[dependencies]
16+
bitcoin = "0.23"
17+
lightning = { version = "0.0.11", path = "../lightning" }
18+
tokio = { version = ">=0.2.12", features = [ "tcp", "io-util", "dns" ], optional = true }
19+
serde = { version = "1", optional = true }
20+
serde_json = { version = "1", optional = true }
21+
serde_derive = { version = "1", optional = true }
22+
base64 = { version = "0.9", optional = true }
23+
24+
[dev-dependencies]
25+
tokio = { version = ">=0.2.12", features = [ "macros", "rt-core" ] }

0 commit comments

Comments
 (0)