Skip to content

Commit 8ce40d5

Browse files
author
Conor Okus
committed
Remove reference to BlockSource
1 parent 0e5751d commit 8ce40d5

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

examples/bitcoind-rpc-client/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Creates a basic bitcoind client
1+
# Wallet actions with an RPC client
22

33
This is example shows how you could create a client that directly communicates with bitcoind from LDK. The API is flexible and allows for different ways to implement the interface.
44

5-
It implements some basic RPC methods that allow you to create a core wallet and print it's balance to stdout.
5+
It implements some basic RPC methods that allow you to create a wallet and print it's balance to stdout.
66

77
To run with this example you need to have a bitcoin core node running in regtest mode. Get the bitcoin core binary either from the [bitcoin core repo](https://bitcoincore.org/bin/bitcoin-core-0.22.0/) or [build from source](https://github.com/bitcoin/bitcoin/blob/v0.21.1/doc/build-unix.md).
88

@@ -29,9 +29,5 @@ Cargo run
2929

3030
The purpose of `RpcClient` is to create a new RPC client connected to the given endpoint with the provided credentials. The credentials should be a base64 encoding of a user name and password joined by a colon, as is required for HTTP basic access authentication.
3131

32-
It implements [BlockSource](https://github.com/rust-bitcoin/rust-lightning/blob/61341df39e90de9d650851a624c0644f5c9dd055/lightning-block-sync/src/lib.rs#L55) against a Bitcoin Core RPC. It is an asynchronous interface for retrieving block headers and data.
33-
34-
Check out our [LDK sample node](https://github.com/lightningdevkit/ldk-sample) for an integrated example.
35-
3632

3733

examples/bitcoind-rpc-client/src/bitcoind_client.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{sync::{Arc}, io};
22

3-
use bitcoin::{BlockHash, Block};
4-
use lightning_block_sync::{rpc::RpcClient, http::{HttpEndpoint}, BlockSource, AsyncBlockSourceResult, BlockHeaderData};
3+
use lightning_block_sync::{rpc::RpcClient, http::{HttpEndpoint}};
54
use serde_json::json;
65
use tokio::sync::Mutex;
76

@@ -16,33 +15,6 @@ pub struct BitcoindClient {
1615
rpc_password: String,
1716
}
1817

19-
impl BlockSource for &BitcoindClient {
20-
fn get_header<'a>(
21-
&'a mut self, header_hash: &'a BlockHash, height_hint: Option<u32>,
22-
) -> AsyncBlockSourceResult<'a, BlockHeaderData> {
23-
Box::pin(async move {
24-
let mut rpc = self.bitcoind_rpc_client.lock().await;
25-
rpc.get_header(header_hash, height_hint).await
26-
})
27-
}
28-
29-
fn get_block<'a>(
30-
&'a mut self, header_hash: &'a BlockHash,
31-
) -> AsyncBlockSourceResult<'a, Block> {
32-
Box::pin(async move {
33-
let mut rpc = self.bitcoind_rpc_client.lock().await;
34-
rpc.get_block(header_hash).await
35-
})
36-
}
37-
38-
fn get_best_block<'a>(&'a mut self) -> AsyncBlockSourceResult<(BlockHash, Option<u32>)> {
39-
Box::pin(async move {
40-
let mut rpc = self.bitcoind_rpc_client.lock().await;
41-
rpc.get_best_block().await
42-
})
43-
}
44-
}
45-
4618
impl BitcoindClient {
4719
pub async fn new(host: String, port: u16, rpc_user: String, rpc_password: String) -> io::Result<Self> {
4820
let http_endpoint = HttpEndpoint::for_host(host.clone()).with_port(port);

0 commit comments

Comments
 (0)