Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 161
Add support for sourcing chain data from Electrum#486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tnull
merged 13 commits into
lightningdevkit:main
from
tnull:2025-02-add-electrum-supportApr 16, 2025
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3bf6e0a
Prefactor: Update bitcoind used in CI to v27.2
tnull df47d33
Prefactor: Upgrade to `electrum-client` v0.22
tnull 2187046
Install `bindgen-cli` in Kotlin CI
tnull 274a21f
Add `bdk_electrum`/`transaction-sync` `electrum` support in `Cargo.toml`
tnull e793b6f
Allow to configure `ChainSource::Electrum` via builder
tnull 70014d6
Implement (cached) `Filter` for `ElectrumRuntimeClient`
tnull 6ead9be
Implement `continuously_sync_wallets` for `ChainSource::Electrum`
tnull 98150cd
Implement `process_broadcast_queue` for `ChainSource::Electrum`
tnull af64dd9
Implement `update_fee_rate_estimates` for `ChainSource::Electrum`
tnull 6ac8b91
Implement `sync_lightning_wallet` for `ChainSource::Electrum`
tnull 2bd559b
Implement `sync_onchain_wallet` for `ChainSource::Electrum`
tnull 95e75d4
Add `full_cycle` test using the new `Electrum` chain source
tnull 5cdd2e3
Update README to signal Electrum support
tnull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| #!/bin/bash | ||
| set -eox pipefail | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # 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 | ||
| @@ -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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| @@ -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 }, | ||
| } | ||
| @@ -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( | ||
| @@ -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( | ||
| @@ -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( | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| 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(), | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.