Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/kotlin.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
Comment thread
tnull marked this conversation as resolved.
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
Expand All@@ -63,6 +63,7 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }

bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.20.1", default-features = false, features = ["use-rustls"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
Expand All@@ -76,6 +77,7 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.22.0", default-features = true }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -92,16 +94,15 @@ winapi = { version = "0.3", features = ["winbase"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
corepc-node = { version = "0.7.0", default-features = false, features = ["27_2"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
- 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.
- 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.
- 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.
Expand All@@ -72,6 +72,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.75.0.
[rust_crate]: https://crates.io/
[ldk]: https://lightningdevkit.org/
[bdk]: https://bitcoindevkit.org/
[electrum]: https://github.com/spesmilo/electrum-protocol
[esplora]: https://github.com/Blockstream/esplora
[sqlite]: https://sqlite.org/
[rust]: https://www.rust-lang.org/
Expand Down
5 changes: 5 additions & 0 deletions bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ dictionary EsploraSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
string? require_token;
boolean advertise_service;
Expand DownExpand Up@@ -72,6 +76,7 @@ interface Builder {
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
Expand Down
4 changes: 1 addition & 3 deletions docker-compose-cln.yml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
version: '3'

services:
bitcoin:
image: blockstream/bitcoind:24.1
image: blockstream/bitcoind:27.2
platform: linux/amd64
command:
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/download_bitcoind_electrs.sh
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -eox pipefail
Comment thread
tnull marked this conversation as resolved.

# Our Esplora-based tests require `electrs` and `bitcoind`
# binaries. Here, we download the binaries, validate them, and export their
# location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
Expand All@@ -7,19 +10,20 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
BITCOIND_VERSION="25.1"
BITCOIND_VERSION="27.2"
if [[ "$HOST_PLATFORM" == *linux* ]]; then
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
BITCOIND_DL_HASH="acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78"
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
BITCOIND_DL_HASH="6ebc56ca1397615d5a6df2b5cf6727b768e3dcac320c2d5c2f321dcaabc7efa2"
else
echo "\n\nUnsupported platform: $HOST_PLATFORM Exiting.."
printf "\n\n"
echo "Unsupported platform: $HOST_PLATFORM Exiting.."
exit 1
fi

Expand Down
41 changes: 39 additions & 2 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, may_announce_channel, AnnounceError, Config, EsploraSyncConfig,
DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig,
EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -83,6 +83,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Esplora { server_url: String, sync_config: Option<EsploraSyncConfig> },
Electrum { server_url: String, sync_config: Option<ElectrumSyncConfig> },
BitcoindRpc { rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String },
}

Expand DownExpand Up@@ -284,6 +285,18 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self {
self.chain_data_source_config =
Some(ChainDataSourceConfig::Electrum { server_url, sync_config });
self
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -691,6 +704,16 @@ impl ArcedNodeBuilder {
self.inner.write().unwrap().set_chain_source_esplora(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) {
self.inner.write().unwrap().set_chain_source_electrum(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -1024,6 +1047,20 @@ fn build_with_store_internal(
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => {
let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default());
Arc::new(ChainSource::new_electrum(
Comment thread
tnull marked this conversation as resolved.
server_url.clone(),
sync_config,
Arc::clone(&wallet),
Arc::clone(&fee_estimator),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::BitcoindRpc { rpc_host, rpc_port, rpc_user, rpc_password }) => {
Arc::new(ChainSource::new_bitcoind_rpc(
rpc_host.clone(),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Add support for sourcing chain data from Electrum by tnull · Pull Request #486 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/kotlin.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
Comment thread
tnull marked this conversation as resolved.
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
Expand All@@ -63,6 +63,7 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }

bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.20.1", default-features = false, features = ["use-rustls"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
Expand All@@ -76,6 +77,7 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.22.0", default-features = true }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -92,16 +94,15 @@ winapi = { version = "0.3", features = ["winbase"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
corepc-node = { version = "0.7.0", default-features = false, features = ["27_2"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
- 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.
- 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.
- 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.
Expand All@@ -72,6 +72,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.75.0.
[rust_crate]: https://crates.io/
[ldk]: https://lightningdevkit.org/
[bdk]: https://bitcoindevkit.org/
[electrum]: https://github.com/spesmilo/electrum-protocol
[esplora]: https://github.com/Blockstream/esplora
[sqlite]: https://sqlite.org/
[rust]: https://www.rust-lang.org/
Expand Down
5 changes: 5 additions & 0 deletions bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ dictionary EsploraSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
string? require_token;
boolean advertise_service;
Expand DownExpand Up@@ -72,6 +76,7 @@ interface Builder {
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
Expand Down
4 changes: 1 addition & 3 deletions docker-compose-cln.yml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
version: '3'

services:
bitcoin:
image: blockstream/bitcoind:24.1
image: blockstream/bitcoind:27.2
platform: linux/amd64
command:
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/download_bitcoind_electrs.sh
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -eox pipefail
Comment thread
tnull marked this conversation as resolved.

# Our Esplora-based tests require `electrs` and `bitcoind`
# binaries. Here, we download the binaries, validate them, and export their
# location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
Expand All@@ -7,19 +10,20 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
BITCOIND_VERSION="25.1"
BITCOIND_VERSION="27.2"
if [[ "$HOST_PLATFORM" == *linux* ]]; then
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
BITCOIND_DL_HASH="acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78"
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
BITCOIND_DL_HASH="6ebc56ca1397615d5a6df2b5cf6727b768e3dcac320c2d5c2f321dcaabc7efa2"
else
echo "\n\nUnsupported platform: $HOST_PLATFORM Exiting.."
printf "\n\n"
echo "Unsupported platform: $HOST_PLATFORM Exiting.."
exit 1
fi

Expand Down
41 changes: 39 additions & 2 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, may_announce_channel, AnnounceError, Config, EsploraSyncConfig,
DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig,
EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -83,6 +83,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Esplora { server_url: String, sync_config: Option<EsploraSyncConfig> },
Electrum { server_url: String, sync_config: Option<ElectrumSyncConfig> },
BitcoindRpc { rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String },
}

Expand DownExpand Up@@ -284,6 +285,18 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self {
self.chain_data_source_config =
Some(ChainDataSourceConfig::Electrum { server_url, sync_config });
self
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -691,6 +704,16 @@ impl ArcedNodeBuilder {
self.inner.write().unwrap().set_chain_source_esplora(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) {
self.inner.write().unwrap().set_chain_source_electrum(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -1024,6 +1047,20 @@ fn build_with_store_internal(
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => {
let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default());
Arc::new(ChainSource::new_electrum(
Comment thread
tnull marked this conversation as resolved.
server_url.clone(),
sync_config,
Arc::clone(&wallet),
Arc::clone(&fee_estimator),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::BitcoindRpc { rpc_host, rpc_port, rpc_user, rpc_password }) => {
Arc::new(ChainSource::new_bitcoind_rpc(
rpc_host.clone(),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add support for sourcing chain data from Electrum by tnull · Pull Request #486 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/kotlin.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
Comment thread
tnull marked this conversation as resolved.
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
Expand All@@ -63,6 +63,7 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }

bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.20.1", default-features = false, features = ["use-rustls"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
Expand All@@ -76,6 +77,7 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.22.0", default-features = true }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -92,16 +94,15 @@ winapi = { version = "0.3", features = ["winbase"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
corepc-node = { version = "0.7.0", default-features = false, features = ["27_2"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
- 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.
- 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.
- 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.
Expand All@@ -72,6 +72,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.75.0.
[rust_crate]: https://crates.io/
[ldk]: https://lightningdevkit.org/
[bdk]: https://bitcoindevkit.org/
[electrum]: https://github.com/spesmilo/electrum-protocol
[esplora]: https://github.com/Blockstream/esplora
[sqlite]: https://sqlite.org/
[rust]: https://www.rust-lang.org/
Expand Down
5 changes: 5 additions & 0 deletions bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ dictionary EsploraSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
string? require_token;
boolean advertise_service;
Expand DownExpand Up@@ -72,6 +76,7 @@ interface Builder {
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
Expand Down
4 changes: 1 addition & 3 deletions docker-compose-cln.yml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
version: '3'

services:
bitcoin:
image: blockstream/bitcoind:24.1
image: blockstream/bitcoind:27.2
platform: linux/amd64
command:
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/download_bitcoind_electrs.sh
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -eox pipefail
Comment thread
tnull marked this conversation as resolved.

# Our Esplora-based tests require `electrs` and `bitcoind`
# binaries. Here, we download the binaries, validate them, and export their
# location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
Expand All@@ -7,19 +10,20 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
BITCOIND_VERSION="25.1"
BITCOIND_VERSION="27.2"
if [[ "$HOST_PLATFORM" == *linux* ]]; then
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
BITCOIND_DL_HASH="acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78"
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
BITCOIND_DL_HASH="6ebc56ca1397615d5a6df2b5cf6727b768e3dcac320c2d5c2f321dcaabc7efa2"
else
echo "\n\nUnsupported platform: $HOST_PLATFORM Exiting.."
printf "\n\n"
echo "Unsupported platform: $HOST_PLATFORM Exiting.."
exit 1
fi

Expand Down
41 changes: 39 additions & 2 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, may_announce_channel, AnnounceError, Config, EsploraSyncConfig,
DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig,
EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -83,6 +83,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Esplora { server_url: String, sync_config: Option<EsploraSyncConfig> },
Electrum { server_url: String, sync_config: Option<ElectrumSyncConfig> },
BitcoindRpc { rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String },
}

Expand DownExpand Up@@ -284,6 +285,18 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self {
self.chain_data_source_config =
Some(ChainDataSourceConfig::Electrum { server_url, sync_config });
self
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -691,6 +704,16 @@ impl ArcedNodeBuilder {
self.inner.write().unwrap().set_chain_source_esplora(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) {
self.inner.write().unwrap().set_chain_source_electrum(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -1024,6 +1047,20 @@ fn build_with_store_internal(
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => {
let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default());
Arc::new(ChainSource::new_electrum(
Comment thread
tnull marked this conversation as resolved.
server_url.clone(),
sync_config,
Arc::clone(&wallet),
Arc::clone(&fee_estimator),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::BitcoindRpc { rpc_host, rpc_port, rpc_user, rpc_password }) => {
Arc::new(ChainSource::new_bitcoind_rpc(
rpc_host.clone(),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add support for sourcing chain data from Electrum by tnull · Pull Request #486 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/kotlin.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
Comment thread
tnull marked this conversation as resolved.
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
Expand All@@ -63,6 +63,7 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }

bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.20.1", default-features = false, features = ["use-rustls"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
Expand All@@ -76,6 +77,7 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.22.0", default-features = true }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -92,16 +94,15 @@ winapi = { version = "0.3", features = ["winbase"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
corepc-node = { version = "0.7.0", default-features = false, features = ["27_2"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
- 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.
- 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.
- 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.
Expand All@@ -72,6 +72,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.75.0.
[rust_crate]: https://crates.io/
[ldk]: https://lightningdevkit.org/
[bdk]: https://bitcoindevkit.org/
[electrum]: https://github.com/spesmilo/electrum-protocol
[esplora]: https://github.com/Blockstream/esplora
[sqlite]: https://sqlite.org/
[rust]: https://www.rust-lang.org/
Expand Down
5 changes: 5 additions & 0 deletions bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ dictionary EsploraSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
string? require_token;
boolean advertise_service;
Expand DownExpand Up@@ -72,6 +76,7 @@ interface Builder {
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
Expand Down
4 changes: 1 addition & 3 deletions docker-compose-cln.yml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
version: '3'

services:
bitcoin:
image: blockstream/bitcoind:24.1
image: blockstream/bitcoind:27.2
platform: linux/amd64
command:
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/download_bitcoind_electrs.sh
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -eox pipefail
Comment thread
tnull marked this conversation as resolved.

# Our Esplora-based tests require `electrs` and `bitcoind`
# binaries. Here, we download the binaries, validate them, and export their
# location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
Expand All@@ -7,19 +10,20 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
BITCOIND_VERSION="25.1"
BITCOIND_VERSION="27.2"
if [[ "$HOST_PLATFORM" == *linux* ]]; then
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
BITCOIND_DL_HASH="acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78"
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
BITCOIND_DL_HASH="6ebc56ca1397615d5a6df2b5cf6727b768e3dcac320c2d5c2f321dcaabc7efa2"
else
echo "\n\nUnsupported platform: $HOST_PLATFORM Exiting.."
printf "\n\n"
echo "Unsupported platform: $HOST_PLATFORM Exiting.."
exit 1
fi

Expand Down
41 changes: 39 additions & 2 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, may_announce_channel, AnnounceError, Config, EsploraSyncConfig,
DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig,
EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -83,6 +83,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Esplora { server_url: String, sync_config: Option<EsploraSyncConfig> },
Electrum { server_url: String, sync_config: Option<ElectrumSyncConfig> },
BitcoindRpc { rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String },
}

Expand DownExpand Up@@ -284,6 +285,18 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self {
self.chain_data_source_config =
Some(ChainDataSourceConfig::Electrum { server_url, sync_config });
self
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -691,6 +704,16 @@ impl ArcedNodeBuilder {
self.inner.write().unwrap().set_chain_source_esplora(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) {
self.inner.write().unwrap().set_chain_source_electrum(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -1024,6 +1047,20 @@ fn build_with_store_internal(
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => {
let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default());
Arc::new(ChainSource::new_electrum(
Comment thread
tnull marked this conversation as resolved.
server_url.clone(),
sync_config,
Arc::clone(&wallet),
Arc::clone(&fee_estimator),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::BitcoindRpc { rpc_host, rpc_port, rpc_user, rpc_password }) => {
Arc::new(ChainSource::new_bitcoind_rpc(
rpc_host.clone(),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Add support for sourcing chain data from Electrum by tnull · Pull Request #486 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/kotlin.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
Comment thread
tnull marked this conversation as resolved.
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
Expand All@@ -63,6 +63,7 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }

bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.20.1", default-features = false, features = ["use-rustls"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
Expand All@@ -76,6 +77,7 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.22.0", default-features = true }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -92,16 +94,15 @@ winapi = { version = "0.3", features = ["winbase"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
corepc-node = { version = "0.7.0", default-features = false, features = ["27_2"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
- 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.
- 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.
- 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.
Expand All@@ -72,6 +72,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.75.0.
[rust_crate]: https://crates.io/
[ldk]: https://lightningdevkit.org/
[bdk]: https://bitcoindevkit.org/
[electrum]: https://github.com/spesmilo/electrum-protocol
[esplora]: https://github.com/Blockstream/esplora
[sqlite]: https://sqlite.org/
[rust]: https://www.rust-lang.org/
Expand Down
5 changes: 5 additions & 0 deletions bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ dictionary EsploraSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
string? require_token;
boolean advertise_service;
Expand DownExpand Up@@ -72,6 +76,7 @@ interface Builder {
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
Expand Down
4 changes: 1 addition & 3 deletions docker-compose-cln.yml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
version: '3'

services:
bitcoin:
image: blockstream/bitcoind:24.1
image: blockstream/bitcoind:27.2
platform: linux/amd64
command:
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/download_bitcoind_electrs.sh
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -eox pipefail
Comment thread
tnull marked this conversation as resolved.

# Our Esplora-based tests require `electrs` and `bitcoind`
# binaries. Here, we download the binaries, validate them, and export their
# location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
Expand All@@ -7,19 +10,20 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
BITCOIND_VERSION="25.1"
BITCOIND_VERSION="27.2"
if [[ "$HOST_PLATFORM" == *linux* ]]; then
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
BITCOIND_DL_HASH="acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78"
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
BITCOIND_DL_HASH="6ebc56ca1397615d5a6df2b5cf6727b768e3dcac320c2d5c2f321dcaabc7efa2"
else
echo "\n\nUnsupported platform: $HOST_PLATFORM Exiting.."
printf "\n\n"
echo "Unsupported platform: $HOST_PLATFORM Exiting.."
exit 1
fi

Expand Down
41 changes: 39 additions & 2 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, may_announce_channel, AnnounceError, Config, EsploraSyncConfig,
DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig,
EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -83,6 +83,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Esplora { server_url: String, sync_config: Option<EsploraSyncConfig> },
Electrum { server_url: String, sync_config: Option<ElectrumSyncConfig> },
BitcoindRpc { rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String },
}

Expand DownExpand Up@@ -284,6 +285,18 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self {
self.chain_data_source_config =
Some(ChainDataSourceConfig::Electrum { server_url, sync_config });
self
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -691,6 +704,16 @@ impl ArcedNodeBuilder {
self.inner.write().unwrap().set_chain_source_esplora(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) {
self.inner.write().unwrap().set_chain_source_electrum(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -1024,6 +1047,20 @@ fn build_with_store_internal(
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => {
let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default());
Arc::new(ChainSource::new_electrum(
Comment thread
tnull marked this conversation as resolved.
server_url.clone(),
sync_config,
Arc::clone(&wallet),
Arc::clone(&fee_estimator),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::BitcoindRpc { rpc_host, rpc_port, rpc_user, rpc_password }) => {
Arc::new(ChainSource::new_bitcoind_rpc(
rpc_host.clone(),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Add support for sourcing chain data from Electrum by tnull · Pull Request #486 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/kotlin.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
Comment thread
tnull marked this conversation as resolved.
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
Expand All@@ -63,6 +63,7 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }

bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.20.1", default-features = false, features = ["use-rustls"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
Expand All@@ -76,6 +77,7 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.22.0", default-features = true }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -92,16 +94,15 @@ winapi = { version = "0.3", features = ["winbase"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
corepc-node = { version = "0.7.0", default-features = false, features = ["27_2"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
- 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.
- 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.
- 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.
Expand All@@ -72,6 +72,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.75.0.
[rust_crate]: https://crates.io/
[ldk]: https://lightningdevkit.org/
[bdk]: https://bitcoindevkit.org/
[electrum]: https://github.com/spesmilo/electrum-protocol
[esplora]: https://github.com/Blockstream/esplora
[sqlite]: https://sqlite.org/
[rust]: https://www.rust-lang.org/
Expand Down
5 changes: 5 additions & 0 deletions bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ dictionary EsploraSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
string? require_token;
boolean advertise_service;
Expand DownExpand Up@@ -72,6 +76,7 @@ interface Builder {
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
Expand Down
4 changes: 1 addition & 3 deletions docker-compose-cln.yml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
version: '3'

services:
bitcoin:
image: blockstream/bitcoind:24.1
image: blockstream/bitcoind:27.2
platform: linux/amd64
command:
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/download_bitcoind_electrs.sh
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -eox pipefail
Comment thread
tnull marked this conversation as resolved.

# Our Esplora-based tests require `electrs` and `bitcoind`
# binaries. Here, we download the binaries, validate them, and export their
# location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
Expand All@@ -7,19 +10,20 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
BITCOIND_VERSION="25.1"
BITCOIND_VERSION="27.2"
if [[ "$HOST_PLATFORM" == *linux* ]]; then
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
BITCOIND_DL_HASH="acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78"
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
BITCOIND_DL_HASH="6ebc56ca1397615d5a6df2b5cf6727b768e3dcac320c2d5c2f321dcaabc7efa2"
else
echo "\n\nUnsupported platform: $HOST_PLATFORM Exiting.."
printf "\n\n"
echo "Unsupported platform: $HOST_PLATFORM Exiting.."
exit 1
fi

Expand Down
41 changes: 39 additions & 2 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, may_announce_channel, AnnounceError, Config, EsploraSyncConfig,
DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig,
EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -83,6 +83,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Esplora { server_url: String, sync_config: Option<EsploraSyncConfig> },
Electrum { server_url: String, sync_config: Option<ElectrumSyncConfig> },
BitcoindRpc { rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String },
}

Expand DownExpand Up@@ -284,6 +285,18 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self {
self.chain_data_source_config =
Some(ChainDataSourceConfig::Electrum { server_url, sync_config });
self
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -691,6 +704,16 @@ impl ArcedNodeBuilder {
self.inner.write().unwrap().set_chain_source_esplora(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) {
self.inner.write().unwrap().set_chain_source_electrum(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -1024,6 +1047,20 @@ fn build_with_store_internal(
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => {
let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default());
Arc::new(ChainSource::new_electrum(
Comment thread
tnull marked this conversation as resolved.
server_url.clone(),
sync_config,
Arc::clone(&wallet),
Arc::clone(&fee_estimator),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::BitcoindRpc { rpc_host, rpc_port, rpc_user, rpc_password }) => {
Arc::new(ChainSource::new_bitcoind_rpc(
rpc_host.clone(),
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Add support for sourcing chain data from Electrum by tnull · Pull Request #486 · lightningdevkit/ldk-node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/kotlin.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,9 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
Comment thread
tnull marked this conversation as resolved.
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
Expand All@@ -63,6 +63,7 @@ lightning-liquidity = { version = "0.1.0", features = ["std"] }

bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
bdk_electrum = { version = "0.20.1", default-features = false, features = ["use-rustls"]}
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
Expand All@@ -76,6 +77,7 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.22.0", default-features = true }
libc = "0.2"
uniffi = { version = "0.27.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All@@ -92,16 +94,15 @@ winapi = { version = "0.3", features = ["winbase"] }
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
electrum-client = { version = "0.21.0", default-features = true }
bitcoincore-rpc = { version = "0.19.0", default-features = false }
proptest = "1.0.0"
regex = "1.5.6"

[target.'cfg(not(no_download))'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "corepc-node_27_2"] }

[target.'cfg(no_download)'.dev-dependencies]
electrsd = { version = "0.29.0", features = ["legacy"] }
electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] }
corepc-node = { version = "0.7.0", default-features = false, features = ["27_2"] }

[target.'cfg(cln_test)'.dev-dependencies]
clightningrpc = { version = "0.3.0-beta.8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ fn main() {
LDK Node currently comes with a decidedly opinionated set of design choices:

- On-chain data is handled by the integrated [BDK][bdk] wallet.
- Chain data may currently be sourced from the Bitcoin Core RPC interface or an [Esplora][esplora] server, while support for Electrum will follow soon.
- Chain data may currently be sourced from the Bitcoin Core RPC interface, or from an [Electrum][electrum] or [Esplora][esplora] server.
- 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.
- 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.
- 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.
Expand All@@ -72,6 +72,7 @@ The Minimum Supported Rust Version (MSRV) is currently 1.75.0.
[rust_crate]: https://crates.io/
[ldk]: https://lightningdevkit.org/
[bdk]: https://bitcoindevkit.org/
[electrum]: https://github.com/spesmilo/electrum-protocol
[esplora]: https://github.com/Blockstream/esplora
[sqlite]: https://sqlite.org/
[rust]: https://www.rust-lang.org/
Expand Down
5 changes: 5 additions & 0 deletions bindings/ldk_node.udl
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ dictionary EsploraSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary ElectrumSyncConfig {
BackgroundSyncConfig? background_sync_config;
};

dictionary LSPS2ServiceConfig {
string? require_token;
boolean advertise_service;
Expand DownExpand Up@@ -72,6 +76,7 @@ interface Builder {
void set_entropy_seed_bytes(sequence<u8> seed_bytes);
void set_entropy_bip39_mnemonic(Mnemonic mnemonic, string? passphrase);
void set_chain_source_esplora(string server_url, EsploraSyncConfig? config);
void set_chain_source_electrum(string server_url, ElectrumSyncConfig? config);
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
void set_gossip_source_p2p();
void set_gossip_source_rgs(string rgs_server_url);
Expand Down
4 changes: 1 addition & 3 deletions docker-compose-cln.yml
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
version: '3'

services:
bitcoin:
image: blockstream/bitcoind:24.1
image: blockstream/bitcoind:27.2
platform: linux/amd64
command:
[
Expand Down
12 changes: 8 additions & 4 deletions scripts/download_bitcoind_electrs.sh
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
#!/bin/bash
set -eox pipefail
Comment thread
tnull marked this conversation as resolved.

# Our Esplora-based tests require `electrs` and `bitcoind`
# binaries. Here, we download the binaries, validate them, and export their
# location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
Expand All@@ -7,19 +10,20 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
BITCOIND_VERSION="25.1"
BITCOIND_VERSION="27.2"
if [[ "$HOST_PLATFORM" == *linux* ]]; then
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
BITCOIND_DL_HASH="acc223af46c178064c132b235392476f66d486453ddbd6bca6f1f8411547da78"
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
BITCOIND_DL_HASH="6ebc56ca1397615d5a6df2b5cf6727b768e3dcac320c2d5c2f321dcaabc7efa2"
else
echo "\n\nUnsupported platform: $HOST_PLATFORM Exiting.."
printf "\n\n"
echo "Unsupported platform: $HOST_PLATFORM Exiting.."
exit 1
fi

Expand Down
41 changes: 39 additions & 2 deletions src/builder.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@

use crate::chain::{ChainSource, DEFAULT_ESPLORA_SERVER_URL};
use crate::config::{
default_user_config, may_announce_channel, AnnounceError, Config, EsploraSyncConfig,
DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
default_user_config, may_announce_channel, AnnounceError, Config, ElectrumSyncConfig,
EsploraSyncConfig, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, WALLET_KEYS_SEED_LEN,
};

use crate::connection::ConnectionManager;
Expand DownExpand Up@@ -83,6 +83,7 @@ const LSPS_HARDENED_CHILD_INDEX: u32 = 577;
#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Esplora { server_url: String, sync_config: Option<EsploraSyncConfig> },
Electrum { server_url: String, sync_config: Option<ElectrumSyncConfig> },
BitcoindRpc { rpc_host: String, rpc_port: u16, rpc_user: String, rpc_password: String },
}

Expand DownExpand Up@@ -284,6 +285,18 @@ impl NodeBuilder {
self
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&mut self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) -> &mut Self {
self.chain_data_source_config =
Some(ChainDataSourceConfig::Electrum { server_url, sync_config });
self
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -691,6 +704,16 @@ impl ArcedNodeBuilder {
self.inner.write().unwrap().set_chain_source_esplora(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Electrum server.
///
/// If no `sync_config` is given, default values are used. See [`ElectrumSyncConfig`] for more
/// information.
pub fn set_chain_source_electrum(
&self, server_url: String, sync_config: Option<ElectrumSyncConfig>,
) {
self.inner.write().unwrap().set_chain_source_electrum(server_url, sync_config);
}

/// Configures the [`Node`] instance to source its chain data from the given Bitcoin Core RPC
/// endpoint.
pub fn set_chain_source_bitcoind_rpc(
Expand DownExpand Up@@ -1024,6 +1047,20 @@ fn build_with_store_internal(
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::Electrum { server_url, sync_config }) => {
let sync_config = sync_config.unwrap_or(ElectrumSyncConfig::default());
Arc::new(ChainSource::new_electrum(
Comment thread
tnull marked this conversation as resolved.
server_url.clone(),
sync_config,
Arc::clone(&wallet),
Arc::clone(&fee_estimator),
Arc::clone(&tx_broadcaster),
Arc::clone(&kv_store),
Arc::clone(&config),
Arc::clone(&logger),
Arc::clone(&node_metrics),
))
},
Some(ChainDataSourceConfig::BitcoindRpc { rpc_host, rpc_port, rpc_user, rpc_password }) => {
Arc::new(ChainSource::new_bitcoind_rpc(
rpc_host.clone(),
Expand Down
Loading