Skip to content

Commit 7b952c8

Browse files
committed
Add transaction sync crate
This crate provides utilities for syncing LDK via the transaction-based `Confirm` interface. The initial implementation facilitates synchronization with an Esplora backend server.
1 parent af7c292 commit 7b952c8

File tree

6 files changed

+467
-0
lines changed

6 files changed

+467
-0
lines changed

.github/workflows/build.yml

+12
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ jobs:
108108
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client
109109
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client
110110
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features rpc-client,rest-client,tokio
111+
- name: Build Transaction Sync Clients on Rust ${{ matrix.toolchain }} with features
112+
if: "!matrix.coverage"
113+
run: |
114+
cd lightning-transaction-sync
115+
cargo build --verbose --color always --features esplora-blocking
116+
cargo build --verbose --color always --features esplora-async
117+
- name: Build Transaction Sync Clients on Rust ${{ matrix.toolchain }} with features and full code-linking for coverage generation
118+
if: matrix.coverage
119+
run: |
120+
cd lightning-transaction-sync
121+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-blocking
122+
RUSTFLAGS="-C link-dead-code" cargo build --verbose --color always --features esplora-async
111123
- name: Test backtrace-debug builds on Rust ${{ matrix.toolchain }}
112124
if: "matrix.build-no-std"
113125
run: |

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
members = [
44
"lightning",
55
"lightning-block-sync",
6+
"lightning-transaction-sync",
67
"lightning-invoice",
78
"lightning-net-tokio",
89
"lightning-persister",

lightning-transaction-sync/Cargo.toml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "lightning-transaction-sync"
3+
version = "0.0.112"
4+
authors = ["Elias Rohrer"]
5+
license = "MIT OR Apache-2.0"
6+
repository = "http://github.com/lightningdevkit/rust-lightning"
7+
description = """
8+
Utilities to fetch transaction data from a chain source and feed them into LDK.
9+
"""
10+
edition = "2018"
11+
12+
[package.metadata.docs.rs]
13+
all-features = true
14+
rustdoc-args = ["--cfg", "docsrs"]
15+
16+
[features]
17+
default = ["esplora-blocking"]
18+
esplora-async = ["async-interface", "esplora-client/async", "tokio"]
19+
esplora-blocking = ["esplora-client/blocking"]
20+
async-interface = []
21+
22+
[dependencies]
23+
lightning = { version = "0.0.112", path = "../lightning" }
24+
bitcoin = "0.29.0"
25+
bdk-macros = "0.6"
26+
tokio = { version = "1.0", default-features = false, features = [], optional = true }
27+
esplora-client = { git = "https://github.com/tnull/rust-esplora-client", branch = "2022-10-get-merkle-block", default-features = false, optional = true }
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::fmt;
2+
use esplora_client::Error as EsploraError;
3+
4+
#[derive(Debug)]
5+
/// An error that possibly needs to be handled by the user.
6+
pub enum TxSyncError {
7+
/// A transaction sync failed.
8+
Failed,
9+
/// An inconsisteny was encounterd during transaction sync.
10+
Inconsistency,
11+
}
12+
13+
impl fmt::Display for TxSyncError {
14+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15+
match *self {
16+
Self::Failed => write!(f, "Failed to conduct transaction sync."),
17+
Self::Inconsistency => {
18+
write!(f, "Encountered an inconsisteny during transaction sync.")
19+
}
20+
}
21+
}
22+
}
23+
24+
impl std::error::Error for TxSyncError {}
25+
26+
impl From<EsploraError> for TxSyncError {
27+
fn from(_e: EsploraError) -> Self {
28+
Self::Failed
29+
}
30+
}

0 commit comments

Comments
 (0)