Skip to content

Commit c872ef4

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 c872ef4

File tree

6 files changed

+1115
-0
lines changed

6 files changed

+1115
-0
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ 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 SPV Client on Rust ${{ matrix.toolchain }} with features
42+
run: |
43+
cd lightning-block-sync
44+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client
45+
cd ..
4146
- name: Test on Rust ${{ matrix.toolchain }} with net-tokio
4247
if: matrix.build-net-tokio
4348
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" ], 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)